From 579f6ef20fd477417fdc35c1f1bab73ab8875654 Mon Sep 17 00:00:00 2001 From: Daniel Mursa Date: Wed, 11 Dec 2024 14:58:32 +0100 Subject: [PATCH 1/8] [maykinmedia/objects-api#481] Update INSTALL.rst --- INSTALL.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/INSTALL.rst b/INSTALL.rst index abf93982..dcc927a3 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -274,3 +274,14 @@ There are no specific commands for the project. See ``python src/manage.py --help``. .. _Django framework commands: https://docs.djangoproject.com/en/dev/ref/django-admin/#available-commands + +Configuration (CLI) +======== + +After deploying Objecttypes API, they need to be configured to be fully functional. The command line tool setup_configuration assist with this configuration: + +You can get the full command documentation with: + +.. code-block:: bash + + python src/manage.py setup_configuration --help \ No newline at end of file From 715684f6cbc602ecfe276f013f72f8b7081bcc50 Mon Sep 17 00:00:00 2001 From: Daniel Mursa Date: Thu, 12 Dec 2024 10:21:23 +0100 Subject: [PATCH 2/8] [maykinmedia/objects-api#481] Fix tests --- .../setup_configuration/tests/test_token_auth_config.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/objecttypes/setup_configuration/tests/test_token_auth_config.py b/src/objecttypes/setup_configuration/tests/test_token_auth_config.py index 15ebd6db..50e4b5ca 100644 --- a/src/objecttypes/setup_configuration/tests/test_token_auth_config.py +++ b/src/objecttypes/setup_configuration/tests/test_token_auth_config.py @@ -68,10 +68,6 @@ def test_valid_setup_complete(self): self.assertEqual(token.application, "Application 2") self.assertEqual(token.administration, "Administration 2") - self.assertNotEqual(token.token, "1cad42916dfa439af8c69000bf7b6af6a66782af") - self.assertNotEqual(token.contact_person, "Person 3") - self.assertNotEqual(token.email, "person-3@example.com") - def test_valid_update_existing_tokens(self): TokenAuthFactory( identifier="token-1", From 58f90b04cb679cd9f67bf56fa8cf0c845a859b2d Mon Sep 17 00:00:00 2001 From: Daniel Mursa Date: Thu, 12 Dec 2024 11:33:36 +0100 Subject: [PATCH 3/8] [maykinmedia/objects-api#481] Remove unnecessary volumes in docker --- docker-compose.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 95486a78..1e9d68ca 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,8 +23,6 @@ services: DISABLE_2FA: yes SUBPATH: ${SUBPATH:-/} volumes: - - media:/app/media - - private_media:/app/private_media - log:/app/log ports: - 8000:8000 @@ -48,6 +46,4 @@ services: volumes: db: - log: - media: - private_media: \ No newline at end of file + log: \ No newline at end of file From b9c2fc488e045fec0a45bc48372d097f68bbecaa Mon Sep 17 00:00:00 2001 From: Daniel Mursa Date: Thu, 12 Dec 2024 11:59:05 +0100 Subject: [PATCH 4/8] [maykinmedia/objects-api#481] Change namespace --- docker/setup_configuration/data.yaml | 4 +-- .../setup_configuration/steps/token_auth.py | 4 +-- .../tests/files/token_auth/invalid_setup.yaml | 2 +- .../token_auth/valid_setup_complete.yaml | 4 +-- .../files/token_auth/valid_setup_default.yaml | 4 +-- .../tests/test_token_auth_config.py | 28 +++++++++---------- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docker/setup_configuration/data.yaml b/docker/setup_configuration/data.yaml index 58c9981a..2b89efd4 100644 --- a/docker/setup_configuration/data.yaml +++ b/docker/setup_configuration/data.yaml @@ -1,5 +1,5 @@ -token_tokenauth_config_enable: true -token_tokenauth: +tokenauth_config_enable: true +tokenauth: items: - identifier: token-1 token: 18b2b74ef994314b84021d47b9422e82b685d82f diff --git a/src/objecttypes/setup_configuration/steps/token_auth.py b/src/objecttypes/setup_configuration/steps/token_auth.py index 7cdf620b..ce6a565e 100644 --- a/src/objecttypes/setup_configuration/steps/token_auth.py +++ b/src/objecttypes/setup_configuration/steps/token_auth.py @@ -21,8 +21,8 @@ class TokenAuthConfigurationStep( Configure tokens for other applications to access Objecttypes 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 ObjectTypes" config_model = TokenAuthGroupConfigurationModel diff --git a/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml b/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml index 2749f17a..8293044a 100644 --- a/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml +++ b/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml @@ -1,3 +1,3 @@ -token_tokenauth_config_enable: true +tokenauth_config_enable: true token_tokenauth: items: \ No newline at end of file diff --git a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml index aca6cca3..fc7d6ead 100644 --- a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml +++ b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml @@ -1,5 +1,5 @@ -token_tokenauth_config_enable: true -token_tokenauth: +tokenauth_config_enable: true +tokenauth: items: - identifier: token-1 token: 18b2b74ef994314b84021d47b9422e82b685d82f diff --git a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml index b9af9475..40d4c9ad 100644 --- a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml +++ b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml @@ -1,5 +1,5 @@ -token_tokenauth_config_enable: true -token_tokenauth: +tokenauth_config_enable: true +tokenauth: items: - identifier: token-1 token: 18b2b74ef994314b84021d47b9422e82b685d82f diff --git a/src/objecttypes/setup_configuration/tests/test_token_auth_config.py b/src/objecttypes/setup_configuration/tests/test_token_auth_config.py index 50e4b5ca..2b494f9d 100644 --- a/src/objecttypes/setup_configuration/tests/test_token_auth_config.py +++ b/src/objecttypes/setup_configuration/tests/test_token_auth_config.py @@ -180,8 +180,8 @@ def test_invalid_setup(self): def test_invalid_setup_email(self): object_source = { - "token_tokenauth_config_enable": True, - "token_tokenauth": { + "tokenauth_config_enable": True, + "tokenauth": { "items": [ { "identifier": "token-1", @@ -205,8 +205,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", @@ -230,8 +230,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", @@ -255,8 +255,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", @@ -277,8 +277,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", @@ -311,8 +311,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", @@ -336,8 +336,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", From 975e0abf9d3ba5bc332a86f7e17d80a8aa8ed448 Mon Sep 17 00:00:00 2001 From: Daniel Mursa Date: Thu, 12 Dec 2024 12:06:54 +0100 Subject: [PATCH 5/8] [maykinmedia/objects-api#481] Change namespace in file --- .../tests/files/token_auth/invalid_setup.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml b/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml index 8293044a..c4481cdc 100644 --- a/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml +++ b/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml @@ -1,3 +1,3 @@ tokenauth_config_enable: true -token_tokenauth: +tokenauth: items: \ No newline at end of file From a2c9c59439a8b3ed45c95f6009dc61cb568aea64 Mon Sep 17 00:00:00 2001 From: Daniel Mursa Date: Thu, 12 Dec 2024 12:20:52 +0100 Subject: [PATCH 6/8] [maykinmedia/objects-api#481] Change namespace zgw_tokens_tokenauth --- docker/setup_configuration/data.yaml | 4 +-- .../setup_configuration/steps/token_auth.py | 4 +-- .../tests/files/token_auth/invalid_setup.yaml | 4 +-- .../token_auth/valid_setup_complete.yaml | 4 +-- .../files/token_auth/valid_setup_default.yaml | 4 +-- .../tests/test_token_auth_config.py | 28 +++++++++---------- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docker/setup_configuration/data.yaml b/docker/setup_configuration/data.yaml index 2b89efd4..2fe064f0 100644 --- a/docker/setup_configuration/data.yaml +++ b/docker/setup_configuration/data.yaml @@ -1,5 +1,5 @@ -tokenauth_config_enable: true -tokenauth: +zgw_tokens_tokenauth_config_enable: true +zgw_tokens_tokenauth: items: - identifier: token-1 token: 18b2b74ef994314b84021d47b9422e82b685d82f diff --git a/src/objecttypes/setup_configuration/steps/token_auth.py b/src/objecttypes/setup_configuration/steps/token_auth.py index ce6a565e..859ee5dc 100644 --- a/src/objecttypes/setup_configuration/steps/token_auth.py +++ b/src/objecttypes/setup_configuration/steps/token_auth.py @@ -21,8 +21,8 @@ class TokenAuthConfigurationStep( Configure tokens for other applications to access Objecttypes API """ - namespace = "tokenauth" - enable_setting = "tokenauth_config_enable" + namespace = "zgw_tokens_tokenauth" + enable_setting = "zgw_tokens_tokenauth_config_enable" verbose_name = "Configuration to set up authentication tokens for ObjectTypes" config_model = TokenAuthGroupConfigurationModel diff --git a/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml b/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml index c4481cdc..eaf9846d 100644 --- a/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml +++ b/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml @@ -1,3 +1,3 @@ -tokenauth_config_enable: true -tokenauth: +zgw_tokens_tokenauth_config_enable: true +zgw_tokens_tokenauth: items: \ No newline at end of file diff --git a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml index fc7d6ead..8ce35f6a 100644 --- a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml +++ b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml @@ -1,5 +1,5 @@ -tokenauth_config_enable: true -tokenauth: +zgw_tokens_tokenauth_config_enable: true +zgw_tokens_tokenauth: items: - identifier: token-1 token: 18b2b74ef994314b84021d47b9422e82b685d82f diff --git a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml index 40d4c9ad..f73977d1 100644 --- a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml +++ b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml @@ -1,5 +1,5 @@ -tokenauth_config_enable: true -tokenauth: +zgw_tokens_tokenauth_config_enable: true +zgw_tokens_tokenauth: items: - identifier: token-1 token: 18b2b74ef994314b84021d47b9422e82b685d82f diff --git a/src/objecttypes/setup_configuration/tests/test_token_auth_config.py b/src/objecttypes/setup_configuration/tests/test_token_auth_config.py index 2b494f9d..46b39d67 100644 --- a/src/objecttypes/setup_configuration/tests/test_token_auth_config.py +++ b/src/objecttypes/setup_configuration/tests/test_token_auth_config.py @@ -180,8 +180,8 @@ def test_invalid_setup(self): def test_invalid_setup_email(self): object_source = { - "tokenauth_config_enable": True, - "tokenauth": { + "zgw_tokens_tokenauth_config_enable": True, + "zgw_tokens_tokenauth": { "items": [ { "identifier": "token-1", @@ -205,8 +205,8 @@ def test_invalid_setup_email(self): def test_invalid_setup_token(self): object_source = { - "tokenauth_config_enable": True, - "tokenauth": { + "zgw_tokens_tokenauth_config_enable": True, + "zgw_tokens_tokenauth": { "items": [ { "identifier": "token-1", @@ -230,8 +230,8 @@ def test_invalid_setup_token(self): def test_invalid_empty_token(self): object_source = { - "tokenauth_config_enable": True, - "tokenauth": { + "zgw_tokens_tokenauth_config_enable": True, + "zgw_tokens_tokenauth": { "items": [ { "identifier": "token-1", @@ -255,8 +255,8 @@ def test_invalid_empty_token(self): def test_invalid_setup_token_missing(self): object_source = { - "tokenauth_config_enable": True, - "tokenauth": { + "zgw_tokens_tokenauth_config_enable": True, + "zgw_tokens_tokenauth": { "items": [ { "identifier": "token-1", @@ -277,8 +277,8 @@ def test_invalid_setup_token_missing(self): def test_invalid_setup_token_unique(self): object_source = { - "tokenauth_config_enable": True, - "tokenauth": { + "zgw_tokens_tokenauth_config_enable": True, + "zgw_tokens_tokenauth": { "items": [ { "identifier": "token-1", @@ -311,8 +311,8 @@ def test_invalid_setup_token_unique(self): def test_invalid_setup_contact_person(self): object_source = { - "tokenauth_config_enable": True, - "tokenauth": { + "zgw_tokens_tokenauth_config_enable": True, + "zgw_tokens_tokenauth": { "items": [ { "identifier": "token-1", @@ -336,8 +336,8 @@ def test_invalid_setup_contact_person(self): def test_invalid_setup_identifier(self): object_source = { - "tokenauth_config_enable": True, - "tokenauth": { + "zgw_tokens_tokenauth_config_enable": True, + "zgw_tokens_tokenauth": { "items": [ { "identifier": "invalid identifier", From a757ed44ce2e4128397116cb9d2e131272bc8892 Mon Sep 17 00:00:00 2001 From: Daniel Mursa Date: Thu, 12 Dec 2024 16:32:23 +0100 Subject: [PATCH 7/8] Revert "[maykinmedia/objects-api#481] Change namespace zgw_tokens_tokenauth" This reverts commit a2c9c59439a8b3ed45c95f6009dc61cb568aea64. --- docker/setup_configuration/data.yaml | 4 +-- .../setup_configuration/steps/token_auth.py | 4 +-- .../tests/files/token_auth/invalid_setup.yaml | 4 +-- .../token_auth/valid_setup_complete.yaml | 4 +-- .../files/token_auth/valid_setup_default.yaml | 4 +-- .../tests/test_token_auth_config.py | 28 +++++++++---------- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docker/setup_configuration/data.yaml b/docker/setup_configuration/data.yaml index 2fe064f0..2b89efd4 100644 --- a/docker/setup_configuration/data.yaml +++ b/docker/setup_configuration/data.yaml @@ -1,5 +1,5 @@ -zgw_tokens_tokenauth_config_enable: true -zgw_tokens_tokenauth: +tokenauth_config_enable: true +tokenauth: items: - identifier: token-1 token: 18b2b74ef994314b84021d47b9422e82b685d82f diff --git a/src/objecttypes/setup_configuration/steps/token_auth.py b/src/objecttypes/setup_configuration/steps/token_auth.py index 859ee5dc..ce6a565e 100644 --- a/src/objecttypes/setup_configuration/steps/token_auth.py +++ b/src/objecttypes/setup_configuration/steps/token_auth.py @@ -21,8 +21,8 @@ class TokenAuthConfigurationStep( Configure tokens for other applications to access Objecttypes API """ - namespace = "zgw_tokens_tokenauth" - enable_setting = "zgw_tokens_tokenauth_config_enable" + namespace = "tokenauth" + enable_setting = "tokenauth_config_enable" verbose_name = "Configuration to set up authentication tokens for ObjectTypes" config_model = TokenAuthGroupConfigurationModel diff --git a/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml b/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml index eaf9846d..c4481cdc 100644 --- a/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml +++ b/src/objecttypes/setup_configuration/tests/files/token_auth/invalid_setup.yaml @@ -1,3 +1,3 @@ -zgw_tokens_tokenauth_config_enable: true -zgw_tokens_tokenauth: +tokenauth_config_enable: true +tokenauth: items: \ No newline at end of file diff --git a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml index 8ce35f6a..fc7d6ead 100644 --- a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml +++ b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_complete.yaml @@ -1,5 +1,5 @@ -zgw_tokens_tokenauth_config_enable: true -zgw_tokens_tokenauth: +tokenauth_config_enable: true +tokenauth: items: - identifier: token-1 token: 18b2b74ef994314b84021d47b9422e82b685d82f diff --git a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml index f73977d1..40d4c9ad 100644 --- a/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml +++ b/src/objecttypes/setup_configuration/tests/files/token_auth/valid_setup_default.yaml @@ -1,5 +1,5 @@ -zgw_tokens_tokenauth_config_enable: true -zgw_tokens_tokenauth: +tokenauth_config_enable: true +tokenauth: items: - identifier: token-1 token: 18b2b74ef994314b84021d47b9422e82b685d82f diff --git a/src/objecttypes/setup_configuration/tests/test_token_auth_config.py b/src/objecttypes/setup_configuration/tests/test_token_auth_config.py index 46b39d67..2b494f9d 100644 --- a/src/objecttypes/setup_configuration/tests/test_token_auth_config.py +++ b/src/objecttypes/setup_configuration/tests/test_token_auth_config.py @@ -180,8 +180,8 @@ def test_invalid_setup(self): def test_invalid_setup_email(self): object_source = { - "zgw_tokens_tokenauth_config_enable": True, - "zgw_tokens_tokenauth": { + "tokenauth_config_enable": True, + "tokenauth": { "items": [ { "identifier": "token-1", @@ -205,8 +205,8 @@ def test_invalid_setup_email(self): def test_invalid_setup_token(self): object_source = { - "zgw_tokens_tokenauth_config_enable": True, - "zgw_tokens_tokenauth": { + "tokenauth_config_enable": True, + "tokenauth": { "items": [ { "identifier": "token-1", @@ -230,8 +230,8 @@ def test_invalid_setup_token(self): def test_invalid_empty_token(self): object_source = { - "zgw_tokens_tokenauth_config_enable": True, - "zgw_tokens_tokenauth": { + "tokenauth_config_enable": True, + "tokenauth": { "items": [ { "identifier": "token-1", @@ -255,8 +255,8 @@ def test_invalid_empty_token(self): def test_invalid_setup_token_missing(self): object_source = { - "zgw_tokens_tokenauth_config_enable": True, - "zgw_tokens_tokenauth": { + "tokenauth_config_enable": True, + "tokenauth": { "items": [ { "identifier": "token-1", @@ -277,8 +277,8 @@ def test_invalid_setup_token_missing(self): def test_invalid_setup_token_unique(self): object_source = { - "zgw_tokens_tokenauth_config_enable": True, - "zgw_tokens_tokenauth": { + "tokenauth_config_enable": True, + "tokenauth": { "items": [ { "identifier": "token-1", @@ -311,8 +311,8 @@ def test_invalid_setup_token_unique(self): def test_invalid_setup_contact_person(self): object_source = { - "zgw_tokens_tokenauth_config_enable": True, - "zgw_tokens_tokenauth": { + "tokenauth_config_enable": True, + "tokenauth": { "items": [ { "identifier": "token-1", @@ -336,8 +336,8 @@ def test_invalid_setup_contact_person(self): def test_invalid_setup_identifier(self): object_source = { - "zgw_tokens_tokenauth_config_enable": True, - "zgw_tokens_tokenauth": { + "tokenauth_config_enable": True, + "tokenauth": { "items": [ { "identifier": "invalid identifier", From a6dd40cc1d4b5de63c5f34531dfb59f44b5b5481 Mon Sep 17 00:00:00 2001 From: Daniel Mursa Date: Thu, 12 Dec 2024 16:39:33 +0100 Subject: [PATCH 8/8] [maykinmedia/objects-api#481] Fix unnecessary "loop" for one element --- src/objecttypes/setup_configuration/steps/sites.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/objecttypes/setup_configuration/steps/sites.py b/src/objecttypes/setup_configuration/steps/sites.py index 51854540..b5993d1e 100644 --- a/src/objecttypes/setup_configuration/steps/sites.py +++ b/src/objecttypes/setup_configuration/steps/sites.py @@ -47,9 +47,7 @@ def execute(self, model: SitesConfigurationModel) -> None: Site.objects.update_or_create( domain=item.domain, defaults={ - key: value - for key, value in model_kwargs.items() - if key != "domain" + "name": item.name, }, )