Fix JWT auth test and alembic migration
A new version of pyjwt was released which alters an internal call it makes to urllib which we have mocked in the unit tests. Our mock must be updated to match. The previous version would call urlopen with a string url argument, newer versions call it with a Request object (urllib accepts both). This change updates the mock to accept both. There has also been a recent alembic release which alters the function signature of alter_column so that most arguments are now required to be keyword arguments. This causes one of our migrations to fail since it was not passing the new type in as a positional argument. Notably, the type was not the next positional argument in the signature ("nullable" is), so this explains why we had two "change patchset to string" migrations: the first one did not actually work. This change alters the migration to do what it effectively did rather that what it was intended to do. The later migration continues to correct the error. Change-Id: I10cdffa43147f7f72e431e7c64e10e9416dfb295
This commit is contained in:
parent
a914670514
commit
38423ed883
|
@ -70,6 +70,9 @@ def mock_get(url, params=None, **kwargs):
|
|||
|
||||
|
||||
def mock_urlopen(url, *args, **kwargs):
|
||||
if hasattr(url, 'full_url'):
|
||||
# Like a urllib.Request object
|
||||
url = url.full_url
|
||||
if url == ("https://my.oidc.provider/auth/realms/realm-one/"
|
||||
"protocol/openid-connect/certs"):
|
||||
io = StringIO()
|
||||
|
|
|
@ -17,11 +17,19 @@ import sqlalchemy as sa
|
|||
|
||||
BUILDSET_TABLE = 'zuul_buildset'
|
||||
|
||||
# Note: the following migration does not do what it was intended to do
|
||||
# (change the column type to a string). It was introduced with an
|
||||
# error which instead caused the nullable flag to be set to true (even
|
||||
# though it was already set), effectively making it a no-op. To
|
||||
# maintain compatibility with later versions of alembic, this has been
|
||||
# updated to explicitly do now what it implicitly did then. A later
|
||||
# migration (19d3a3ebfe1d) corrects the error and changes the type.
|
||||
|
||||
|
||||
def upgrade(table_prefix=''):
|
||||
op.alter_column(table_prefix + BUILDSET_TABLE,
|
||||
'patchset',
|
||||
sa.String(255),
|
||||
nullable=True,
|
||||
existing_nullable=True,
|
||||
existing_type=sa.Integer)
|
||||
|
||||
|
|
Loading…
Reference in New Issue