From 025474cf1c8736bbb0941a1b590f91c4d8348d80 Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Thu, 9 Jan 2025 12:36:54 +0100 Subject: [PATCH] Added test documentation for #1059 --- server/test/api/test_organisation.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/test/api/test_organisation.py b/server/test/api/test_organisation.py index 6bdecd80e..1fb0fa0ff 100644 --- a/server/test/api/test_organisation.py +++ b/server/test/api/test_organisation.py @@ -3,13 +3,13 @@ from server.cron import idp_metadata_parser from server.cron.idp_metadata_parser import idp_metadata_file from server.db.db import db -from server.db.domain import Organisation, OrganisationInvitation, User, JoinRequest, OrganisationMembership +from server.db.domain import Organisation, OrganisationInvitation, User, JoinRequest, OrganisationMembership, ApiKey from server.test.abstract_test import AbstractTest, API_AUTH_HEADER from server.test.seed import (unihard_name, unifra_name, schac_home_organisation_unihar, schac_home_organisation_example, read_image, user_jane_name, unihard_short_name, unihard_unit_support_name, co_ai_computing_name, unifra_secret, co_research_name, - group_science_name, unihard_secret_unit_support) + group_science_name, unihard_secret_unit_support, unihard_hashed_secret_unit_support) class TestOrganisation(AbstractTest): @@ -479,6 +479,12 @@ def test_find_api_unit_access(self): with_basic_auth=False) collaborations = res["collaborations"] self.assertEqual(1, len(collaborations)) + self.assertEqual(co_ai_computing_name, collaborations[0]["name"]) + # Test logic that determined the filtering of CO's with no units or other units than the used ApiKey + api_key = ApiKey.query.filter(ApiKey.hashed_secret == unihard_hashed_secret_unit_support).one() + self.assertEqual(1, len(api_key.units)) + self.assertEqual(1, len(collaborations[0]["units"])) + self.assertEqual(collaborations[0]["units"][0], api_key.units[0].name) def test_search_users(self): self.login("urn:harry")