Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
stolpeo committed Jan 2, 2025
1 parent 4025afd commit 903a127
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 126 deletions.
1 change: 1 addition & 0 deletions adminsec/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def get_user_info(self, username):
"userAccountControl",
"telephoneNumber",
"uidNumber",
"cn",
],
}

Expand Down
4 changes: 2 additions & 2 deletions adminsec/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
124 changes: 0 additions & 124 deletions adminsec/tests/test_views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()

0 comments on commit 903a127

Please sign in to comment.