@@ -724,3 +724,145 @@ def test_check_user_sync_appstate_persistent_error(user_utils, requests_mock):
724724
725725 # an "update_user_display_name" should have been triggered for every 2 get calls (1 call by check_user_sync, 1 by resync)
726726 assert patche .call_count == get .call_count / 2
727+
728+
729+ def test_create_or_get_manage_api_key_for_user (user_utils , requests_mock ):
730+ pass
731+ # TODO
732+
733+
734+ def test_get_manage_api_key_for_user (user_utils , requests_mock ):
735+ pass
736+ # TODO
737+
738+
739+ def test_delete_manage_api_key (user_utils , requests_mock ):
740+ pass
741+ # TODO
742+
743+
744+ def test_get_manage_group_id (user_utils , requests_mock ):
745+ pass
746+ # TODO
747+
748+
749+ def test_is_user_in_manage_group (user_utils , requests_mock ):
750+ pass
751+ # TODO
752+
753+
754+ def test_add_user_to_manage_group (user_utils , requests_mock ):
755+ pass
756+ # TODO
757+
758+
759+ def test_get_mas_applications_in_workspace (user_utils , requests_mock ):
760+ get = requests_mock .get (
761+ f"{ MAS_API_URL } /workspaces/{ MAS_WORKSPACE_ID } /applications" ,
762+ request_headers = {"x-access-token" : TOKEN },
763+ json = [{"id" : "manage" }],
764+ status_code = 200
765+ )
766+ assert user_utils .get_mas_applications_in_workspace () == [{"id" : "manage" }]
767+ assert get .call_count == 1
768+
769+
770+ def test_get_mas_applications_in_workspace_error (user_utils , requests_mock ):
771+ get = requests_mock .get (
772+ f"{ MAS_API_URL } /workspaces/{ MAS_WORKSPACE_ID } /applications" ,
773+ request_headers = {"x-access-token" : TOKEN },
774+ json = {"error" : "internal" },
775+ status_code = 500
776+ )
777+ with pytest .raises (Exception ) as excinfo :
778+ user_utils .get_mas_applications_in_workspace ()
779+ assert get .call_count == 1
780+ assert str (excinfo .value ) == '500 {"error": "internal"}'
781+
782+
783+ def test_get_mas_application_availability (user_utils , requests_mock ):
784+ application_id = "manage"
785+ get = requests_mock .get (
786+ f"{ MAS_API_URL } /workspaces/{ MAS_WORKSPACE_ID } /applications/{ application_id } " ,
787+ request_headers = {"x-access-token" : TOKEN },
788+ json = {"id" : "manage" },
789+ status_code = 200
790+ )
791+ assert user_utils .get_mas_application_availability (application_id ) == {"id" : "manage" }
792+ assert get .call_count == 1
793+
794+
795+ def test_get_mas_application_availability_error (user_utils , requests_mock ):
796+ application_id = "manage"
797+ get = requests_mock .get (
798+ f"{ MAS_API_URL } /workspaces/{ MAS_WORKSPACE_ID } /applications/{ application_id } " ,
799+ request_headers = {"x-access-token" : TOKEN },
800+ json = {"error" : "internal" },
801+ status_code = 500
802+ )
803+ with pytest .raises (Exception ) as excinfo :
804+ user_utils .get_mas_application_availability (application_id )
805+ assert get .call_count == 1
806+ assert str (excinfo .value ) == '500 {"error": "internal"}'
807+
808+
809+ def test_await_mas_application_availability (user_utils , requests_mock ):
810+ pass
811+ # TODO
812+
813+
814+ def test_parse_initial_users_from_aws_secret_json (user_utils ):
815+
816+ actual_initial_users = user_utils .parse_initial_users_from_aws_secret_json (
817+ {
818+ "user1@example.com" : "primary,joe,bloggs" ,
819+ "user2@example.com" : " primary , ben , bob " ,
820+ "user3@example.com" : "secondary ,bill, bibb"
821+ }
822+ )
823+
824+ expected_initial_users = {
825+ "users" : {
826+ "primary" : [
827+ {
828+ "email" : "user1@example.com" ,
829+ "given_name" : "joe" ,
830+ "family_name" : "bloggs"
831+ },
832+ {
833+ "email" : "user2@example.com" ,
834+ "given_name" : "ben" ,
835+ "family_name" : "bob"
836+ }
837+ ],
838+ "secondary" : [
839+ {
840+ "email" : "user3@example.com" ,
841+ "given_name" : "bill" ,
842+ "family_name" : "bibb"
843+ }
844+ ]
845+ }
846+ }
847+
848+ assert actual_initial_users == expected_initial_users
849+
850+ with pytest .raises (Exception ) as excinfo :
851+ user_utils .parse_initial_users_from_aws_secret_json ({
852+ "user1@example.com" : "primary"
853+ })
854+ assert "Wrong number of CSV values for user1@example.com (expected 3 but got 1)" == str (excinfo .value )
855+
856+ with pytest .raises (Exception ) as excinfo :
857+ user_utils .parse_initial_users_from_aws_secret_json ({
858+ "user1@example.com" : "unknown,x,y"
859+ })
860+ assert "Unknown user type for user1@example.com: unknown" == str (excinfo .value )
861+
862+
863+ def test_create_initial_user_for_saas (user_utils , requests_mock ):
864+ pass
865+
866+
867+ def test_create_initial_users_for_saas (user_utils , requests_mock ):
868+ pass
0 commit comments