mirror of
https://github.com/ansible/awx.git
synced 2026-03-19 18:07:33 -02:30
Fix null values on Token modified field.
This commit is contained in:
20
awx/main/migrations/0043_v330_oauth2accesstoken_modified.py
Normal file
20
awx/main/migrations/0043_v330_oauth2accesstoken_modified.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.11 on 2018-07-10 14:02
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('main', '0042_v330_org_member_role_deparent'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='oauth2accesstoken',
|
||||||
|
name='modified',
|
||||||
|
field=models.DateTimeField(editable=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -112,6 +112,10 @@ class OAuth2AccessToken(AbstractAccessToken):
|
|||||||
default='write',
|
default='write',
|
||||||
help_text=_('Allowed scopes, further restricts user\'s permissions. Must be a simple space-separated string with allowed scopes [\'read\', \'write\'].')
|
help_text=_('Allowed scopes, further restricts user\'s permissions. Must be a simple space-separated string with allowed scopes [\'read\', \'write\'].')
|
||||||
)
|
)
|
||||||
|
modified = models.DateTimeField(
|
||||||
|
editable=False,
|
||||||
|
auto_now=True
|
||||||
|
)
|
||||||
|
|
||||||
def is_valid(self, scopes=None):
|
def is_valid(self, scopes=None):
|
||||||
valid = super(OAuth2AccessToken, self).is_valid(scopes)
|
valid = super(OAuth2AccessToken, self).is_valid(scopes)
|
||||||
@@ -119,4 +123,3 @@ class OAuth2AccessToken(AbstractAccessToken):
|
|||||||
self.last_used = now()
|
self.last_used = now()
|
||||||
self.save(update_fields=['last_used'])
|
self.save(update_fields=['last_used'])
|
||||||
return valid
|
return valid
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ def test_oauth_token_create(oauth_application, get, post, admin):
|
|||||||
reverse('api:o_auth2_application_token_list', kwargs={'pk': oauth_application.pk}),
|
reverse('api:o_auth2_application_token_list', kwargs={'pk': oauth_application.pk}),
|
||||||
{'scope': 'read'}, admin, expect=201
|
{'scope': 'read'}, admin, expect=201
|
||||||
)
|
)
|
||||||
assert 'modified' in response.data
|
assert 'modified' in response.data and response.data['modified'] is not None
|
||||||
assert 'updated' not in response.data
|
assert 'updated' not in response.data
|
||||||
token = AccessToken.objects.get(token=response.data['token'])
|
token = AccessToken.objects.get(token=response.data['token'])
|
||||||
refresh_token = RefreshToken.objects.get(token=response.data['refresh_token'])
|
refresh_token = RefreshToken.objects.get(token=response.data['refresh_token'])
|
||||||
|
|||||||
Reference in New Issue
Block a user