Example #1
0
 def consume(cache, args):
     username, password, project_dom, user_dom, tenant_id = args
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     client = cache["client"]
     user = client.create_user(username, password,
                               "*****@*****.**" % username, tenant_id,
                               user_dom)
     user_endpoint = objects.Endpoint(
         client.auth_url,
         user.name,
         password,
         self.context["tenants"][tenant_id]["name"],
         consts.EndpointPermission.USER,
         client.region_name,
         project_domain_name=project_dom,
         user_domain_name=user_dom,
         endpoint_type=self.endpoint.endpoint_type,
         https_insecure=self.endpoint.insecure,
         https_cacert=self.endpoint.cacert)
     users.append({
         "id": user.id,
         "endpoint": user_endpoint,
         "tenant_id": tenant_id
     })
Example #2
0
    def _role_delete(self, role_id):
        """Creates keystone user role with random name.

        :param user_id: id of the role
        """
        admin_clients = keystone_wrapper.wrap(self.admin_clients("keystone"))

        admin_clients.delete_role(role_id)
Example #3
0
    def _role_delete(self, role_id):
        """Creates keystone user role with random name.

        :param user_id: id of the role
        """
        admin_clients = keystone_wrapper.wrap(self.admin_clients("keystone"))

        admin_clients.delete_role(role_id)
Example #4
0
 def setUp(self):
     super(KeystoneV3WrapperTestCase, self).setUp()
     self.client = mock.MagicMock()
     self.client.version = "v3"
     self.wrapped_client = keystone.wrap(self.client)
     self.client.domains.get.side_effect = exceptions.NotFound
     self.client.domains.list.return_value = [
         mock.MagicMock(id="domain_id")]
Example #5
0
 def consume(cache, args):
     domain, task_id, i = args
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     tenant = cache["client"].create_project(
         self.generate_random_name(), domain)
     tenant_dict = {"id": tenant.id, "name": tenant.name}
     tenants.append(tenant_dict)
Example #6
0
 def consume(cache, args):
     domain, task_id, i = args
     if "client" not in cache:
         clients = osclients.Clients(self.credential)
         cache["client"] = keystone.wrap(clients.keystone())
     tenant = cache["client"].create_project(
         self.generate_random_name(), domain)
     tenant_dict = {"id": tenant.id, "name": tenant.name, "users": []}
     tenants.append(tenant_dict)
Example #7
0
 def consume(cache, args):
     domain, task_id, i = args
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     tenant = cache["client"].create_project(
         self.PATTERN_TENANT % {"task_id": task_id, "iter": i}, domain)
     tenant_dict = {"id": tenant.id, "name": tenant.name}
     tenants.append(tenant_dict)
Example #8
0
 def consume(cache, args):
     domain, task_id, i = args
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     tenant = cache["client"].create_project(
         self.PATTERN_TENANT % {"task_id": task_id, "iter": i}, domain)
     tenant_dict = {"id": tenant.id, "name": tenant.name}
     tenants.append(tenant_dict)
Example #9
0
 def setUp(self):
     super(KeystoneV3WrapperTestCase, self).setUp()
     self.client = mock.MagicMock()
     self.client.version = "v3"
     self.wrapped_client = keystone.wrap(self.client)
     self.client.domains.get.side_effect = exceptions.NotFound
     self.client.domains.list.return_value = [
         mock.MagicMock(id="domain_id")
     ]
Example #10
0
    def _role_create(self, **kwargs):
        """Creates keystone user role with random name.

        :param **kwargs: Optional additional arguments for roles creation
        :returns: keystone user role
        """
        admin_clients = keystone_wrapper.wrap(self.admin_clients("keystone"))

        role = admin_clients.create_role(self.generate_random_name(), **kwargs)
        return role
