Authenticate login API with user_login.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
5a58dba347
commit
4f0abceb20
5 files changed
+49
-21
No files matched your search
@@ -8,7 +8,7 @@ from apps.accounts.models import User
|
||||
class AccountAdminModelTests(TestCase):
|
||||
def test_account_admin_flags_and_executive(self):
|
||||
user = User.objects.create_user(
|
||||
user_name="acct1",
|
||||
user_login="acct1",
|
||||
password="secret",
|
||||
status=User.STATUS_ACCOUNT_ADMIN,
|
||||
)
|
||||
@@ -18,7 +18,7 @@ class AccountAdminModelTests(TestCase):
|
||||
|
||||
def test_inactive_clears_flags(self):
|
||||
user = User.objects.create_user(
|
||||
user_name="acct2",
|
||||
user_login="acct2",
|
||||
password="secret",
|
||||
status=User.STATUS_ACCOUNT_ADMIN,
|
||||
)
|
||||
@@ -30,7 +30,7 @@ class AccountAdminModelTests(TestCase):
|
||||
|
||||
def test_director_admin_is_not_superuser(self):
|
||||
user = User.objects.create_user(
|
||||
user_name="diradmin1",
|
||||
user_login="diradmin1",
|
||||
password="secret",
|
||||
status=User.STATUS_DIRECTOR_ADMIN,
|
||||
)
|
||||
@@ -42,21 +42,21 @@ class AccountAdminApiTests(TestCase):
|
||||
def setUp(self):
|
||||
self.client = APIClient()
|
||||
self.account_admin = User.objects.create_user(
|
||||
user_name="acctadmin",
|
||||
user_login="acctadmin",
|
||||
password="acct123",
|
||||
status=User.STATUS_ACCOUNT_ADMIN,
|
||||
)
|
||||
self.gm = User.objects.create_user(
|
||||
user_name="gm1", password="gm123", status=User.STATUS_GM
|
||||
user_login="gm1", password="gm123", status=User.STATUS_GM
|
||||
)
|
||||
self.buh = User.objects.create_user(
|
||||
user_name="buh1", password="buh123", status=User.STATUS_BUH
|
||||
user_login="buh1", password="buh123", status=User.STATUS_BUH
|
||||
)
|
||||
self.director = User.objects.create_user(
|
||||
user_name="dir1", password="dir123", status=User.STATUS_DIRECTOR
|
||||
user_login="dir1", password="dir123", status=User.STATUS_DIRECTOR
|
||||
)
|
||||
self.superuser = User.objects.create_superuser(
|
||||
user_name="admin1",
|
||||
user_login="admin1",
|
||||
password="admin123",
|
||||
)
|
||||
self.assertTrue(self.superuser.is_superuser)
|
||||
@@ -67,6 +67,7 @@ class AccountAdminApiTests(TestCase):
|
||||
response = self.client.post(
|
||||
"/api/v1/users/",
|
||||
{
|
||||
"user_login": "newgm",
|
||||
"user_name": "newgm",
|
||||
"status": User.STATUS_GM,
|
||||
"password": "temp-pass",
|
||||
@@ -84,7 +85,7 @@ class AccountAdminApiTests(TestCase):
|
||||
self.client.force_authenticate(self.account_admin)
|
||||
response = self.client.post(
|
||||
"/api/v1/users/",
|
||||
{"user_name": "nopass", "status": User.STATUS_GM},
|
||||
{"user_login": "nopass", "user_name": "nopass", "status": User.STATUS_GM},
|
||||
format="json",
|
||||
)
|
||||
self.assertEqual(response.status_code, 400)
|
||||
@@ -95,6 +96,7 @@ class AccountAdminApiTests(TestCase):
|
||||
response = self.client.post(
|
||||
"/api/v1/users/",
|
||||
{
|
||||
"user_login": "blocked",
|
||||
"user_name": "blocked",
|
||||
"status": User.STATUS_GM,
|
||||
"password": "x",
|
||||
@@ -153,6 +155,7 @@ class AccountAdminApiTests(TestCase):
|
||||
response = self.client.post(
|
||||
"/api/v1/users/",
|
||||
{
|
||||
"user_login": "breakglass",
|
||||
"user_name": "breakglass",
|
||||
"status": User.STATUS_BUH,
|
||||
"password": "bg-pass",
|
||||
@@ -188,7 +191,7 @@ class AccountAdminApiTests(TestCase):
|
||||
|
||||
def test_peer_account_admin_can_deactivate_other_account_admin(self):
|
||||
peer = User.objects.create_user(
|
||||
user_name="acctadmin2",
|
||||
user_login="acctadmin2",
|
||||
password="acct123",
|
||||
status=User.STATUS_ACCOUNT_ADMIN,
|
||||
)
|
||||
@@ -204,7 +207,7 @@ class AccountAdminApiTests(TestCase):
|
||||
self.assertFalse(peer.is_active)
|
||||
|
||||
def test_superuser_hidden_from_user_list(self):
|
||||
User.objects.create_superuser(user_name="hidden_su", password="x")
|
||||
User.objects.create_superuser(user_login="hidden_su", password="x")
|
||||
self.client.force_authenticate(self.account_admin)
|
||||
response = self.client.get("/api/v1/users/")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@@ -217,6 +220,7 @@ class AccountAdminApiTests(TestCase):
|
||||
response = self.client.post(
|
||||
"/api/v1/users/",
|
||||
{
|
||||
"user_login": "bad_su",
|
||||
"user_name": "bad_su",
|
||||
"status": User.STATUS_SUPERUSER,
|
||||
"password": "x",
|
||||
|
||||
Reference in new issue
Block a user