management.tests.test_security_managerΒΆ

Test suite for security manager.

ClassesΒΆ

MockSecurityFeature1

Mock security feature for testing.

MockSecurityFeature2

Mock security feature for testing.

SecurityManagerTest

Test suite for SecurityManager.

Module ContentsΒΆ

class management.tests.test_security_manager.MockSecurityFeature1[source]ΒΆ

Bases: management.security.features.SecurityFeature

Mock security feature for testing.

verbose_name = 'Mock Feature 1'[source]ΒΆ
db_field_name = 'mock_feature_1'[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_manager.MockSecurityFeature2[source]ΒΆ

Bases: management.security.features.SecurityFeature

Mock security feature for testing.

verbose_name = 'Mock Feature 2'[source]ΒΆ
db_field_name = 'mock_feature_2'[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_manager.SecurityManagerTest(methodName='runTest')[source]ΒΆ

Bases: django.test.TestCase

Test suite for SecurityManager.

setUp()[source]ΒΆ

Set up test fixtures.

test_get_security_level_returns_current_level()[source]ΒΆ

Test get_security_level returns the current security mode.

test_get_security_level_with_different_modes()[source]ΒΆ

Test get_security_level with different security modes.

test_get_security_config_model_returns_config()[source]ΒΆ

Test get_security_config_model returns SecurityConfig instance.

test_is_feature_allowed_returns_true_for_dev_mode()[source]ΒΆ

Test is_feature_allowed always returns True in DEV mode.

test_is_feature_allowed_with_feature_class()[source]ΒΆ

Test is_feature_allowed works with feature class.

test_is_feature_allowed_with_feature_instance()[source]ΒΆ

Test is_feature_allowed works with feature instance.

test_is_feature_allowed_returns_false_when_not_allowed()[source]ΒΆ

Test is_feature_allowed returns False when feature not in allowed set.

test_is_feature_allowed_with_target_level_parameter()[source]ΒΆ

Test is_feature_allowed with explicit target_level parameter.

test_is_feature_allowed_with_target_level_dev()[source]ΒΆ

Test is_feature_allowed with target_level=DEV returns True.

test_get_features_to_disable_returns_correct_features()[source]ΒΆ

Test get_features_to_disable returns features not allowed at given level.

test_get_features_to_disable_returns_empty_for_dev()[source]ΒΆ

Test get_features_to_disable returns empty list for DEV mode.

test_get_features_to_disable_with_different_levels()[source]ΒΆ

Test get_features_to_disable with different security levels.

test_reset_settings_disables_features(mock_disable)[source]ΒΆ

Test reset_settings calls disable on features that are not allowed.

test_reset_settings_does_not_disable_allowed_features(mock_disable)[source]ΒΆ

Test reset_settings does not disable features that remain allowed.

test_enable_feature_calls_enable_when_allowed(mock_enable)[source]ΒΆ

Test enable_feature calls enable method when feature is allowed.

test_enable_feature_does_not_call_enable_when_not_allowed(mock_enable)[source]ΒΆ

Test enable_feature does not call enable when feature is not allowed.

test_enable_feature_with_kwargs(mock_enable)[source]ΒΆ

Test enable_feature passes kwargs to enable method.

test_enable_feature_with_none_kwargs(mock_enable)[source]ΒΆ

Test enable_feature calls enable without kwargs when kwargs is None.

test_enable_feature_with_feature_instance(mock_enable)[source]ΒΆ

Test enable_feature works with feature instance.

test_is_feature_allowed_handles_string_security_level()[source]ΒΆ

Test is_feature_allowed correctly handles string security level values.

test_level_feature_map_contains_all_security_modes()[source]ΒΆ

Test LEVEL_FEATURE_MAP contains entries for all security modes.

test_level_feature_map_dev_has_all_features()[source]ΒΆ

Test DEV mode has the most features in LEVEL_FEATURE_MAP.