aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-11-14 14:45:11 +0300
committerFrederick Muriuki Muriithi2022-11-14 14:45:11 +0300
commit06b9089e4db442767573bf1eead8b5c050437071 (patch)
tree8ba0804bf20a105015dc64bdfe631b8ddb0043ce /gn3/auth
parent673d68366008c582a74820ae66ade57998148cfb (diff)
downloadgenenetwork3-06b9089e4db442767573bf1eead8b5c050437071.tar.gz
auth: Add test for `create_group`
* gn3/auth/authorisation/__init__.py: Add `authorised_p` decorator to be used for all function requiring authorisation. * gn3/auth/authorisation/groups.py: Add `create_group` function stub * tests/unit/auth/conftest.py: Add fixture for test users * tests/unit/auth/test_groups.py: Add tests for `create_group`
Diffstat (limited to 'gn3/auth')
-rw-r--r--gn3/auth/authorisation/__init__.py11
-rw-r--r--gn3/auth/authorisation/groups.py7
2 files changed, 18 insertions, 0 deletions
diff --git a/gn3/auth/authorisation/__init__.py b/gn3/auth/authorisation/__init__.py
index cc370e2..a6991d2 100644
--- a/gn3/auth/authorisation/__init__.py
+++ b/gn3/auth/authorisation/__init__.py
@@ -1 +1,12 @@
"""The authorisation module."""
+from typing import Union
+
+def authorised_p(success_message: Union[str, bool] = False, error_message: Union[str, bool] = False):
+ """Authorisation decorator."""
+ def __authoriser__(*args, **kwargs):
+ return {
+ "status": "error",
+ "message": error_message or "unauthorised"
+ }
+
+ return __authoriser__
diff --git a/gn3/auth/authorisation/groups.py b/gn3/auth/authorisation/groups.py
new file mode 100644
index 0000000..8c8a87f
--- /dev/null
+++ b/gn3/auth/authorisation/groups.py
@@ -0,0 +1,7 @@
+"""Handle the management of resource/user groups."""
+
+from . import authorised_p
+
+@authorised_p
+def create_group(group_name):
+ raise Exception("NOT IMPLEMENTED!")