Пример #1
0
    def test_admin_creds(self, MockRestClient):
        cfg.CONF.set_default('neutron', False, 'service_available')
        iso_creds = isolated_creds.IsolatedCreds('test class',
                                                 password='******')
        self._mock_user_create('1234', 'fake_admin_user')
        self._mock_tenant_create('1234', 'fake_admin_tenant')
        self.useFixture(
            mockpatch.PatchObject(json_iden_client.IdentityClientJSON,
                                  'list_roles',
                                  return_value=({
                                      'status': 200
                                  }, [{
                                      'id': '1234',
                                      'name': 'admin'
                                  }])))

        user_mock = mock.patch.object(json_iden_client.IdentityClientJSON,
                                      'assign_user_role')
        user_mock.start()
        self.addCleanup(user_mock.stop)
        with mock.patch.object(json_iden_client.IdentityClientJSON,
                               'assign_user_role') as user_mock:
            admin_creds = iso_creds.get_admin_creds()
        user_mock.assert_called_once_with('1234', '1234', '1234')
        self.assertEqual(admin_creds.username, 'fake_admin_user')
        self.assertEqual(admin_creds.tenant_name, 'fake_admin_tenant')
        # Verify IDs
        self.assertEqual(admin_creds.tenant_id, '1234')
        self.assertEqual(admin_creds.user_id, '1234')
Пример #2
0
    def setUpClass(cls):
        cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__)

        if not cls.config.service_available.cinder:
            skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
            raise cls.skipException(skip_msg)

        if cls.config.compute.allow_tenant_isolation:
            creds = cls.isolated_creds.get_primary_creds()
            username, tenant_name, password = creds
            os = clients.Manager(username=username,
                                 password=password,
                                 tenant_name=tenant_name,
                                 interface=cls._interface)
        else:
            os = clients.Manager(interface=cls._interface)

        cls.os = os
        cls.volumes_client = os.volumes_client
        cls.snapshots_client = os.snapshots_client
        cls.servers_client = os.servers_client
        cls.image_ref = cls.config.compute.image_ref
        cls.flavor_ref = cls.config.compute.flavor_ref
        cls.build_interval = cls.config.volume.build_interval
        cls.build_timeout = cls.config.volume.build_timeout
        cls.snapshots = []
        cls.volumes = []

        cls.volumes_client.keystone_auth(cls.os.username, cls.os.password,
                                         cls.os.auth_url,
                                         cls.volumes_client.service,
                                         cls.os.tenant_name)
Пример #3
0
 def test_network_admin_creation(self, MockRestClient):
     iso_creds = isolated_creds.IsolatedCreds('test class',
                                              password='******')
     self._mock_user_create('1234', 'fake_admin_user')
     self._mock_tenant_create('1234', 'fake_admin_tenant')
     self._mock_network_create(iso_creds, '1234', 'fake_admin_net')
     self._mock_subnet_create(iso_creds, '1234', 'fake_admin_subnet')
     self._mock_router_create('1234', 'fake_admin_router')
     router_interface_mock = self.patch(
         'tempest.services.network.json.network_client.NetworkClientJSON.'
         'add_router_interface_with_subnet_id')
     self.useFixture(
         mockpatch.PatchObject(json_iden_client.IdentityClientJSON,
                               'list_roles',
                               return_value=({
                                   'status': 200
                               }, [{
                                   'id': '123456',
                                   'name': 'admin'
                               }])))
     with mock.patch.object(json_iden_client.IdentityClientJSON,
                            'assign_user_role'):
         iso_creds.get_admin_creds()
     router_interface_mock.called_once_with('1234', '1234')
     network = iso_creds.get_admin_network()
     subnet = iso_creds.get_admin_subnet()
     router = iso_creds.get_admin_router()
     self.assertEqual(network['id'], '1234')
     self.assertEqual(network['name'], 'fake_admin_net')
     self.assertEqual(subnet['id'], '1234')
     self.assertEqual(subnet['name'], 'fake_admin_subnet')
     self.assertEqual(router['id'], '1234')
     self.assertEqual(router['name'], 'fake_admin_router')
