forked from deis/deis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95746aa
commit ecc1acc
Showing
11 changed files
with
1,296 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
from __future__ import unicode_literals | ||
|
||
from django.contrib.auth.models import User | ||
from django.test import TestCase | ||
from rest_framework.authtoken.models import Token | ||
|
||
|
||
class TestUsers(TestCase): | ||
""" Tests users endpoint""" | ||
|
||
fixtures = ['tests.json'] | ||
|
||
def test_super_user_can_list(self): | ||
url = '/v1/users/' | ||
|
||
user = User.objects.get(username='autotest') | ||
token = Token.objects.get(user=user) | ||
|
||
response = self.client.get(url, | ||
HTTP_AUTHORIZATION='token {}'.format(token)) | ||
|
||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(len(response.data['results']), 2) | ||
self.assertEqual(response.data['results'][0]['username'], 'autotest') | ||
self.assertEqual(response.data['results'][1]['username'], 'autotest2') | ||
|
||
def test_non_super_user_cannot_list(self): | ||
url = '/v1/users/' | ||
|
||
user = User.objects.get(username='autotest2') | ||
token = Token.objects.get(user=user) | ||
|
||
response = self.client.get(url, | ||
HTTP_AUTHORIZATION='token {}'.format(token)) | ||
self.assertEqual(response.status_code, 403) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.