Skip to content

Commit

Permalink
Extend SCIM v2 group tests
Browse files Browse the repository at this point in the history
- Adds test for content of listing groups.
- Adds test for user being unable to query the groups api.
  • Loading branch information
knikolla committed Oct 25, 2023
1 parent 7b8069f commit 80a7c72
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/coldfront_plugin_api/tests/unit/test_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,27 @@ def admin_client(self):
client.login(username='admin', password='test1234')
return client

@property
def logged_in_user_client(self):
client = APIClient()
client.login(username='cgray', password='test1234')
return client

def test_list_groups(self):
user = self.new_user()
project = self.new_project(pi=user)
allocation = self.new_allocation(project, self.resource, 1)

response = self.admin_client.get("/api/scim/v2/Groups")
desired_in_response = {
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:Group"],
"id": allocation.id,
"displayName": f"Members of allocation {allocation.id} of project {allocation.project.title}",
"members": []
}

self.assertEqual(response.status_code, 200)
self.assertIn(desired_in_response, response.json())

def test_get_group(self):
user = self.new_user()
Expand Down Expand Up @@ -117,3 +130,17 @@ def test_add_remove_group_members(self):
"members": []
}
self.assertEqual(response.json(), desired_response)

def test_normal_user_fobidden(self):
response = self.logged_in_user_client.get(f"/api/scim/v2/Groups")
self.assertEqual(response.status_code, 403)

response = self.logged_in_user_client.get(f"/api/scim/v2/Groups/1234")
self.assertEqual(response.status_code, 403)

response = self.logged_in_user_client.patch(
f"/api/scim/v2/Groups/1234",
data={},
format="json"
)
self.assertEqual(response.status_code, 403)

0 comments on commit 80a7c72

Please sign in to comment.