diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f6ed65fa..c37fd031 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,10 +26,10 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] - requirements-level: [pypi] + python-version: ["3.9", "3.12"] cache-service: [redis] db-service: [postgresql14, mysql8] + search-service: [opensearch2] include: - db-service: postgresql14 @@ -41,7 +41,8 @@ jobs: env: CACHE: ${{ matrix.cache-service }} DB: ${{ matrix.db-service }} - EXTRAS: tests,admin,${{ matrix.DB_EXTRAS }} + SEARCH: ${{ matrix.search-service }} + EXTRAS: tests,admin,${{ matrix.DB_EXTRAS }},${{ matrix.search-service }} steps: - name: Checkout uses: actions/checkout@v4 diff --git a/invenio_accounts/cli.py b/invenio_accounts/cli.py index ff506d2c..c8aa5684 100644 --- a/invenio_accounts/cli.py +++ b/invenio_accounts/cli.py @@ -18,7 +18,9 @@ from flask.cli import with_appcontext from flask_security.forms import ConfirmRegisterForm from flask_security.utils import hash_password +from invenio_access.permissions import system_identity from invenio_db import db +from invenio_users_resources.proxies import current_groups_service from werkzeug.datastructures import MultiDict from werkzeug.local import LocalProxy @@ -53,6 +55,11 @@ def domains(): """Domain commands.""" +@click.group() +def groups(): + """Group commands.""" + + @users.command("create") @click.argument("email") @click.password_option() @@ -178,3 +185,14 @@ def domains_create(domain): click.secho(f"Domain {domain} creating failed with {error}", fg="red") else: click.secho(f"Domain {domain} created successfully", fg="green") + + +@groups.command("create") +@click.argument("name") +@with_appcontext +@commit +def groups_create(name): + """Create group.""" + _datastore.create_role(id=name, name=name, is_managed=False) + current_groups_service.rebuild_index(system_identity) + click.secho(f'Role "({name})s" created successfully.', fg="green") diff --git a/run-tests.sh b/run-tests.sh index f6ee8e53..bc2d8687 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -44,7 +44,7 @@ fi python -m check_manifest python -m setup extract_messages --output-file /dev/null python -m sphinx.cmd.build -qnN docs docs/_build/html -eval "$(docker-services-cli up --db ${DB:-postgresql} --cache ${CACHE:-redis} --env)" +eval "$(docker-services-cli up --db ${DB:-postgresql} --search ${SEARCH:-opensearch} --cache ${CACHE:-redis} --env)" # Note: expansion of pytest_args looks like below to not cause an unbound # variable error when 1) "nounset" and 2) the array is empty. python -m pytest ${pytest_args[@]+"${pytest_args[@]}"} diff --git a/setup.cfg b/setup.cfg index 7fea8010..2ff4af0b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,11 +31,13 @@ install_requires = cryptography>=3.0.0 Flask-KVSession-Invenio>=0.6.3 Flask-Security-Invenio>=3.2.0 + invenio_access>=2.0.0 invenio-celery>=1.2.3 invenio-i18n>=2.0.0 invenio-mail>=1.0.2 invenio-rest>=1.2.4 invenio-theme>=2.0.0 + invenio_users_resources>=5.0.0 maxminddb-geolite2>=2017.404 pyjwt>=1.5.0 simplekv>=0.11.2 @@ -50,6 +52,10 @@ mysql = invenio-db[mysql]>=1.0.14 sqlite = invenio-db>=1.0.14 +opensearch1 = + invenio-search[opensearch1]>=2.1.0,<3.0.0 +opensearch2 = + invenio-search[opensearch2]>=2.1.0,<3.0.0 tests = mock>=1.3.0 invenio-app>=1.4.0 @@ -62,6 +68,8 @@ flask.commands = roles = invenio_accounts.cli:roles users = invenio_accounts.cli:users domains = invenio_accounts.cli:domains + groups = invenio_accounts.cli:groups + invenio_admin.views = invenio_accounts_user = invenio_accounts.admin:user_adminview invenio_accounts_role = invenio_accounts.admin:role_adminview