Example #11
0
    def _remove_role(self, admin_endpoint, role):
        """Remove given role from users.

        :param admin_endpoint: The base url.
        :param role: dictionary with role parameters (id, name).
        """
        client = keystone.wrap(osclients.Clients(admin_endpoint).keystone())

        for user in self.context["users"]:
            with logging.ExceptionLogger(LOG, _("Failed to remove role: %s") % role["id"]):
                client.remove_role(user_id=user["id"], role_id=role["id"], project_id=user["tenant_id"])
Example #12
0
    def _role_create(self, **kwargs):
        """Creates keystone user role with random name.

        :param **kwargs: Optional additional arguments for roles creation
        :returns: keystone user role
        """
        admin_clients = keystone_wrapper.wrap(self.admin_clients("keystone"))

        role = admin_clients.create_role(
            self.generate_random_name(), **kwargs)
        return role
Example #13
0
    def _get_role_object(self, context_role):
        """Check if role exists.

        :param context_role: name of existing role.
        """
        client = keystone.wrap(osclients.Clients(self.credential).keystone())
        default_roles = client.list_roles()
        for def_role in default_roles:
            if str(def_role.name) == context_role:
                return def_role
        else:
            raise exceptions.NoSuchRole(role=context_role)
Example #14
0
    def _get_role_object(self, context_role):
        """Check if role exists.

        :param context_role: name of existing role.
        """
        client = keystone.wrap(osclients.Clients(self.credential).keystone())
        default_roles = client.list_roles()
        for def_role in default_roles:
            if str(def_role.name) == context_role:
                return def_role
        else:
            raise exceptions.NoSuchRole(role=context_role)
Example #15
0
    def _remove_role(self, admin_credential, role):
        """Remove given role from users.

        :param admin_credential: The admin credential.
        :param role: dictionary with role parameters (id, name).
        """
        client = keystone.wrap(osclients.Clients(admin_credential).keystone())

        for user in self.context["users"]:
            with logging.ExceptionLogger(
                    LOG, _("Failed to remove role: %s") % role["id"]):
                client.remove_role(
                    user_id=user["id"], role_id=role["id"],
                    project_id=user["tenant_id"])
Example #16
0
 def consume(cache, args):
     username, password, project_dom, user_dom, tenant_id = args
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     client = cache["client"]
     user = client.create_user(username, password,
                               "*****@*****.**" % username,
                               tenant_id, user_dom)
     user_endpoint = objects.Endpoint(
         client.auth_url, user.name, password,
         self.context["tenants"][tenant_id]["name"],
         consts.EndpointPermission.USER, client.region_name,
         project_domain_name=project_dom, user_domain_name=user_dom,
         endpoint_type=self.endpoint.endpoint_type)
     users.append({"id": user.id,
                   "endpoint": user_endpoint,
                   "tenant_id": tenant_id})
Example #17
0
    def setup(self):
        self.ks_client = keystone.wrap(
            osclients.Clients(self.context["admin"]["credential"]).keystone())
        self.context['host'] = self.config.get('host')

        users = self.context["users"]
        new_users = []
        for user in users:
            self.ks_client.ec2.create(user['id'], user['tenant_id'])
            ec2_creds = self.ks_client.ec2.list(user['id'])[0]

            user['ec2'] = {}
            user['ec2']['secret_key'] = ec2_creds._info['secret']
            user['ec2']['access_key'] = ec2_creds._info['access']
            user['bucket_name'] = "bucket_for_" + user['id']
            new_users.append(user)

        self.context["users"] = new_users
Example #18
0
    def _add_role(self, admin_endpoint, context_role):
        """Add role to users.

        :param admin_endpoint: The base url.
        :param context_role: name of existing role.
        """
        client = keystone.wrap(osclients.Clients(admin_endpoint).keystone())
        default_roles = client.list_roles()
        for def_role in default_roles:
            if str(def_role.name) == context_role:
                role = def_role
                break
        else:
            raise exceptions.NoSuchRole(role=context_role)

        LOG.debug("Adding role %s to all users" % (role.id))
        for user in self.context["users"]:
            client.add_role(user_id=user["id"], role_id=role.id, project_id=user["tenant_id"])

        return {"id": str(role.id), "name": str(role.name)}
