Пример #1
0
 def test_create_user(self, mock_generate_random_name):
     scenario = basic.KeystoneBasic(self.context)
     scenario._user_create = mock.MagicMock()
     scenario.create_user(name_length=20, password="******", tenant_id="id")
     scenario._user_create.assert_called_once_with(name_length=20,
                                                   password="******",
                                                   tenant_id="id")
 def test_create_and_list_tenants(self):
     scenario = basic.KeystoneBasic(self.context)
     scenario._tenant_create = mock.MagicMock()
     scenario._list_tenants = mock.MagicMock()
     scenario.create_and_list_tenants(enabled=True)
     scenario._tenant_create.assert_called_once_with(enabled=True)
     scenario._list_tenants.assert_called_with()
 def test_create_and_list_users(self):
     scenario = basic.KeystoneBasic(self.context)
     scenario._user_create = mock.MagicMock()
     scenario._list_users = mock.MagicMock()
     scenario.create_and_list_users(password="******", tenant_id="id")
     scenario._user_create.assert_called_once_with(password="******",
                                                   tenant_id="id")
     scenario._list_users.assert_called_once_with()
 def test_create_and_delete_role(self):
     scenario = basic.KeystoneBasic(self.context)
     fake_role = mock.MagicMock()
     scenario._role_create = mock.MagicMock(return_value=fake_role)
     scenario._resource_delete = mock.MagicMock()
     scenario.create_and_delete_role()
     scenario._role_create.assert_called_once_with()
     scenario._resource_delete.assert_called_once_with(fake_role)
Пример #5
0
 def test_create_and_list_tenants(self, mock_generate_random_name):
     scenario = basic.KeystoneBasic(self.context)
     scenario._tenant_create = mock.MagicMock()
     scenario._list_tenants = mock.MagicMock()
     scenario.create_and_list_tenants(name_length=20, enabled=True)
     scenario._tenant_create.assert_called_once_with(name_length=20,
                                                     enabled=True)
     scenario._list_tenants.assert_called_with()
 def test_create_and_list_ec2credentials(self):
     context = self._get_context()
     scenario = basic.KeystoneBasic(context)
     scenario._create_ec2credentials = mock.MagicMock()
     scenario._list_ec2credentials = mock.MagicMock()
     scenario.create_and_list_ec2credentials()
     scenario._create_ec2credentials.assert_called_once_with(
         "fake_user_id", "fake_tenant_id")
     scenario._list_ec2credentials.assert_called_with("fake_user_id")
Пример #7
0
 def test_create_update_and_delete_tenant(self):
     scenario = basic.KeystoneBasic()
     fake_tenant = mock.MagicMock()
     scenario._tenant_create = mock.MagicMock(return_value=fake_tenant)
     scenario._update_tenant = mock.MagicMock()
     scenario._resource_delete = mock.MagicMock()
     scenario.create_update_and_delete_tenant()
     scenario._update_tenant.assert_called_once_with(fake_tenant)
     scenario._resource_delete.assert_called_once_with(fake_tenant)
 def test_create_tenant_with_users(self):
     scenario = basic.KeystoneBasic(self.context)
     fake_tenant = mock.MagicMock()
     scenario._tenant_create = mock.MagicMock(return_value=fake_tenant)
     scenario._users_create = mock.MagicMock()
     scenario.create_tenant_with_users(users_per_tenant=1, enabled=True)
     scenario._tenant_create.assert_called_once_with(enabled=True)
     scenario._users_create.assert_called_once_with(fake_tenant,
                                                    users_per_tenant=1)
    def test_create_delete_user(self):
        create_result = mock.MagicMock()

        scenario = basic.KeystoneBasic(self.context)
        scenario._user_create = mock.MagicMock(return_value=create_result)
        scenario._resource_delete = mock.MagicMock()

        scenario.create_delete_user(email="abcd", enabled=True)

        scenario._user_create.assert_called_once_with(email="abcd",
                                                      enabled=True)
        scenario._resource_delete.assert_called_once_with(create_result)
Пример #10
0
 def test_create_and_delete_ec2credential(self):
     fake_creds = mock.MagicMock()
     context = self._get_context()
     scenario = basic.KeystoneBasic(context)
     scenario._create_ec2credentials = mock.MagicMock(
         return_value=fake_creds)
     scenario._delete_ec2credential = mock.MagicMock()
     scenario.create_and_delete_ec2credential()
     scenario._create_ec2credentials.assert_called_once_with(
         "fake_user_id", "fake_tenant_id")
     scenario._delete_ec2credential.assert_called_once_with(
         "fake_user_id", fake_creds.access)
Пример #11
0
 def test_create_and_list_services(self):
     scenario = basic.KeystoneBasic(self.context)
     service_type = "test_service_type"
     description = "test_description"
     fake_service = mock.MagicMock()
     scenario._service_create = mock.MagicMock(return_value=fake_service)
     scenario._list_services = mock.MagicMock()
     scenario.create_and_list_services(service_type=service_type,
                                       description=description)
     scenario._service_create.assert_called_once_with(
         service_type, description)
     scenario._list_services.assert_called_once_with()
