def test_flavor_update_with_extra_specs_policy(self, mock_save):
        fakes.stub_out_flavor_get_by_flavor_id(self)
        rule_name = policies.POLICY_ROOT % 'index'
        # 'update' policy is checked before flavor extra specs 'index' policy
        # so we have to allow it for everyone otherwise it will fail first
        # for unauthorized contexts.
        rule = fm_policies.POLICY_ROOT % 'update'
        self.policy.set_rules({rule: "@"}, overwrite=False)
        req = fakes.HTTPRequest.blank('', version='2.61')

        authorize_res, unauthorize_res = self.common_policy_check(
            self.all_system_authorized_contexts,
            self.all_system_unauthorized_contexts,
            rule_name,
            self.fm_ctrl._update,
            req,
            '1',
            body={'flavor': {
                'description': None
            }},
            fatal=False)
        for resp in authorize_res:
            self.assertIn('extra_specs', resp['flavor'])
        for resp in unauthorize_res:
            self.assertNotIn('extra_specs', resp['flavor'])
 def setUp(self):
     super(FlavorDisabledTestV21, self).setUp()
     fakes.stub_out_nw_api(self)
     fakes.stub_out_flavor_get_all(self)
     fakes.stub_out_flavor_get_by_flavor_id(self)
     self.stub_out('nova.api.openstack.wsgi.Request.get_db_flavor',
                   fake_get_db_flavor)
Exemplo n.º 3
0
 def test_flavor_show_with_extra_specs_policy(self):
     fakes.stub_out_flavor_get_by_flavor_id(self)
     rule_name = policies.POLICY_ROOT % 'index'
     req = fakes.HTTPRequest.blank('', version='2.61')
     authorize_res, unauthorize_res = self.common_policy_auth(
         self.all_authorized_contexts,
         rule_name,
         self.flavor_ctrl.show,
         req,
         '1',
         fatal=False)
     for resp in authorize_res:
         self.assertIn('extra_specs', resp['flavor'])
     for resp in unauthorize_res:
         self.assertNotIn('extra_specs', resp['flavor'])
 def setUp(self):
     super(FlavorsTestV21, self).setUp()
     fakes.stub_out_networking(self)
     fakes.stub_out_flavor_get_all(self)
     fakes.stub_out_flavor_get_by_flavor_id(self)
     self.controller = self.Controller()
Exemplo n.º 5
0
 def setUp(self):
     super(FlavorsTestV21, self).setUp()
     fakes.stub_out_networking(self)
     fakes.stub_out_flavor_get_all(self)
     fakes.stub_out_flavor_get_by_flavor_id(self)
     self.controller = self.Controller()
 def setUp(self):
     super(FlavorDisabledTestV21, self).setUp()
     fakes.stub_out_nw_api(self)
     fakes.stub_out_flavor_get_all(self)
     fakes.stub_out_flavor_get_by_flavor_id(self)
Exemplo n.º 7
0
 def setUp(self):
     super(FlavorDisabledTestV21, self).setUp()
     fakes.stub_out_nw_api(self)
     fakes.stub_out_flavor_get_all(self)
     fakes.stub_out_flavor_get_by_flavor_id(self)
Exemplo n.º 8
0
 def setUp(self):
     super(FlavorsPolicyEnforcementV21, self).setUp()
     self.flavor_controller = flavors_v21.FlavorsController()
     fakes.stub_out_flavor_get_by_flavor_id(self)
     fakes.stub_out_flavor_get_all(self)
     self.req = fakes.HTTPRequest.blank('')
Exemplo n.º 9
0
 def setUp(self):
     super(FlavorExtraDataTestV21, self).setUp()
     fakes.stub_out_flavor_get_all(self)
     fakes.stub_out_flavor_get_by_flavor_id(self)