当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.Forbidden方法代码示例

本文整理汇总了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() 
开发者ID:openstack,项目名称:patrole,代码行数:18,代码来源:test_rbac_rule_validation.py

示例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.") 
开发者ID:openstack,项目名称:patrole,代码行数:21,代码来源:test_rbac_rule_validation.py

示例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.") 
开发者ID:openstack,项目名称:patrole,代码行数:20,代码来源:test_rbac_rule_validation.py

示例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.") 
开发者ID:openstack,项目名称:patrole,代码行数:21,代码来源:test_rbac_rule_validation.py

示例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) 
开发者ID:openstack,项目名称:patrole,代码行数:21,代码来源:test_volumes_manage_rbac.py

示例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") 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:9,代码来源:test_provider_sec_group.py

示例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) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:12,代码来源:test_admin_policy.py

示例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) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:11,代码来源:test_admin_policy.py

示例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) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:6,代码来源:test_admin_policy.py

示例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) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:9,代码来源:test_qos.py

示例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) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:9,代码来源:test_qos.py

示例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) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:11,代码来源:test_router_nonat_ops.py

示例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") 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:9,代码来源:test_provider_sec_group.py

示例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')
        ) 
开发者ID:openstack,项目名称:qinling,代码行数:13,代码来源:test_functions.py


注:本文中的tempest.lib.exceptions.Forbidden方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。