Пример #4
0
    def test_no_network_creation_with_config_set(self, MockRestClient):
        cfg.CONF.set_default('create_isolated_networks', False, group='auth')
        iso_creds = isolated_creds.IsolatedCreds(name='test class')
        self._mock_assign_user_role()
        self._mock_list_role()
        self._mock_user_create('1234', 'fake_prim_user')
        self._mock_tenant_create('1234', 'fake_prim_tenant')
        net = mock.patch.object(iso_creds.network_admin_client,
                                'delete_network')
        net_mock = net.start()
        subnet = mock.patch.object(iso_creds.network_admin_client,
                                   'delete_subnet')
        subnet_mock = subnet.start()
        router = mock.patch.object(iso_creds.network_admin_client,
                                   'delete_router')
        router_mock = router.start()

        primary_creds = iso_creds.get_primary_creds()
        self.assertEqual(net_mock.mock_calls, [])
        self.assertEqual(subnet_mock.mock_calls, [])
        self.assertEqual(router_mock.mock_calls, [])
        network = primary_creds.network
        subnet = primary_creds.subnet
        router = primary_creds.router
        self.assertIsNone(network)
        self.assertIsNone(subnet)
        self.assertIsNone(router)
Пример #5
0
    def test_role_creds(self, MockRestClient):
        cfg.CONF.set_default('neutron', False, 'service_available')
        iso_creds = isolated_creds.IsolatedCreds('v2', 'test class')
        self._mock_list_2_roles()
        self._mock_user_create('1234', 'fake_role_user')
        self._mock_tenant_create('1234', 'fake_role_tenant')

        user_mock = mock.patch.object(json_iden_client.IdentityClientJSON,
                                      'assign_user_role')
        user_mock.start()
        self.addCleanup(user_mock.stop)
        with mock.patch.object(json_iden_client.IdentityClientJSON,
                               'assign_user_role') as user_mock:
            role_creds = iso_creds.get_creds_by_roles(roles=['role1', 'role2'])
        calls = user_mock.mock_calls
        # Assert that the role creation is called with the 2 specified roles
        self.assertEqual(len(calls), 2)
        args = map(lambda x: x[1], calls)
        args = list(args)
        self.assertIn(('1234', '1234', '1234'), args)
        self.assertIn(('1234', '1234', '12345'), args)
        self.assertEqual(role_creds.username, 'fake_role_user')
        self.assertEqual(role_creds.tenant_name, 'fake_role_tenant')
        # Verify IDs
        self.assertEqual(role_creds.tenant_id, '1234')
        self.assertEqual(role_creds.user_id, '1234')
Пример #6
0
 def test_tempest_client_xml(self):
     iso_creds = isolated_creds.IsolatedCreds('test class', interface='xml')
     self.assertEqual(iso_creds.interface, 'xml')
     self.assertTrue(isinstance(iso_creds.identity_admin_client,
                                xml_iden_client.IdentityClientXML))
     self.assertTrue(isinstance(iso_creds.network_admin_client,
                                xml_network_client.NetworkClientXML))
Пример #7
0
    def test_no_network_resources(self, MockRestClient):
        net_dict = {
            'network': False,
            'router': False,
            'subnet': False,
            'dhcp': False,
        }
        iso_creds = isolated_creds.IsolatedCreds(name='test class',
                                                 network_resources=net_dict)
        self._mock_assign_user_role()
        self._mock_list_role()
        self._mock_user_create('1234', 'fake_prim_user')
        self._mock_tenant_create('1234', 'fake_prim_tenant')
        net = mock.patch.object(iso_creds.network_admin_client,
                                'delete_network')
        net_mock = net.start()
        subnet = mock.patch.object(iso_creds.network_admin_client,
                                   'delete_subnet')
        subnet_mock = subnet.start()
        router = mock.patch.object(iso_creds.network_admin_client,
                                   'delete_router')
        router_mock = router.start()

        primary_creds = iso_creds.get_primary_creds()
        self.assertEqual(net_mock.mock_calls, [])
        self.assertEqual(subnet_mock.mock_calls, [])
        self.assertEqual(router_mock.mock_calls, [])
        network = primary_creds.network
        subnet = primary_creds.subnet
        router = primary_creds.router
        self.assertIsNone(network)
        self.assertIsNone(subnet)
        self.assertIsNone(router)
