Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump major #341

Merged
merged 5 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
Changes
=======

Version 5.0.0 (released 2024-12-06)

- fix: sqlalchemy.exc.ArgumentError:
- global: use invenio_base.jws not itsdangerous
- tests: apply changes for sqlalchemy>=2.0
- setup: bump major dependencies

Version 4.1.3 (release 2024-12-03)

- utils: improve and fix creation/update of groups
Expand Down
2 changes: 1 addition & 1 deletion invenio_oauthclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .oauth import oauth_link_external_id, oauth_unlink_external_id
from .proxies import current_oauthclient

__version__ = "4.1.3"
__version__ = "5.0.0"

__all__ = (
"__version__",
Expand Down
9 changes: 7 additions & 2 deletions invenio_oauthclient/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2024 Graz University of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -174,7 +175,11 @@ def get(cls, user_id, client_id, token_type="", access_token=None):
if access_token:
args.append(RemoteToken.access_token == access_token)

return cls.query.options(db.joinedload("remote_account")).filter(*args).first()
return (
cls.query.options(db.joinedload(RemoteToken.remote_account))
.filter(*args)
.first()
)

@classmethod
def get_by_token(cls, client_id, access_token, token_type=""):
Expand All @@ -186,7 +191,7 @@ def get_by_token(cls, client_id, access_token, token_type=""):
:returns: A :class:`invenio_oauthclient.models.RemoteToken` instance.
"""
return (
cls.query.options(db.joinedload("remote_account"))
cls.query.options(db.joinedload(RemoteToken.remote_account))
.filter(
RemoteAccount.id == RemoteToken.id_remote_account,
RemoteAccount.client_id == client_id,
Expand Down
9 changes: 1 addition & 8 deletions invenio_oauthclient/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,14 @@

from flask import current_app, request, session
from flask_principal import RoleNeed
from invenio_base.jws import TimedJSONWebSignatureSerializer
from invenio_db.utils import rebuild_encrypted_properties
from uritools import uricompose, urisplit
from werkzeug.local import LocalProxy
from werkzeug.utils import import_string

from .models import RemoteToken

try:
# itsdangerous < 2.1.0
from itsdangerous import TimedJSONWebSignatureSerializer
except ImportError:
# itsdangerous >= 2.1.0
from invenio_base.jws import TimedJSONWebSignatureSerializer


_security = LocalProxy(lambda: current_app.extensions["security"])


Expand Down
18 changes: 9 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ zip_safe = False
install_requires =
blinker>=1.4
Flask-OAuthlib>=0.9.6
invenio-accounts>=5.0.0,<6.0.0
invenio-base>=1.3.0,<2.0.0
invenio-i18n>=2.0.0,<3.0.0
invenio-accounts>=6.0.0,<7.0.0
invenio-base>=2.0.0,<3.0.0
invenio-i18n>=3.0.0,<4.0.0
invenio-mail>=1.0.2,<3.0.0
invenio-theme>=3.0.0,<4.0.0
invenio-theme>=4.0.0,<5.0.0
oauthlib>=1.1.2
markupsafe>=2.1.5
requests-oauthlib>=0.6.2
Expand All @@ -46,14 +46,14 @@ tests =
flask_admin>=1.6.0
pytest-black-ng>=0.4.0
httpretty>=0.8.14
invenio-userprofiles>=3.0.0,<4.0.0
invenio-userprofiles>=4.0.0,<5.0.0
mock>=1.3.0
oauthlib>=1.1.2,<3.0.0
pytest-invenio>=1.4.2,<3.0.0
requests-oauthlib>=0.6.2,<1.2.0
oauthlib>=1.1.2
pytest-invenio>=3.0.0,<4.0.0
requests-oauthlib>=0.6.2
simplejson>=3.8
sphinx>=4.5
invenio-db[mysql,postgresql,versioning]>=1.0.9,<2.0.0
invenio-db[mysql,postgresql,versioning]>=2.0.0,<3.0.0

# Kept for backwards compatibility
admin =
Expand Down
12 changes: 7 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,19 @@ def base_app(request):
InvenioCelery(base_app)

with base_app.app_context():
if str(db.engine.url) != "sqlite://" and not database_exists(
str(db.engine.url)
if str(
db.engine.url.render_as_string(hide_password=False)
) != "sqlite://" and not database_exists(
str(db.engine.url.render_as_string(hide_password=False))
):
create_database(str(db.engine.url))
create_database(str(db.engine.url.render_as_string(hide_password=False)))
db.create_all()

def teardown():
with base_app.app_context():
db.session.close()
if str(db.engine.url) != "sqlite://":
drop_database(str(db.engine.url))
if str(db.engine.url.render_as_string(hide_password=False)) != "sqlite://":
drop_database(str(db.engine.url.render_as_string(hide_password=False)))
shutil.rmtree(instance_path)
db.engine.dispose()

Expand Down
11 changes: 8 additions & 3 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2024 Graz University of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -111,10 +112,14 @@ def teardown():
request.addfinalizer(teardown)

with app.app_context():
is_sqllite = str(db.engine.url) == "sqlite://"
db_exists = database_exists(str(db.engine.url))
is_sqllite = (
str(db.engine.url.render_as_string(hide_password=False)) == "sqlite://"
)
db_exists = database_exists(
str(db.engine.url.render_as_string(hide_password=False))
)
if not is_sqllite and not db_exists:
create_database(str(db.engine.url))
create_database(str(db.engine.url.render_as_string(hide_password=False)))
db.create_all()
tables = list(
filter(
Expand Down
3 changes: 2 additions & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2024 Graz University of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -17,8 +18,8 @@
from flask_security import login_user
from helpers import check_response_redirect_url
from invenio_accounts.testutils import login_user_via_session
from invenio_base.jws import TimedJSONWebSignatureSerializer
from invenio_db import db
from itsdangerous import TimedJSONWebSignatureSerializer
from mock import MagicMock
from simplejson import JSONDecodeError

Expand Down
3 changes: 2 additions & 1 deletion tests/test_views_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
# Copyright (C) 2024 Graz University of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -16,8 +17,8 @@
from flask_oauthlib.client import OAuth as FlaskOAuth
from helpers import check_response_redirect_url, check_response_redirect_url_args
from invenio_accounts.testutils import login_user_via_session
from invenio_base.jws import TimedJSONWebSignatureSerializer
from invenio_db import db
from itsdangerous import TimedJSONWebSignatureSerializer
from mock import MagicMock
from simplejson import JSONDecodeError

Expand Down