Skip to content

Commit

Permalink
[#485] Update namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmursa-dev committed Dec 16, 2024
1 parent 162c16f commit b83409a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 32 deletions.
4 changes: 2 additions & 2 deletions docker/setup_configuration/data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ objecttypes:
service_identifier: objecttypes-api


token_tokenauth_config_enable: true
token_tokenauth:
tokenauth_config_enable: true
tokenauth:
items:
- identifier: token-1
token: 18b2b74ef994314b84021d47b9422e82b685d82f
Expand Down
7 changes: 5 additions & 2 deletions src/objects/setup_configuration/steps/token_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ class TokenAuthConfigurationStep(
Configure tokens for other applications to access Objects API
"""

namespace = "token_tokenauth"
enable_setting = "token_tokenauth_config_enable"
namespace = "tokenauth"
enable_setting = "tokenauth_config_enable"

verbose_name = "Configuration to set up authentication tokens for objects"
config_model = TokenAuthGroupConfigurationModel

def execute(self, model: TokenAuthGroupConfigurationModel) -> None:
if len(model.items) == 0:
logger.warning("No tokens provided for configuration")

for item in model.items:
logger.info(f"Configuring {item.identifier}")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tokenauth_config_enable: true
tokenauth:
items:
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
token_tokenauth_config_enable: true
token_tokenauth:
tokenauth_config_enable: true
tokenauth:
items:
- identifier: token-1
token: 18b2b74ef994314b84021d47b9422e82b685d82f
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
token_tokenauth_config_enable: true
token_tokenauth:
tokenauth_config_enable: true
tokenauth:
items:
- identifier: token-1
token: 18b2b74ef994314b84021d47b9422e82b685d82f
Expand Down

This file was deleted.

42 changes: 21 additions & 21 deletions src/objects/setup_configuration/tests/test_token_auth_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
from objects.token.models import TokenAuth
from objects.token.tests.factories import TokenAuthFactory

DIR_FILES = (Path(__file__).parent / "files").resolve()
DIR_FILES = (Path(__file__).parent / "files/auth_token").resolve()


class TokenAuthConfigurationStepTests(TestCase):
def test_valid_setup_default(self):
execute_single_step(
TokenAuthConfigurationStep,
yaml_source=str(DIR_FILES / "token_auth_valid_setup_default.yaml"),
yaml_source=str(DIR_FILES / "valid_setup_default.yaml"),
)

tokens = TokenAuth.objects.all()
Expand All @@ -46,7 +46,7 @@ def test_valid_setup_default(self):
def test_valid_setup_complete(self):
execute_single_step(
TokenAuthConfigurationStep,
yaml_source=str(DIR_FILES / "token_auth_valid_setup_complete.yaml"),
yaml_source=str(DIR_FILES / "valid_setup_complete.yaml"),
)

tokens = TokenAuth.objects.all()
Expand Down Expand Up @@ -91,7 +91,7 @@ def test_valid_update_existing_tokens(self):
)
execute_single_step(
TokenAuthConfigurationStep,
yaml_source=str(DIR_FILES / "token_auth_valid_setup_complete.yaml"),
yaml_source=str(DIR_FILES / "valid_setup_complete.yaml"),
)

tokens = TokenAuth.objects.all()
Expand Down Expand Up @@ -124,7 +124,7 @@ def test_valid_update_existing_tokens(self):
def test_valid_idempotent_step(self):
execute_single_step(
TokenAuthConfigurationStep,
yaml_source=str(DIR_FILES / "token_auth_valid_setup_complete.yaml"),
yaml_source=str(DIR_FILES / "valid_setup_complete.yaml"),
)

tokens = TokenAuth.objects.all()
Expand Down Expand Up @@ -152,7 +152,7 @@ def test_valid_idempotent_step(self):

execute_single_step(
TokenAuthConfigurationStep,
yaml_source=str(DIR_FILES / "token_auth_valid_setup_complete.yaml"),
yaml_source=str(DIR_FILES / "valid_setup_complete.yaml"),
)

tokens = TokenAuth.objects.all()
Expand Down Expand Up @@ -180,16 +180,16 @@ def test_invalid_setup(self):
with self.assertRaises(PrerequisiteFailed) as command_error:
execute_single_step(
TokenAuthConfigurationStep,
yaml_source=str(DIR_FILES / "token_auth_invalid_setup.yaml"),
yaml_source=str(DIR_FILES / "invalid_setup.yaml"),
)

self.assertTrue("Input should be a valid list" in str(command_error.exception))
self.assertEqual(TokenAuth.objects.count(), 0)

def test_invalid_setup_email(self):
object_source = {
"token_tokenauth_config_enable": True,
"token_tokenauth": {
"tokenauth_config_enable": True,
"tokenauth": {
"items": [
{
"identifier": "token-1",
Expand All @@ -213,8 +213,8 @@ def test_invalid_setup_email(self):

def test_invalid_setup_token(self):
object_source = {
"token_tokenauth_config_enable": True,
"token_tokenauth": {
"tokenauth_config_enable": True,
"tokenauth": {
"items": [
{
"identifier": "token-1",
Expand All @@ -238,8 +238,8 @@ def test_invalid_setup_token(self):

def test_invalid_empty_token(self):
object_source = {
"token_tokenauth_config_enable": True,
"token_tokenauth": {
"tokenauth_config_enable": True,
"tokenauth": {
"items": [
{
"identifier": "token-1",
Expand All @@ -263,8 +263,8 @@ def test_invalid_empty_token(self):

def test_invalid_setup_token_missing(self):
object_source = {
"token_tokenauth_config_enable": True,
"token_tokenauth": {
"tokenauth_config_enable": True,
"tokenauth": {
"items": [
{
"identifier": "token-1",
Expand All @@ -285,8 +285,8 @@ def test_invalid_setup_token_missing(self):

def test_invalid_setup_token_unique(self):
object_source = {
"token_tokenauth_config_enable": True,
"token_tokenauth": {
"tokenauth_config_enable": True,
"tokenauth": {
"items": [
{
"identifier": "token-1",
Expand Down Expand Up @@ -319,8 +319,8 @@ def test_invalid_setup_token_unique(self):

def test_invalid_setup_contact_person(self):
object_source = {
"token_tokenauth_config_enable": True,
"token_tokenauth": {
"tokenauth_config_enable": True,
"tokenauth": {
"items": [
{
"identifier": "token-1",
Expand All @@ -344,8 +344,8 @@ def test_invalid_setup_contact_person(self):

def test_invalid_setup_identifier(self):
object_source = {
"token_tokenauth_config_enable": True,
"token_tokenauth": {
"tokenauth_config_enable": True,
"tokenauth": {
"items": [
{
"identifier": "invalid identifier",
Expand Down

0 comments on commit b83409a

Please sign in to comment.