"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "barbican/tests/api/test_resources_policy.py" between
barbican-11.0.0.tar.gz and barbican-12.0.0.tar.gz

About: OpenStack Barbican is the OpenStack Key Manager service. It provides secure storage, provisioning and management of secret data.
The "Wallaby" series (latest release).

test_resources_policy.py  (barbican-11.0.0):test_resources_policy.py  (barbican-12.0.0)
skipping to change at line 38 skipping to change at line 38
from barbican.api.controllers import secrets from barbican.api.controllers import secrets
from barbican.api.controllers import secretstores from barbican.api.controllers import secretstores
from barbican.api.controllers import versions from barbican.api.controllers import versions
from barbican.common import accept as common_accept from barbican.common import accept as common_accept
from barbican.common import config from barbican.common import config
from barbican.common import policy from barbican.common import policy
from barbican import context from barbican import context
from barbican.model import models from barbican.model import models
from barbican.tests import utils from barbican.tests import utils
# Point to the policy.json file located in source control. # Point to the policy.yaml file located in source control.
TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
'../../../etc', 'barbican')) '../../../etc', 'barbican'))
CONF = config.new_config() CONF = config.new_config()
policy.init() policy.init()
ENFORCER = policy.ENFORCER ENFORCER = policy.ENFORCER
class TestableResource(object): class TestableResource(object):
skipping to change at line 1142 skipping to change at line 1142
side_effect=self._generate_get_error()) side_effect=self._generate_get_error())
self.project_repo.find_by_external_project_id = fail_method self.project_repo.find_by_external_project_id = fail_method
self.setup_project_repository_mock(self.project_repo) self.setup_project_repository_mock(self.project_repo)
self.resource = SecretStoresResource() self.resource = SecretStoresResource()
def test_rules_should_be_loaded(self): def test_rules_should_be_loaded(self):
self.assertIsNotNone(self.policy_enforcer.rules) self.assertIsNotNone(self.policy_enforcer.rules)
def test_should_pass_get_all_secret_stores(self): def test_should_pass_get_all_secret_stores(self):
self._assert_pass_rbac(['admin'], self._assert_pass_rbac(
self._invoke_on_get) ['admin', 'observer', 'audit', 'creator', 'reader'],
self._invoke_on_get)
def test_should_raise_get_all_secret_stores(self):
self._assert_fail_rbac([None, 'creator', 'observer', 'audit'],
self._invoke_on_get)
def test_should_pass_get_global_default(self): def test_should_pass_get_global_default(self):
self._assert_pass_rbac(['admin'], self._assert_pass_rbac(
self._invoke_get_global_default) ['admin', 'observer', 'audit', 'creator', 'reader'],
self._invoke_get_global_default)
def test_should_raise_get_global_default(self):
self._assert_fail_rbac([None, 'creator', 'observer', 'audit'],
self._invoke_get_global_default)
def test_should_pass_get_preferred(self): def test_should_pass_get_preferred(self):
self._assert_pass_rbac(['admin'], self._assert_pass_rbac(
self._invoke_get_preferred) ['admin', 'observer', 'audit', 'creator', 'reader'],
self._invoke_get_preferred)
def test_should_raise_get_preferred(self):
self._assert_fail_rbac([None, 'creator', 'observer', 'audit'],
self._invoke_get_preferred)
def _invoke_on_get(self): def _invoke_on_get(self):
self.resource.on_get(self.req, self.resp) self.resource.on_get(self.req, self.resp)
def _invoke_get_global_default(self): def _invoke_get_global_default(self):
with mock.patch('pecan.request', self.req): with mock.patch('pecan.request', self.req):
with mock.patch('pecan.response', self.resp): with mock.patch('pecan.response', self.resp):
return self.resource.controller.get_global_default() return self.resource.controller.get_global_default()
def _invoke_get_preferred(self): def _invoke_get_preferred(self):
skipping to change at line 1212 skipping to change at line 1203
secret_store_res = mock.MagicMock() secret_store_res = mock.MagicMock()
secret_store_res.to_dict_fields = mock.MagicMock(side_effect=IOError) secret_store_res.to_dict_fields = mock.MagicMock(side_effect=IOError)
secret_store_res.id = self.store_id secret_store_res.id = self.store_id
self.resource = SecretStoreResource(secret_store_res) self.resource = SecretStoreResource(secret_store_res)
def test_rules_should_be_loaded(self): def test_rules_should_be_loaded(self):
self.assertIsNotNone(self.policy_enforcer.rules) self.assertIsNotNone(self.policy_enforcer.rules)
def test_should_pass_get_a_secret_store(self): def test_should_pass_get_a_secret_store(self):
self._assert_pass_rbac(['admin'], self._assert_pass_rbac(
self._invoke_on_get) ['admin', 'observer', 'audit', 'creator', 'reader'],
self._invoke_on_get)
def test_should_raise_get_a_secret_store(self):
self._assert_fail_rbac([None, 'creator', 'observer', 'audit'],
self._invoke_on_get)
def _invoke_on_get(self): def _invoke_on_get(self):
self.resource.on_get(self.req, self.resp) self.resource.on_get(self.req, self.resp)
class WhenTestingPreferredSecretStoreResource(BaseTestCase): class WhenTestingPreferredSecretStoreResource(BaseTestCase):
"""RBAC tests for barbican.api.resources.PreferredSecretStoreResource""" """RBAC tests for barbican.api.resources.PreferredSecretStoreResource"""
def setUp(self): def setUp(self):
super(WhenTestingPreferredSecretStoreResource, self).setUp() super(WhenTestingPreferredSecretStoreResource, self).setUp()
self.external_project_id = '12345project' self.external_project_id = '12345project'
skipping to change at line 1254 skipping to change at line 1242
self.resource = PreferredSecretStoreResource(mock.MagicMock()) self.resource = PreferredSecretStoreResource(mock.MagicMock())
def test_rules_should_be_loaded(self): def test_rules_should_be_loaded(self):
self.assertIsNotNone(self.policy_enforcer.rules) self.assertIsNotNone(self.policy_enforcer.rules)
def test_should_pass_set_preferred_secret_store(self): def test_should_pass_set_preferred_secret_store(self):
self._assert_pass_rbac(['admin'], self._assert_pass_rbac(['admin'],
self._invoke_on_post) self._invoke_on_post)
def test_should_raise_set_preferred_secret_store(self): def test_should_raise_set_preferred_secret_store(self):
self._assert_fail_rbac([None, 'creator', 'observer', 'audit'], self._assert_fail_rbac(
self._invoke_on_post) [None, 'creator', 'observer', 'audit', 'reader'],
self._invoke_on_post)
def _invoke_on_post(self): def _invoke_on_post(self):
self.resource.on_post(self.req, self.resp) self.resource.on_post(self.req, self.resp)
class WhenTestingSecretConsumersResource(BaseTestCase): class WhenTestingSecretConsumersResource(BaseTestCase):
"""RBAC tests for barbican.api.resources.SecretConsumersResource""" """RBAC tests for barbican.api.resources.SecretConsumersResource"""
def setUp(self): def setUp(self):
super(WhenTestingSecretConsumersResource, self).setUp() super(WhenTestingSecretConsumersResource, self).setUp()
self.external_project_id = '12345project' self.external_project_id = '12345project'
 End of changes. 6 change blocks. 
27 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)