Skip to content

Commit

Permalink
Merge branch 'issue/django-setup-configuration-tokens' into issue/dja…
Browse files Browse the repository at this point in the history
…ngo-setup-configuration-mozilla-django-oidc-db
  • Loading branch information
danielmursa-dev committed Dec 13, 2024
2 parents 1b9388d + a6dd40c commit d03910a
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 36 deletions.
11 changes: 11 additions & 0 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 1 addition & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -48,6 +46,4 @@ services:

volumes:
db:
log:
media:
private_media:
log:
4 changes: 2 additions & 2 deletions docker/setup_configuration/data.yaml
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
4 changes: 1 addition & 3 deletions src/objecttypes/setup_configuration/steps/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)

Expand Down
4 changes: 2 additions & 2 deletions src/objecttypes/setup_configuration/steps/token_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
token_tokenauth_config_enable: true
token_tokenauth:
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
32 changes: 14 additions & 18 deletions src/objecttypes/setup_configuration/tests/test_token_auth_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "[email protected]")

def test_valid_update_existing_tokens(self):
TokenAuthFactory(
identifier="token-1",
Expand Down Expand Up @@ -184,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",
Expand All @@ -209,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",
Expand All @@ -234,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",
Expand All @@ -259,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",
Expand All @@ -281,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",
Expand Down Expand Up @@ -315,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",
Expand All @@ -340,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",
Expand Down

0 comments on commit d03910a

Please sign in to comment.