diff options
52 files changed, 184 insertions, 184 deletions
diff --git a/gn_auth/auth/authentication/oauth2/endpoints/introspection.py b/gn_auth/auth/authentication/oauth2/endpoints/introspection.py index a567363..222ddcb 100644 --- a/gn_auth/auth/authentication/oauth2/endpoints/introspection.py +++ b/gn_auth/auth/authentication/oauth2/endpoints/introspection.py @@ -6,7 +6,7 @@ from flask import request as flask_request from authlib.oauth2.rfc7662 import ( IntrospectionEndpoint as _IntrospectionEndpoint) -from gn3.auth.authentication.oauth2.models.oauth2token import OAuth2Token +from gn_auth.auth.authentication.oauth2.models.oauth2token import OAuth2Token from .utilities import query_token as _query_token diff --git a/gn_auth/auth/authentication/oauth2/endpoints/revocation.py b/gn_auth/auth/authentication/oauth2/endpoints/revocation.py index b8517b6..ad9e67c 100644 --- a/gn_auth/auth/authentication/oauth2/endpoints/revocation.py +++ b/gn_auth/auth/authentication/oauth2/endpoints/revocation.py @@ -3,8 +3,8 @@ from flask import current_app from authlib.oauth2.rfc7009 import RevocationEndpoint as _RevocationEndpoint -from gn3.auth import db -from gn3.auth.authentication.oauth2.models.oauth2token import ( +from gn_auth.auth import db +from gn_auth.auth.authentication.oauth2.models.oauth2token import ( save_token, OAuth2Token, revoke_token) from .utilities import query_token as _query_token diff --git a/gn_auth/auth/authentication/oauth2/endpoints/utilities.py b/gn_auth/auth/authentication/oauth2/endpoints/utilities.py index 299f151..d32f9b3 100644 --- a/gn_auth/auth/authentication/oauth2/endpoints/utilities.py +++ b/gn_auth/auth/authentication/oauth2/endpoints/utilities.py @@ -4,8 +4,8 @@ from typing import Any, Optional from flask import current_app from pymonad.maybe import Nothing -from gn3.auth import db -from gn3.auth.authentication.oauth2.models.oauth2token import ( +from gn_auth.auth import db +from gn_auth.auth.authentication.oauth2.models.oauth2token import ( OAuth2Token, token_by_access_token, token_by_refresh_token) def query_token(# pylint: disable=[unused-argument] diff --git a/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py b/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py index f80d02e..6d8112e 100644 --- a/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py +++ b/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py @@ -9,9 +9,9 @@ from flask import current_app as app from authlib.oauth2.rfc6749 import grants from authlib.oauth2.rfc7636 import create_s256_code_challenge -from gn3.auth import db -from gn3.auth.db_utils import with_db_connection -from gn3.auth.authentication.users import User +from gn_auth.auth import db +from gn_auth.auth.db_utils import with_db_connection +from gn_auth.auth.authentication.users import User from ..models.oauth2client import OAuth2Client from ..models.authorization_code import ( diff --git a/gn_auth/auth/authentication/oauth2/grants/password_grant.py b/gn_auth/auth/authentication/oauth2/grants/password_grant.py index 3233877..75fc122 100644 --- a/gn_auth/auth/authentication/oauth2/grants/password_grant.py +++ b/gn_auth/auth/authentication/oauth2/grants/password_grant.py @@ -3,10 +3,10 @@ from flask import current_app as app from authlib.oauth2.rfc6749 import grants -from gn3.auth import db -from gn3.auth.authentication.users import valid_login, user_by_email +from gn_auth.auth import db +from gn_auth.auth.authentication.users import valid_login, user_by_email -from gn3.auth.authorisation.errors import NotFoundError +from gn_auth.auth.authorisation.errors import NotFoundError class PasswordGrant(grants.ResourceOwnerPasswordCredentialsGrant): """Implement the 'Password' grant.""" diff --git a/gn_auth/auth/authentication/oauth2/models/authorization_code.py b/gn_auth/auth/authentication/oauth2/models/authorization_code.py index f282814..98b5d0f 100644 --- a/gn_auth/auth/authentication/oauth2/models/authorization_code.py +++ b/gn_auth/auth/authentication/oauth2/models/authorization_code.py @@ -5,7 +5,7 @@ from typing import NamedTuple from pymonad.maybe import Just, Maybe, Nothing -from gn3.auth import db +from gn_auth.auth import db from .oauth2client import OAuth2Client diff --git a/gn_auth/auth/authentication/oauth2/models/oauth2client.py b/gn_auth/auth/authentication/oauth2/models/oauth2client.py index 2a307e3..07618dd 100644 --- a/gn_auth/auth/authentication/oauth2/models/oauth2client.py +++ b/gn_auth/auth/authentication/oauth2/models/oauth2client.py @@ -6,10 +6,10 @@ from typing import Sequence, Optional, NamedTuple from pymonad.maybe import Just, Maybe, Nothing -from gn3.auth import db -from gn3.auth.authentication.users import User, users, user_by_id, same_password +from gn_auth.auth import db +from gn_auth.auth.authentication.users import User, users, user_by_id, same_password -from gn3.auth.authorisation.errors import NotFoundError +from gn_auth.auth.authorisation.errors import NotFoundError class OAuth2Client(NamedTuple): """ diff --git a/gn_auth/auth/authentication/oauth2/models/oauth2token.py b/gn_auth/auth/authentication/oauth2/models/oauth2token.py index 72e20cc..725c096 100644 --- a/gn_auth/auth/authentication/oauth2/models/oauth2token.py +++ b/gn_auth/auth/authentication/oauth2/models/oauth2token.py @@ -5,10 +5,10 @@ from typing import NamedTuple, Optional from pymonad.maybe import Just, Maybe, Nothing -from gn3.auth import db -from gn3.auth.authentication.users import User, user_by_id +from gn_auth.auth import db +from gn_auth.auth.authentication.users import User, user_by_id -from gn3.auth.authorisation.errors import NotFoundError +from gn_auth.auth.authorisation.errors import NotFoundError from .oauth2client import client, OAuth2Client diff --git a/gn_auth/auth/authentication/oauth2/resource_server.py b/gn_auth/auth/authentication/oauth2/resource_server.py index 223e811..32c463f 100644 --- a/gn_auth/auth/authentication/oauth2/resource_server.py +++ b/gn_auth/auth/authentication/oauth2/resource_server.py @@ -4,8 +4,8 @@ from flask import current_app as app from authlib.oauth2.rfc6750 import BearerTokenValidator as _BearerTokenValidator from authlib.integrations.flask_oauth2 import ResourceProtector -from gn3.auth import db -from gn3.auth.authentication.oauth2.models.oauth2token import token_by_access_token +from gn_auth.auth import db +from gn_auth.auth.authentication.oauth2.models.oauth2token import token_by_access_token class BearerTokenValidator(_BearerTokenValidator): """Extends `authlib.oauth2.rfc6750.BearerTokenValidator`""" diff --git a/gn_auth/auth/authentication/oauth2/server.py b/gn_auth/auth/authentication/oauth2/server.py index 7d7113a..b085219 100644 --- a/gn_auth/auth/authentication/oauth2/server.py +++ b/gn_auth/auth/authentication/oauth2/server.py @@ -8,7 +8,7 @@ from authlib.oauth2.rfc6749.errors import InvalidClientError from authlib.integrations.flask_oauth2 import AuthorizationServer # from authlib.oauth2.rfc7636 import CodeChallenge -from gn3.auth import db +from gn_auth.auth import db from .models.oauth2client import client from .models.oauth2token import OAuth2Token, save_token diff --git a/gn_auth/auth/authentication/oauth2/views.py b/gn_auth/auth/authentication/oauth2/views.py index 2bd3865..43d9e49 100644 --- a/gn_auth/auth/authentication/oauth2/views.py +++ b/gn_auth/auth/authentication/oauth2/views.py @@ -14,9 +14,9 @@ from flask import ( render_template, current_app as app) -from gn3.auth import db -from gn3.auth.db_utils import with_db_connection -from gn3.auth.authorisation.errors import ForbiddenAccess +from gn_auth.auth import db +from gn_auth.auth.db_utils import with_db_connection +from gn_auth.auth.authorisation.errors import ForbiddenAccess from .resource_server import require_oauth from .endpoints.revocation import RevocationEndpoint diff --git a/gn_auth/auth/authorisation/data/genotypes.py b/gn_auth/auth/authorisation/data/genotypes.py index 8f901a5..41822a1 100644 --- a/gn_auth/auth/authorisation/data/genotypes.py +++ b/gn_auth/auth/authorisation/data/genotypes.py @@ -4,11 +4,11 @@ from typing import Iterable from MySQLdb.cursors import DictCursor -import gn3.auth.db as authdb -import gn3.db_utils as gn3db -from gn3.auth.dictify import dictify -from gn3.auth.authorisation.checks import authorised_p -from gn3.auth.authorisation.groups.models import Group +import gn_auth.auth.db as authdb +import gn_auth.db_utils as gn3db +from gn_auth.auth.dictify import dictify +from gn_auth.auth.authorisation.checks import authorised_p +from gn_auth.auth.authorisation.groups.models import Group def linked_genotype_data(conn: authdb.DbConnection) -> Iterable[dict]: """Retrive genotype data that is linked to user groups.""" diff --git a/gn_auth/auth/authorisation/data/mrna.py b/gn_auth/auth/authorisation/data/mrna.py index bdfc5c1..0b08571 100644 --- a/gn_auth/auth/authorisation/data/mrna.py +++ b/gn_auth/auth/authorisation/data/mrna.py @@ -3,11 +3,11 @@ import uuid from typing import Iterable from MySQLdb.cursors import DictCursor -import gn3.auth.db as authdb -import gn3.db_utils as gn3db -from gn3.auth.dictify import dictify -from gn3.auth.authorisation.checks import authorised_p -from gn3.auth.authorisation.groups.models import Group +import gn_auth.auth.db as authdb +import gn_auth.db_utils as gn3db +from gn_auth.auth.dictify import dictify +from gn_auth.auth.authorisation.checks import authorised_p +from gn_auth.auth.authorisation.groups.models import Group def linked_mrna_data(conn: authdb.DbConnection) -> Iterable[dict]: """Retrieve mRNA Assay data that is linked to user groups.""" diff --git a/gn_auth/auth/authorisation/data/phenotypes.py b/gn_auth/auth/authorisation/data/phenotypes.py index ff98295..2f4c564 100644 --- a/gn_auth/auth/authorisation/data/phenotypes.py +++ b/gn_auth/auth/authorisation/data/phenotypes.py @@ -4,11 +4,11 @@ from typing import Any, Iterable from MySQLdb.cursors import DictCursor -import gn3.auth.db as authdb -import gn3.db_utils as gn3db -from gn3.auth.dictify import dictify -from gn3.auth.authorisation.checks import authorised_p -from gn3.auth.authorisation.groups.models import Group +import gn_auth.auth.db as authdb +import gn_auth.db_utils as gn3db +from gn_auth.auth.dictify import dictify +from gn_auth.auth.authorisation.checks import authorised_p +from gn_auth.auth.authorisation.groups.models import Group def linked_phenotype_data( authconn: authdb.DbConnection, gn3conn: gn3db.Connection, diff --git a/gn_auth/auth/authorisation/data/views.py b/gn_auth/auth/authorisation/data/views.py index 8adf862..a25e9a2 100644 --- a/gn_auth/auth/authorisation/data/views.py +++ b/gn_auth/auth/authorisation/data/views.py @@ -10,31 +10,31 @@ from MySQLdb.cursors import DictCursor from authlib.integrations.flask_oauth2.errors import _HTTPException from flask import request, jsonify, Response, Blueprint, current_app as app -import gn3.db_utils as gn3db -from gn3 import jobs -from gn3.commands import run_async_cmd -from gn3.db.traits import build_trait_name +import gn_auth.db_utils as gn3db +from gn_auth import jobs +from gn_auth.commands import run_async_cmd +from gn_auth.db.traits import build_trait_name -from gn3.auth import db -from gn3.auth.db_utils import with_db_connection +from gn_auth.auth import db +from gn_auth.auth.db_utils import with_db_connection -from gn3.auth.authorisation.checks import require_json -from gn3.auth.authorisation.errors import InvalidData, NotFoundError +from gn_auth.auth.authorisation.checks import require_json +from gn_auth.auth.authorisation.errors import InvalidData, NotFoundError -from gn3.auth.authorisation.groups.models import group_by_id +from gn_auth.auth.authorisation.groups.models import group_by_id -from gn3.auth.authorisation.users.models import user_resource_roles +from gn_auth.auth.authorisation.users.models import user_resource_roles -from gn3.auth.authorisation.resources.checks import authorised_for -from gn3.auth.authorisation.resources.models import ( +from gn_auth.auth.authorisation.resources.checks import authorised_for +from gn_auth.auth.authorisation.resources.models import ( user_resources, public_resources, attach_resources_data) -from gn3.auth.authentication.users import User -from gn3.auth.authentication.oauth2.resource_server import require_oauth +from gn_auth.auth.authentication.users import User +from gn_auth.auth.authentication.oauth2.resource_server import require_oauth -from gn3.auth.authorisation.data.phenotypes import link_phenotype_data -from gn3.auth.authorisation.data.mrna import link_mrna_data, ungrouped_mrna_data -from gn3.auth.authorisation.data.genotypes import ( +from gn_auth.auth.authorisation.data.phenotypes import link_phenotype_data +from gn_auth.auth.authorisation.data.mrna import link_mrna_data, ungrouped_mrna_data +from gn_auth.auth.authorisation.data.genotypes import ( link_genotype_data, ungrouped_genotype_data) data = Blueprint("data", __name__) diff --git a/gn_auth/auth/authorisation/groups/data.py b/gn_auth/auth/authorisation/groups/data.py index ee6f70e..d05747b 100644 --- a/gn_auth/auth/authorisation/groups/data.py +++ b/gn_auth/auth/authorisation/groups/data.py @@ -1,11 +1,11 @@ """Handles the resource objects' data.""" from MySQLdb.cursors import DictCursor -from gn3 import db_utils as gn3db -from gn3.auth import db as authdb -from gn3.auth.authorisation.groups import Group -from gn3.auth.authorisation.checks import authorised_p -from gn3.auth.authorisation.errors import NotFoundError +from gn_auth import db_utils as gn3db +from gn_auth.auth import db as authdb +from gn_auth.auth.authorisation.groups import Group +from gn_auth.auth.authorisation.checks import authorised_p +from gn_auth.auth.authorisation.errors import NotFoundError def __fetch_mrna_data_by_ids__( conn: gn3db.Connection, dataset_ids: tuple[str, ...]) -> tuple[ diff --git a/gn_auth/auth/authorisation/groups/models.py b/gn_auth/auth/authorisation/groups/models.py index 5a3ae50..9008bef 100644 --- a/gn_auth/auth/authorisation/groups/models.py +++ b/gn_auth/auth/authorisation/groups/models.py @@ -7,9 +7,9 @@ from typing import Any, Sequence, Iterable, Optional, NamedTuple from flask import g from pymonad.maybe import Just, Maybe, Nothing -from gn3.auth import db -from gn3.auth.dictify import dictify -from gn3.auth.authentication.users import User, user_by_id +from gn_auth.auth import db +from gn_auth.auth.dictify import dictify +from gn_auth.auth.authentication.users import User, user_by_id from ..checks import authorised_p from ..privileges import Privilege diff --git a/gn_auth/auth/authorisation/groups/views.py b/gn_auth/auth/authorisation/groups/views.py index 628df36..d1724cc 100644 --- a/gn_auth/auth/authorisation/groups/views.py +++ b/gn_auth/auth/authorisation/groups/views.py @@ -7,11 +7,11 @@ from functools import partial from MySQLdb.cursors import DictCursor from flask import request, jsonify, Response, Blueprint, current_app -from gn3.auth import db -from gn3 import db_utils as gn3db +from gn_auth.auth import db +from gn_auth import db_utils as gn3db -from gn3.auth.dictify import dictify -from gn3.auth.db_utils import with_db_connection +from gn_auth.auth.dictify import dictify +from gn_auth.auth.db_utils import with_db_connection from .data import link_data_to_group from .models import ( diff --git a/gn_auth/auth/authorisation/resources/checks.py b/gn_auth/auth/authorisation/resources/checks.py index fafde76..a341dbd 100644 --- a/gn_auth/auth/authorisation/resources/checks.py +++ b/gn_auth/auth/authorisation/resources/checks.py @@ -3,8 +3,8 @@ from uuid import UUID from functools import reduce from typing import Sequence -from gn3.auth import db -from gn3.auth.authentication.users import User +from gn_auth.auth import db +from gn_auth.auth.authentication.users import User def __organise_privileges_by_resource_id__(rows): def __organise__(privs, row): diff --git a/gn_auth/auth/authorisation/resources/models.py b/gn_auth/auth/authorisation/resources/models.py index b301a93..d96979f 100644 --- a/gn_auth/auth/authorisation/resources/models.py +++ b/gn_auth/auth/authorisation/resources/models.py @@ -5,10 +5,10 @@ from uuid import UUID, uuid4 from functools import reduce, partial from typing import Any, Dict, Sequence, Optional, NamedTuple -from gn3.auth import db -from gn3.auth.dictify import dictify -from gn3.auth.authentication.users import User -from gn3.auth.db_utils import with_db_connection +from gn_auth.auth import db +from gn_auth.auth.dictify import dictify +from gn_auth.auth.authentication.users import User +from gn_auth.auth.db_utils import with_db_connection from .checks import authorised_for diff --git a/gn_auth/auth/authorisation/resources/views.py b/gn_auth/auth/authorisation/resources/views.py index 3b2bbeb..9645303 100644 --- a/gn_auth/auth/authorisation/resources/views.py +++ b/gn_auth/auth/authorisation/resources/views.py @@ -6,7 +6,7 @@ from functools import reduce from flask import request, jsonify, Response, Blueprint, current_app as app -from gn3.auth.db_utils import with_db_connection +from gn_auth.auth.db_utils import with_db_connection from .checks import authorised_for from .models import ( diff --git a/gn_auth/auth/authorisation/roles/models.py b/gn_auth/auth/authorisation/roles/models.py index 97e11af..742a90e 100644 --- a/gn_auth/auth/authorisation/roles/models.py +++ b/gn_auth/auth/authorisation/roles/models.py @@ -5,10 +5,10 @@ from typing import Any, Sequence, Iterable, NamedTuple from pymonad.either import Left, Right, Either -from gn3.auth import db -from gn3.auth.dictify import dictify -from gn3.auth.authentication.users import User -from gn3.auth.authorisation.errors import AuthorisationError +from gn_auth.auth import db +from gn_auth.auth.dictify import dictify +from gn_auth.auth.authentication.users import User +from gn_auth.auth.authorisation.errors import AuthorisationError from ..checks import authorised_p from ..privileges import Privilege diff --git a/gn_auth/auth/authorisation/roles/views.py b/gn_auth/auth/authorisation/roles/views.py index 3670aab..6510365 100644 --- a/gn_auth/auth/authorisation/roles/views.py +++ b/gn_auth/auth/authorisation/roles/views.py @@ -3,8 +3,8 @@ import uuid from flask import jsonify, Response, Blueprint, current_app -from gn3.auth import db -from gn3.auth.dictify import dictify +from gn_auth.auth import db +from gn_auth.auth.dictify import dictify from .models import user_role diff --git a/gn_auth/auth/authorisation/users/admin/ui.py b/gn_auth/auth/authorisation/users/admin/ui.py index 242c7a6..4351a68 100644 --- a/gn_auth/auth/authorisation/users/admin/ui.py +++ b/gn_auth/auth/authorisation/users/admin/ui.py @@ -2,11 +2,11 @@ from functools import wraps from flask import flash, url_for, redirect -from gn3.auth.authentication.users import User -from gn3.auth.db_utils import with_db_connection -from gn3.auth.authorisation.roles.models import user_roles +from gn_auth.auth.authentication.users import User +from gn_auth.auth.db_utils import with_db_connection +from gn_auth.auth.authorisation.roles.models import user_roles -from gn3.session import logged_in, session_user, clear_session_info +from gn_auth.session import logged_in, session_user, clear_session_info def is_admin(func): """Verify user is a system admin.""" diff --git a/gn_auth/auth/authorisation/users/admin/views.py b/gn_auth/auth/authorisation/users/admin/views.py index c9f1887..ab04f91 100644 --- a/gn_auth/auth/authorisation/users/admin/views.py +++ b/gn_auth/auth/authorisation/users/admin/views.py @@ -17,17 +17,17 @@ from flask import ( render_template) -from gn3 import session -from gn3.auth import db -from gn3.auth.db_utils import with_db_connection +from gn_auth import session +from gn_auth.auth import db +from gn_auth.auth.db_utils import with_db_connection -from gn3.auth.authentication.oauth2.models.oauth2client import ( +from gn_auth.auth.authentication.oauth2.models.oauth2client import ( save_client, OAuth2Client, oauth2_clients, client as oauth2_client, delete_client as _delete_client) -from gn3.auth.authentication.users import ( +from gn_auth.auth.authentication.users import ( User, user_by_id, valid_login, diff --git a/gn_auth/auth/authorisation/users/collections/models.py b/gn_auth/auth/authorisation/users/collections/models.py index 7577fa8..eb9b188 100644 --- a/gn_auth/auth/authorisation/users/collections/models.py +++ b/gn_auth/auth/authorisation/users/collections/models.py @@ -6,7 +6,7 @@ from datetime import datetime from redis import Redis from email_validator import validate_email, EmailNotValidError -from gn3.auth.authorisation.errors import InvalidData, NotFoundError +from gn_auth.auth.authorisation.errors import InvalidData, NotFoundError from ..models import User diff --git a/gn_auth/auth/authorisation/users/collections/views.py b/gn_auth/auth/authorisation/users/collections/views.py index 1fa25a3..3dcc10f 100644 --- a/gn_auth/auth/authorisation/users/collections/views.py +++ b/gn_auth/auth/authorisation/users/collections/views.py @@ -4,13 +4,13 @@ from uuid import UUID from redis import Redis from flask import jsonify, request, Response, Blueprint, current_app -from gn3.auth import db -from gn3.auth.db_utils import with_db_connection -from gn3.auth.authorisation.checks import require_json -from gn3.auth.authorisation.errors import NotFoundError +from gn_auth.auth import db +from gn_auth.auth.db_utils import with_db_connection +from gn_auth.auth.authorisation.checks import require_json +from gn_auth.auth.authorisation.errors import NotFoundError -from gn3.auth.authentication.users import User, user_by_id -from gn3.auth.authentication.oauth2.resource_server import require_oauth +from gn_auth.auth.authentication.users import User, user_by_id +from gn_auth.auth.authentication.oauth2.resource_server import require_oauth from .models import ( add_traits, diff --git a/gn_auth/auth/authorisation/users/masquerade/models.py b/gn_auth/auth/authorisation/users/masquerade/models.py index 9f24b6b..c45d761 100644 --- a/gn_auth/auth/authorisation/users/masquerade/models.py +++ b/gn_auth/auth/authorisation/users/masquerade/models.py @@ -5,13 +5,13 @@ from datetime import datetime from flask import current_app as app -from gn3.auth import db +from gn_auth.auth import db -from gn3.auth.authorisation.errors import ForbiddenAccess -from gn3.auth.authorisation.roles.models import user_roles +from gn_auth.auth.authorisation.errors import ForbiddenAccess +from gn_auth.auth.authorisation.roles.models import user_roles -from gn3.auth.authentication.users import User -from gn3.auth.authentication.oauth2.models.oauth2token import ( +from gn_auth.auth.authentication.users import User +from gn_auth.auth.authentication.oauth2.models.oauth2token import ( OAuth2Token, save_token) __FIVE_HOURS__ = (60 * 60 * 5) diff --git a/gn_auth/auth/authorisation/users/masquerade/views.py b/gn_auth/auth/authorisation/users/masquerade/views.py index 43286a1..9e42945 100644 --- a/gn_auth/auth/authorisation/users/masquerade/views.py +++ b/gn_auth/auth/authorisation/users/masquerade/views.py @@ -4,12 +4,12 @@ from functools import partial from flask import request, jsonify, Response, Blueprint -from gn3.auth.db_utils import with_db_connection -from gn3.auth.authorisation.errors import InvalidData -from gn3.auth.authorisation.checks import require_json +from gn_auth.auth.db_utils import with_db_connection +from gn_auth.auth.authorisation.errors import InvalidData +from gn_auth.auth.authorisation.checks import require_json -from gn3.auth.authentication.users import user_by_id -from gn3.auth.authentication.oauth2.resource_server import require_oauth +from gn_auth.auth.authentication.users import user_by_id +from gn_auth.auth.authentication.oauth2.resource_server import require_oauth from .models import masquerade_as diff --git a/gn_auth/auth/authorisation/users/models.py b/gn_auth/auth/authorisation/users/models.py index 89c1d22..71fa390 100644 --- a/gn_auth/auth/authorisation/users/models.py +++ b/gn_auth/auth/authorisation/users/models.py @@ -2,12 +2,12 @@ import uuid from functools import reduce -from gn3.auth import db -from gn3.auth.authorisation.roles.models import Role -from gn3.auth.authorisation.checks import authorised_p -from gn3.auth.authorisation.privileges import Privilege +from gn_auth.auth import db +from gn_auth.auth.authorisation.roles.models import Role +from gn_auth.auth.authorisation.checks import authorised_p +from gn_auth.auth.authorisation.privileges import Privilege -from gn3.auth.authentication.users import User +from gn_auth.auth.authentication.users import User @authorised_p( ("system:user:list",), diff --git a/gn_auth/auth/authorisation/users/views.py b/gn_auth/auth/authorisation/users/views.py index 826e222..7783dca 100644 --- a/gn_auth/auth/authorisation/users/views.py +++ b/gn_auth/auth/authorisation/users/views.py @@ -7,9 +7,9 @@ import sqlite3 from email_validator import validate_email, EmailNotValidError from flask import request, jsonify, Response, Blueprint, current_app -from gn3.auth import db -from gn3.auth.dictify import dictify -from gn3.auth.db_utils import with_db_connection +from gn_auth.auth import db +from gn_auth.auth.dictify import dictify +from gn_auth.auth.db_utils import with_db_connection from .models import list_users from .masquerade.views import masq diff --git a/tests/unit/auth/conftest.py b/tests/unit/auth/conftest.py index a7c64a8..facfb81 100644 --- a/tests/unit/auth/conftest.py +++ b/tests/unit/auth/conftest.py @@ -3,7 +3,7 @@ import uuid import datetime from contextlib import contextmanager -from gn3.auth.authentication.oauth2.models.oauth2token import OAuth2Token +from gn_auth.auth.authentication.oauth2.models.oauth2token import OAuth2Token from .fixtures import * # pylint: disable=[wildcard-import,unused-wildcard-import] diff --git a/tests/unit/auth/fixtures/group_fixtures.py b/tests/unit/auth/fixtures/group_fixtures.py index d7bbc56..b2bae24 100644 --- a/tests/unit/auth/fixtures/group_fixtures.py +++ b/tests/unit/auth/fixtures/group_fixtures.py @@ -3,9 +3,9 @@ import uuid import pytest -from gn3.auth import db -from gn3.auth.authorisation.groups import Group, GroupRole -from gn3.auth.authorisation.resources import Resource, ResourceCategory +from gn_auth.auth import db +from gn_auth.auth.authorisation.groups import Group, GroupRole +from gn_auth.auth.authorisation.resources import Resource, ResourceCategory from .role_fixtures import RESOURCE_EDITOR_ROLE, RESOURCE_READER_ROLE diff --git a/tests/unit/auth/fixtures/migration_fixtures.py b/tests/unit/auth/fixtures/migration_fixtures.py index eb42c2b..2a67c01 100644 --- a/tests/unit/auth/fixtures/migration_fixtures.py +++ b/tests/unit/auth/fixtures/migration_fixtures.py @@ -4,8 +4,8 @@ from yoyo.backends import DatabaseBackend from yoyo import get_backend, read_migrations from yoyo.migrations import Migration, MigrationList -from gn3.auth import db -from gn3.migrations import apply_migrations, rollback_migrations +from gn_auth.auth import db +from gn_auth.migrations import apply_migrations, rollback_migrations @pytest.fixture(scope="session") def auth_testdb_path(fxtr_app_config): # pylint: disable=redefined-outer-name diff --git a/tests/unit/auth/fixtures/oauth2_client_fixtures.py b/tests/unit/auth/fixtures/oauth2_client_fixtures.py index 654d048..70cd2c2 100644 --- a/tests/unit/auth/fixtures/oauth2_client_fixtures.py +++ b/tests/unit/auth/fixtures/oauth2_client_fixtures.py @@ -5,9 +5,9 @@ import datetime import pytest -from gn3.auth import db -from gn3.auth.authentication.users import hash_password -from gn3.auth.authentication.oauth2.models.oauth2client import OAuth2Client +from gn_auth.auth import db +from gn_auth.auth.authentication.users import hash_password +from gn_auth.auth.authentication.oauth2.models.oauth2client import OAuth2Client @pytest.fixture(autouse=True) def fxtr_patch_envvars(monkeypatch): diff --git a/tests/unit/auth/fixtures/resource_fixtures.py b/tests/unit/auth/fixtures/resource_fixtures.py index 117b4f4..efe617e 100644 --- a/tests/unit/auth/fixtures/resource_fixtures.py +++ b/tests/unit/auth/fixtures/resource_fixtures.py @@ -1,7 +1,7 @@ """Fixtures and utilities for resource-related tests""" import pytest -from gn3.auth import db +from gn_auth.auth import db from .group_fixtures import TEST_RESOURCES diff --git a/tests/unit/auth/fixtures/role_fixtures.py b/tests/unit/auth/fixtures/role_fixtures.py index ee86aa2..c97716f 100644 --- a/tests/unit/auth/fixtures/role_fixtures.py +++ b/tests/unit/auth/fixtures/role_fixtures.py @@ -3,9 +3,9 @@ import uuid import pytest -from gn3.auth import db -from gn3.auth.authorisation.roles import Role -from gn3.auth.authorisation.privileges import Privilege +from gn_auth.auth import db +from gn_auth.auth.authorisation.roles import Role +from gn_auth.auth.authorisation.privileges import Privilege RESOURCE_READER_ROLE = Role( uuid.UUID("c3ca2507-ee24-4835-9b31-8c21e1c072d3"), "resource_reader", True, diff --git a/tests/unit/auth/fixtures/user_fixtures.py b/tests/unit/auth/fixtures/user_fixtures.py index d248f54..21708a5 100644 --- a/tests/unit/auth/fixtures/user_fixtures.py +++ b/tests/unit/auth/fixtures/user_fixtures.py @@ -3,8 +3,8 @@ import uuid import pytest -from gn3.auth import db -from gn3.auth.authentication.users import User, hash_password +from gn_auth.auth import db +from gn_auth.auth.authentication.users import User, hash_password TEST_USERS = ( User(uuid.UUID("ecb52977-3004-469e-9428-2a1856725c7f"), "group@lead.er", diff --git a/tests/unit/auth/test_credentials.py b/tests/unit/auth/test_credentials.py index f2a3d25..8011ec2 100644 --- a/tests/unit/auth/test_credentials.py +++ b/tests/unit/auth/test_credentials.py @@ -3,9 +3,9 @@ import pytest from yoyo.migrations import MigrationList from hypothesis import given, settings, strategies, HealthCheck -from gn3.auth import db -from gn3.auth.authentication import credentials_in_database -from gn3.migrations import get_migration, apply_migrations, rollback_migrations +from gn_auth.auth import db +from gn_auth.auth.authentication import credentials_in_database +from gn_auth.migrations import get_migration, apply_migrations, rollback_migrations from tests.unit.auth.conftest import migrations_up_to diff --git a/tests/unit/auth/test_groups.py b/tests/unit/auth/test_groups.py index 4824e14..8a47cf8 100644 --- a/tests/unit/auth/test_groups.py +++ b/tests/unit/auth/test_groups.py @@ -4,12 +4,12 @@ from uuid import UUID import pytest from pymonad.maybe import Nothing -from gn3.auth import db -from gn3.auth.authentication.users import User -from gn3.auth.authorisation.roles import Role -from gn3.auth.authorisation.privileges import Privilege -from gn3.auth.authorisation.errors import AuthorisationError -from gn3.auth.authorisation.groups.models import ( +from gn_auth.auth import db +from gn_auth.auth.authentication.users import User +from gn_auth.auth.authorisation.roles import Role +from gn_auth.auth.authorisation.privileges import Privilege +from gn_auth.auth.authorisation.errors import AuthorisationError +from gn_auth.auth.authorisation.groups.models import ( Group, GroupRole, user_group, create_group, create_group_role) from tests.unit.auth import conftest @@ -45,8 +45,8 @@ def test_create_group(# pylint: disable=[too-many-arguments] THEN: verify they are only able to create the group if they have the appropriate privileges """ - mocker.patch("gn3.auth.authorisation.groups.models.uuid4", uuid_fn) - mocker.patch("gn3.auth.authorisation.checks.require_oauth.acquire", + mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", uuid_fn) + mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire", conftest.get_tokeniser(user)) with db.connection(auth_testdb_path) as conn: assert create_group( @@ -61,8 +61,8 @@ def test_create_group_raises_exception_with_non_privileged_user(# pylint: disabl WHEN: the user attempts to create a group THEN: verify the system raises an exception """ - mocker.patch("gn3.auth.authorisation.groups.models.uuid4", uuid_fn) - mocker.patch("gn3.auth.authorisation.checks.require_oauth.acquire", + mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", uuid_fn) + mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire", conftest.get_tokeniser(user)) with db.connection(auth_testdb_path) as conn: with pytest.raises(AuthorisationError): @@ -88,9 +88,9 @@ def test_create_group_role(mocker, fxtr_users_in_group, user, expected): THEN: verify they are only able to create the role if they have the appropriate privileges and that the role is attached to the given group """ - mocker.patch("gn3.auth.authorisation.groups.models.uuid4", uuid_fn) - mocker.patch("gn3.auth.authorisation.roles.models.uuid4", uuid_fn) - mocker.patch("gn3.auth.authorisation.checks.require_oauth.acquire", + mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", uuid_fn) + mocker.patch("gn_auth.auth.authorisation.roles.models.uuid4", uuid_fn) + mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire", conftest.get_tokeniser(user)) conn, _group, _users = fxtr_users_in_group with db.cursor(conn) as cursor: @@ -114,9 +114,9 @@ def test_create_group_role_raises_exception_with_unauthorised_users( THEN: verify they are only able to create the role if they have the appropriate privileges and that the role is attached to the given group """ - mocker.patch("gn3.auth.authorisation.groups.models.uuid4", uuid_fn) - mocker.patch("gn3.auth.authorisation.roles.models.uuid4", uuid_fn) - mocker.patch("gn3.auth.authorisation.checks.require_oauth.acquire", + mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", uuid_fn) + mocker.patch("gn_auth.auth.authorisation.roles.models.uuid4", uuid_fn) + mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire", conftest.get_tokeniser(user)) conn, _group, _users = fxtr_users_in_group with pytest.raises(AuthorisationError): @@ -132,11 +132,11 @@ def test_create_multiple_groups(mocker, fxtr_users): THEN: The system should prevent that, and respond with an appropriate error message """ - mocker.patch("gn3.auth.authorisation.groups.models.uuid4", uuid_fn) + mocker.patch("gn_auth.auth.authorisation.groups.models.uuid4", uuid_fn) user = User( UUID("ecb52977-3004-469e-9428-2a1856725c7f"), "group@lead.er", "Group Leader") - mocker.patch("gn3.auth.authorisation.checks.require_oauth.acquire", + mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire", conftest.get_tokeniser(user)) conn, _test_users = fxtr_users # First time, successfully creates the group diff --git a/tests/unit/auth/test_migrations_add_data_to_table.py b/tests/unit/auth/test_migrations_add_data_to_table.py index 9cb5d0c..fa46cc9 100644 --- a/tests/unit/auth/test_migrations_add_data_to_table.py +++ b/tests/unit/auth/test_migrations_add_data_to_table.py @@ -1,8 +1,8 @@ """Test data insertion when migrations are run.""" import pytest -from gn3.auth import db -from gn3.migrations import get_migration, apply_migrations, rollback_migrations +from gn_auth.auth import db +from gn_auth.migrations import get_migration, apply_migrations, rollback_migrations from tests.unit.auth.conftest import ( apply_single_migration, rollback_single_migration, migrations_up_to) diff --git a/tests/unit/auth/test_migrations_add_remove_columns.py b/tests/unit/auth/test_migrations_add_remove_columns.py index ea9bf7b..a44563a 100644 --- a/tests/unit/auth/test_migrations_add_remove_columns.py +++ b/tests/unit/auth/test_migrations_add_remove_columns.py @@ -1,8 +1,8 @@ """Test migrations that alter tables adding/removing columns.""" import pytest -from gn3.auth import db -from gn3.migrations import get_migration, apply_migrations, rollback_migrations +from gn_auth.auth import db +from gn_auth.migrations import get_migration, apply_migrations, rollback_migrations from tests.unit.auth.conftest import ( apply_single_migration, rollback_single_migration, migrations_up_to) diff --git a/tests/unit/auth/test_migrations_create_tables.py b/tests/unit/auth/test_migrations_create_tables.py index 2b8140b..f56489a 100644 --- a/tests/unit/auth/test_migrations_create_tables.py +++ b/tests/unit/auth/test_migrations_create_tables.py @@ -1,8 +1,8 @@ """Test migrations that create tables""" import pytest -from gn3.auth import db -from gn3.migrations import get_migration, apply_migrations, rollback_migrations +from gn_auth.auth import db +from gn_auth.migrations import get_migration, apply_migrations, rollback_migrations from tests.unit.auth.conftest import ( apply_single_migration, rollback_single_migration, migrations_up_to) diff --git a/tests/unit/auth/test_migrations_drop_tables.py b/tests/unit/auth/test_migrations_drop_tables.py index 2362c77..4ce0d45 100644 --- a/tests/unit/auth/test_migrations_drop_tables.py +++ b/tests/unit/auth/test_migrations_drop_tables.py @@ -2,8 +2,8 @@ import pytest -from gn3.auth import db -from gn3.migrations import get_migration, apply_migrations, rollback_migrations +from gn_auth.auth import db +from gn_auth.migrations import get_migration, apply_migrations, rollback_migrations from tests.unit.auth.conftest import ( apply_single_migration, rollback_single_migration, migrations_up_to) diff --git a/tests/unit/auth/test_migrations_indexes.py b/tests/unit/auth/test_migrations_indexes.py index b1f06d9..dcec7c4 100644 --- a/tests/unit/auth/test_migrations_indexes.py +++ b/tests/unit/auth/test_migrations_indexes.py @@ -1,8 +1,8 @@ """Test that indexes are created and removed.""" import pytest -from gn3.auth import db -from gn3.migrations import get_migration, apply_migrations, rollback_migrations +from gn_auth.auth import db +from gn_auth.migrations import get_migration, apply_migrations, rollback_migrations from tests.unit.auth.conftest import ( apply_single_migration, rollback_single_migration, migrations_up_to) diff --git a/tests/unit/auth/test_migrations_init_data_in_resource_categories_table.py b/tests/unit/auth/test_migrations_init_data_in_resource_categories_table.py index dd3d4c6..8a92ae1 100644 --- a/tests/unit/auth/test_migrations_init_data_in_resource_categories_table.py +++ b/tests/unit/auth/test_migrations_init_data_in_resource_categories_table.py @@ -3,8 +3,8 @@ Test that the `resource_categories` table is initialised with the startup data. """ import pytest -from gn3.auth import db -from gn3.migrations import get_migration, apply_migrations, rollback_migrations +from gn_auth.auth import db +from gn_auth.migrations import get_migration, apply_migrations, rollback_migrations from tests.unit.auth.conftest import ( apply_single_migration, rollback_single_migration, migrations_up_to) diff --git a/tests/unit/auth/test_migrations_insert_data_into_empty_table.py b/tests/unit/auth/test_migrations_insert_data_into_empty_table.py index ebb7fa6..0cf9a1f 100644 --- a/tests/unit/auth/test_migrations_insert_data_into_empty_table.py +++ b/tests/unit/auth/test_migrations_insert_data_into_empty_table.py @@ -4,7 +4,7 @@ from contextlib import closing import pytest -from gn3.migrations import get_migration, apply_migrations, rollback_migrations +from gn_auth.migrations import get_migration, apply_migrations, rollback_migrations from tests.unit.auth.conftest import ( apply_single_migration, rollback_single_migration, migrations_up_to) diff --git a/tests/unit/auth/test_privileges.py b/tests/unit/auth/test_privileges.py index 8395293..a40e875 100644 --- a/tests/unit/auth/test_privileges.py +++ b/tests/unit/auth/test_privileges.py @@ -1,8 +1,8 @@ """Test the privileges module""" import pytest -from gn3.auth import db -from gn3.auth.authorisation.privileges import Privilege, user_privileges +from gn_auth.auth import db +from gn_auth.auth.authorisation.privileges import Privilege, user_privileges from tests.unit.auth import conftest diff --git a/tests/unit/auth/test_resources.py b/tests/unit/auth/test_resources.py index 2884add..12b8d95 100644 --- a/tests/unit/auth/test_resources.py +++ b/tests/unit/auth/test_resources.py @@ -3,11 +3,11 @@ import uuid import pytest -from gn3.auth import db +from gn_auth.auth import db -from gn3.auth.authorisation.groups import Group -from gn3.auth.authorisation.errors import AuthorisationError -from gn3.auth.authorisation.resources.models import ( +from gn_auth.auth.authorisation.groups import Group +from gn_auth.auth.authorisation.errors import AuthorisationError +from gn_auth.auth.authorisation.resources.models import ( Resource, user_resources, create_resource, ResourceCategory, public_resources) @@ -33,8 +33,8 @@ uuid_fn = lambda : uuid.UUID("d32611e3-07fc-4564-b56c-786c6db6de2b") "test_resource", resource_category, False),)))) def test_create_resource(mocker, fxtr_users_in_group, user, expected): """Test that resource creation works as expected.""" - mocker.patch("gn3.auth.authorisation.resources.models.uuid4", uuid_fn) - mocker.patch("gn3.auth.authorisation.checks.require_oauth.acquire", + mocker.patch("gn_auth.auth.authorisation.resources.models.uuid4", uuid_fn) + mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire", conftest.get_tokeniser(user)) conn, _group, _users = fxtr_users_in_group resource = create_resource( @@ -63,8 +63,8 @@ def test_create_resource(mocker, fxtr_users_in_group, user, expected): def test_create_resource_raises_for_unauthorised_users( mocker, fxtr_users_in_group, user, expected): """Test that resource creation works as expected.""" - mocker.patch("gn3.auth.authorisation.resources.models.uuid4", uuid_fn) - mocker.patch("gn3.auth.authorisation.checks.require_oauth.acquire", + mocker.patch("gn_auth.auth.authorisation.resources.models.uuid4", uuid_fn) + mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire", conftest.get_tokeniser(user)) conn, _group, _users = fxtr_users_in_group with pytest.raises(AuthorisationError): diff --git a/tests/unit/auth/test_roles.py b/tests/unit/auth/test_roles.py index 02fd9f7..31d5e8e 100644 --- a/tests/unit/auth/test_roles.py +++ b/tests/unit/auth/test_roles.py @@ -3,10 +3,10 @@ import uuid import pytest -from gn3.auth import db -from gn3.auth.authorisation.privileges import Privilege -from gn3.auth.authorisation.errors import AuthorisationError -from gn3.auth.authorisation.roles.models import Role, user_roles, create_role +from gn_auth.auth import db +from gn_auth.auth.authorisation.privileges import Privilege +from gn_auth.auth.authorisation.errors import AuthorisationError +from gn_auth.auth.authorisation.roles.models import Role, user_roles, create_role from tests.unit.auth import conftest from tests.unit.auth.fixtures import TEST_USERS @@ -36,8 +36,8 @@ def test_create_role(# pylint: disable=[too-many-arguments] THEN: verify they are only able to create the role if they have the appropriate privileges """ - mocker.patch("gn3.auth.authorisation.roles.models.uuid4", uuid_fn) - mocker.patch("gn3.auth.authorisation.checks.require_oauth.acquire", + mocker.patch("gn_auth.auth.authorisation.roles.models.uuid4", uuid_fn) + mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire", conftest.get_tokeniser(user)) with db.connection(auth_testdb_path) as conn, db.cursor(conn) as cursor: the_role = create_role(cursor, "a_test_role", PRIVILEGES) @@ -55,8 +55,8 @@ def test_create_role_raises_exception_for_unauthorised_users(# pylint: disable=[ THEN: verify they are only able to create the role if they have the appropriate privileges """ - mocker.patch("gn3.auth.authorisation.roles.models.uuid4", uuid_fn) - mocker.patch("gn3.auth.authorisation.checks.require_oauth.acquire", + mocker.patch("gn_auth.auth.authorisation.roles.models.uuid4", uuid_fn) + mocker.patch("gn_auth.auth.authorisation.checks.require_oauth.acquire", conftest.get_tokeniser(user)) with db.connection(auth_testdb_path) as conn, db.cursor(conn) as cursor: with pytest.raises(AuthorisationError): diff --git a/tests/unit/auth/test_token.py b/tests/unit/auth/test_token.py index 76316ea..4a864fe 100644 --- a/tests/unit/auth/test_token.py +++ b/tests/unit/auth/test_token.py @@ -2,7 +2,7 @@ import pytest -from gn3.auth import db +from gn_auth.auth import db SUCCESS_RESULT = { "status_code": 200, diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 8005c8e..4180528 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -5,7 +5,7 @@ from tempfile import TemporaryDirectory import pytest -from gn3.app import create_app +from gn_auth.app import create_app @pytest.fixture(scope="session") def fxtr_app(): |