diff --git a/adminsec/ldap.py b/adminsec/ldap.py index 26f8ac0..e2dd865 100644 --- a/adminsec/ldap.py +++ b/adminsec/ldap.py @@ -188,6 +188,7 @@ def get_user_info(self, username): "userAccountControl", "telephoneNumber", "uidNumber", + "cn", ], } diff --git a/adminsec/tests/test_tasks.py b/adminsec/tests/test_tasks.py index 3b569ee..45989a7 100644 --- a/adminsec/tests/test_tasks.py +++ b/adminsec/tests/test_tasks.py @@ -104,7 +104,7 @@ def setup_test_data_server1(connection): }, ) connection.strategy.add_entry( - "cn=user,ou=test," + AUTH_LDAP_USER_SEARCH_BASE, + "cn=Jane Joe,ou=test," + AUTH_LDAP_USER_SEARCH_BASE, { "objectclass": "person", "mail": USER_MAIL_INSTITUTE, @@ -126,7 +126,7 @@ def setup_test_data_server2(connection): }, ) connection.strategy.add_entry( - "cn=user,ou=test," + AUTH_LDAP2_USER_SEARCH_BASE, + "cn=John Doe,ou=test," + AUTH_LDAP2_USER_SEARCH_BASE, { "objectclass": "person", "mail": USER_MAIL_INSTITUTE2, diff --git a/adminsec/tests/test_views_api.py b/adminsec/tests/test_views_api.py index 7c8666d..9833f6b 100644 --- a/adminsec/tests/test_views_api.py +++ b/adminsec/tests/test_views_api.py @@ -8,7 +8,6 @@ from test_plus import TestCase from usersec.models import REQUEST_STATUS_ACTIVE -from usersec.serializers import HPC_ALUMNI_GROUP from usersec.tests.factories import ( HpcGroupCreateRequestFactory, HpcGroupFactory, @@ -627,126 +626,3 @@ def test_delete_fail(self): self.response_405() else: self.response_403() - - -class TestHpcAccessStatusApiView(ApiTestCase): - """Tests for the HpcAccessStatusApiView.""" - - def test_get_succeed(self): - """Test the GET method (staff users can do).""" - - expected = { - "hpc_users": [ - { - "uid": self.hpcuser_user.uid, - "email": self.hpcuser_user.user.email, - "full_name": "User Name", - "first_name": self.hpcuser_user.user.first_name, - "last_name": self.hpcuser_user.user.last_name, - "phone_number": None, - "primary_group": self.hpcuser_group.name, - "resources_requested": self.hpcuser_user.resources_requested, - "status": "INITIAL", - "description": self.hpcuser_user.description, - "username": self.hpcuser_user.username, - "expiration": self.hpcuser_user.expiration.strftime("%Y-%m-%dT%H:%M:%SZ"), - "home_directory": self.hpcuser_user.home_directory, - "login_shell": self.hpcuser_user.login_shell, - } - ], - "hpc_groups": [ - { - "owner": None, - "delegate": None, - "resources_requested": self.hpcuser_group.resources_requested, - "status": "INITIAL", - "description": self.hpcuser_group.description, - "name": self.hpcuser_group.name, - "folders": self.hpcuser_group.folders, - "expiration": self.hpcuser_group.expiration.strftime("%Y-%m-%dT%H:%M:%SZ"), - "gid": self.hpcuser_group.gid, - } - ], - "hpc_projects": [ - { - "gid": self.hpcuser_project.gid, - "group": self.hpcuser_group.name, - "delegate": None, - "resources_requested": self.hpcuser_project.resources_requested, - "status": "INITIAL", - "description": self.hpcuser_project.description, - "name": self.hpcuser_project.name, - "folders": self.hpcuser_project.folders, - "expiration": self.hpcuser_project.expiration.strftime("%Y-%m-%dT%H:%M:%SZ"), - "members": [], - } - ], - } - for user in [self.user_staff, self.user_admin, self.user_hpcadmin]: - with self.login(user): - self.get("adminsec:api-hpcaccess-status") - self.response_200() - self.assertEqual(self.last_response.json(), expected) - - def test_get_succeed_alumni(self): - self.hpcuser_user.primary_group = None - self.hpcuser_user.save() - expected = { - "hpc_users": [ - { - "uid": self.hpcuser_user.uid, - "email": self.hpcuser_user.user.email, - "full_name": "User Name", - "first_name": self.hpcuser_user.user.first_name, - "last_name": self.hpcuser_user.user.last_name, - "phone_number": None, - "primary_group": HPC_ALUMNI_GROUP, - "resources_requested": self.hpcuser_user.resources_requested, - "status": "INITIAL", - "description": self.hpcuser_user.description, - "username": self.hpcuser_user.username, - "expiration": self.hpcuser_user.expiration.strftime("%Y-%m-%dT%H:%M:%SZ"), - "home_directory": self.hpcuser_user.home_directory, - "login_shell": self.hpcuser_user.login_shell, - } - ], - "hpc_groups": [ - { - "owner": None, - "delegate": None, - "resources_requested": self.hpcuser_group.resources_requested, - "status": "INITIAL", - "description": self.hpcuser_group.description, - "name": self.hpcuser_group.name, - "folders": self.hpcuser_group.folders, - "expiration": self.hpcuser_group.expiration.strftime("%Y-%m-%dT%H:%M:%SZ"), - "gid": self.hpcuser_group.gid, - } - ], - "hpc_projects": [ - { - "gid": self.hpcuser_project.gid, - "group": self.hpcuser_group.name, - "delegate": None, - "resources_requested": self.hpcuser_project.resources_requested, - "status": "INITIAL", - "description": self.hpcuser_project.description, - "name": self.hpcuser_project.name, - "folders": self.hpcuser_project.folders, - "expiration": self.hpcuser_project.expiration.strftime("%Y-%m-%dT%H:%M:%SZ"), - "members": [], - } - ], - } - for user in [self.user_staff, self.user_admin, self.user_hpcadmin]: - with self.login(user): - self.get("adminsec:api-hpcaccess-status") - self.response_200() - self.assertEqual(self.last_response.json(), expected) - - def test_get_fail(self): - """Test the GET method (non-staff cannot do).""" - for user in [self.user_user]: - with self.login(user): - self.get("adminsec:api-hpcaccess-status") - self.response_403()