identity: Fix project list
SDK returns generators, not lists, and we do not see errors until they are iterated. Force early iteration by wrapping then in a list to ensure we actually see the HTTP 403 errors we were expecting. Change-Id: I0ab72e587bf4e16ae877db7a81023a226124e4d5 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
@@ -342,21 +342,21 @@ class ListProject(command.Lister):
|
||||
user = self.app.client_manager.auth_ref.user_id
|
||||
|
||||
if user:
|
||||
data = identity_client.user_projects(user, **kwargs)
|
||||
data = list(identity_client.user_projects(user, **kwargs))
|
||||
else:
|
||||
try:
|
||||
data = identity_client.projects(**kwargs)
|
||||
data = list(identity_client.projects(**kwargs))
|
||||
except sdk_exc.ForbiddenException:
|
||||
# NOTE(adriant): if no filters, assume a forbidden is non-admin
|
||||
# wanting their own project list.
|
||||
if not kwargs:
|
||||
user = self.app.client_manager.auth_ref.user_id
|
||||
data = identity_client.user_projects(user)
|
||||
data = list(identity_client.user_projects(user))
|
||||
else:
|
||||
raise
|
||||
|
||||
if parsed_args.sort:
|
||||
data = utils.sort_items(data, parsed_args.sort)
|
||||
data = list(utils.sort_items(data, parsed_args.sort))
|
||||
|
||||
return (
|
||||
column_headers,
|
||||
|
||||
Reference in New Issue
Block a user