Merge "Enable black in pre-commit"

This commit is contained in:
Zuul 2024-07-26 19:44:38 +00:00 committed by Gerrit Code Review
commit 267474d318
8 changed files with 69 additions and 34 deletions

@ -27,12 +27,11 @@ repos:
# hooks: # hooks:
# - id: pyupgrade # - id: pyupgrade
# args: ['--py38-plus'] # args: ['--py38-plus']
# TODO(gtema): Uncomment it once all files are blackified - repo: https://github.com/psf/black
# - repo: https://github.com/psf/black rev: 24.4.0
# rev: 24.4.0 hooks:
# hooks: - id: black
# - id: black args: ['-S', '-l', '79']
# args: ['-S', '-l', '79']
# - repo: https://opendev.org/openstack/hacking # - repo: https://opendev.org/openstack/hacking
# rev: 6.1.0 # rev: 6.1.0
# hooks: # hooks:

@ -6,6 +6,7 @@ KEYCLOAK_PASSWORD = os.environ.get('KEYCLOAK_PASSWORD')
KEYCLOAK_URL = os.environ.get('KEYCLOAK_URL') KEYCLOAK_URL = os.environ.get('KEYCLOAK_URL')
HOST_IP = os.environ.get('HOST_IP', 'localhost') HOST_IP = os.environ.get('HOST_IP', 'localhost')
class KeycloakClient(object): class KeycloakClient(object):
def __init__(self): def __init__(self):
self.session = requests.session() self.session = requests.session()
@ -29,7 +30,7 @@ class KeycloakClient(object):
r = requests.post(self.token_endpoint(realm), data=params).json() r = requests.post(self.token_endpoint(realm), data=params).json()
headers = { headers = {
'Authorization': ("Bearer %s" % r['access_token']), 'Authorization': ("Bearer %s" % r['access_token']),
'Content-Type': 'application/json' 'Content-Type': 'application/json',
} }
self.session.headers.update(headers) self.session.headers.update(headers)
return r return r
@ -43,7 +44,9 @@ class KeycloakClient(object):
'implicitFlowEnabled': True, 'implicitFlowEnabled': True,
'directAccessGrantsEnabled': True, 'directAccessGrantsEnabled': True,
} }
return self.session.post(self.construct_url(realm, 'clients'), json=data) return self.session.post(
self.construct_url(realm, 'clients'), json=data
)
def main(): def main():
@ -51,7 +54,7 @@ def main():
redirect_uris = [ redirect_uris = [
f'http://{HOST_IP}/identity/v3/auth/OS-FEDERATION/identity_providers/sso/protocols/openid/websso', f'http://{HOST_IP}/identity/v3/auth/OS-FEDERATION/identity_providers/sso/protocols/openid/websso',
f'http://{HOST_IP}/identity/v3/auth/OS-FEDERATION/websso/openid' f'http://{HOST_IP}/identity/v3/auth/OS-FEDERATION/websso/openid',
] ]
c.create_client('master', 'devstack', 'nomoresecret', redirect_uris) c.create_client('master', 'devstack', 'nomoresecret', redirect_uris)

@ -44,7 +44,7 @@ extensions = [
'sphinxcontrib.apidoc', 'sphinxcontrib.apidoc',
'sphinxcontrib.seqdiag', 'sphinxcontrib.seqdiag',
'sphinx_feature_classification.support_matrix', 'sphinx_feature_classification.support_matrix',
'sphinxcontrib.blockdiag' 'sphinxcontrib.blockdiag',
] ]
blockdiag_html_image_format = 'SVG' blockdiag_html_image_format = 'SVG'
@ -134,8 +134,13 @@ modindex_common_prefix = ['keystone.']
# List of tuples 'sourcefile', 'target', u'title', u'Authors name', 'manual' # List of tuples 'sourcefile', 'target', u'title', u'Authors name', 'manual'
man_pages = [ man_pages = [
('cli/keystone-manage', 'keystone-manage', 'Keystone Management Utility', (
['OpenStack'], 1) 'cli/keystone-manage',
'keystone-manage',
'Keystone Management Utility',
['OpenStack'],
1,
)
] ]
@ -235,8 +240,14 @@ latex_elements = {
# NOTE(gyee): Specify toctree_only=True for a better document structure of # NOTE(gyee): Specify toctree_only=True for a better document structure of
# the generated PDF file. # the generated PDF file.
latex_documents = [ latex_documents = [
('index', 'doc-keystone.tex', 'Keystone Documentation', (
'OpenStack', 'manual', True) 'index',
'doc-keystone.tex',
'Keystone Documentation',
'OpenStack',
'manual',
True,
)
] ]
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
@ -266,9 +277,15 @@ latex_documents = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
('index', 'keystone', 'Keystone Documentation', (
'OpenStack', 'keystone', 'One line description of project.', 'index',
'Miscellaneous'), 'keystone',
'Keystone Documentation',
'OpenStack',
'keystone',
'One line description of project.',
'Miscellaneous',
),
] ]
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.

