<s> from django . test . utils import override_settings <EOL> from openstack_auth import policy as policy_backend <EOL> from openstack_dashboard import policy <EOL> from openstack_dashboard . test import helpers as test <EOL> class PolicyBackendTestCase ( test . TestCase ) : <EOL> def test_policy_file_load ( self ) : <EOL> policy_backend . reset ( ) <EOL> enforcer = policy_backend . _get_enforcer ( ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( enforcer ) ) <EOL> self . assertTrue ( '<STR_LIT>' in enforcer ) <EOL> self . assertTrue ( '<STR_LIT>' in enforcer ) <EOL> def test_policy_reset ( self ) : <EOL> policy_backend . _get_enforcer ( ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( policy_backend . _ENFORCER ) ) <EOL> policy_backend . reset ( ) <EOL> self . assertIsNone ( policy_backend . _ENFORCER ) <EOL> @ override_settings ( POLICY_CHECK_FUNCTION = policy_backend . check ) <EOL> def test_check_admin_required_false ( self ) : <EOL> policy_backend . reset ( ) <EOL> value = policy . check ( ( ( "<STR_LIT>" , "<STR_LIT>" ) , ) , <EOL> request = self . request ) <EOL> self . assertFalse ( value ) <EOL> @ override_settings ( POLICY_CHECK_FUNCTION = policy_backend . check ) <EOL> def test_check_identity_rule_not_found_false ( self ) : <EOL> policy_backend . reset ( ) <EOL> value = policy . check ( ( ( "<STR_LIT>" , "<STR_LIT>" ) , ) , <EOL> request = self . request ) <EOL> self . assertFalse ( value ) <EOL> @ override_settings ( POLICY_CHECK_FUNCTION = policy_backend . check ) <EOL> def test_check_nova_context_is_admin_false ( self ) : <EOL> policy_backend . reset ( ) <EOL> value = policy . check ( ( ( "<STR_LIT>" , "<STR_LIT>" ) , ) , <EOL> request = self . request ) <EOL> self . assertFalse ( value ) <EOL> @ override_settings ( POLICY_CHECK_FUNCTION = policy_backend . check ) <EOL> def test_compound_check_false ( self ) : <EOL> policy_backend . reset ( ) <EOL> value = policy . check ( ( ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , ) , <EOL> request = self . request ) <EOL> self . assertFalse ( value ) <EOL> @ override_settings ( POLICY_CHECK_FUNCTION = policy_backend . check ) <EOL> def test_scope_not_found ( self ) : <EOL> policy_backend . reset ( ) <EOL> value = policy . check ( ( ( "<STR_LIT>" , "<STR_LIT:default>" ) , ) , <EOL> request = self . request ) <EOL> self . assertTrue ( value ) <EOL> class PolicyBackendTestCaseAdmin ( test . BaseAdminViewTests ) : <EOL> @ override_settings ( POLICY_CHECK_FUNCTION = policy_backend . check ) <EOL> def test_check_admin_required_true ( self ) : <EOL> policy_backend . reset ( ) <EOL> value = policy . check ( ( ( "<STR_LIT>" , "<STR_LIT>" ) , ) , <EOL> request = self . request ) <EOL> self . assertTrue ( value ) <EOL> @ override_settings ( POLICY_CHECK_FUNCTION = policy_backend . check ) <EOL> def test_check_identity_rule_not_found_true ( self ) : <EOL> policy_backend . reset ( ) <EOL> value = policy . check ( ( ( "<STR_LIT>" , "<STR_LIT>" ) , ) , <EOL> request = self . request ) <EOL> self . assertTrue ( value ) <EOL> @ override_settings ( POLICY_CHECK_FUNCTION = policy_backend . check ) <EOL> def test_compound_check_true ( self ) : <EOL> policy_backend . reset ( ) <EOL> value = policy . check ( ( ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , ) , <EOL> request = self . request ) <EOL> self . assertTrue ( value ) <EOL> @ override_settings ( POLICY_CHECK_FUNCTION = policy_backend . check ) <EOL> def test_check_nova_context_is_admin_true ( self ) : <EOL> policy_backend . reset ( ) <EOL> value = policy . check ( ( ( "<STR_LIT>" , "<STR_LIT>" ) , ) , <EOL> request = self . request ) <EOL> self . assertTrue ( value ) </s>
