tests.test_permissions_synchronizer

Module Contents

Classes

TestSyncPermissions

Test permissions synchronization.

TestSyncPermissionsConfig

Tests different config setups for permissions synchronization.

Functions

check_config(→ None)

Checks if the config loads without error, or if it triggers the expected exception in the case of an invalid config.

Attributes

CURR_DIR

tests.test_permissions_synchronizer.CURR_DIR[source]
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.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

reset_test_service()[source]

Generates a new test service in Magpie app.

delete_test_service()[source]

Deletes the test service if it exists.

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.

test_webhooks_no_match()[source]

Tests the case where a resource found in the incoming webhook finds no match in the config.

test_webhooks_invalid_service()[source]

Tests the case where a service used in the sync_permissions section of the config is invalid.

test_webhooks_valid_regex()[source]

Tests the permissions synchronization of resources that use a regex to extract a display_name in the config.

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.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

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.

test_unidirectional_named_tokens()[source]

Tests config with a unidirectional mapping that uses named tokens.

test_cross_service_mappings()[source]

Tests config that uses mappings between permissions of different services.