Esempio n. 1
0
    def test_user_delete(self):
        resource = fakes.FakeResource()
        resource.delete = mock.MagicMock()

        scenario = utils.KeystoneScenario()
        scenario._resource_delete(resource)
        resource.delete.assert_called_once_with()
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       'keystone.delete_resource')
Esempio n. 2
0
 def test_list_tenants(self):
     fake_keystone = fakes.FakeKeystoneClient()
     fake_keystone.tenants.list = mock.MagicMock()
     fake_clients = fakes.FakeClients()
     fake_clients._keystone = fake_keystone
     scenario = utils.KeystoneScenario(admin_clients=fake_clients)
     scenario._list_tenants()
     fake_keystone.tenants.list.assert_called_once()
     self._test_atomic_action_timer(scenario.atomic_actions(),
                                    'keystone.list_tenants')
Esempio n. 3
0
    def test_get_user(self):
        user = mock.MagicMock()
        fake_keystone = fakes.FakeKeystoneClient()
        fake_keystone.users.get = mock.MagicMock(return_value=user)
        fake_clients = fakes.FakeClients()
        fake_clients._keystone = fake_keystone
        scenario = utils.KeystoneScenario(admin_clients=fake_clients)

        scenario._get_user(user_id=user.id)

        fake_keystone.users.get.assert_called_once_with(user.id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.get_user")
Esempio n. 4
0
    def test_get_service(self):
        service = mock.MagicMock()
        fake_keystone = fakes.FakeKeystoneClient()
        fake_keystone.services.get = mock.MagicMock(return_value=service)
        fake_clients = fakes.FakeClients()
        fake_clients._keystone = fake_keystone
        scenario = utils.KeystoneScenario(admin_clients=fake_clients)

        scenario._get_service(service_id=service.id)

        fake_keystone.services.get.assert_called_once_with(service.id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.get_service")
Esempio n. 5
0
    def test_get_tenant(self):
        tenant = mock.MagicMock()
        fake_keystone = fakes.FakeKeystoneClient()
        fake_keystone.tenants.get = mock.MagicMock(return_value=tenant)
        fake_clients = fakes.FakeClients()
        fake_clients._keystone = fake_keystone
        scenario = utils.KeystoneScenario(admin_clients=fake_clients)

        scenario._get_tenant(tenant_id=tenant.id)

        fake_keystone.tenants.get.assert_called_once_with(tenant.id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.get_tenant")
Esempio n. 6
0
    def test_update_user_password(self):
        password = "******"
        user = mock.MagicMock()
        fake_keystone = fakes.FakeKeystoneClient()
        fake_keystone.users.update_password = mock.MagicMock()
        fake_clients = fakes.FakeClients()
        fake_clients._keystone = fake_keystone
        scenario = utils.KeystoneScenario(admin_clients=fake_clients)

        scenario._update_user_password(password=password, user_id=user.id)

        fake_keystone.users.update_password.assert_called_once_with(
            user.id, password)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.update_user_password")
Esempio n. 7
0
    def test_tenant_create(self, mock_gen_name):
        name = "abc"
        mock_gen_name.return_value = name

        tenant = {}
        fake_keystone = fakes.FakeKeystoneClient()
        fake_keystone.tenants.create = mock.MagicMock(return_value=tenant)
        fake_clients = fakes.FakeClients()
        fake_clients._keystone = fake_keystone
        scenario = utils.KeystoneScenario(admin_clients=fake_clients)

        result = scenario._tenant_create()

        self.assertEqual(tenant, result)
        fake_keystone.tenants.create.assert_called_once_with(name)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       'keystone.create_tenant')
Esempio n. 8
0
    def test_user_create(self, mock_gen_name):
        name = "abc"
        mock_gen_name.return_value = name

        user = {}
        fake_keystone = fakes.FakeKeystoneClient()
        fake_keystone.users.create = mock.MagicMock(return_value=user)
        fake_clients = fakes.FakeClients()
        fake_clients._keystone = fake_keystone
        scenario = utils.KeystoneScenario(admin_clients=fake_clients)

        result = scenario._user_create()

        self.assertEqual(user, result)
        fake_keystone.users.create.assert_called_once_with(
            name, name, name + "@rally.me")
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       'keystone.create_user')
Esempio n. 9
0
    def test_user_create(self, mock_gen_name, mock_uuid4):
        user = {}
        fake_keystone = fakes.FakeKeystoneClient()
        fake_keystone.users.create = mock.MagicMock(return_value=user)
        fake_clients = fakes.FakeClients()
        fake_clients._keystone = fake_keystone
        scenario = utils.KeystoneScenario(admin_clients=fake_clients)

        result = scenario._user_create()

        self.assertEqual(user, result)
        fake_keystone.users.create.assert_called_once_with(
            mock_gen_name.return_value,
            password=mock_uuid4.return_value,
            email=mock_gen_name.return_value + "@rally.me")
        mock_uuid4.assert_called_with()
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.create_user")
Esempio n. 10
0
    def test_tenant_create_with_users(self, mock_gen_name):
        name = "abc"
        mock_gen_name.return_value = name

        tenant = mock.MagicMock()
        fake_keystone = fakes.FakeKeystoneClient()
        fake_keystone.users.create = mock.MagicMock()
        fake_clients = fakes.FakeClients()
        fake_clients._keystone = fake_keystone
        scenario = utils.KeystoneScenario(admin_clients=fake_clients)

        scenario._users_create(tenant, users_per_tenant=1, name_length=10)

        fake_keystone.users.create.assert_called_once_with(
                    name, password=name, email=name + "@rally.me",
                    tenant_id=tenant.id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.create_users")
Esempio n. 11
0
    def test_update_tenant(self):
        tenant = mock.MagicMock()
        description = tenant.name + "_description_updated_test"
        name = tenant.name + "test_updated_test"
        fake_keystone = fakes.FakeKeystoneClient()
        fake_keystone.tenants.update = mock.MagicMock()
        fake_clients = fakes.FakeClients()
        fake_clients._keystone = fake_keystone
        scenario = utils.KeystoneScenario(admin_clients=fake_clients)

        scenario._update_tenant(tenant=tenant,
                                name=name,
                                description=description)

        fake_keystone.tenants.update.assert_called_once_with(
            tenant.id, name, description)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.update_tenant")
Esempio n. 12
0
    def test_service_create(self, mock_gen_name):
        name = "abc"
        mock_gen_name.return_value = name
        service_type = name + "service_type"
        description = name + "_description"

        service = {}
        fake_keystone = fakes.FakeKeystoneClient()
        fake_keystone.services.create = mock.MagicMock(return_value=service)
        fake_clients = fakes.FakeClients()
        fake_clients._keystone = fake_keystone
        scenario = utils.KeystoneScenario(admin_clients=fake_clients)

        result = scenario._service_create(name=name,
                                          service_type=service_type,
                                          description=description)

        self.assertEqual(service, result)
        fake_keystone.services.create.assert_called_once_with(
            name, service_type, description)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.create_service")
Esempio n. 13
0
 def test_get_service_by_name(self):
     scenario = utils.KeystoneScenario()
     svc_foo, svc_bar = mock.Mock(), mock.Mock()
     scenario._list_services = mock.Mock(return_value=[svc_foo, svc_bar])
     self.assertEqual(scenario._get_service_by_name(svc_bar.name), svc_bar)
     self.assertIsNone(scenario._get_service_by_name("spam"))