Пример #8
0
    def get_client_manager(cls, interface=None):
        """
        Returns an OpenStack client manager
        """
        cls.isolated_creds = isolated_creds.IsolatedCreds(
            cls.__name__, network_resources=cls.network_resources)

        force_tenant_isolation = getattr(cls, 'force_tenant_isolation', None)
        if CONF.compute.allow_tenant_isolation or force_tenant_isolation:
            creds = cls.isolated_creds.get_primary_creds()
            if getattr(cls, '_interface', None):
                os = clients.Manager(credentials=creds,
                                     interface=cls._interface,
                                     service=cls._service)
            elif interface:
                os = clients.Manager(credentials=creds,
                                     interface=interface,
                                     service=cls._service)
            else:
                os = clients.Manager(credentials=creds, service=cls._service)
        else:
            if getattr(cls, '_interface', None):
                os = clients.Manager(interface=cls._interface,
                                     service=cls._service)
            elif interface:
                os = clients.Manager(interface=interface, service=cls._service)
            else:
                os = clients.Manager(service=cls._service)
        return os
Пример #9
0
 def test_tempest_client(self):
     iso_creds = isolated_creds.IsolatedCreds(name='test class')
     self.assertTrue(
         isinstance(iso_creds.identity_admin_client,
                    json_iden_client.IdentityClientJSON))
     self.assertTrue(
         isinstance(iso_creds.network_admin_client,
                    json_network_client.NetworkClientJSON))
Пример #10
0
 def test_official_client(self):
     self.useFixture(
         mockpatch.PatchObject(keystoneclient.Client, 'authenticate'))
     iso_creds = isolated_creds.IsolatedCreds('test class',
                                              tempest_client=False)
     self.assertTrue(
         isinstance(iso_creds.identity_admin_client, keystoneclient.Client))
     self.assertTrue(
         isinstance(iso_creds.network_admin_client, neutronclient.Client))
Пример #11
0
    def setUpClass(cls):
        cls.set_network_resources()
        super(BaseObjectTest, cls).setUpClass()
        if not CONF.service_available.swift:
            skip_msg = ("%s skipped as swift is not available" % cls.__name__)
            raise cls.skipException(skip_msg)
        cls.isolated_creds = isolated_creds.IsolatedCreds(
            cls.__name__, network_resources=cls.network_resources)
        if CONF.compute.allow_tenant_isolation:
            # Get isolated creds for normal user
            creds = cls.isolated_creds.get_primary_creds()
            username, tenant_name, password = creds
            cls.os = clients.Manager(username=username,
                                     password=password,
                                     tenant_name=tenant_name)
            # Get isolated creds for admin user
            admin_creds = cls.isolated_creds.get_admin_creds()
            admin_username, admin_tenant_name, admin_password = admin_creds
            cls.os_admin = clients.Manager(username=admin_username,
                                           password=admin_password,
                                           tenant_name=admin_tenant_name)
            # Get isolated creds for alt user
            alt_creds = cls.isolated_creds.get_alt_creds()
            alt_username, alt_tenant, alt_password = alt_creds
            cls.os_alt = clients.Manager(username=alt_username,
                                         password=alt_password,
                                         tenant_name=alt_tenant)
            # Add isolated users to operator role so that they can create a
            # container in swift.
            cls._assign_member_role()
        else:
            cls.os = clients.Manager()
            cls.os_admin = clients.AdminManager()
            cls.os_alt = clients.AltManager()

        cls.object_client = cls.os.object_client
        cls.container_client = cls.os.container_client
        cls.account_client = cls.os.account_client
        cls.custom_object_client = cls.os.custom_object_client
        cls.token_client = cls.os_admin.token_client
        cls.identity_admin_client = cls.os_admin.identity_client
        cls.custom_account_client = cls.os.custom_account_client
        cls.object_client_alt = cls.os_alt.object_client
        cls.container_client_alt = cls.os_alt.container_client
        cls.identity_client_alt = cls.os_alt.identity_client

        # Make sure we get fresh auth data after assigning swift role
        cls.object_client.auth_provider.clear_auth()
        cls.container_client.auth_provider.clear_auth()
        cls.account_client.auth_provider.clear_auth()
        cls.custom_object_client.auth_provider.clear_auth()
        cls.custom_account_client.auth_provider.clear_auth()
        cls.object_client_alt.auth_provider.clear_auth()
        cls.container_client_alt.auth_provider.clear_auth()

        cls.data = base.DataGenerator(cls.identity_admin_client)
