def setUp(self): super(AttachInterfacesDeprecatedPolicyTest, self).setUp() self.controller = attach_interfaces.InterfaceAttachmentController() self.admin_req = fakes.HTTPRequest.blank('') self.admin_req.environ['nova.context'] = self.project_admin_context self.reader_req = fakes.HTTPRequest.blank('') self.reader_req.environ['nova.context'] = self.project_reader_context self.deprecated_policy = "os_compute_api:os-attach-interfaces" # Overridde rule with different checks than defaults so that we can # verify the rule overridden case. override_rules = {self.deprecated_policy: base_policy.RULE_ADMIN_API} # NOTE(gmann): Only override the deprecated rule in policy file so # that # we can verify if overridden checks are considered by oslo.policy. # Oslo.policy will consider the overridden rules if: # 1. overridden deprecated rule's checks are different than defaults # 2. new rules are not present in policy file self.policy = self.useFixture( nova_fixtures.OverridePolicyFixture(rules_in_file=override_rules))
def setUp(self): super(ServicesDeprecatedPolicyTest, self).setUp() self.controller = services_v21.ServiceController() self.member_req = fakes.HTTPRequest.blank('') self.member_req.environ['nova.context'] = self.system_reader_context self.reader_req = fakes.HTTPRequest.blank('') self.reader_req.environ['nova.context'] = self.project_reader_context self.deprecated_policy = "os_compute_api:os-services" # Overridde rule with different checks than defaults so that we can # verify the rule overridden case. override_rules = {self.deprecated_policy: base_policy.SYSTEM_READER} # NOTE(gmann): Only override the deprecated rule in policy file so # that # we can verify if overridden checks are considered by oslo.policy. # Oslo.policy will consider the overridden rules if: # 1. overridden deprecated rule's checks are different than defaults # 2. new rules are not present in policy file self.policy = self.useFixture( fixtures.OverridePolicyFixture(rules_in_file=override_rules))
def setUp(self): super(InstanceActionsDeprecatedPolicyTest, self).setUp() self.controller = instance_actions_v21.InstanceActionsController() self.admin_or_owner_req = fakes.HTTPRequest.blank('') self.admin_or_owner_req.environ[ 'nova.context'] = self.project_admin_context self.reader_req = fakes.HTTPRequest.blank('') self.reader_req.environ['nova.context'] = self.project_reader_context self.deprecated_policy = ia_policies.ROOT_POLICY # Overridde rule with different checks than defaults so that we can # verify the rule overridden case. override_rules = { self.deprecated_policy: base_policy.RULE_ADMIN_OR_OWNER, } # NOTE(brinzhang): Only override the deprecated rule in policy file # so that we can verify if overridden checks are considered by # oslo.policy. # Oslo.policy will consider the overridden rules if: # 1. overridden deprecated rule's checks are different than defaults # 2. new rules are not present in policy file self.policy = self.useFixture( nova_fixtures.OverridePolicyFixture(rules_in_file=override_rules))
def test_policy_checks_with_fresh_init_and_no_policy_override(self): self.policy = self.useFixture(nova_fixtures.OverridePolicyFixture( rules_in_file={})) policy.reset() self.assertEqual(upgradecheck.Code.SUCCESS, self.cmd._check_policy().code)