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

View File

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

View File

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

View File

@ -44,7 +44,7 @@ extensions = [
'sphinxcontrib.apidoc',
'sphinxcontrib.seqdiag',
'sphinx_feature_classification.support_matrix',
'sphinxcontrib.blockdiag'
'sphinxcontrib.blockdiag',
]
blockdiag_html_image_format = 'SVG'
@ -134,8 +134,13 @@ modindex_common_prefix = ['keystone.']
# List of tuples 'sourcefile', 'target', u'title', u'Authors name', 'manual'
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
# the generated PDF file.
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
@ -266,9 +277,15 @@ latex_documents = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'keystone', 'Keystone Documentation',
'OpenStack', 'keystone', 'One line description of project.',
'Miscellaneous'),
(
'index',
'keystone',
'Keystone Documentation',
'OpenStack',
'keystone',
'One line description of project.',
'Miscellaneous',
),
]
# Documents to append as an appendix to all manuals.

View File

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

View File

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

View File

@ -196,9 +196,13 @@ htmlhelp_basename = 'KeystoneReleaseNotesdoc'
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'KeystoneReleaseNotes.tex',
(
'index',
'KeystoneReleaseNotes.tex',
'Keystone Release Notes Documentation',
'Keystone Developers', 'manual'),
'Keystone Developers',
'manual',
),
]
# 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
# (source start file, name, description, authors, manual section).
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.
@ -241,10 +250,15 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'KeystoneReleaseNotes', 'Keystone Release Notes Documentation',
'Keystone Developers', 'KeystoneReleaseNotes',
(
'index',
'KeystoneReleaseNotes',
'Keystone Release Notes Documentation',
'Keystone Developers',
'KeystoneReleaseNotes',
'Identity, Authentication and Access Management for OpenStack.',
'Miscellaneous'),
'Miscellaneous',
),
]
# Documents to append as an appendix to all manuals.

View File

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

View File

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