management.tests.test_security_decoratorsΒΆ

Test suite for security decorators.

ClassesΒΆ

MockSecurityFeature

Mock security feature for testing.

SecurityLevelDecoratorTest

Test suite for the security_level decorator.

Module ContentsΒΆ

class management.tests.test_security_decorators.MockSecurityFeature[source]ΒΆ

Bases: management.security.features.SecurityFeature

Mock security feature for testing.

verbose_name = 'Mock Feature'[source]ΒΆ
db_field_name = 'mock_feature'[source]ΒΆ
enable(**kwargs)[source]ΒΆ

Mock enable method.

Parameters:

kwargs (object)

Return type:

None

disable(**kwargs)[source]ΒΆ

Mock disable method.

Parameters:

kwargs (object)

Return type:

None

is_enabled()[source]ΒΆ

Mock is_enabled method.

Return type:

bool

class management.tests.test_security_decorators.SecurityLevelDecoratorTest(methodName='runTest')[source]ΒΆ

Bases: django.test.TestCase

Test suite for the security_level decorator.

test_decorator_allows_access_when_feature_allowed()[source]ΒΆ

Test decorator allows function execution when feature is allowed.

test_decorator_denies_access_when_feature_not_allowed()[source]ΒΆ

Test decorator raises PermissionDenied when feature is not allowed.

test_decorator_with_feature_class()[source]ΒΆ

Test decorator works with feature class instead of instance.

test_decorator_preserves_function_metadata()[source]ΒΆ

Test decorator preserves original function’s metadata using functools.wraps.

test_decorator_passes_args_and_kwargs()[source]ΒΆ

Test decorator correctly passes arguments and keyword arguments to decorated function.

test_decorator_with_autogenpki_feature()[source]ΒΆ

Test decorator works with real AutoGenPkiFeature.

test_decorator_with_method()[source]ΒΆ

Test decorator works on class methods.

test_decorator_raises_permission_denied_with_correct_message()[source]ΒΆ

Test decorator raises PermissionDenied with informative message.

test_decorator_creates_new_security_manager_per_call()[source]ΒΆ

Test decorator creates a new SecurityManager instance for each call.

test_decorator_with_exception_in_decorated_function()[source]ΒΆ

Test decorator allows exceptions from decorated function to propagate.

test_decorator_with_return_value()[source]ΒΆ

Test decorator correctly returns value from decorated function.

test_decorator_with_none_return()[source]ΒΆ

Test decorator works when decorated function returns None.

test_multiple_decorators_stacked()[source]ΒΆ

Test security_level decorator works when stacked with other decorators.

test_decorator_with_complex_return_types()[source]ΒΆ

Test decorator works with various complex return types.