@ -644,9 +644,11 @@ class UserAppCredListCreateResource(ks_flask.ResourceBase):
# explicitly if not already there # explicitly if not already there
for role in roles: for role in roles:
for implied_role in PROVIDERS.role_api.list_implied_roles( for implied_role in PROVIDERS.role_api.list_implied_roles(
role['id']): role['id']
):
imp_role_obj = PROVIDERS.role_api.get_role( imp_role_obj = PROVIDERS.role_api.get_role(
implied_role['implied_role_id']) implied_role['implied_role_id']
)
if imp_role_obj['id'] not in [x['id'] for x in roles]: if imp_role_obj['id'] not in [x['id'] for x in roles]:
roles.append(imp_role_obj) roles.append(imp_role_obj)
# NOTE(cmurphy): The user is not allowed to add a role that is not # NOTE(cmurphy): The user is not allowed to add a role that is not

@ -92,7 +92,8 @@ class ApplicationCredentialTestCase(test_v3.RestfulTestCase):
'/v3/users/%s/application_credentials' % self.user_id, '/v3/users/%s/application_credentials' % self.user_id,
json=app_cred_body, json=app_cred_body,
expected_status_code=http.client.CREATED, expected_status_code=http.client.CREATED,
headers={'X-Auth-Token': token}) headers={'X-Auth-Token': token},
)
# Create operation returns the secret # Create operation returns the secret
self.assertIn('secret', resp.json['application_credential']) self.assertIn('secret', resp.json['application_credential'])
# But not the stored hash # But not the stored hash
@ -100,7 +101,7 @@ class ApplicationCredentialTestCase(test_v3.RestfulTestCase):
# Ensure implied role is also granted # Ensure implied role is also granted
self.assertIn( self.assertIn(
implied_role_id, implied_role_id,
[x['id'] for x in resp.json["application_credential"]["roles"]] [x['id'] for x in resp.json["application_credential"]["roles"]],
) )
def test_create_application_credential_with_secret(self): def test_create_application_credential_with_secret(self):

@ -196,9 +196,13 @@ htmlhelp_basename = 'KeystoneReleaseNotesdoc'
# (source start file, target name, title, # (source start file, target name, title,
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [ latex_documents = [
('index', 'KeystoneReleaseNotes.tex', (
'Keystone Release Notes Documentation', 'index',
'Keystone Developers', 'manual'), 'KeystoneReleaseNotes.tex',
'Keystone Release Notes Documentation',
'Keystone Developers',
'manual',
),
] ]
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
@ -227,8 +231,13 @@ latex_documents = [
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
('index', 'keystonereleasenotes', 'Keystone Release Notes Documentation', (
['Keystone Developers'], 1) 'index',
'keystonereleasenotes',
'Keystone Release Notes Documentation',
['Keystone Developers'],
1,
)
] ]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
@ -241,10 +250,15 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
('index', 'KeystoneReleaseNotes', 'Keystone Release Notes Documentation', (
'Keystone Developers', 'KeystoneReleaseNotes', 'index',
'Identity, Authentication and Access Management for OpenStack.', 'KeystoneReleaseNotes',
'Miscellaneous'), 'Keystone Release Notes Documentation',
'Keystone Developers',
'KeystoneReleaseNotes',
'Identity, Authentication and Access Management for OpenStack.',
'Miscellaneous',
),
] ]
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.

@ -15,6 +15,4 @@
import setuptools import setuptools
setuptools.setup( setuptools.setup(setup_requires=['pbr>=2.0.0'], pbr=True)
setup_requires=['pbr>=2.0.0'],
pbr=True)

@ -23,8 +23,9 @@ passenv = http_proxy,HTTP_PROXY,https_proxy,HTTPS_PROXY,no_proxy,NO_PROXY,PBR_VE
[testenv:pep8] [testenv:pep8]
deps = deps =
{[testenv]deps} {[testenv]deps}
pre-commit
commands = commands =
flake8 pre-commit run --all-files --show-diff-on-failure
# Run bash8 during pep8 runs to ensure violations are caught by # Run bash8 during pep8 runs to ensure violations are caught by
# the check and gate queues # the check and gate queues
bashate devstack/plugin.sh bashate devstack/plugin.sh