Ejemplo n.º 1
0
    def test_list_services(self):
        scenario = utils.KeystoneScenario(self.context)
        scenario._list_services()

        self.admin_clients("keystone").services.list.assert_called_once_with()
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.service_list")
Ejemplo n.º 2
0
 def test_delete_ec2credentials(self, mock_clients):
     scenario = utils.KeystoneScenario(self.context)
     mock_clients("keystone").ec2.delete = mock.MagicMock()
     scenario._delete_ec2credential("user_id", "access")
     mock_clients("keystone").ec2.delete.assert_called_once_with(
         "user_id", "access")
     self._test_atomic_action_timer(scenario.atomic_actions(),
                                    "keystone.delete_ec2creds")
Ejemplo n.º 3
0
 def test_list_ec2credentials(self, mock_clients):
     scenario = utils.KeystoneScenario(self.context)
     creds_list = mock.Mock()
     mock_clients("keystone").ec2.list.return_value = creds_list
     list_creds = scenario._list_ec2credentials("user_id")
     self.assertEqual(list_creds, creds_list)
     mock_clients("keystone").ec2.list.assert_called_once_with("user_id")
     self._test_atomic_action_timer(scenario.atomic_actions(),
                                    "keystone.list_ec2creds")
Ejemplo n.º 4
0
    def test_user_delete(self):
        resource = fakes.FakeResource()
        resource.delete = mock.MagicMock()

        scenario = utils.KeystoneScenario(self.context)
        scenario._resource_delete(resource)
        resource.delete.assert_called_once_with()
        r = "keystone.delete_%s" % resource.__class__.__name__.lower()
        self._test_atomic_action_timer(scenario.atomic_actions(), r)
