From 06b9089e4db442767573bf1eead8b5c050437071 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 14 Nov 2022 14:45:11 +0300 Subject: 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` --- gn3/auth/authorisation/__init__.py | 11 +++++++++++ gn3/auth/authorisation/groups.py | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 gn3/auth/authorisation/groups.py (limited to 'gn3') 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!") -- cgit v1.2.3