diff --git a/tempest/api/compute/admin/test_aggregates_negative.py b/tempest/api/compute/admin/test_aggregates_negative.py index 6868fa61f4..48f6f94be4 100644 --- a/tempest/api/compute/admin/test_aggregates_negative.py +++ b/tempest/api/compute/admin/test_aggregates_negative.py @@ -45,7 +45,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): def test_aggregate_create_as_user(self): # Regular user is not allowed to create an aggregate. aggregate_name = data_utils.rand_name(self.aggregate_name_prefix) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.user_client.create_aggregate, name=aggregate_name) @@ -82,14 +82,14 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): aggregate = self.client.create_aggregate(name=aggregate_name) self.addCleanup(self.client.delete_aggregate, aggregate['id']) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.user_client.delete_aggregate, aggregate['id']) @test.attr(type=['negative', 'gate']) def test_aggregate_list_as_user(self): # Regular user is not allowed to list aggregates. - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.user_client.list_aggregates) @test.attr(type=['negative', 'gate']) @@ -99,7 +99,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): aggregate = self.client.create_aggregate(name=aggregate_name) self.addCleanup(self.client.delete_aggregate, aggregate['id']) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.user_client.get_aggregate, aggregate['id']) @@ -139,7 +139,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): aggregate = self.client.create_aggregate(name=aggregate_name) self.addCleanup(self.client.delete_aggregate, aggregate['id']) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.user_client.add_host, aggregate['id'], self.host) @@ -166,7 +166,7 @@ class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): self.client.add_host(aggregate['id'], self.host) self.addCleanup(self.client.remove_host, aggregate['id'], self.host) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.user_client.remove_host, aggregate['id'], self.host) diff --git a/tempest/api/compute/admin/test_availability_zone_negative.py b/tempest/api/compute/admin/test_availability_zone_negative.py index d062b0c656..546aa3b052 100644 --- a/tempest/api/compute/admin/test_availability_zone_negative.py +++ b/tempest/api/compute/admin/test_availability_zone_negative.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from tempest_lib import exceptions as lib_exc + from tempest.api.compute import base -from tempest import exceptions from tempest import test @@ -33,5 +34,5 @@ class AZAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): # List of availability zones and available services with # non-administrator user self.assertRaises( - exceptions.Unauthorized, + lib_exc.Unauthorized, self.non_adm_client.get_availability_zone_list_detail) diff --git a/tempest/api/compute/admin/test_fixed_ips_negative.py b/tempest/api/compute/admin/test_fixed_ips_negative.py index 310b4dd3df..bb5fa8c7b3 100644 --- a/tempest/api/compute/admin/test_fixed_ips_negative.py +++ b/tempest/api/compute/admin/test_fixed_ips_negative.py @@ -45,14 +45,14 @@ class FixedIPsNegativeTestJson(base.BaseV2ComputeAdminTest): @test.attr(type=['negative', 'gate']) @test.services('network') def test_list_fixed_ip_details_with_non_admin_user(self): - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.get_fixed_ip_details, self.ip) @test.attr(type=['negative', 'gate']) @test.services('network') def test_set_reserve_with_non_admin_user(self): body = {"reserve": "None"} - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.reserve_fixed_ip, self.ip, body) @@ -60,7 +60,7 @@ class FixedIPsNegativeTestJson(base.BaseV2ComputeAdminTest): @test.services('network') def test_set_unreserve_with_non_admin_user(self): body = {"unreserve": "None"} - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.reserve_fixed_ip, self.ip, body) diff --git a/tempest/api/compute/admin/test_flavors_access_negative.py b/tempest/api/compute/admin/test_flavors_access_negative.py index a31d16355a..5031432c56 100644 --- a/tempest/api/compute/admin/test_flavors_access_negative.py +++ b/tempest/api/compute/admin/test_flavors_access_negative.py @@ -18,7 +18,6 @@ import uuid from tempest.api.compute import base from tempest.common.utils import data_utils -from tempest import exceptions from tempest import test @@ -69,7 +68,7 @@ class FlavorsAccessNegativeTestJSON(base.BaseV2ComputeAdminTest): new_flavor_id, is_public='False') self.addCleanup(self.client.delete_flavor, new_flavor['id']) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.flavors_client.add_flavor_access, new_flavor['id'], self.tenant_id) @@ -89,7 +88,7 @@ class FlavorsAccessNegativeTestJSON(base.BaseV2ComputeAdminTest): self.client.add_flavor_access(new_flavor['id'], self.tenant_id) self.addCleanup(self.client.remove_flavor_access, new_flavor['id'], self.tenant_id) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.flavors_client.remove_flavor_access, new_flavor['id'], self.tenant_id) diff --git a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py index 5249c32332..e414973f14 100644 --- a/tempest/api/compute/admin/test_flavors_extra_specs_negative.py +++ b/tempest/api/compute/admin/test_flavors_extra_specs_negative.py @@ -63,7 +63,7 @@ class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest): def test_flavor_non_admin_set_keys(self): # Test to SET flavor extra spec as a user without admin privileges. specs = {"key1": "value1", "key2": "value2"} - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.flavors_client.set_flavor_extra_spec, self.flavor['id'], specs) @@ -75,7 +75,7 @@ class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest): body = self.client.set_flavor_extra_spec( self.flavor['id'], specs) self.assertEqual(body['key1'], 'value1') - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.flavors_client. update_flavor_extra_spec, self.flavor['id'], @@ -87,7 +87,7 @@ class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest): specs = {"key1": "value1", "key2": "value2"} self.client.set_flavor_extra_spec(self.flavor['id'], specs) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.flavors_client.unset_flavor_extra_spec, self.flavor['id'], 'key1') diff --git a/tempest/api/compute/admin/test_flavors_negative.py b/tempest/api/compute/admin/test_flavors_negative.py index 86125fb457..34d8e3ff6d 100644 --- a/tempest/api/compute/admin/test_flavors_negative.py +++ b/tempest/api/compute/admin/test_flavors_negative.py @@ -15,11 +15,12 @@ import uuid +from tempest_lib import exceptions as lib_exc + from tempest.api.compute import base from tempest.api_schema.request.compute.v2 import flavors from tempest.common.utils import data_utils from tempest import config -from tempest import exceptions from tempest import test @@ -88,7 +89,7 @@ class FlavorsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): flavor_name = data_utils.rand_name(self.flavor_name_prefix) new_flavor_id = str(uuid.uuid4()) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.user_client.create_flavor, flavor_name, self.ram, self.vcpus, self.disk, new_flavor_id, ephemeral=self.ephemeral, @@ -97,7 +98,7 @@ class FlavorsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): @test.attr(type=['negative', 'gate']) def test_delete_flavor_as_user(self): # only admin user can delete a flavor - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.user_client.delete_flavor, self.flavor_ref_alt) diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py index 51caef50ec..20429b18af 100644 --- a/tempest/api/compute/admin/test_hosts_negative.py +++ b/tempest/api/compute/admin/test_hosts_negative.py @@ -40,7 +40,7 @@ class HostsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): @test.attr(type=['negative', 'gate']) def test_list_hosts_with_non_admin_user(self): - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.list_hosts) @test.attr(type=['negative', 'gate']) @@ -53,7 +53,7 @@ class HostsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): def test_show_host_detail_with_non_admin_user(self): hostname = self._get_host_name() - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.show_host_detail, hostname) @@ -61,7 +61,7 @@ class HostsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): def test_update_host_with_non_admin_user(self): hostname = self._get_host_name() - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.update_host, hostname, status='enable', @@ -132,7 +132,7 @@ class HostsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): def test_startup_host_with_non_admin_user(self): hostname = self._get_host_name() - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.startup_host, hostname) @@ -148,7 +148,7 @@ class HostsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): def test_shutdown_host_with_non_admin_user(self): hostname = self._get_host_name() - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.shutdown_host, hostname) @@ -164,6 +164,6 @@ class HostsAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): def test_reboot_host_with_non_admin_user(self): hostname = self._get_host_name() - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.reboot_host, hostname) diff --git a/tempest/api/compute/admin/test_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py index cb973e1adb..a9c1cb1414 100644 --- a/tempest/api/compute/admin/test_hypervisor_negative.py +++ b/tempest/api/compute/admin/test_hypervisor_negative.py @@ -18,7 +18,6 @@ import uuid from tempest.api.compute import base from tempest.common.utils import data_utils -from tempest import exceptions from tempest import test @@ -54,7 +53,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): self.assertTrue(len(hypers) > 0) self.assertRaises( - exceptions.Unauthorized, + lib_exc.Unauthorized, self.non_adm_client.get_hypervisor_show_details, hypers[0]['id']) @@ -64,7 +63,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): self.assertTrue(len(hypers) > 0) self.assertRaises( - exceptions.Unauthorized, + lib_exc.Unauthorized, self.non_adm_client.get_hypervisor_servers, hypers[0]['id']) @@ -80,7 +79,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): @test.attr(type=['negative', 'gate']) def test_get_hypervisor_stats_with_non_admin_user(self): self.assertRaises( - exceptions.Unauthorized, + lib_exc.Unauthorized, self.non_adm_client.get_hypervisor_stats) @test.attr(type=['negative', 'gate']) @@ -98,7 +97,7 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): self.assertTrue(len(hypers) > 0) self.assertRaises( - exceptions.Unauthorized, + lib_exc.Unauthorized, self.non_adm_client.get_hypervisor_uptime, hypers[0]['id']) @@ -106,14 +105,14 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): def test_get_hypervisor_list_with_non_admin_user(self): # List of hypervisor and available services with non admin user self.assertRaises( - exceptions.Unauthorized, + lib_exc.Unauthorized, self.non_adm_client.get_hypervisor_list) @test.attr(type=['negative', 'gate']) def test_get_hypervisor_list_details_with_non_admin_user(self): # List of hypervisor details and available services with non admin user self.assertRaises( - exceptions.Unauthorized, + lib_exc.Unauthorized, self.non_adm_client.get_hypervisor_list_details) @test.attr(type=['negative', 'gate']) @@ -131,6 +130,6 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): self.assertTrue(len(hypers) > 0) self.assertRaises( - exceptions.Unauthorized, + lib_exc.Unauthorized, self.non_adm_client.search_hypervisor, hypers[0]['hypervisor_hostname']) diff --git a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py index c4905d919d..1e03bd0122 100644 --- a/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py +++ b/tempest/api/compute/admin/test_instance_usage_audit_log_negative.py @@ -16,6 +16,8 @@ import datetime import urllib +from tempest_lib import exceptions as lib_exc + from tempest.api.compute import base from tempest import exceptions from tempest import test @@ -31,11 +33,11 @@ class InstanceUsageAuditLogNegativeTestJSON(base.BaseV2ComputeAdminTest): @test.attr(type=['negative', 'gate']) def test_instance_usage_audit_logs_with_nonadmin_user(self): # the instance_usage_audit_logs API just can be accessed by admin user - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.instance_usages_audit_log_client. list_instance_usage_audit_logs) now = datetime.datetime.now() - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.instance_usages_audit_log_client. get_instance_usage_audit_log, urllib.quote(now.strftime("%Y-%m-%d %H:%M:%S"))) diff --git a/tempest/api/compute/admin/test_quotas_negative.py b/tempest/api/compute/admin/test_quotas_negative.py index e86cb8c839..2fb7be66d3 100644 --- a/tempest/api/compute/admin/test_quotas_negative.py +++ b/tempest/api/compute/admin/test_quotas_negative.py @@ -18,7 +18,6 @@ from tempest_lib import exceptions as lib_exc from tempest.api.compute import base from tempest.common.utils import data_utils from tempest import config -from tempest import exceptions from tempest import test CONF = config.CONF @@ -40,7 +39,7 @@ class QuotasAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): @test.attr(type=['negative', 'gate']) def test_update_quota_normal_user(self): - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.client.update_quota_set, self.demo_tenant_id, ram=0) @@ -60,7 +59,7 @@ class QuotasAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id, cores=default_vcpu_quota) - self.assertRaises((exceptions.Unauthorized, lib_exc.OverLimit), + self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit), self.create_test_server) @test.attr(type=['negative', 'gate']) @@ -76,7 +75,7 @@ class QuotasAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id, ram=default_mem_quota) - self.assertRaises((exceptions.Unauthorized, lib_exc.OverLimit), + self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit), self.create_test_server) @test.attr(type=['negative', 'gate']) @@ -91,7 +90,7 @@ class QuotasAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): instances=instances_quota) self.addCleanup(self.adm_client.update_quota_set, self.demo_tenant_id, instances=default_instances_quota) - self.assertRaises((exceptions.Unauthorized, lib_exc.OverLimit), + self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit), self.create_test_server) @decorators.skip_because(bug="1186354", @@ -117,7 +116,7 @@ class QuotasAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): # Check we cannot create anymore # A 403 Forbidden or 413 Overlimit (old behaviour) exception # will be raised when out of quota - self.assertRaises((exceptions.Unauthorized, lib_exc.OverLimit), + self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit), self.sg_client.create_security_group, "sg-overlimit", "sg-desc") @@ -156,6 +155,6 @@ class QuotasAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): # Check we cannot create SG rule anymore # A 403 Forbidden or 413 Overlimit (old behaviour) exception # will be raised when out of quota - self.assertRaises((lib_exc.OverLimit, exceptions.Unauthorized), + self.assertRaises((lib_exc.OverLimit, lib_exc.Unauthorized), self.sg_client.create_security_group_rule, secgroup_id, ip_protocol, 1025, 1025) diff --git a/tempest/api/compute/admin/test_servers_negative.py b/tempest/api/compute/admin/test_servers_negative.py index ab1ed81a34..0d4731d29b 100644 --- a/tempest/api/compute/admin/test_servers_negative.py +++ b/tempest/api/compute/admin/test_servers_negative.py @@ -72,7 +72,7 @@ class ServersAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): ram, vcpus, disk, flavor_id) self.addCleanup(self.flavors_client.delete_flavor, flavor_id) - self.assertRaises((exceptions.Unauthorized, lib_exc.OverLimit), + self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit), self.client.resize, self.servers[0]['id'], flavor_ref['id']) @@ -93,7 +93,7 @@ class ServersAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): ram, vcpus, disk, flavor_id) self.addCleanup(self.flavors_client.delete_flavor, flavor_id) - self.assertRaises((exceptions.Unauthorized, lib_exc.OverLimit), + self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit), self.client.resize, self.servers[0]['id'], flavor_ref['id']) @@ -118,7 +118,7 @@ class ServersAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): @test.attr(type=['negative', 'gate']) def test_get_server_diagnostics_by_non_admin(self): # Non-admin user can not view server diagnostics according to policy - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_adm_client.get_server_diagnostics, self.s1_id) diff --git a/tempest/api/compute/admin/test_services_negative.py b/tempest/api/compute/admin/test_services_negative.py index bb19a392e7..39d0ee138e 100644 --- a/tempest/api/compute/admin/test_services_negative.py +++ b/tempest/api/compute/admin/test_services_negative.py @@ -12,8 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. +from tempest_lib import exceptions as lib_exc + from tempest.api.compute import base -from tempest import exceptions from tempest import test @@ -31,7 +32,7 @@ class ServicesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest): @test.attr(type=['negative', 'gate']) def test_list_services_with_non_admin_user(self): - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.list_services) @test.attr(type=['negative', 'gate']) diff --git a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py index da8ba35420..b371f2dfde 100644 --- a/tempest/api/compute/admin/test_simple_tenant_usage_negative.py +++ b/tempest/api/compute/admin/test_simple_tenant_usage_negative.py @@ -62,5 +62,5 @@ class TenantUsagesNegativeTestJSON(base.BaseV2ComputeAdminTest): params = {'start': self.start, 'end': self.end, 'detailed': int(bool(True))} - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.client.list_tenant_usages, params) diff --git a/tempest/api/compute/limits/test_absolute_limits_negative.py b/tempest/api/compute/limits/test_absolute_limits_negative.py index 42adbfe930..9776db3d85 100644 --- a/tempest/api/compute/limits/test_absolute_limits_negative.py +++ b/tempest/api/compute/limits/test_absolute_limits_negative.py @@ -17,7 +17,6 @@ from tempest_lib import exceptions as lib_exc from tempest.api.compute import base from tempest.common import tempest_fixtures as fixtures -from tempest import exceptions from tempest import test @@ -53,5 +52,5 @@ class AbsoluteLimitsNegativeTestJSON(base.BaseV2ComputeTest): # A 403 Forbidden or 413 Overlimit (old behaviour) exception # will be raised when out of quota - self.assertRaises((exceptions.Unauthorized, lib_exc.OverLimit), + self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit), self.create_test_server, meta=meta_data) diff --git a/tempest/api/compute/servers/test_server_metadata_negative.py b/tempest/api/compute/servers/test_server_metadata_negative.py index 7b488f92f6..7fe95dd008 100644 --- a/tempest/api/compute/servers/test_server_metadata_negative.py +++ b/tempest/api/compute/servers/test_server_metadata_negative.py @@ -132,14 +132,14 @@ class ServerMetadataNegativeTestJSON(base.BaseV2ComputeTest): req_metadata = {} for num in range(1, quota_metadata + 2): req_metadata['key' + str(num)] = 'val' + str(num) - self.assertRaises((lib_exc.OverLimit, exceptions.Unauthorized), + self.assertRaises((lib_exc.OverLimit, lib_exc.Unauthorized), self.client.set_server_metadata, self.server_id, req_metadata) # A 403 Forbidden or 413 Overlimit (old behaviour) exception # will be raised while exceeding metadata items limit for # tenant. - self.assertRaises((exceptions.Unauthorized, lib_exc.OverLimit), + self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit), self.client.update_server_metadata, self.server_id, req_metadata) diff --git a/tempest/api/compute/servers/test_server_personality.py b/tempest/api/compute/servers/test_server_personality.py index 55f90c8e4c..bd3ebb027f 100644 --- a/tempest/api/compute/servers/test_server_personality.py +++ b/tempest/api/compute/servers/test_server_personality.py @@ -17,7 +17,6 @@ import base64 from tempest_lib import exceptions as lib_exc from tempest.api.compute import base -from tempest import exceptions from tempest import test @@ -45,7 +44,7 @@ class ServerPersonalityTestJSON(base.BaseV2ComputeTest): 'contents': base64.b64encode(file_contents)}) # A 403 Forbidden or 413 Overlimit (old behaviour) exception # will be raised when out of quota - self.assertRaises((exceptions.Unauthorized, lib_exc.OverLimit), + self.assertRaises((lib_exc.Unauthorized, lib_exc.OverLimit), self.create_test_server, personality=personality) @test.attr(type='gate') diff --git a/tempest/api/identity/admin/test_roles_negative.py b/tempest/api/identity/admin/test_roles_negative.py index 679db13689..789e8b6b3a 100644 --- a/tempest/api/identity/admin/test_roles_negative.py +++ b/tempest/api/identity/admin/test_roles_negative.py @@ -36,7 +36,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): @test.attr(type=['negative', 'gate']) def test_list_roles_by_unauthorized_user(self): # Non-administrator user should not be able to list roles - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.list_roles) @test.attr(type=['negative', 'gate']) @@ -44,7 +44,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): # Request to list roles without a valid token should fail token = self.client.auth_provider.get_token() self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, self.client.list_roles) + self.assertRaises(lib_exc.Unauthorized, self.client.list_roles) self.client.auth_provider.clear_auth() @test.attr(type=['negative', 'gate']) @@ -56,7 +56,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): def test_create_role_by_unauthorized_user(self): # Non-administrator user should not be able to create role role_name = data_utils.rand_name(name='role-') - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.create_role, role_name) @test.attr(type=['negative', 'gate']) @@ -65,7 +65,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): token = self.client.auth_provider.get_token() self.client.delete_token(token) role_name = data_utils.rand_name(name='role-') - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.client.create_role, role_name) self.client.auth_provider.clear_auth() @@ -86,7 +86,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): body = self.client.create_role(role_name) self.data.roles.append(body) role_id = body.get('id') - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.delete_role, role_id) @test.attr(type=['negative', 'gate']) @@ -98,7 +98,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): role_id = body.get('id') token = self.client.auth_provider.get_token() self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.client.delete_role, role_id) self.client.auth_provider.clear_auth() @@ -115,7 +115,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): # Non-administrator user should not be authorized to # assign a role to user (user, tenant, role) = self._get_role_params() - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.assign_user_role, tenant['id'], user['id'], role['id']) @@ -125,7 +125,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): (user, tenant, role) = self._get_role_params() token = self.client.auth_provider.get_token() self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.client.assign_user_role, tenant['id'], user['id'], role['id']) self.client.auth_provider.clear_auth() @@ -162,7 +162,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): self.client.assign_user_role(tenant['id'], user['id'], role['id']) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.remove_user_role, tenant['id'], user['id'], role['id']) @@ -175,7 +175,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): role['id']) token = self.client.auth_provider.get_token() self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.client.remove_user_role, tenant['id'], user['id'], role['id']) self.client.auth_provider.clear_auth() @@ -208,7 +208,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): # a user's roles (user, tenant, role) = self._get_role_params() self.client.assign_user_role(tenant['id'], user['id'], role['id']) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.list_user_roles, tenant['id'], user['id']) @@ -219,7 +219,7 @@ class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): token = self.client.auth_provider.get_token() self.client.delete_token(token) try: - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.client.list_user_roles, tenant['id'], user['id']) finally: diff --git a/tempest/api/identity/admin/test_tenant_negative.py b/tempest/api/identity/admin/test_tenant_negative.py index 81ba6ffbbf..a4bf2630c0 100644 --- a/tempest/api/identity/admin/test_tenant_negative.py +++ b/tempest/api/identity/admin/test_tenant_negative.py @@ -28,7 +28,7 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): @test.attr(type=['negative', 'gate']) def test_list_tenants_by_unauthorized_user(self): # Non-administrator user should not be able to list tenants - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.list_tenants) @test.attr(type=['negative', 'gate']) @@ -36,7 +36,7 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): # Request to list tenants without a valid token should fail token = self.client.auth_provider.get_token() self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, self.client.list_tenants) + self.assertRaises(lib_exc.Unauthorized, self.client.list_tenants) self.client.auth_provider.clear_auth() @test.attr(type=['negative', 'gate']) @@ -45,7 +45,7 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): tenant_name = data_utils.rand_name(name='tenant-') tenant = self.client.create_tenant(tenant_name) self.data.tenants.append(tenant) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.delete_tenant, tenant['id']) @test.attr(type=['negative', 'gate']) @@ -56,7 +56,7 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): self.data.tenants.append(tenant) token = self.client.auth_provider.get_token() self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, self.client.delete_tenant, + self.assertRaises(lib_exc.Unauthorized, self.client.delete_tenant, tenant['id']) self.client.auth_provider.clear_auth() @@ -84,7 +84,7 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): def test_create_tenant_by_unauthorized_user(self): # Non-administrator user should not be authorized to create a tenant tenant_name = data_utils.rand_name(name='tenant-') - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.create_tenant, tenant_name) @test.attr(type=['negative', 'gate']) @@ -93,7 +93,7 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): tenant_name = data_utils.rand_name(name='tenant-') token = self.client.auth_provider.get_token() self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, self.client.create_tenant, + self.assertRaises(lib_exc.Unauthorized, self.client.create_tenant, tenant_name) self.client.auth_provider.clear_auth() @@ -122,7 +122,7 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): tenant_name = data_utils.rand_name(name='tenant-') tenant = self.client.create_tenant(tenant_name) self.data.tenants.append(tenant) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.update_tenant, tenant['id']) @test.attr(type=['negative', 'gate']) @@ -133,6 +133,6 @@ class TenantsNegativeTestJSON(base.BaseIdentityV2AdminTest): self.data.tenants.append(tenant) token = self.client.auth_provider.get_token() self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, self.client.update_tenant, + self.assertRaises(lib_exc.Unauthorized, self.client.update_tenant, tenant['id']) self.client.auth_provider.clear_auth() diff --git a/tempest/api/identity/admin/test_users_negative.py b/tempest/api/identity/admin/test_users_negative.py index a3a3e2401f..33a2f355de 100644 --- a/tempest/api/identity/admin/test_users_negative.py +++ b/tempest/api/identity/admin/test_users_negative.py @@ -36,7 +36,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): def test_create_user_by_unauthorized_user(self): # Non-administrator should not be authorized to create a user self.data.setup_test_tenant() - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.create_user, self.alt_user, self.alt_password, self.data.tenant['id'], self.alt_email) @@ -80,7 +80,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): token = self.client.auth_provider.get_token() # Delete the token from database self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, self.client.create_user, + self.assertRaises(lib_exc.Unauthorized, self.client.create_user, self.alt_user, self.alt_password, self.data.tenant['id'], self.alt_email) @@ -113,7 +113,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): token = self.client.auth_provider.get_token() # Delete the token from database self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, self.client.update_user, + self.assertRaises(lib_exc.Unauthorized, self.client.update_user, self.alt_user) # Unset the token to allow further tests to generate a new token @@ -123,14 +123,14 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): def test_update_user_by_unauthorized_user(self): # Non-administrator should not be authorized to update user self.data.setup_test_tenant() - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.update_user, self.alt_user) @test.attr(type=['negative', 'gate']) def test_delete_users_by_unauthorized_user(self): # Non-administrator user should not be authorized to delete a user self.data.setup_test_user() - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.delete_user, self.data.user['id']) @@ -148,7 +148,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): token = self.client.auth_provider.get_token() # Delete the token from database self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, self.client.delete_user, + self.assertRaises(lib_exc.Unauthorized, self.client.delete_user, self.alt_user) # Unset the token to allow further tests to generate a new token @@ -159,7 +159,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): # Disabled user's token should not get authenticated self.data.setup_test_user() self.disable_user(self.data.test_user) - self.assertRaises(exceptions.Unauthorized, self.token_client.auth, + self.assertRaises(lib_exc.Unauthorized, self.token_client.auth, self.data.test_user, self.data.test_password, self.data.test_tenant) @@ -169,7 +169,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): # User's token for a disabled tenant should not be authenticated self.data.setup_test_user() self.disable_tenant(self.data.test_tenant) - self.assertRaises(exceptions.Unauthorized, self.token_client.auth, + self.assertRaises(lib_exc.Unauthorized, self.token_client.auth, self.data.test_user, self.data.test_password, self.data.test_tenant) @@ -178,7 +178,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): def test_authentication_with_invalid_tenant(self): # User's token for an invalid tenant should not be authenticated self.data.setup_test_user() - self.assertRaises(exceptions.Unauthorized, self.token_client.auth, + self.assertRaises(lib_exc.Unauthorized, self.token_client.auth, self.data.test_user, self.data.test_password, 'junktenant1234') @@ -187,7 +187,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): def test_authentication_with_invalid_username(self): # Non-existent user's token should not get authenticated self.data.setup_test_user() - self.assertRaises(exceptions.Unauthorized, self.token_client.auth, + self.assertRaises(lib_exc.Unauthorized, self.token_client.auth, 'junkuser123', self.data.test_password, self.data.test_tenant) @@ -195,7 +195,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): def test_authentication_with_invalid_password(self): # User's token with invalid password should not be authenticated self.data.setup_test_user() - self.assertRaises(exceptions.Unauthorized, self.token_client.auth, + self.assertRaises(lib_exc.Unauthorized, self.token_client.auth, self.data.test_user, 'junkpass1234', self.data.test_tenant) @@ -203,7 +203,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): def test_get_users_by_unauthorized_user(self): # Non-administrator user should not be authorized to get user list self.data.setup_test_user() - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.get_users) @test.attr(type=['negative', 'gate']) @@ -211,7 +211,7 @@ class UsersNegativeTestJSON(base.BaseIdentityV2AdminTest): # Request to get list of users without a valid token should fail token = self.client.auth_provider.get_token() self.client.delete_token(token) - self.assertRaises(exceptions.Unauthorized, self.client.get_users) + self.assertRaises(lib_exc.Unauthorized, self.client.get_users) self.client.auth_provider.clear_auth() @test.attr(type=['negative', 'gate']) diff --git a/tempest/api/identity/admin/v3/test_projects_negative.py b/tempest/api/identity/admin/v3/test_projects_negative.py index 8bb7d50cab..23a16d1eea 100644 --- a/tempest/api/identity/admin/v3/test_projects_negative.py +++ b/tempest/api/identity/admin/v3/test_projects_negative.py @@ -27,7 +27,7 @@ class ProjectsNegativeTestJSON(base.BaseIdentityV3AdminTest): @test.attr(type=['negative', 'gate']) def test_list_projects_by_unauthorized_user(self): # Non-admin user should not be able to list projects - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.non_admin_client.list_projects) @test.attr(type=['negative', 'gate']) @@ -45,7 +45,7 @@ class ProjectsNegativeTestJSON(base.BaseIdentityV3AdminTest): # Non-admin user should not be authorized to create a project project_name = data_utils.rand_name('project-') self.assertRaises( - exceptions.Unauthorized, self.non_admin_client.create_project, + lib_exc.Unauthorized, self.non_admin_client.create_project, project_name) @test.attr(type=['negative', 'gate']) @@ -68,7 +68,7 @@ class ProjectsNegativeTestJSON(base.BaseIdentityV3AdminTest): project = self.client.create_project(project_name) self.data.projects.append(project) self.assertRaises( - exceptions.Unauthorized, self.non_admin_client.delete_project, + lib_exc.Unauthorized, self.non_admin_client.delete_project, project['id']) @test.attr(type=['negative', 'gate']) diff --git a/tempest/api/image/v2/test_images_member_negative.py b/tempest/api/image/v2/test_images_member_negative.py index 1f8e3d0be0..9965286091 100644 --- a/tempest/api/image/v2/test_images_member_negative.py +++ b/tempest/api/image/v2/test_images_member_negative.py @@ -10,6 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. +from tempest_lib import exceptions as lib_exc + from tempest.api.image import base from tempest import exceptions from tempest import test @@ -35,7 +37,7 @@ class ImagesMemberNegativeTest(base.BaseV2MemberImageTest): self.alt_tenant_id) self.assertEqual(member['status'], 'pending') self.assertNotIn(image_id, self._list_image_ids_as_alt()) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.os_img_client.update_member_status, image_id, self.alt_tenant_id, 'accepted') self.assertNotIn(image_id, self._list_image_ids_as_alt()) diff --git a/tempest/api/object_storage/test_account_quotas_negative.py b/tempest/api/object_storage/test_account_quotas_negative.py index 36e7111596..0e136bf430 100644 --- a/tempest/api/object_storage/test_account_quotas_negative.py +++ b/tempest/api/object_storage/test_account_quotas_negative.py @@ -21,7 +21,6 @@ from tempest.api.object_storage import base from tempest import clients from tempest.common.utils import data_utils from tempest import config -from tempest import exceptions from tempest import test CONF = config.CONF @@ -86,12 +85,12 @@ class AccountQuotasNegativeTest(base.BaseObjectTest): """ # Not able to remove quota - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.account_client.create_account_metadata, {"Quota-Bytes": ""}) # Not able to modify quota - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.account_client.create_account_metadata, {"Quota-Bytes": "100"}) diff --git a/tempest/api/object_storage/test_account_services_negative.py b/tempest/api/object_storage/test_account_services_negative.py index ef04387798..9acf668cc2 100644 --- a/tempest/api/object_storage/test_account_services_negative.py +++ b/tempest/api/object_storage/test_account_services_negative.py @@ -14,9 +14,10 @@ # License for the specific language governing permissions and limitations # under the License. +from tempest_lib import exceptions as lib_exc + from tempest.api.object_storage import base from tempest import clients -from tempest import exceptions from tempest import test @@ -44,6 +45,6 @@ class AccountNegativeTest(base.BaseObjectTest): params = {'format': 'json'} # list containers with non-authorized user token - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.account_client.list_account_containers, params=params) diff --git a/tempest/api/object_storage/test_container_acl_negative.py b/tempest/api/object_storage/test_container_acl_negative.py index 138d25a30e..7fe472c9cd 100644 --- a/tempest/api/object_storage/test_container_acl_negative.py +++ b/tempest/api/object_storage/test_container_acl_negative.py @@ -14,10 +14,11 @@ # License for the specific language governing permissions and limitations # under the License. +from tempest_lib import exceptions as lib_exc + from tempest.api.object_storage import base from tempest import clients from tempest.common.utils import data_utils -from tempest import exceptions from tempest import test @@ -47,7 +48,7 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): request_part='headers', auth_data=None ) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.object_client.create_object, self.container_name, object_name, 'data', headers={}) @@ -63,7 +64,7 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): request_part='headers', auth_data=None ) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.object_client.delete_object, self.container_name, object_name) @@ -77,7 +78,7 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): request_part='headers', auth_data=self.test_auth_data ) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.object_client.create_object, self.container_name, object_name, 'data', headers={}) @@ -94,7 +95,7 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): request_part='headers', auth_data=self.test_auth_data ) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.object_client.get_object, self.container_name, object_name) @@ -111,7 +112,7 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): request_part='headers', auth_data=self.test_auth_data ) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.object_client.delete_object, self.container_name, object_name) @@ -134,7 +135,7 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): request_part='headers', auth_data=self.test_auth_data ) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.object_client.get_object, self.container_name, object_name) @@ -153,7 +154,7 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): auth_data=self.test_auth_data ) object_name = data_utils.rand_name(name='Object') - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.object_client.create_object, self.container_name, object_name, 'data', headers={}) @@ -175,7 +176,7 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): auth_data=self.test_auth_data ) object_name = data_utils.rand_name(name='Object') - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.object_client.create_object, self.container_name, object_name, 'data', headers={}) @@ -201,7 +202,7 @@ class ObjectACLsNegativeTest(base.BaseObjectTest): request_part='headers', auth_data=self.test_auth_data ) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.object_client.delete_object, self.container_name, object_name) diff --git a/tempest/api/object_storage/test_object_formpost_negative.py b/tempest/api/object_storage/test_object_formpost_negative.py index 32f5917713..cdd9d2cc55 100644 --- a/tempest/api/object_storage/test_object_formpost_negative.py +++ b/tempest/api/object_storage/test_object_formpost_negative.py @@ -18,9 +18,10 @@ import hmac import time import urlparse +from tempest_lib import exceptions as lib_exc + from tempest.api.object_storage import base from tempest.common.utils import data_utils -from tempest import exceptions from tempest import test @@ -117,7 +118,7 @@ class ObjectFormPostNegativeTest(base.BaseObjectTest): url = "%s/%s" % (self.container_name, self.object_name) exc = self.assertRaises( - exceptions.Unauthorized, + lib_exc.Unauthorized, self.object_client.post, url, body, headers=headers) self.assertIn('FormPost: Form Expired', str(exc)) @@ -133,7 +134,7 @@ class ObjectFormPostNegativeTest(base.BaseObjectTest): url = "%s/%s" % (self.container_name, self.object_name) exc = self.assertRaises( - exceptions.Unauthorized, + lib_exc.Unauthorized, self.object_client.post, url, body, headers=headers) self.assertIn('FormPost: Invalid Signature', str(exc)) diff --git a/tempest/api/object_storage/test_object_temp_url_negative.py b/tempest/api/object_storage/test_object_temp_url_negative.py index b752348b59..ca342933c0 100644 --- a/tempest/api/object_storage/test_object_temp_url_negative.py +++ b/tempest/api/object_storage/test_object_temp_url_negative.py @@ -19,9 +19,10 @@ import hmac import time import urlparse +from tempest_lib import exceptions as lib_exc + from tempest.api.object_storage import base from tempest.common.utils import data_utils -from tempest import exceptions from tempest import test @@ -104,5 +105,5 @@ class ObjectTempUrlNegativeTest(base.BaseObjectTest): # temp URL is valid for 1 seconds, let's wait 2 time.sleep(2) - self.assertRaises(exceptions.Unauthorized, + self.assertRaises(lib_exc.Unauthorized, self.object_client.get, url) diff --git a/tempest/common/service_client.py b/tempest/common/service_client.py index e43ced4b68..9aeb243199 100644 --- a/tempest/common/service_client.py +++ b/tempest/common/service_client.py @@ -59,8 +59,6 @@ class ServiceClient(rest_client.RestClient): method, url, extra_headers=extra_headers, headers=headers, body=body) - except lib_exceptions.Unauthorized as ex: - raise exceptions.Unauthorized(ex) except lib_exceptions.BadRequest as ex: raise exceptions.BadRequest(ex) # TODO(oomichi): This is just a workaround for failing gate tests @@ -68,7 +66,7 @@ class ServiceClient(rest_client.RestClient): # We will need to remove this translation and replace negative tests # with lib_exceptions.Forbidden in the future. except lib_exceptions.Forbidden as ex: - raise exceptions.Unauthorized(ex) + raise lib_exceptions.Unauthorized(ex) class ResponseBody(dict): diff --git a/tempest/exceptions.py b/tempest/exceptions.py index 333246c65d..81db5d9c85 100644 --- a/tempest/exceptions.py +++ b/tempest/exceptions.py @@ -151,10 +151,6 @@ class InvalidHttpSuccessCode(RestClientException): message = "The success code is different than the expected one" -class Unauthorized(RestClientException): - message = 'Unauthorized' - - class BadRequest(RestClientException): message = "Bad request" diff --git a/tempest/services/identity/json/token_client.py b/tempest/services/identity/json/token_client.py index 93936bcf3d..1e8b31e85a 100644 --- a/tempest/services/identity/json/token_client.py +++ b/tempest/services/identity/json/token_client.py @@ -13,6 +13,7 @@ # under the License. import json +from tempest_lib import exceptions as lib_exc from tempest.common import service_client from tempest import config @@ -87,7 +88,7 @@ class TokenClientJSON(service_client.ServiceClient): if resp.status in [401, 403]: resp_body = json.loads(resp_body) - raise exceptions.Unauthorized(resp_body['error']['message']) + raise lib_exc.Unauthorized(resp_body['error']['message']) elif resp.status not in [200, 201]: raise exceptions.IdentityError( 'Unexpected status code {0}'.format(resp.status)) diff --git a/tempest/services/identity/v3/json/token_client.py b/tempest/services/identity/v3/json/token_client.py index 14c4a0a5e7..1467d7ca87 100644 --- a/tempest/services/identity/v3/json/token_client.py +++ b/tempest/services/identity/v3/json/token_client.py @@ -13,6 +13,7 @@ # under the License. import json +from tempest_lib import exceptions as lib_exc from tempest.common import service_client from tempest import config @@ -112,7 +113,7 @@ class V3TokenClientJSON(service_client.ServiceClient): if resp.status in [401, 403]: resp_body = json.loads(resp_body) - raise exceptions.Unauthorized(resp_body['error']['message']) + raise lib_exc.Unauthorized(resp_body['error']['message']) elif resp.status not in [200, 201, 204]: raise exceptions.IdentityError( 'Unexpected status code {0}'.format(resp.status))