tests.test_permissions_synchronizer =================================== .. py:module:: tests.test_permissions_synchronizer Attributes ---------- .. autoapisummary:: tests.test_permissions_synchronizer.CURR_DIR Classes ------- .. autoapisummary:: tests.test_permissions_synchronizer.TestSyncPermissions tests.test_permissions_synchronizer.TestSyncPermissionsConfig Functions --------- .. autoapisummary:: tests.test_permissions_synchronizer.check_config Module Contents --------------- .. py:data:: CURR_DIR .. py:class:: TestSyncPermissions(methodName='runTest') Bases: :py:obj:`tests.utils.TestConfig`, :py:obj:`unittest.TestCase` Test permissions synchronization. These tests parse the sync config and checks that when a permission is created/deleted in the `PermissionSynchronizer` the proper permissions are created/deleted for every synchronized service. These tests require a running instance of Magpie. Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name. .. py:method:: setUpClass() :classmethod: Hook method for setting up class fixture before running tests in the class. .. py:method:: setUp() Hook method for setting up the test fixture before exercising it. .. py:method:: tearDown() Hook method for deconstructing the test fixture after testing it. .. py:method:: reset_test_service() Generates a new test service in Magpie app. .. py:method:: delete_test_service() Deletes the test service if it exists. .. py:method:: create_test_permission(resource_id: int, perm_name: magpie.permissions.Permission, perm_access: magpie.permissions.Access, perm_scope: magpie.permissions.Scope, user_name: Optional[str], group_name: Optional[str]) -> None Creates a test permission in Magpie app. .. py:method:: delete_test_permission(resource_id: int, permission_name: magpie.permissions.Permission, user_name: Optional[str], group_name: Optional[str]) -> None Creates a test permission in Magpie app. .. py:method:: check_user_permissions(resource_id: int, expected_permissions: List) -> None Checks if the test user has the `expected_permissions` on the `resource_id`. .. py:method:: check_group_permissions(resource_id: int, expected_permissions: List) -> None Checks if the test group has the `expected_permissions` on the `resource_id`. .. py:method:: test_webhooks_no_tokens() Tests the permissions synchronization of resources that don't use any tokens in the config. .. py:method:: test_webhooks_valid_tokens() Tests the permissions synchronization of resources that use valid tokens in the config. .. py:method:: test_webhooks_invalid_multimatch() Tests the invalid case where a resource in the incoming webhook matches multiple resource keys in the config. .. py:method:: test_webhooks_no_match() Tests the case where a resource found in the incoming webhook finds no match in the config. .. py:method:: test_webhooks_invalid_service() Tests the case where a service used in the `sync_permissions` section of the config is invalid. .. py:method:: test_webhooks_valid_regex() Tests the permissions synchronization of resources that use a regex to extract a display_name in the config. .. py:function:: check_config(config_data: Dict, expected_exception_type: Type[Exception] = None) -> None Checks if the config loads without error, or if it triggers the expected exception in the case of an invalid config. .. py:class:: TestSyncPermissionsConfig(methodName='runTest') Bases: :py:obj:`unittest.TestCase` Tests different config setups for permissions synchronization. Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name. .. py:method:: setUp() Hook method for setting up the test fixture before exercising it. .. py:method:: test_not_unique_multitoken() Tests if config respects the constraint of using maximum one `MULTI_TOKEN` in a single resource. .. py:method:: test_not_unique_named_token() Tests an invalid config where duplicate named tokens are used in a single resource. .. py:method:: test_unknown_res_key() Tests an invalid config where an unknown resource key is found in the permissions_mapping. .. py:method:: test_duplicate_resource_key() Tests an invalid config where the same resource key is used for different resources. .. py:method:: test_invalid_mapping_format() Tests an invalid config where a permissions_mapping uses an invalid format. .. py:method:: test_multi_token_bidirectional() Tests the usage of MULTI_TOKEN in a bidirectional mapping. .. py:method:: test_unidirectional_multi_token() Tests the usage of MULTI_TOKEN in a unidirectional mapping. .. py:method:: test_bidirectional_named_tokens() Tests config with a bidirectional mapping that uses named tokens. .. py:method:: test_unidirectional_named_tokens() Tests config with a unidirectional mapping that uses named tokens. .. py:method:: test_cross_service_mappings() Tests config that uses mappings between permissions of different services.