diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..7f11465 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,63 @@ +name: CI + +on: + push: + branches: + - "main" + tags: + - v* + pull_request: + branches: + - main + +env: + DOCKER_BUILDKIT: 1 + TARGET_PLATFORMS: linux/amd64,linux/arm64 + REGISTRY: ghcr.io + IMAGE_NAME: kcworks + +jobs: + build_and_release: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + # Checks-out your repository under $GITHUB_WORKSPACE + - name: Checkout + uses: actions/checkout@v3 + + # Set up Python 3.9 environment + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: "3.9" + + # Cache docker images so they don't rebuild every time + # - name: Cache Local Images + # id: local-images + # uses: actions/cache@v3 + # with: + # path: /var/lib/docker/ + # key: local-docker-directory + + # - name: Build Images + # run: | + # docker compose up -d --build + + # - name: Set up services + # run: | + # docker exec -it knowledgecommonsworks_web-ui_1 bash -c "bash ./scripts/setup-services.sh" + # exit + + # - name: Build statics and assets + # run: | + # docker exec -it knowledgecommonsworks_web-ui_1 bash -c "bash ./scripts/build-assets.sh" + # exit + + # - name: Run unit tests + # run: cd site && pytest + + # - name: Stop services + # if: always() + # run: | + # docker compose down + diff --git a/INSTALL.rst b/INSTALL.rst index 6354100..8bb7aaf 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -1,8 +1,8 @@ Installation ============ -invenio-remote-user-data is on PyPI so all you need is: +invenio-remote-user-data-kcworks is on PyPI so all you need is: .. code-block:: console - $ pip install invenio-remote-user-data \ No newline at end of file + $ pip install invenio-remote-user-data-kcworks \ No newline at end of file diff --git a/Pipfile b/Pipfile index 3263119..6193f40 100644 --- a/Pipfile +++ b/Pipfile @@ -4,14 +4,14 @@ verify_ssl = true name = "pypi" [packages] -invenio-app-rdm = "~=12.0.0b3.dev3" +invenio-app-rdm = "<13.0.0" pytest = "*" pytest-invenio = "*" invenio-search = "*" opensearch-dsl = "*" invenio-utilities-tuw = "*" invenio-queues = "*" -invenio-remote-user-data = {editable = true, path = "."} +invenio-remote-user-data-kcworks = {editable = true, path = "."} requests-mock = "*" deepdiff = "*" celery = "*" @@ -20,7 +20,7 @@ invenio-groups = {file = "../invenio-groups", editable = true} [dev-packages] [requires] -python_version = "3.9" +python_version = ">=3.9" [pipenv] allow_prereleases = true diff --git a/Pipfile.lock b/Pipfile.lock index 599c37f..476caec 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1354,7 +1354,7 @@ ], "version": "==1.2.0" }, - "invenio-remote-user-data": { + "invenio-remote-user-data-kcworks": { "editable": true, "path": "." }, diff --git a/README.md b/README.md index 5b59b87..be32ce0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ -# Invenio extension for drawing user and groups data from a Remote API. +# Invenio Remote User Data Service for Knowledge Commons Works -This extension provides a service to draw user and groups data from a remote service associated with a SAML login ID provider. This is user data that cannot be derived from the SAML response itself at login, but must be pulled separately from an API endpoint exposed by the same service. This extension assumes the existence of two API endpoints exposed by the remote service: one for user data and one for group data. +Version 0.5.2-beta1 + +* Beta release * + +This extension for the Knowledge Commons Works installation of InvenioRDM provides a service to draw user and groups data from a remote service associated with a SAML login ID provider. This is user data that cannot be derived from the SAML response itself at login, but must be pulled separately from an API endpoint exposed by the same service. This extension assumes the existence of two API endpoints exposed by the remote service: one for user data and one for group data. + +Although this extension was developed for the Knowledge Commons Works installation of InvenioRDM, it could be adapted to other installations of InvenioRDM or other remote services. Most of the changes needed would be in the integration of group collection memberships via the `invenio_group_collections_kcworks` extension. ## Linking Invenio roles and collections with remote service groups @@ -20,7 +26,7 @@ The service's update operations are triggered in two ways: automatically when a ### Automatic update at login -When a user logs in, the `invenio_remote_user_data` extension checks to see whether the current user logged in with a SAML provider. If so, it sends an API request to the appropriate remote API associated with that remote service (configured via a variable in the instance's `invenio.cfg` file) and stores or updates the user's data from the remote service in the user's Invenio account metadata. +When a user logs in, the `invenio_remote_user_data_kcworks` extension checks to see whether the current user logged in with a SAML provider. If so, it sends an API request to the appropriate remote API associated with that remote service (configured via a variable in the instance's `invenio.cfg` file) and stores or updates the user's data from the remote service in the user's Invenio account metadata. Only user metadata updates take place automatically at login. These include updates to the user's group memberships on the remote service, but this user update operation does not update any of the metadata for the groups themselves. Group metadata updates are only triggered by the webhook signal. diff --git a/authors.rst b/authors.rst index b627c7e..3fe19b1 100644 --- a/authors.rst +++ b/authors.rst @@ -1,13 +1,13 @@ .. - Copyright (C) 2023 MESH Research + Copyright (C) 2024 MESH Research - invenio-remote-user-data is free software; you can redistribute it and/or + invenio-remote-user-data-kcworks is free software; you can redistribute it and/or modify it under the terms of the MIT License; see LICENSE file for more details. Authors ======= -Extension to allow for remote user data to be passed to Invenio. +Extension to allow for remote user data to be passed to the Knowledge Commons Works installation of InvenioRDM. - Mesh Research \ No newline at end of file diff --git a/invenio_remote_user_data/__init__.py b/invenio_remote_user_data_kcworks/__init__.py similarity index 96% rename from invenio_remote_user_data/__init__.py rename to invenio_remote_user_data_kcworks/__init__.py index 000d19a..f41cf7f 100644 --- a/invenio_remote_user_data/__init__.py +++ b/invenio_remote_user_data_kcworks/__init__.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # -# This file is part of the invenio-remote-user-data package. +# This file is part of the invenio-remote-user-data-kcworks package. # Copyright (C) 2023, MESH Research. # -# invenio-remote-user-data is free software; you can redistribute it +# invenio-remote-user-data-kcworks is free software; you can redistribute it # and/or modify it under the terms of the MIT License; see # LICENSE file for more details. @@ -34,7 +34,7 @@ on the Invenio server, the `groups` service will handle creation of the group. If a user is the last member of a group and is removed, the `groups` service deletes the group (i.e., the invenio-accounts role). -The `remote-user-data` service, though, only sends the signal for the +The `remote-user-data-kcworks` service, though, only sends the signal for the `groups` service to add or remove the user from the group. Note that the group membership updates are one-directional. If a user is @@ -106,7 +106,7 @@ Logging ------- -The `remote-user-data` extension will log each POST request to the webhook +The `remote-user-data-kcworks` extension will log each POST request to the webhook endpoint, each signal received, and each task initiated to update the data. These logs will be written to a dedicated log file, `logs/remote_data_updates.log`. @@ -229,6 +229,6 @@ from __future__ import absolute_import, print_function from .ext import InvenioRemoteUserData -__version__ = "1.0.0a" +__version__ = "0.5.2-beta1" __all__ = ("__version__", "InvenioRemoteUserData") diff --git a/invenio_remote_user_data/cli.py b/invenio_remote_user_data_kcworks/cli.py similarity index 100% rename from invenio_remote_user_data/cli.py rename to invenio_remote_user_data_kcworks/cli.py diff --git a/invenio_remote_user_data/components/__init__.py b/invenio_remote_user_data_kcworks/components/__init__.py similarity index 100% rename from invenio_remote_user_data/components/__init__.py rename to invenio_remote_user_data_kcworks/components/__init__.py diff --git a/invenio_remote_user_data/components/groups.py b/invenio_remote_user_data_kcworks/components/groups.py similarity index 98% rename from invenio_remote_user_data/components/groups.py rename to invenio_remote_user_data_kcworks/components/groups.py index f903e01..4f00298 100644 --- a/invenio_remote_user_data/components/groups.py +++ b/invenio_remote_user_data_kcworks/components/groups.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # -# This file is part of the invenio-remote-user-data package. +# This file is part of the invenio-remote-user-data-kcworks package. # Copyright (C) 2023, MESH Research. # -# invenio-remote-user-data is free software; you can redistribute it +# invenio-remote-user-data-kcworks is free software; you can redistribute it # and/or modify it under the terms of the MIT License; see # LICENSE file for more details. diff --git a/invenio_remote_user_data/config.py b/invenio_remote_user_data_kcworks/config.py similarity index 90% rename from invenio_remote_user_data/config.py rename to invenio_remote_user_data_kcworks/config.py index ac252cc..1ae5728 100644 --- a/invenio_remote_user_data/config.py +++ b/invenio_remote_user_data_kcworks/config.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # -# This file is part of the invenio-remote-user-data package. +# This file is part of the invenio-remote-user-data-kcworks package. # Copyright (C) 2023, MESH Research. # -# invenio-remote-user-data is free software; you can redistribute it +# invenio-remote-user-data-kcworks is free software; you can redistribute it # and/or modify it under the terms of the MIT License; see # LICENSE file for more details. diff --git a/invenio_remote_user_data/errors.py b/invenio_remote_user_data_kcworks/errors.py similarity index 100% rename from invenio_remote_user_data/errors.py rename to invenio_remote_user_data_kcworks/errors.py diff --git a/invenio_remote_user_data/ext.py b/invenio_remote_user_data_kcworks/ext.py similarity index 91% rename from invenio_remote_user_data/ext.py rename to invenio_remote_user_data_kcworks/ext.py index 4966519..2744a6d 100644 --- a/invenio_remote_user_data/ext.py +++ b/invenio_remote_user_data_kcworks/ext.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # -# This file is part of the invenio-remote-user-data package. +# This file is part of the invenio-remote-user-data-kcworks package. # Copyright (C) 2023, MESH Research. # -# invenio-remote-user-data is free software; you can redistribute it +# invenio-remote-user-data-kcworks is free software; you can redistribute it # and/or modify it under the terms of the MIT License; see # LICENSE file for more details. @@ -28,7 +28,8 @@ def on_user_logged_in(_, user: User) -> None: with current_app.app_context(): current_app.logger.info( - "invenio_remote_user_data.ext: user_logged_in signal received " + "invenio_remote_user_data_kcworks.ext: user_logged_in " + "signal received " f"for user {user.id}" ) current_app.logger.debug(f"current_user: {current_user}") @@ -66,7 +67,7 @@ def on_user_logged_in(_, user: User) -> None: class InvenioRemoteUserData(object): - """Flask extension for Invenio-remote-user-data. + """Flask extension for Invenio-remote-user-data-kcworks. Args: object (_type_): _description_ @@ -87,7 +88,7 @@ def init_app(self, app) -> None: self.init_config(app) self.init_services(app) self.init_listeners(app) - app.extensions["invenio-remote-user-data"] = self + app.extensions["invenio-remote-user-data-kcworks"] = self def init_config(self, app) -> None: """Initialize configuration for the extention. diff --git a/invenio_remote_user_data/permissions.py b/invenio_remote_user_data_kcworks/permissions.py similarity index 100% rename from invenio_remote_user_data/permissions.py rename to invenio_remote_user_data_kcworks/permissions.py diff --git a/invenio_remote_user_data/proxies.py b/invenio_remote_user_data_kcworks/proxies.py similarity index 69% rename from invenio_remote_user_data/proxies.py rename to invenio_remote_user_data_kcworks/proxies.py index 6b18aef..c8f390e 100644 --- a/invenio_remote_user_data/proxies.py +++ b/invenio_remote_user_data_kcworks/proxies.py @@ -2,13 +2,13 @@ from werkzeug.local import LocalProxy current_remote_user_data = LocalProxy( - lambda: current_app.extensions["invenio-remote-user-data"] + lambda: current_app.extensions["invenio-remote-user-data-kcworks"] ) current_remote_user_data_service = LocalProxy( lambda: current_remote_user_data.service ) -current_remote_group_data_service = LocalProxy( +current_remote_group_service = LocalProxy( lambda: current_remote_user_data.group_service ) diff --git a/invenio_remote_user_data/queues.py b/invenio_remote_user_data_kcworks/queues.py similarity index 74% rename from invenio_remote_user_data/queues.py rename to invenio_remote_user_data_kcworks/queues.py index 76eff7f..bd5e2e4 100644 --- a/invenio_remote_user_data/queues.py +++ b/invenio_remote_user_data_kcworks/queues.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # -# This file is part of the invenio-remote-user-data package. +# This file is part of the invenio-remote-user-data-kcworks package. # Copyright (C) 2023, MESH Research. # -# invenio-remote-user-data is free software; you can redistribute it +# invenio-remote-user-data-kcworks is free software; you can redistribute it # and/or modify it under the terms of the MIT License; see # LICENSE file for more details. diff --git a/invenio_remote_user_data/service.py b/invenio_remote_user_data_kcworks/service.py similarity index 99% rename from invenio_remote_user_data/service.py rename to invenio_remote_user_data_kcworks/service.py index c2eee12..2dea236 100644 --- a/invenio_remote_user_data/service.py +++ b/invenio_remote_user_data_kcworks/service.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # -# This file is part of the invenio-remote-user-data package. +# This file is part of the invenio-remote-user-data-kcworks package. # Copyright (C) 2023, MESH Research. # -# invenio-remote-user-data is free software; you can redistribute it +# invenio-remote-user-data-kcworks is free software; you can redistribute it # and/or modify it under the terms of the MIT License; see # LICENSE file for more details. @@ -144,7 +144,7 @@ def update_group_from_remote( return dictionary. This method is triggered by the - :class:`invenio_remote_user_data.views.RemoteUserDataUpdateWebhook` + :class:`invenio_remote_user_data_kcworks.views.RemoteUserDataUpdateWebhook` view. Parameters: diff --git a/invenio_remote_user_data/signals.py b/invenio_remote_user_data_kcworks/signals.py similarity index 71% rename from invenio_remote_user_data/signals.py rename to invenio_remote_user_data_kcworks/signals.py index c0169ec..645a109 100644 --- a/invenio_remote_user_data/signals.py +++ b/invenio_remote_user_data_kcworks/signals.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- # -# This file is part of the invenio-remote-user-data package. +# This file is part of the invenio-remote-user-data-kcworks package. # Copyright (C) 2023, MESH Research. # -# invenio-remote-user-data is free software; you can redistribute it +# invenio-remote-user-data-kcworks is free software; you can redistribute it # and/or modify it under the terms of the MIT License; see # LICENSE file for more details. -"""Signals for invenio-remote-user-data.""" +"""Signals for invenio-remote-user-data-kcworks.""" from blinker import Namespace diff --git a/invenio_remote_user_data/tasks.py b/invenio_remote_user_data_kcworks/tasks.py similarity index 90% rename from invenio_remote_user_data/tasks.py rename to invenio_remote_user_data_kcworks/tasks.py index bcc9ce6..de790e6 100644 --- a/invenio_remote_user_data/tasks.py +++ b/invenio_remote_user_data_kcworks/tasks.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # -# This file is part of the invenio-remote-user-data package. +# This file is part of the invenio-remote-user-data-kcworks package. # Copyright (C) 2023, MESH Research. # -# invenio-remote-user-data is free software; you can redistribute it +# invenio-remote-user-data-kcworks is free software; you can redistribute it # and/or modify it under the terms of the MIT License; see # LICENSE file for more details. @@ -17,7 +17,7 @@ from invenio_accounts.models import UserIdentity # Role, from .proxies import ( current_remote_user_data_service, - current_remote_group_data_service, + current_remote_group_service, ) task_logger = get_task_logger(__name__) @@ -60,6 +60,6 @@ def do_group_data_update(idp, remote_id, **kwargs): task_logger.info(dir(task_logger)) task_logger.info(task_logger.handlers) app.logger.info(task_logger.handlers) - service = current_remote_group_data_service + service = current_remote_group_service service.update_group_from_remote(system_identity, idp, remote_id) return True diff --git a/invenio_remote_user_data/utils.py b/invenio_remote_user_data_kcworks/utils.py similarity index 91% rename from invenio_remote_user_data/utils.py rename to invenio_remote_user_data_kcworks/utils.py index 20a1909..e92cf16 100644 --- a/invenio_remote_user_data/utils.py +++ b/invenio_remote_user_data_kcworks/utils.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- # -# This file is part of the invenio-remote-user-data package. +# This file is part of the invenio-remote-user-data-kcworks package. # Copyright (C) 2023, MESH Research. # -# invenio-remote-user-data is free software; you can redistribute it +# invenio-remote-user-data-kcworks is free software; you can redistribute it # and/or modify it under the terms of the MIT License; see # LICENSE file for more details. -"""Utility functions for invenio-remote-user-data.""" +"""Utility functions for invenio-remote-user-data-kcworks.""" # import logging # import os diff --git a/invenio_remote_user_data/views.py b/invenio_remote_user_data_kcworks/views.py similarity index 96% rename from invenio_remote_user_data/views.py rename to invenio_remote_user_data_kcworks/views.py index 125887f..43e668b 100644 --- a/invenio_remote_user_data/views.py +++ b/invenio_remote_user_data_kcworks/views.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- # -# This file is part of the invenio-remote-user-data package. +# This file is part of the invenio-remote-user-data-kcworks package. # Copyright (C) 2023, MESH Research. # -# invenio-remote-user-data is free software; you can redistribute it +# invenio-remote-user-data-kcworks is free software; you can redistribute it # and/or modify it under the terms of the MIT License; see # LICENSE file for more details. -"""View for an invenio-remote-user-data webhook receiver. +"""View for an invenio-remote-user-data-kcworks webhook receiver. This view is used to receive webhook notifications from a remote IDP when user or group data has been updated on the remote server. The view is @@ -123,11 +123,11 @@ class RemoteUserDataUpdateWebhook(MethodView): """ - View class providing methods for the remote-user-data webhook api endpoint. + View class for the remote-user-data-kcworks webhook api endpoint. """ # init_every_request = False # FIXME: is this right? - view_name = "remote_user_data_webhook" + view_name = "remote_user_data_kcworks_webhook" def __init__(self): # self.webhook_token = os.getenv("REMOTE_USER_DATA_WEBHOOK_TOKEN") @@ -292,7 +292,7 @@ def create_api_blueprint(app): with app.app_context(): blueprint = Blueprint( - "invenio_remote_user_data", + "invenio_remote_user_data_kcworks", __name__, url_prefix="/webhooks/user_data_update", ) diff --git a/pyproject.toml b/pyproject.toml index b8058fe..66fea75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,7 @@ -[build-system] -requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" - [project] -name = "invenio-remote-user-data" -version = "0.0.1" -description = "An extension to draw user data from remote sources into InvenioRDM" +name = "invenio-remote-user-data-kcworks" +version = "0.5.2-beta1" +description = "An extension to draw user data from remote sources into the Knowledge Commons Works InvenioRDM instance" readme = "README.md" authors = [{ name = "Mesh Research", email = "scottia4@msu.edu" }] license = { file = "LICENSE" } @@ -21,14 +17,21 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules" ] keywords = ["invenio", "inveniordm", "users", "research"] + +requires-python = ">=3.9" dependencies = [ - "click>=7.0", - "invenio-app-rdm", + "celery", + "click", + "deepdiff", + "invenio-app-rdm[opensearch2]<13.0.0", + "invenio-groups", + "invenio-queues", "invenio-search", - "opensearch-dsl", "invenio-utilities-tuw", + "opensearch-dsl", + "requests-mock", ] -requires-python = ">=3.9" + [project.optional-dependencies] dev = [ @@ -40,34 +43,90 @@ dev = [ "pytest-runner", "requests-mock", ] - +test = ["coverage"] [project.urls] -Homepage = "https://github.com/MESH-Research/invenio-remote-user-data" - - -[tool.pytest.ini_options] -addopts = "--doctest-glob='*.rst' --doctest-modules" -testpaths = [ "tests", "invenio_remote_user_data" ] - +Homepage = "https://github.com/MESH-Research/invenio-remote-user-data-kcworks" [project.scripts] -user-data = "invenio_remote_user_data.cli:cli" +user-data = "invenio_remote_user_data_kcworks.cli:cli" [project.entry-points."flask.commands"] -user-data = "invenio_remote_user_data.cli:cli" +user-data = "invenio_remote_user_data_kcworks.cli:cli" [project.entry-points."invenio_base.apps"] -invenio_remote_user_data = "invenio_remote_user_data.ext:InvenioRemoteUserData" +invenio_remote_user_data_kcworks = "invenio_remote_user_data_kcworks.ext:InvenioRemoteUserData" [project.entry-points."invenio_base.api_apps"] -invenio_remote_user_data = "invenio_remote_user_data.ext:InvenioRemoteUserData" +invenio_remote_user_data_kcworks = "invenio_remote_user_data_kcworks.ext:InvenioRemoteUserData" [project.entry-points."invenio_base.api_blueprints"] -invenio_remote_user_data = "invenio_remote_user_data.views:create_api_blueprint" +invenio_remote_user_data_kcworks = "invenio_remote_user_data_kcworks.views:create_api_blueprint" [project.entry-points."invenio_queues.queues"] -invenio_remote_user_data = "invenio_remote_user_data.queues:declare_queues" +invenio_remote_user_data_kcworks = "invenio_remote_user_data_kcworks.queues:declare_queues" [project.entry-points."invenio_celery.tasks"] -invenio_remote_user_data = "invenio_remote_user_data.tasks" +invenio_remote_user_data_kcworks = "invenio_remote_user_data_kcworks.tasks" + +[tool.pytest.ini_options] +addopts = "--doctest-glob='*.rst' --doctest-modules" +testpaths = [ "tests", "invenio_remote_user_data_kcworks" ] + +[tool.check-manifest] +ignore = [ + "* .mo", + "*.bin", + "*.gitkeep", + ".*-requirements.txt", + ".bzrignore", + ".DS_Store", + ".egg-info", + ".egg-info/*", + ".gitattributes", + ".github/*", + ".gitignore", + ".hgsigs", + ".hgtags", + ".hgignore", + ".travis.yml", + "Jenkinsfile", + "PKG-INFO", + "setup.cfg" +] + + +[build-system] +requires = ["setuptools>=61.0.0", "wheel"] +build-backend = "setuptools.build_meta" + +[tool.bumpver] +current_version = "0.5.2-beta1" +version_pattern = "MAJOR.MINOR.PATCH[-TAGNUM]" +commit_message = "Bumping version {old_version} -> {new_version}." +tag_message = "{new_version}" +tag_scope = "default" +pre_commit_hook = "" +post_commit_hook = "" +commit = true +tag = true +push = true + +[tool.bumpver.file_patterns] +pyproject.toml = [ + 'current_version = "{version}"', + 'version = "{version}"', +] +README.md = [ + '{version}"', + "{pep440_version}" +] +VERSION = [ + "{version}", +] +"invenio_remote_user_data_kcworks/__init__.py" = [ + '__version__ = "{version}"', +] + +[tool.pydocstyle] +add_ignore = "D401" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a82cb05..0000000 --- a/setup.cfg +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2024 MESH Research -# -# invenio-remote-user-data is free software; you can redistribute it and/or -# modify it under the terms of the MIT License; see LICENSE file for more -# details. - -[metadata] -version = attr: invenio_remote_user_data.__version__ - -[options.entry_points] -console_scripts = - user-data = invenio_remote_user_data.cli:cli -flask.commands = - user-data = invenio_remote_user_data.cli:cli -invenio_base.apps = - invenio_remote_user_data = invenio_remote_user_data.ext:InvenioRemoteUserData -invenio_base.api_apps = - invenio_remote_user_data = invenio_remote_user_data.ext:InvenioRemoteUserData -invenio_base.api_blueprints = - invenio_remote_user_data = invenio_remote_user_data.views:create_api_blueprint -invenio_queues.queues = - invenio_remote_user_data = invenio_remote_user_data.queues:declare_queues -invenio_celery.tasks = - invenio_remote_user_data = invenio_remote_user_data.tasks - - -[check-manifest] -ignore = - .*-requirements.txt - *.bin - *.gitkeep - -[bdist_wheel] -universal = 1 - -[tool:pytest] -addopts = --doctest-glob="*.rst" --doctest-modules -testpaths = tests invenio_remote_user_data - -[pydocstyle] -add_ignore = D401 \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 5d604c8..0000000 --- a/setup.py +++ /dev/null @@ -1,82 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2024 MESH Research -# -# invenio-remote-user-data is free software; you can redistribute it and/or -# modify it under the terms of the MIT License; see LICENSE file for more -# details. - -"""Extension to draw user data into InvenioRDM from a remote source""" - -from setuptools import find_packages, setup - -readme = open("README.md").read() -history = "" -# history = open("CHANGES.md").read() - -install_requires = [ - "click>=7.0", - "invenio-app-rdm", - "invenio-search", - "opensearch-dsl", - "invenio-utilities-tuw", -] - -tests_require = [ - "pytest>=7.3.2", - "pytest-invenio", - "pytest-runner", - "requests-mock", -] - -dev_requires = [ - "check-manifest", - "pipenv", - "pip-tools", - "pytest>=7.3.2", - "pytest-invenio", - "pytest-runner", - "requests-mock", -] - -extras_require = {"tests": tests_require, "dev": dev_requires} - -extras_require["all"] = [] -for reqs in extras_require.values(): - extras_require["all"].extend(reqs) - -packages = find_packages( - include=["invenio_remote_user_data", "invenio_remote_user_data.*"] -) - -setup( - name="invenio-remote-user-data", - description=__doc__, - long_description=readme + "\n\n" + history, - long_description_content_type="text/markdown", - keywords="invenio inveniordm users", - license="MIT", - author="Mesh Research", - author_email="scottia4@msu.edu", - url="https://github.com/MESH-Research/invenio-remote-user-data", - packages=packages, - include_package_data=True, - platforms="any", - install_requires=install_requires, - extras_require=extras_require, - tests_require=tests_require, - setup_requires=["pytest-runner"], - classifiers=[ - "Environment :: Web Environment", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Topic :: Internet :: WWW/HTTP :: Dynamic Content", - "Topic :: Software Development :: Libraries :: Python Modules", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - ], -) diff --git a/tests/conftest.py b/tests/conftest.py index 3712bd6..ca5b5a3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,7 +2,7 @@ # # Copyright (C) 2023-4 Mesh Research # -# invenio-remote-user-data is free software; you can redistribute +# invenio-remote-user-data-kcworks is free software; you can redistribute # it and/or modify it under the terms of the MIT License; see LICENSE file # for more details. @@ -64,7 +64,7 @@ def _(x): test_config = { - # "THEME_FRONTPAGE_TEMPLATE": "invenio_remote_user_data/base.html", + # "THEME_FRONTPAGE_TEMPLATE": "invenio_remote_user_data_kcworks/base.html", "SQLALCHEMY_DATABASE_URI": ( "postgresql+psycopg2://invenio:invenio@localhost/invenio" ), diff --git a/tests/test_components_groups.py b/tests/test_components_groups.py index 5841597..5091981 100644 --- a/tests/test_components_groups.py +++ b/tests/test_components_groups.py @@ -1,11 +1,11 @@ # from invenio_utilities_tuw.utils import get_user_by_identifier -from invenio_remote_user_data.components.groups import ( +from invenio_remote_user_data_kcworks.components.groups import ( GroupRolesComponent, ) # from pprint import pprint -from invenio_remote_user_data.proxies import ( +from invenio_remote_user_data_kcworks.proxies import ( current_remote_user_data_service, ) diff --git a/tests/test_ext.py b/tests/test_ext.py index cb5e148..250e47e 100644 --- a/tests/test_ext.py +++ b/tests/test_ext.py @@ -1,12 +1,12 @@ from flask import Flask -from invenio_remote_user_data import ( +from invenio_remote_user_data_kcworks import ( InvenioRemoteUserData, ) -def test_version(): +def test_version(app): """Test version import.""" - from invenio_remote_user_data import ( + from invenio_remote_user_data_kcworks import ( __version__, ) @@ -17,13 +17,13 @@ def test_init(app): """Test extension initialization.""" dummy_app = Flask("testapp") ext = InvenioRemoteUserData(dummy_app) - assert "invenio-remote-user-data" in dummy_app.extensions + assert "invenio-remote-user-data-kcworks" in dummy_app.extensions dummy_app = Flask("testapp") ext = InvenioRemoteUserData() - assert "invenio-remote-user-data" not in dummy_app.extensions + assert "invenio-remote-user-data-kcworks" not in dummy_app.extensions ext.init_app(dummy_app) - assert "invenio-remote-user-data" in dummy_app.extensions + assert "invenio-remote-user-data-kcworks" in dummy_app.extensions - assert "invenio-remote-user-data" in app.extensions - assert app.extensions["invenio-remote-user-data"].service + assert "invenio-remote-user-data-kcworks" in app.extensions + assert app.extensions["invenio-remote-user-data-kcworks"].service diff --git a/tests/test_service.py b/tests/test_service.py index 7afc028..42ccb2a 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -15,12 +15,12 @@ from invenio_search.utils import build_alias_name from invenio_users_resources.proxies import current_users_service from invenio_utilities_tuw.utils import get_identity_for_user -from invenio_remote_user_data.components.groups import ( +from invenio_remote_user_data_kcworks.components.groups import ( GroupRolesComponent, ) -from invenio_remote_user_data.proxies import ( +from invenio_remote_user_data_kcworks.proxies import ( current_remote_user_data_service as user_data_service, - current_remote_group_data_service as group_data_service, + current_remote_group_service as group_data_service, ) import json from pprint import pprint @@ -1157,8 +1157,8 @@ def test_on_user_logged_in( client, app, db, user_factory, requests_mock, myuser ): """Test service initialization and signal triggers.""" - assert "invenio-remote-user-data" in app.extensions - assert app.extensions["invenio-remote-user-data"].service + assert "invenio-remote-user-data-kcworks" in app.extensions + assert app.extensions["invenio-remote-user-data-kcworks"].service # mock the remote api endpoint # base_url = app.config["REMOTE_USER_DATA_API_ENDPOINTS"][ diff --git a/tests/test_views.py b/tests/test_views.py index 850d1a0..e3fd776 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -7,20 +7,23 @@ current_groups_service as current_groups, current_users_service as current_users, ) -from py import log import pytest import json import os -from invenio_remote_user_data.components.groups import GroupRolesComponent -from invenio_remote_user_data.service import RemoteUserDataService +from invenio_remote_user_data_kcworks.components.groups import ( + GroupRolesComponent, +) +from invenio_remote_user_data_kcworks.service import ( + RemoteUserDataService, +) def test_webhook_get(client, app, search_clear): """Test webhook.""" response = client.get( url_for( - "invenio_remote_user_data.remote_user_data_webhook", + "invenio_remote_user_data_kcworks.remote_user_data_kcworks_webhook", ) ) @@ -68,7 +71,9 @@ def test_webhook_get(client, app, search_clear): "name": "Joe User", "first_name": "Joe", "last_name": "User", - "institutional_affiliation": "Michigan State University", + "institutional_affiliation": ( + "Michigan State University" + ), "orcid": "0000-0002-1825-0097", "groups": [ { @@ -163,7 +168,8 @@ def test_webhook_post( app.logger.debug(f"admin roles: {admin.user.roles}") response = client.post( url_for( - "invenio_remote_user_data.remote_user_data_webhook", + "invenio_remote_user_data_kcworks." + "remote_user_data_kcworks_webhook", ), data=json.dumps(payload), headers=headers,