本文整理匯總了Python中tempest.lib.exceptions.Forbidden方法的典型用法代碼示例。如果您正苦於以下問題:Python exceptions.Forbidden方法的具體用法?Python exceptions.Forbidden怎麽用?Python exceptions.Forbidden使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tempest.lib.exceptions
的用法示例。
在下文中一共展示了exceptions.Forbidden方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_rule_validation_lack_permission_throw_exc
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_rule_validation_lack_permission_throw_exc(self, mock_authority,
mock_log):
"""Test that having no permission and exception thrown is success.
Negative test case success scenario.
"""
mock_authority.PolicyAuthority.return_value.allowed.return_value =\
False
@rbac_rv.action(mock.sentinel.service, mock.sentinel.action)
def test_policy(*args):
raise exceptions.Forbidden()
test_policy(self.mock_test_args)
mock_log.warning.assert_not_called()
mock_log.error.assert_not_called()
示例2: test_rule_validation_forbidden_negative
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_rule_validation_forbidden_negative(self, mock_authority,
mock_log):
"""Test Forbidden error is thrown and have permission fails.
Negative test case: if Forbidden is thrown and the user should be
allowed to perform the action, then the Forbidden exception should be
raised.
"""
mock_authority.PolicyAuthority.return_value.allowed.return_value = True
@rbac_rv.action(mock.sentinel.service, mock.sentinel.action)
def test_policy(*args):
raise exceptions.Forbidden()
test_re = "Role Member was not allowed to perform sentinel.action."
self.assertRaisesRegex(exceptions.Forbidden, test_re, test_policy,
self.mock_test_args)
mock_log.error.assert_called_once_with("Role Member was not allowed to"
" perform sentinel.action.")
示例3: test_rule_validation_rbac_malformed_response_negative
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_rule_validation_rbac_malformed_response_negative(
self, mock_authority, mock_log):
"""Test RbacMalformedResponse error is thrown with permission fails.
Negative test case: if RbacMalformedResponse is thrown and the user is
allowed to perform the action, then this is an expected failure.
"""
mock_authority.PolicyAuthority.return_value.allowed.return_value = True
@rbac_rv.action(mock.sentinel.service, mock.sentinel.action)
def test_policy(*args):
raise rbac_exceptions.RbacMalformedResponse()
test_re = "Role Member was not allowed to perform sentinel.action."
self.assertRaisesRegex(exceptions.Forbidden, test_re, test_policy,
self.mock_test_args)
mock_log.error.assert_called_once_with("Role Member was not allowed to"
" perform sentinel.action.")
示例4: test_rule_validation_rbac_conflicting_policies_negative
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_rule_validation_rbac_conflicting_policies_negative(self,
mock_authority,
mock_log):
"""Test RbacConflictingPolicies error is thrown with permission fails.
Negative test case: if RbacConflictingPolicies is thrown and the user
is allowed to perform the action, then this is an expected failure.
"""
mock_authority.PolicyAuthority.return_value.allowed.return_value = True
@rbac_rv.action(mock.sentinel.service, mock.sentinel.action)
def test_policy(*args):
raise rbac_exceptions.RbacConflictingPolicies()
test_re = "Role Member was not allowed to perform sentinel.action."
self.assertRaisesRegex(exceptions.Forbidden, test_re, test_policy,
self.mock_test_args)
mock_log.error.assert_called_once_with("Role Member was not allowed to"
" perform sentinel.action.")
示例5: test_volume_manage
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_volume_manage(self):
volume_id = self.create_volume()['id']
volume = self.volumes_client.show_volume(volume_id)['volume']
# By default, the volume is managed after creation. We need to
# unmanage the volume first before testing manage volume.
self._unmanage_volume(volume)
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
try:
self._manage_volume(volume)
except exceptions.Forbidden as e:
# Since the test role under test does not have permission to
# manage the volume, Forbidden exception is thrown and the
# manageable list will not be cleaned up. Therefore, we need to
# re-manage the volume at the end of the test case for proper
# resource clean up.
self.addCleanup(self._manage_volume, volume)
raise exceptions.Forbidden(e)
示例6: test_create_mtz_networks
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_create_mtz_networks(self):
# Multiple Transport Zone use provier network to implement
# its TZ allocation.
# Only admin client can create MTZ networks.
# non-admin client can not create mtz network
self.assertRaises(lib_exc.Forbidden,
self.create_mtz_networks,
networks_client=self.networks_client)
開發者ID:openstack,項目名稱:vmware-nsx-tempest-plugin,代碼行數:10,代碼來源:test_multiple_transport_zones_negative.py
示例7: test_tenant_cannot_create_provider_sec_group
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_tenant_cannot_create_provider_sec_group(self):
project_id = self.cmgr_alt.networks_client.tenant_id
self.assertRaises(exceptions.Forbidden,
self.create_security_provider_group,
self.cmgr_alt, project_id=project_id,
provider=True)
LOG.debug("Non-Admin Tenant cannot create provider sec group")
示例8: test_tenant_cannot_delete_its_policy
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_tenant_cannot_delete_its_policy(self):
tenant_cmgr = self.cmgr_alt
tenant_id = tenant_cmgr.networks_client.tenant_id
sg = self.create_security_group_policy(cmgr=self.cmgr_adm,
tenant_id=tenant_id)
sg_id = sg.get('id')
tenant_sg_client = tenant_cmgr.security_groups_client
self.assertRaises(exceptions.Forbidden,
self.delete_security_group,
tenant_sg_client, sg_id)
示例9: test_tenant_cannot_update_its_policy
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_tenant_cannot_update_its_policy(self):
tenant_cmgr = self.cmgr_alt
tenant_id = tenant_cmgr.networks_client.tenant_id
sg = self.create_security_group_policy(cmgr=self.cmgr_adm,
tenant_id=tenant_id)
sg_id = sg.get('id')
self.assertRaises(exceptions.Forbidden,
self.update_security_group_policy,
sg_id, self.alt_policy_id, self.cmgr_alt)
示例10: test_tenant_cannot_create_policy
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_tenant_cannot_create_policy(self):
self.assertRaises(exceptions.Forbidden,
self.create_security_group_policy,
self.cmgr_pri)
示例11: test_policy_create_forbidden_for_regular_tenants
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_policy_create_forbidden_for_regular_tenants(self):
"""project/tenant cannot create policy."""
self.assertRaises(
exceptions.Forbidden,
self.create_qos_policy,
'test-policy', 'test policy', False,
qos_client=self.pri_qos_client)
示例12: test_rule_create_forbidden_for_regular_tenants
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_rule_create_forbidden_for_regular_tenants(self):
"""project/tenant cannot create rule."""
self.assertRaises(
exceptions.Forbidden,
self.create_qos_bandwidth_limit_rule,
'policy', max_kbps=1, max_burst_kbps=2,
qos_client=self.pri_qos_client)
示例13: test_only_admin_can_configure_snat
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_only_admin_can_configure_snat(self):
"""Only admin can configure the SNAT"""
self.security_group = self._create_security_group()
self.network = self._create_network()
self.subnet = self._create_subnet(self.network)
self.assertRaises(exceptions.Forbidden, self._create_router,
router_name=data_utils.rand_name('router-smoke'),
external_network_id=CONF.network.public_network_id,
enable_snat=False)
示例14: test_tenant_cannot_create_provider_sec_group
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_tenant_cannot_create_provider_sec_group(self):
project_id = self.cmgr_alt.networks_client.tenant_id
self.assertRaises(exceptions.Forbidden,
self.create_security_provider_group,
self.cmgr_alt, project_id=project_id,
provider=True)
LOG.info("Non-Admin Tenant cannot create provider sec group")
示例15: test_get_all_not_allowed
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import Forbidden [as 別名]
def test_get_all_not_allowed(self):
# Get other projects functions by normal user
context = self.assertRaises(
exceptions.Forbidden,
self.client.get_resources,
'functions?all_projects=true'
)
self.assertIn(
'Operation not allowed',
context.resp_body.get('faultstring')
)