Пример #12
0
    def setUpClass(cls):
        super(NegativeTestCase, cls).setUpClass()

        # If no credentials are provided, the Manager will use those
        # in CONF.identity and generate an auth_provider from them
        cls.isolated_creds = isolated_creds.IsolatedCreds('v2',
                                                          name=cls.__name__)
        creds = cls.isolated_creds.get_alt_creds()
        mgr = clients.Manager(credentials=creds)
        cls.alt_client = MuranoClient(mgr.auth_provider)
Пример #13
0
 def resource_setup(cls):
     cls.set_network_resources()
     super(BaseImageTest, cls).resource_setup()
     cls.created_images = []
     cls._interface = 'json'
     cls.isolated_creds = isolated_creds.IsolatedCreds(
         cls.__name__, network_resources=cls.network_resources)
     if not CONF.service_available.glance:
         skip_msg = ("%s skipped as glance is not available" % cls.__name__)
         raise cls.skipException(skip_msg)
     cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
Пример #14
0
 def test_alt_creds(self, MockRestClient):
     cfg.CONF.set_default('neutron', False, 'service_available')
     iso_creds = isolated_creds.IsolatedCreds('test class',
                                              password='******')
     self._mock_user_create('1234', 'fake_alt_user')
     self._mock_tenant_create('1234', 'fake_alt_tenant')
     alt_creds = iso_creds.get_alt_creds()
     self.assertEqual(alt_creds.username, 'fake_alt_user')
     self.assertEqual(alt_creds.tenant_name, 'fake_alt_tenant')
     # Verify IDs
     self.assertEqual(alt_creds.tenant_id, '1234')
     self.assertEqual(alt_creds.user_id, '1234')
Пример #15
0
 def test_primary_creds(self, MockRestClient):
     cfg.CONF.set_default('neutron', False, 'service_available')
     iso_creds = isolated_creds.IsolatedCreds(name='test class')
     self._mock_assign_user_role()
     self._mock_list_role()
     self._mock_tenant_create('1234', 'fake_prim_tenant')
     self._mock_user_create('1234', 'fake_prim_user')
     primary_creds = iso_creds.get_primary_creds()
     self.assertEqual(primary_creds.username, 'fake_prim_user')
     self.assertEqual(primary_creds.tenant_name, 'fake_prim_tenant')
     # Verify IDs
     self.assertEqual(primary_creds.tenant_id, '1234')
     self.assertEqual(primary_creds.user_id, '1234')