Ejemplo n.º 5
0
    def test_get_tenant(self):
        tenant = mock.MagicMock()
        scenario = utils.KeystoneScenario(self.context)
        scenario._get_tenant(tenant_id=tenant.id)

        self.admin_clients("keystone").tenants.get.assert_called_once_with(
            tenant.id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.get_tenant")
Ejemplo n.º 6
0
    def test_get_role(self):
        role = mock.MagicMock()
        scenario = utils.KeystoneScenario()
        scenario._get_role(role_id=role.id)

        self.admin_clients("keystone").roles.get.assert_called_once_with(
            role.id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.get_role")
Ejemplo n.º 7
0
    def test_get_user(self):
        user = mock.MagicMock()
        scenario = utils.KeystoneScenario(self.context)
        scenario._get_user(user_id=user.id)

        self.admin_clients("keystone").users.get.assert_called_once_with(
            user.id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.get_user")
Ejemplo n.º 8
0
    def test_get_service(self):
        service = mock.MagicMock()
        scenario = utils.KeystoneScenario(self.context)
        scenario._get_service(service_id=service.id)

        self.admin_clients("keystone").services.get.assert_called_once_with(
            service.id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.get_service")
Ejemplo n.º 9
0
    def test_role_delete(self, mock_wrap):
        role = mock.MagicMock()
        scenario = utils.KeystoneScenario(self.context)
        scenario._role_delete(role.id)

        mock_wrap.assert_called_once_with(scenario.admin_clients("keystone"))
        mock_wrap.return_value.delete_role.assert_called_once_with(role.id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.role_delete")
Ejemplo n.º 10
0
    def test_role_create(self, mock_generate_random_name):
        scenario = utils.KeystoneScenario()
        result = scenario._role_create()

        self.assertEqual(
            self.admin_clients("keystone").roles.create.return_value, result)
        self.admin_clients("keystone").roles.create.assert_called_once_with(
            mock_generate_random_name.return_value)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.create_role")
Ejemplo n.º 11
0
 def test_create_ec2credentials(self, mock_clients):
     scenario = utils.KeystoneScenario(self.context)
     creds = mock.Mock()
     mock_clients("keystone").ec2.create.return_value = creds
     create_creds = scenario._create_ec2credentials("user_id", "tenant_id")
     self.assertEqual(create_creds, creds)
     mock_clients("keystone").ec2.create.assert_called_once_with(
         "user_id", "tenant_id")
     self._test_atomic_action_timer(scenario.atomic_actions(),
                                    "keystone.create_ec2creds")
Ejemplo n.º 12
0
    def test_token_validate(self):
        token = mock.MagicMock()
        scenario = utils.KeystoneScenario(self.context)

        scenario._token_validate(token)
        self.admin_clients("keystone").tokens.validate.assert_called_once_with(
            token)

        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.validate_token")
Ejemplo n.º 13
0
    def test_tenant_create(self):
        scenario = utils.KeystoneScenario(self.context)
        scenario.generate_random_name = mock.Mock()
        result = scenario._tenant_create()

        self.assertEqual(
            self.admin_clients("keystone").tenants.create.return_value, result)
        self.admin_clients("keystone").tenants.create.assert_called_once_with(
            scenario.generate_random_name.return_value)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.create_tenant")
Ejemplo n.º 14
0
    def test_update_user_enabled(self):
        user = mock.Mock()
        enabled = mock.Mock()
        scenario = utils.KeystoneScenario(self.context)

        scenario._update_user_enabled(user, enabled)
        self.admin_clients(
            "keystone").users.update_enabled.assert_called_once_with(
                user, enabled)

        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.update_user_enabled")
Ejemplo n.º 15
0
    def test_list_roles_for_user(self):
        user = mock.MagicMock()
        tenant = mock.MagicMock()
        scenario = utils.KeystoneScenario(self.context)

        scenario._list_roles_for_user(user, tenant)

        self.admin_clients(
            "keystone").roles.roles_for_user.assert_called_once_with(
                user, tenant)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.list_roles")
Ejemplo n.º 16
0
    def test_update_user_password(self):
        password = "******"
        user = mock.MagicMock()
        scenario = utils.KeystoneScenario(self.context)

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

        self.admin_clients(
            "keystone").users.update_password.assert_called_once_with(
                user.id, password)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.update_user_password")
Ejemplo n.º 17
0
    def test_update_tenant(self):
        tenant = mock.MagicMock()
        description = "new description"

        scenario = utils.KeystoneScenario(self.context)
        scenario.generate_random_name = mock.Mock()
        scenario._update_tenant(tenant=tenant, description=description)

        self.admin_clients("keystone").tenants.update.assert_called_once_with(
            tenant.id, scenario.generate_random_name.return_value, description)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.update_tenant")
Ejemplo n.º 18
0
    def test_user_create(self, mock_generate_random_name, mock_uuid4):
        scenario = utils.KeystoneScenario()
        result = scenario._user_create()

        self.assertEqual(
            self.admin_clients("keystone").users.create.return_value, result)
        self.admin_clients("keystone").users.create.assert_called_once_with(
            "foobarov",
            password=mock_uuid4.return_value,
            email="*****@*****.**")
        mock_uuid4.assert_called_with()
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.create_user")
Ejemplo n.º 19
0
    def test_tenant_create_with_users(self, mock_generate_random_name):
        tenant = mock.MagicMock()
        scenario = utils.KeystoneScenario()

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

        self.admin_clients("keystone").users.create.assert_called_once_with(
            "foobarov",
            password="******",
            email="*****@*****.**",
            tenant_id=tenant.id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.create_users")
Ejemplo n.º 20
0
    def test_role_remove(self):
        user = mock.MagicMock()
        role = mock.MagicMock()
        tenant = mock.MagicMock()
        scenario = utils.KeystoneScenario()

        scenario._role_remove(user=user, role=role, tenant=tenant)

        self.admin_clients(
            "keystone").roles.remove_user_role.assert_called_once_with(
                user, role, tenant)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.remove_role")
Ejemplo n.º 21
0
    def test_update_tenant(self):
        tenant = mock.MagicMock()
        description = tenant.name + "_description_updated_test"
        name = tenant.name + "test_updated_test"
        scenario = utils.KeystoneScenario()
        scenario._update_tenant(tenant=tenant,
                                name=name,
                                description=description)

        self.admin_clients("keystone").tenants.update.assert_called_once_with(
            tenant.id, name, description)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.update_tenant")
Ejemplo n.º 22
0
    def test_role_add(self):
        user = mock.MagicMock()
        role = mock.MagicMock()
        tenant = mock.MagicMock()
        scenario = utils.KeystoneScenario(self.context)

        scenario._role_add(user=user.id, role=role.id, tenant=tenant.id)

        self.admin_clients(
            "keystone").roles.add_user_role.assert_called_once_with(
                user.id, role.id, tenant.id)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.add_role")
Ejemplo n.º 23
0
    def test_role_create(self, mock_wrap, **kwargs):
        role = mock.MagicMock()
        mock_wrap.return_value.create_role.return_value = role
        scenario = utils.KeystoneScenario(self.context)
        scenario.generate_random_name = mock.MagicMock()
        return_role = scenario._role_create(**kwargs)

        self.assertEqual(role, return_role)

        mock_wrap.assert_called_once_with(scenario.admin_clients("keystone"))
        mock_wrap.return_value.create_role.assert_called_once_with(
            scenario.generate_random_name.return_value, **kwargs)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.create_role")
Ejemplo n.º 24
0
    def test_token_authenticate(self):
        name = mock.MagicMock()
        psswd = "foopsswd"
        tenant_id = mock.MagicMock()
        tenant_name = mock.MagicMock()

        scenario = utils.KeystoneScenario(self.context)
        scenario._authenticate_token(name, psswd, tenant_id, tenant_name)
        self.admin_clients(
            "keystone").tokens.authenticate.assert_called_once_with(
                name, tenant_id, tenant_name, "foopsswd")

        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.token_authenticate")
Ejemplo n.º 25
0
    def test_update_user_password_v3(self,
                                     mock_open_stack_scenario_admin_clients):
        password = "******"
        user = mock.MagicMock()
        scenario = utils.KeystoneScenario()

        type(mock_open_stack_scenario_admin_clients.return_value).version = (
            mock.PropertyMock(return_value="v3"))
        scenario._update_user_password(password=password, user_id=user.id)

        mock_open_stack_scenario_admin_clients(
            "keystone").users.update.assert_called_once_with(user.id,
                                                             password=password)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.update_user_password")
Ejemplo n.º 26
0
    def test_service_create(self):
        service_type = "service_type"
        description = "description"
        scenario = utils.KeystoneScenario(self.context)
        scenario.generate_random_name = mock.Mock()

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

        self.assertEqual(
            self.admin_clients("keystone").services.create.return_value,
            result)
        self.admin_clients("keystone").services.create.assert_called_once_with(
            scenario.generate_random_name.return_value, service_type,
            description)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.create_service")
Ejemplo n.º 27
0
    def test_service_create(self):
        name = "abc"
        service_type = name + "_service_type"
        description = name + "_description"

        scenario = utils.KeystoneScenario()

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

        self.assertEqual(
            self.admin_clients("keystone").services.create.return_value,
            result)
        self.admin_clients("keystone").services.create.assert_called_once_with(
            name, service_type, description)
        self._test_atomic_action_timer(scenario.atomic_actions(),
                                       "keystone.create_service")
Ejemplo n.º 28
0
 def test_list_tenants(self):
     scenario = utils.KeystoneScenario()
     scenario._list_tenants()
     self.admin_clients("keystone").tenants.list.assert_called_once_with()
     self._test_atomic_action_timer(scenario.atomic_actions(),
                                    "keystone.list_tenants")
Ejemplo n.º 29
0
 def test_get_service_by_name(self):
     scenario = utils.KeystoneScenario(self.context)
     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"))