diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0235b72..ed8f82a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,7 +2,7 @@ # # This file is part of Invenio. # Copyright (C) 2020 CERN. -# Copyright (C) 2022 Graz University of Technology. +# Copyright (C) 2022-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. @@ -29,51 +29,34 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: ["3.9", "3.12"] requirements-level: [pypi] - db-service: [postgresql13, mysql8] + db-service: [postgresql14, mysql8] include: - - db-service: postgresql13 + - db-service: postgresql14 DB: postgresql - POSTGRESQL_VERSION: POSTGRESQL_13_LATEST - SQLALCHEMY_DATABASE_URI: "postgresql+psycopg2://invenio:invenio@localhost:5432/invenio" - db-service: mysql8 DB: mysql - MYSQL_VERSION: MYSQL_8_LATEST - SQLALCHEMY_DATABASE_URI: "mysql+pymysql://invenio:invenio@localhost:3306/invenio" env: - SQLALCHEMY_DATABASE_URI: ${{matrix.SQLALCHEMY_DATABASE_URI}} - POSTGRESQL_VERSION: ${{matrix.POSTGRESQL_VERSION}} - MYSQL_VERSION: ${{matrix.MYSQL_VERSION}} DB: ${{ matrix.DB }} EXTRAS: tests steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - - name: Generate dependencies - run: | - pip install wheel requirements-builder - requirements-builder -e "$EXTRAS" ${{ matrix.requirements-file }} --level=${{ matrix.requirements-level }} setup.py > .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt - - - name: Cache pip - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('.${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt') }} + cache: pip + cache-dependency-path: setup.cfg - name: Install dependencies run: | - pip install -r .${{matrix.requirements-level}}-${{ matrix.python-version }}-requirements.txt pip install .[$EXTRAS] pip freeze docker --version diff --git a/invenio_oauthclient/admin.py b/invenio_oauthclient/admin.py deleted file mode 100644 index 7ec6fad..0000000 --- a/invenio_oauthclient/admin.py +++ /dev/null @@ -1,108 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of Invenio. -# Copyright (C) 2016-2018 CERN. -# -# 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. - -"""Views for OAuth.""" - -from flask_admin.contrib.sqla import ModelView -from invenio_accounts.admin import user_identity_adminview - -from .models import RemoteAccount, RemoteToken - - -def _(x): - """Identity.""" - return x - - -class RemoteAccountView(ModelView): - """Flask-Admin view to manage remote accounts from invenio-oauthclient.""" - - can_view_details = True - - column_list = ( - "id", - "user_id", - "client_id", - "extra_data", - "remote_tokens", - ) - - remote_account_columns = ( - "id", - "user_id", - "client_id", - "extra_data", - ) - - column_searchable_list = column_sortable_list = remote_account_columns - - column_filters = ( - "id", - "user_id", - "client_id", - ) - - column_default_sort = ("id", True) - - column_display_all_relations = True - inline_models = (RemoteToken,) - - column_labels = { - "id": _("ID"), - "user_id": _("User ID"), - "client_id": _("Client ID"), - } - - -class RemoteTokenView(ModelView): - """Flask-Admin view to manage remote tokens from invenio-oauthclient.""" - - can_view_details = True - - column_list = ( - "id_remote_account", - "token_type", - ) - - column_searchable_list = column_sortable_list = column_list - - column_filters = ( - "id_remote_account", - "token_type", - ) - - form_columns = ( - "remote_account", - "token_type", - ) - - column_labels = { - "id_remote_account": _("ID Remote Account"), - } - - -remote_account_adminview = { - "model": RemoteAccount, - "modelview": RemoteAccountView, - "category": _("User Management"), - "name": _("Linked accounts"), -} - - -remote_token_adminview = { - "model": RemoteToken, - "modelview": RemoteTokenView, - "category": _("User Management"), - "name": _("Linked account tokens"), -} - -__all__ = ( - "remote_account_adminview", - "remote_token_adminview", - "user_identity_adminview", -) diff --git a/setup.cfg b/setup.cfg index 1e503a8..478c038 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,7 +42,6 @@ install_requires = [options.extras_require] tests = - flask_admin>=1.6.0 pytest-black-ng>=0.4.0 httpretty>=0.8.14 invenio-userprofiles>=3.0.0 @@ -55,7 +54,6 @@ tests = invenio-db[mysql,postgresql,versioning]>=1.0.9,<2.0.0 # Kept for backwards compatibility -admin = docs = github = mysql = @@ -64,9 +62,6 @@ postgresql = sqlite = [options.entry_points] -invenio_admin.views = - invenio_oauth_remote_account = invenio_oauthclient.admin:remote_account_adminview - invenio_oauth_remote_token = invenio_oauthclient.admin:remote_token_adminview invenio_base.apps = invenio_oauthclient = invenio_oauthclient:InvenioOAuthClient invenio_base.api_apps = diff --git a/tests/test_admin.py b/tests/test_admin.py deleted file mode 100644 index ade39ec..0000000 --- a/tests/test_admin.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of Invenio. -# Copyright (C) 2016-2018 CERN. -# -# 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. - -"""Views for OAuth.""" - -from flask import url_for -from flask_admin import Admin -from invenio_db import db - -from invenio_oauthclient import InvenioOAuthClient -from invenio_oauthclient.admin import ( - remote_account_adminview, - remote_token_adminview, - user_identity_adminview, -) - - -def test_admin(app): - """Test flask-admin interace.""" - InvenioOAuthClient(app) - - assert isinstance(remote_account_adminview, dict) - assert isinstance(remote_token_adminview, dict) - assert isinstance(user_identity_adminview, dict) - - assert "model" in remote_account_adminview - assert "modelview" in remote_account_adminview - assert "model" in remote_token_adminview - assert "modelview" in remote_token_adminview - assert "model" in user_identity_adminview - assert "modelview" in user_identity_adminview - - admin = Admin(app, name="Test") - - user_model = remote_account_adminview.pop("model") - user_view = remote_account_adminview.pop("modelview") - admin.add_view(user_view(user_model, db.session, **remote_account_adminview)) - - with app.app_context(): - # create user and save url for testing - request_url = url_for("remoteaccount.index_view") - - with app.app_context(): - with app.test_client() as client: - res = client.get(request_url, follow_redirects=True) - assert res.status_code == 200 - assert "Extra Data" in str(res.get_data()) - assert "Tokens" in str(res.get_data())