Пример #16
0
 def test_all_cred_cleanup(self, MockRestClient):
     cfg.CONF.set_default('neutron', False, 'service_available')
     iso_creds = isolated_creds.IsolatedCreds('test class',
                                              password='******')
     tenant_fix = self._mock_tenant_create('1234', 'fake_prim_tenant')
     user_fix = self._mock_user_create('1234', 'fake_prim_user')
     username, tenant_name, password = iso_creds.get_primary_creds()
     tenant_fix.cleanUp()
     user_fix.cleanUp()
     tenant_fix = self._mock_tenant_create('12345', 'fake_alt_tenant')
     user_fix = self._mock_user_create('12345', 'fake_alt_user')
     alt_username, alt_tenant, alt_password = iso_creds.get_alt_creds()
     tenant_fix.cleanUp()
     user_fix.cleanUp()
     tenant_fix = self._mock_tenant_create('123456', 'fake_admin_tenant')
     user_fix = self._mock_user_create('123456', 'fake_admin_user')
     self.useFixture(
         mockpatch.PatchObject(json_iden_client.IdentityClientJSON,
                               'list_roles',
                               return_value=({
                                   'status': 200
                               }, [{
                                   'id': '123456',
                                   'name': 'admin'
                               }])))
     with patch.object(json_iden_client.IdentityClientJSON,
                       'assign_user_role'):
         admin_username, admin_tenant, admin_pass = \
             iso_creds.get_admin_creds()
     user_mock = self.patch(
         'tempest.services.identity.json.identity_client.'
         'IdentityClientJSON.delete_user')
     tenant_mock = self.patch(
         'tempest.services.identity.json.identity_client.'
         'IdentityClientJSON.delete_tenant')
     iso_creds.clear_isolated_creds()
     # Verify user delete calls
     calls = user_mock.mock_calls
     self.assertEqual(len(calls), 3)
     args = map(lambda x: x[1][0], calls)
     self.assertIn('1234', args)
     self.assertIn('12345', args)
     self.assertIn('123456', args)
     # Verify tenant delete calls
     calls = tenant_mock.mock_calls
     self.assertEqual(len(calls), 3)
     args = map(lambda x: x[1][0], calls)
     self.assertIn('1234', args)
     self.assertIn('12345', args)
     self.assertIn('123456', args)
Пример #17
0
 def test_alt_creds(self, MockRestClient):
     cfg.CONF.set_default('neutron', False, 'service_available')
     iso_creds = isolated_creds.IsolatedCreds('test class',
                                              password='******')
     self._mock_user_create('1234', 'fake_alt_user')
     self._mock_tenant_create('1234', 'fake_alt_tenant')
     username, tenant_name, password = iso_creds.get_alt_creds()
     self.assertEqual(username, 'fake_alt_user')
     self.assertEqual(tenant_name, 'fake_alt_tenant')
     # Verify helper methods
     tenant = iso_creds.get_alt_tenant()
     user = iso_creds.get_alt_user()
     self.assertEqual(tenant['id'], '1234')
     self.assertEqual(user['id'], '1234')
Пример #18
0
 def test_dhcp_without_subnet(self, MockRestClient):
     net_dict = {
         'network': False,
         'router': False,
         'subnet': False,
         'dhcp': True,
     }
     iso_creds = isolated_creds.IsolatedCreds('test class',
                                              password='******',
                                              network_resources=net_dict)
     self._mock_user_create('1234', 'fake_prim_user')
     self._mock_tenant_create('1234', 'fake_prim_tenant')
     self.assertRaises(exceptions.InvalidConfiguration,
                       iso_creds.get_primary_creds)
Пример #19
0
 def setUpClass(cls):
     cls.created_images = []
     cls._interface = 'json'
     cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__)
     if not cls.config.service_available.glance:
         skip_msg = ("%s skipped as glance is not available" % cls.__name__)
         raise cls.skipException(skip_msg)
     if cls.config.compute.allow_tenant_isolation:
         creds = cls.isolated_creds.get_primary_creds()
         username, tenant_name, password = creds
         cls.os = clients.Manager(username=username,
                                  password=password,
                                  tenant_name=tenant_name)
     else:
         cls.os = clients.Manager()
Пример #20
0
def get_isolated_credentials(name,
                             network_resources=None,
                             force_tenant_isolation=False):
    # If a test requires a new account to work, it can have it via forcing
    # tenant isolation. A new account will be produced only for that test.
    # In case admin credentials are not available for the account creation,
    # the test should be skipped else it would fail.
    if CONF.auth.allow_tenant_isolation or force_tenant_isolation:
        return isolated_creds.IsolatedCreds(
            name=name, network_resources=network_resources)
    else:
        if CONF.auth.locking_credentials_provider:
            # Most params are not relevant for pre-created accounts
            return accounts.Accounts(name=name)
        else:
            return accounts.NotLockingAccounts(name=name)