Example #19
0
    def _add_role(self, admin_credential, context_role):
        """Add role to users.

        :param admin_credential: The admin credential.
        :param context_role: name of existing role.
        """
        client = keystone.wrap(osclients.Clients(admin_credential).keystone())
        default_roles = client.list_roles()
        for def_role in default_roles:
            if str(def_role.name) == context_role:
                role = def_role
                break
        else:
            raise exceptions.NoSuchRole(role=context_role)

        LOG.debug("Adding role %s to all users" % (role.id))
        for user in self.context["users"]:
            client.add_role(user_id=user["id"], role_id=role.id,
                            project_id=user["tenant_id"])

        return {"id": str(role.id), "name": str(role.name)}
Example #20
0
 def consume(cache, args):
     username, password, project_dom, user_dom, tenant_id = args
     if "client" not in cache:
         clients = osclients.Clients(self.credential)
         cache["client"] = keystone.wrap(clients.keystone())
     client = cache["client"]
     user = client.create_user(
         username, password,
         "*****@*****.**" % username,
         tenant_id, user_dom,
         default_role=default_role)
     user_credential = objects.Credential(
         client.auth_url, user.name, password,
         self.context["tenants"][tenant_id]["name"],
         consts.EndpointPermission.USER, client.region_name,
         project_domain_name=project_dom, user_domain_name=user_dom,
         endpoint_type=self.credential.endpoint_type,
         https_insecure=self.credential.insecure,
         https_cacert=self.credential.cacert)
     users.append({"id": user.id,
                   "credential": user_credential,
                   "tenant_id": tenant_id})
Example #21
0
 def consume(cache, user_id):
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     cache["client"].delete_user(user_id)
Example #22
0
 def consume(cache, tenant_id):
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     cache["client"].delete_project(tenant_id)
 def _manager(self):
     return keystone_wrapper.wrap(getattr(self.admin, self._service)())
Example #24
0
 def consume(cache, user_id):
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     cache["client"].delete_user(user_id)
Example #25
0
 def consume(cache, resource_id):
     if "client" not in cache:
         clients = osclients.Clients(self.credential)
         cache["client"] = keystone.wrap(clients.keystone())
     getattr(cache["client"], func_name)(resource_id)
Example #26
0
 def consume(cache, args):
     role_id, user_id, project_id = args
     if "client" not in cache:
         clients = osclients.Clients(self.credential)
         cache["client"] = keystone.wrap(clients.keystone())
     getattr(cache["client"], func_name)(role_id, user_id, project_id)
Example #27
0
 def setUp(self):
     super(KeystoneV2WrapperTestCase, self).setUp()
     self.client = mock.MagicMock()
     self.client.version = "v2.0"
     self.wrapped_client = keystone.wrap(self.client)
Example #28
0
 def consume(cache, resource_id):
     if "client" not in cache:
         clients = osclients.Clients(self.credential)
         cache["client"] = keystone.wrap(clients.keystone())
     getattr(cache["client"], func_name)(resource_id)
Example #29
0
 def setUp(self):
     super(KeystoneV2WrapperTestCase, self).setUp()
     self.client = mock.MagicMock()
     self.client.version = "v2.0"
     self.wrapped_client = keystone.wrap(self.client)
Example #30
0
 def consume(cache, args):
     role_id, user_id, project_id = args
     if "client" not in cache:
         clients = osclients.Clients(self.credential)
         cache["client"] = keystone.wrap(clients.keystone())
     getattr(cache["client"], func_name)(role_id, user_id, project_id)
Example #31
0
 def _manager(self):
     return keystone_wrapper.wrap(getattr(self.admin, self._service)())
Example #32
0
 def consume(cache, tenant_id):
     if "client" not in cache:
         clients = osclients.Clients(self.endpoint)
         cache["client"] = keystone.wrap(clients.keystone())
     cache["client"].delete_project(tenant_id)