Пример #12
0
 def test_create_tenant_with_users(self, mock_generate_random_name):
     scenario = basic.KeystoneBasic(self.context)
     fake_tenant = mock.MagicMock()
     scenario._tenant_create = mock.MagicMock(return_value=fake_tenant)
     scenario._users_create = mock.MagicMock()
     scenario.create_tenant_with_users(users_per_tenant=1, name_length=20,
                                       enabled=True)
     scenario._tenant_create.assert_called_once_with(name_length=20,
                                                     enabled=True)
     scenario._users_create.assert_called_once_with(fake_tenant,
                                                    users_per_tenant=1,
                                                    name_length=20)
Пример #13
0
    def test_create_delete_user(self, mock_generate_random_name):
        create_result = mock.MagicMock()

        scenario = basic.KeystoneBasic(self.context)
        scenario._user_create = mock.MagicMock(return_value=create_result)
        scenario._resource_delete = mock.MagicMock()

        scenario.create_delete_user(name_length=30, email="abcd", enabled=True)

        scenario._user_create.assert_called_once_with(name_length=30,
                                                      email="abcd",
                                                      enabled=True)
        scenario._resource_delete.assert_called_once_with(create_result)
Пример #14
0
    def test_create_user_set_enabled_and_delete(self):
        scenario = basic.KeystoneBasic(self.context)
        scenario._user_create = mock.Mock()
        scenario._update_user_enabled = mock.Mock()
        scenario._resource_delete = mock.Mock()

        scenario.create_user_set_enabled_and_delete(enabled=True, email="abcd")
        scenario._user_create.assert_called_once_with(email="abcd",
                                                      enabled=True)
        scenario._update_user_enabled.assert_called_once_with(
            scenario._user_create.return_value, False)
        scenario._resource_delete.assert_called_once_with(
            scenario._user_create.return_value)
Пример #15
0
    def test_create_user_update_password(self):
        scenario = basic.KeystoneBasic(self.context)
        fake_password = "******"
        fake_user = mock.MagicMock()
        scenario._user_create = mock.MagicMock(return_value=fake_user)
        scenario.generate_random_name = mock.MagicMock(
            return_value=fake_password)
        scenario._update_user_password = mock.MagicMock()

        scenario.create_user_update_password()
        scenario.generate_random_name.assert_called_once_with()
        scenario._user_create.assert_called_once_with()
        scenario._update_user_password.assert_called_once_with(
            fake_user.id, fake_password)
Пример #16
0
 def test_create_and_delete_service(self):
     scenario = basic.KeystoneBasic()
     name = "Rally_test_service"
     service_type = "rally_test_type"
     description = "test_description"
     fake_service = mock.MagicMock()
     scenario._service_create = mock.MagicMock(return_value=fake_service)
     scenario._delete_service = mock.MagicMock()
     scenario.create_and_delete_service(name=name,
                                        service_type=service_type,
                                        description=description)
     scenario._service_create.assert_called_once_with(
         name, service_type, description)
     scenario._delete_service.assert_called_once_with(fake_service.id)
Пример #17
0
 def test_create_and_list_user_roles(self):
     context = self._get_context()
     scenario = basic.KeystoneBasic(context)
     fake_tenant = context["tenant"]["id"]
     fake_user = context["user"]["id"]
     fake_role = mock.MagicMock()
     scenario._tenant_create = mock.MagicMock(return_value=fake_tenant)
     scenario._user_create = mock.MagicMock(return_value=fake_user)
     scenario._role_create = mock.MagicMock(return_value=fake_role)
     scenario._role_add = mock.MagicMock()
     scenario._list_roles_for_user = mock.MagicMock()
     scenario.create_add_and_list_user_roles()
     scenario._role_create.assert_called_once_with()
     scenario._role_add.assert_called_once_with(fake_user, fake_role,
                                                fake_tenant)
     scenario._list_roles_for_user.assert_called_once_with(
         fake_user, fake_tenant)
Пример #18
0
    def _test_get_entities(self, service_name="keystone"):
        scenario = basic.KeystoneBasic(self.context)
        fake_tenant = mock.MagicMock()
        fake_user = mock.MagicMock()
        fake_role = mock.MagicMock()
        fake_service = mock.MagicMock()

        scenario._tenant_create = mock.MagicMock(return_value=fake_tenant)
        scenario._user_create = mock.MagicMock(return_value=fake_user)
        scenario._role_create = mock.MagicMock(return_value=fake_role)
        scenario._service_create = mock.MagicMock(return_value=fake_service)

        scenario._get_tenant = mock.MagicMock(return_value=fake_tenant)
        scenario._get_user = mock.MagicMock(return_value=fake_user)
        scenario._get_role = mock.MagicMock(return_value=fake_role)
        scenario._get_service_by_name = mock.MagicMock(
            return_value=fake_service)
        scenario._get_service = mock.MagicMock(return_value=fake_service)

        scenario.get_entities(service_name)

        scenario._tenant_create.assert_called_once_with()
        scenario._user_create.assert_called_once_with()
        scenario._role_create.assert_called_once_with()

        scenario._get_tenant.assert_called_once_with(fake_tenant.id)
        scenario._get_user.assert_called_once_with(fake_user.id)
        scenario._get_role.assert_called_once_with(fake_role.id)

        if service_name is None:
            scenario._service_create.assert_called_once_with()
            self.assertFalse(scenario._get_service_by_name.called)
        else:
            scenario._get_service_by_name.assert_called_once_with(service_name)
            self.assertFalse(scenario._service_create.called)
        scenario._get_service.assert_called_once_with(fake_service.id)