Пример #21
0
    def setUpClass(cls):
        super(OfficialClientTest, cls).setUpClass()
        cls.isolated_creds = isolated_creds.IsolatedCreds(__name__,
                                                          tempest_client=False)

        username, tenant_name, password = cls.credentials()

        cls.manager = OfficialClientManager(username, password, tenant_name)
        cls.compute_client = cls.manager.compute_client
        cls.image_client = cls.manager.image_client
        cls.identity_client = cls.manager.identity_client
        cls.network_client = cls.manager.network_client
        cls.volume_client = cls.manager.volume_client
        cls.orchestration_client = cls.manager.orchestration_client
        cls.resource_keys = {}
        cls.os_resources = []
Пример #22
0
 def test_official_client(self):
     self.useFixture(mockpatch.PatchObject(keystoneclient.Client,
                                           'authenticate'))
     self.useFixture(mockpatch.PatchObject(clients.OfficialClientManager,
                                           '_get_image_client'))
     self.useFixture(mockpatch.PatchObject(clients.OfficialClientManager,
                                           '_get_object_storage_client'))
     self.useFixture(mockpatch.PatchObject(clients.OfficialClientManager,
                                           '_get_orchestration_client'))
     self.useFixture(mockpatch.PatchObject(clients.OfficialClientManager,
                                           '_get_ceilometer_client'))
     iso_creds = isolated_creds.IsolatedCreds('test class',
                                              tempest_client=False)
     self.assertTrue(isinstance(iso_creds.identity_admin_client,
                                keystoneclient.Client))
     self.assertTrue(isinstance(iso_creds.network_admin_client,
                                neutronclient.Client))
Пример #23
0
    def setUpClass(cls):
        if not cls.config.service_available.nova:
            skip_msg = ("%s skipped as nova is not available" % cls.__name__)
            raise cls.skipException(skip_msg)
        cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__)

        if cls.config.compute.allow_tenant_isolation:
            creds = cls.isolated_creds.get_primary_creds()
            username, tenant_name, password = creds
            os = clients.Manager(username=username,
                                 password=password,
                                 tenant_name=tenant_name,
                                 interface=cls._interface)
        else:
            os = clients.Manager(interface=cls._interface)

        cls.os = os
        cls.servers_client = os.servers_client
        cls.flavors_client = os.flavors_client
        cls.images_client = os.images_client
        cls.extensions_client = os.extensions_client
        cls.floating_ips_client = os.floating_ips_client
        cls.keypairs_client = os.keypairs_client
        cls.security_groups_client = os.security_groups_client
        cls.quotas_client = os.quotas_client
        cls.limits_client = os.limits_client
        cls.volumes_extensions_client = os.volumes_extensions_client
        cls.volumes_client = os.volumes_client
        cls.interfaces_client = os.interfaces_client
        cls.fixed_ips_client = os.fixed_ips_client
        cls.availability_zone_client = os.availability_zone_client
        cls.aggregates_client = os.aggregates_client
        cls.services_client = os.services_client
        cls.hypervisor_client = os.hypervisor_client
        cls.build_interval = cls.config.compute.build_interval
        cls.build_timeout = cls.config.compute.build_timeout
        cls.ssh_user = cls.config.compute.ssh_user
        cls.image_ref = cls.config.compute.image_ref
        cls.image_ref_alt = cls.config.compute.image_ref_alt
        cls.flavor_ref = cls.config.compute.flavor_ref
        cls.flavor_ref_alt = cls.config.compute.flavor_ref_alt
        cls.servers = []
        cls.images = []

        cls.servers_client_v3_auth = os.servers_client_v3_auth
