tests.test_permissions_synchronizer
Module Contents
Classes
Test permissions synchronization. |
|
Tests different config setups for permissions synchronization. |
Functions
|
Checks if the config loads without error, or if it triggers the expected exception in the case of an invalid config. |
Attributes
-
class
tests.test_permissions_synchronizer.
TestSyncPermissions
(methodName='runTest')[source] Bases:
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.
-
classmethod
setUpClass
()[source] Hook method for setting up class fixture before running tests in the class.
-
create_test_permission
(resource_id: int, perm_name: magpie.permissions.Permission, perm_access: magpie.permissions.Access, perm_scope: magpie.permissions.Scope, user_name: str, group_name: str) → None[source] Creates a test permission in Magpie app.
-
delete_test_permission
(resource_id: int, permission_name: magpie.permissions.Permission, user_name: str, group_name: str) → None[source] Creates a test permission in Magpie app.
-
check_user_permissions
(resource_id: int, expected_permissions: List) → None[source] Checks if the test user has the expected_permissions on the resource_id.
-
check_group_permissions
(resource_id: int, expected_permissions: List) → None[source] Checks if the test group has the expected_permissions on the resource_id.
-
test_webhooks_no_tokens
()[source] Tests the permissions synchronization of resources that don’t use any tokens in the config.
-
test_webhooks_valid_tokens
()[source] Tests the permissions synchronization of resources that use valid tokens in the config.
-
test_webhooks_invalid_multimatch
()[source] Tests the invalid case where a resource in the incoming webhook matches multiple resource keys in the config.
-
classmethod
-
tests.test_permissions_synchronizer.
check_config
(config_data: Dict, expected_exception_type: Type[Exception] = None) → None[source] Checks if the config loads without error, or if it triggers the expected exception in the case of an invalid config.
-
class
tests.test_permissions_synchronizer.
TestSyncPermissionsConfig
(methodName='runTest')[source] Bases:
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.
-
test_not_unique_multitoken
()[source] Tests if config respects the constraint of using maximum one MULTI_TOKEN in a single resource.
-
test_not_unique_named_token
()[source] Tests an invalid config where duplicate named tokens are used in a single resource.
-
test_unknown_res_key
()[source] Tests an invalid config where an unknown resource key is found in the permissions_mapping.
-
test_duplicate_resource_key
()[source] Tests an invalid config where the same resource key is used for different resources.
-
test_invalid_mapping_format
()[source] Tests an invalid config where a permissions_mapping uses an invalid format.
-
test_multi_token_bidirectional
()[source] Tests the usage of MULTI_TOKEN in a bidirectional mapping.
-
test_unidirectional_multi_token
()[source] Tests the usage of MULTI_TOKEN in a unidirectional mapping.
-
test_bidirectional_named_tokens
()[source] Tests config with a bidirectional mapping that uses named tokens.
-