aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/auth/conftest.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-08-04 10:10:28 +0300
committerFrederick Muriuki Muriithi2023-08-04 10:20:09 +0300
commit8b7c598407a5fea9a3d78473e72df87606998cd4 (patch)
tree8526433a17eca6b511feb082a0574f9b15cb9469 /tests/unit/auth/conftest.py
parentf7fcbbcc014686ac597b783a8dcb38b43024b9d6 (diff)
downloadgn-auth-8b7c598407a5fea9a3d78473e72df87606998cd4.tar.gz
Copy over files from GN3 repository.
Diffstat (limited to 'tests/unit/auth/conftest.py')
-rw-r--r--tests/unit/auth/conftest.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit/auth/conftest.py b/tests/unit/auth/conftest.py
new file mode 100644
index 0000000..a7c64a8
--- /dev/null
+++ b/tests/unit/auth/conftest.py
@@ -0,0 +1,24 @@
+"""Module for fixtures and test utilities"""
+import uuid
+import datetime
+from contextlib import contextmanager
+
+from gn3.auth.authentication.oauth2.models.oauth2token import OAuth2Token
+
+from .fixtures import * # pylint: disable=[wildcard-import,unused-wildcard-import]
+
+def get_tokeniser(user):
+ """Get contextmanager for mocking token acquisition."""
+ @contextmanager
+ def __token__(*args, **kwargs):# pylint: disable=[unused-argument]
+ yield {
+ usr.user_id: OAuth2Token(
+ token_id=uuid.UUID("d32611e3-07fc-4564-b56c-786c6db6de2b"),
+ client=None, token_type="Bearer", access_token="123456ABCDE",
+ refresh_token=None, revoked=False, expires_in=864000,
+ user=usr, issued_at=int(datetime.datetime.now().timestamp()),
+ scope="profile group role resource register-client")
+ for usr in TEST_USERS
+ }[user.user_id]
+
+ return __token__