Пример #24
0
 def setUpClass(cls):
     cls.set_network_resources()
     super(BaseImageTest, cls).setUpClass()
     cls.created_images = []
     cls._interface = 'json'
     cls.isolated_creds = isolated_creds.IsolatedCreds(
         cls.__name__, network_resources=cls.network_resources)
     if not CONF.service_available.glance:
         skip_msg = ("%s skipped as glance is not available" % cls.__name__)
         raise cls.skipException(skip_msg)
     if CONF.compute.allow_tenant_isolation:
         creds = cls.isolated_creds.get_primary_creds()
         username, tenant_name, password = creds
         cls.os = clients.Manager(username=username,
                                  password=password,
                                  tenant_name=tenant_name)
     else:
         cls.os = clients.Manager()
Пример #25
0
    def get_client_manager(cls):
        """
        Returns an Openstack client manager
        """
        cls.isolated_creds = isolated_creds.IsolatedCreds(cls.__name__)

        force_tenant_isolation = getattr(cls, 'force_tenant_isolation', None)
        if (cls.config.compute.allow_tenant_isolation
                or force_tenant_isolation):
            creds = cls.isolated_creds.get_primary_creds()
            username, tenant_name, password = creds
            os = clients.Manager(username=username,
                                 password=password,
                                 tenant_name=tenant_name,
                                 interface=cls._interface)
        else:
            os = clients.Manager(interface=cls._interface)
        return os
Пример #26
0
 def test_all_cred_cleanup(self, MockRestClient):
     cfg.CONF.set_default('neutron', False, 'service_available')
     iso_creds = isolated_creds.IsolatedCreds(name='test class',
                                              password='******')
     self._mock_assign_user_role()
     roles_fix = self._mock_list_role()
     tenant_fix = self._mock_tenant_create('1234', 'fake_prim_tenant')
     user_fix = self._mock_user_create('1234', 'fake_prim_user')
     iso_creds.get_primary_creds()
     tenant_fix.cleanUp()
     user_fix.cleanUp()
     tenant_fix = self._mock_tenant_create('12345', 'fake_alt_tenant')
     user_fix = self._mock_user_create('12345', 'fake_alt_user')
     iso_creds.get_alt_creds()
     tenant_fix.cleanUp()
     user_fix.cleanUp()
     roles_fix.cleanUp()
     tenant_fix = self._mock_tenant_create('123456', 'fake_admin_tenant')
     user_fix = self._mock_user_create('123456', 'fake_admin_user')
     self._mock_list_roles('123456', 'admin')
     iso_creds.get_admin_creds()
     user_mock = self.patch(
         'tempest.services.identity.v2.json.identity_client.'
         'IdentityClientJSON.delete_user')
     tenant_mock = self.patch(
         'tempest.services.identity.v2.json.identity_client.'
         'IdentityClientJSON.delete_tenant')
     iso_creds.clear_isolated_creds()
     # Verify user delete calls
     calls = user_mock.mock_calls
     self.assertEqual(len(calls), 3)
     args = map(lambda x: x[1][0], calls)
     args = list(args)
     self.assertIn('1234', args)
     self.assertIn('12345', args)
     self.assertIn('123456', args)
     # Verify tenant delete calls
     calls = tenant_mock.mock_calls
     self.assertEqual(len(calls), 3)
     args = map(lambda x: x[1][0], calls)
     args = list(args)
     self.assertIn('1234', args)
     self.assertIn('12345', args)
     self.assertIn('123456', args)
Пример #27
0
    def setUpClass(cls):
        super(OfficialClientTest, cls).setUpClass()
        cls.isolated_creds = isolated_creds.IsolatedCreds(
            cls.__name__, tempest_client=False,
            network_resources=cls.network_resources)

        cls.manager = clients.OfficialClientManager(
            credentials=cls.credentials())
        cls.compute_client = cls.manager.compute_client
        cls.image_client = cls.manager.image_client
        cls.baremetal_client = cls.manager.baremetal_client
        cls.identity_client = cls.manager.identity_client
        cls.network_client = cls.manager.network_client
        cls.volume_client = cls.manager.volume_client
        cls.object_storage_client = cls.manager.object_storage_client
        cls.orchestration_client = cls.manager.orchestration_client
        cls.data_processing_client = cls.manager.data_processing_client
        cls.resource_keys = {}
        cls.os_resources = []
