-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
User: Make email required at all times, password required for new users
- Loading branch information
Showing
5 changed files
with
28 additions
and
11 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 |
---|---|---|
|
@@ -26,16 +26,11 @@ def test_user_list(self): | |
self.assertNotIn(item, user, r.content[:1000]) | ||
|
||
def test_user_add(self): | ||
# simple user without password | ||
r = self.client.post(reverse("user-list"), { | ||
"username": "api-user-1", | ||
}, format="json") | ||
self.assertEqual(r.status_code, 201, r.content[:1000]) | ||
|
||
# user with good password | ||
password = "testTEST1234!@#$" | ||
r = self.client.post(reverse("user-list"), { | ||
"username": "api-user-2", | ||
"email": "[email protected]", | ||
"password": password, | ||
}, format="json") | ||
self.assertEqual(r.status_code, 201, r.content[:1000]) | ||
|
@@ -50,6 +45,7 @@ def test_user_add(self): | |
# user with weak password | ||
r = self.client.post(reverse("user-list"), { | ||
"username": "api-user-3", | ||
"email": "[email protected]", | ||
"password": "weakPassword", | ||
}, format="json") | ||
self.assertEqual(r.status_code, 400, r.content[:1000]) | ||
|
@@ -59,30 +55,36 @@ def test_user_change_password(self): | |
# some user | ||
r = self.client.post(reverse("user-list"), { | ||
"username": "api-user-4", | ||
"email": "[email protected]", | ||
"password": "testTEST1234!@#$", | ||
}, format="json") | ||
self.assertEqual(r.status_code, 201, r.content[:1000]) | ||
user_id = r.json()["id"] | ||
|
||
r = self.client.put("{}{}/".format(reverse("user-list"), user_id), { | ||
"username": "api-user-4", | ||
"first_name": "first", | ||
"email": "[email protected]", | ||
}, format="json") | ||
self.assertEqual(r.status_code, 200, r.content[:1000]) | ||
|
||
r = self.client.patch("{}{}/".format(reverse("user-list"), user_id), { | ||
"last_name": "last", | ||
"email": "[email protected]", | ||
}, format="json") | ||
self.assertEqual(r.status_code, 200, r.content[:1000]) | ||
|
||
r = self.client.put("{}{}/".format(reverse("user-list"), user_id), { | ||
"username": "api-user-4", | ||
"email": "[email protected]", | ||
"password": "testTEST1234!@#$", | ||
}, format="json") | ||
self.assertEqual(r.status_code, 400, r.content[:1000]) | ||
self.assertIn("Update of password though API is not allowed", r.content.decode("utf-8")) | ||
|
||
r = self.client.patch("{}{}/".format(reverse("user-list"), user_id), { | ||
"password": "testTEST1234!@#$", | ||
"email": "[email protected]", | ||
}, format="json") | ||
self.assertEqual(r.status_code, 400, r.content[:1000]) | ||
self.assertIn("Update of password though API is not allowed", r.content.decode("utf-8")) |
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