Пример #28
0
    def setUpClass(cls):
        cls.isolated_creds = isolated_creds.IsolatedCreds(__name__,
                                                          tempest_client=False)
        if cls.config.compute.allow_tenant_isolation:
            creds = cls.isolated_creds.get_primary_creds()
            username, tenant_name, password = creds
        else:
            username = cls.config.identity.username
            password = cls.config.identity.password
            tenant_name = cls.config.identity.tenant_name

        cls.manager = OfficialClientManager(username, password, tenant_name)
        cls.compute_client = cls.manager.compute_client
        cls.image_client = cls.manager.image_client
        cls.identity_client = cls.manager.identity_client
        cls.network_client = cls.manager.network_client
        cls.volume_client = cls.manager.volume_client
        cls.resource_keys = {}
        cls.os_resources = []
Пример #29
0
    def resource_setup(cls):
        cls.set_network_resources()
        super(BaseObjectTest, cls).resource_setup()
        if not CONF.service_available.swift:
            skip_msg = ("%s skipped as swift is not available" % cls.__name__)
            raise cls.skipException(skip_msg)
        cls.isolated_creds = isolated_creds.IsolatedCreds(
            cls.__name__, network_resources=cls.network_resources)
        if CONF.compute.allow_tenant_isolation:
            # Get isolated creds for normal user
            cls.os = clients.Manager(cls.isolated_creds.get_primary_creds())
            # Get isolated creds for admin user
            cls.os_admin = clients.Manager(
                cls.isolated_creds.get_admin_creds())
            # Get isolated creds for alt user
            cls.os_alt = clients.Manager(cls.isolated_creds.get_alt_creds())
        else:
            cls.os = clients.Manager()
            cls.os_admin = clients.AdminManager()
            cls.os_alt = clients.AltManager()

        cls.object_client = cls.os.object_client
        cls.container_client = cls.os.container_client
        cls.account_client = cls.os.account_client
        cls.custom_object_client = cls.os.custom_object_client
        cls.token_client = cls.os_admin.token_client
        cls.identity_admin_client = cls.os_admin.identity_client
        cls.custom_account_client = cls.os.custom_account_client
        cls.object_client_alt = cls.os_alt.object_client
        cls.container_client_alt = cls.os_alt.container_client
        cls.identity_client_alt = cls.os_alt.identity_client

        # Make sure we get fresh auth data after assigning swift role
        cls.object_client.auth_provider.clear_auth()
        cls.container_client.auth_provider.clear_auth()
        cls.account_client.auth_provider.clear_auth()
        cls.custom_object_client.auth_provider.clear_auth()
        cls.custom_account_client.auth_provider.clear_auth()
        cls.object_client_alt.auth_provider.clear_auth()
        cls.container_client_alt.auth_provider.clear_auth()

        cls.data = SwiftDataGenerator(cls.identity_admin_client)
Пример #30
0
    def test_admin_creds(self, MockRestClient):
        cfg.CONF.set_default('neutron', False, 'service_available')
        iso_creds = isolated_creds.IsolatedCreds(name='test class')
        self._mock_list_roles('1234', 'admin')
        self._mock_user_create('1234', 'fake_admin_user')
        self._mock_tenant_create('1234', 'fake_admin_tenant')

        user_mock = mock.patch.object(json_iden_client.IdentityClientJSON,
                                      'assign_user_role')
        user_mock.start()
        self.addCleanup(user_mock.stop)
        with mock.patch.object(json_iden_client.IdentityClientJSON,
                               'assign_user_role') as user_mock:
            admin_creds = iso_creds.get_admin_creds()
        user_mock.assert_has_calls([mock.call('1234', '1234', '1234')])
        self.assertEqual(admin_creds.username, 'fake_admin_user')
        self.assertEqual(admin_creds.tenant_name, 'fake_admin_tenant')
        # Verify IDs
        self.assertEqual(admin_creds.tenant_id, '1234')
        self.assertEqual(admin_creds.user_id, '1234')