Skip to content

Commit

Permalink
[#2563] Fix disable setup configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
pi-sigma committed Aug 12, 2024
1 parent fa1cea1 commit 57250a6
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/open_inwoner/configurations/bootstrap/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def is_configured(self) -> bool:
return OpenIDConnectDigiDConfig.get_solo().enabled

def configure(self):
if not getattr(settings, "DIGID_OIDC_CONFIG_ENABLE", None):
return

config = OpenIDConnectDigiDConfig.get_solo()

# Use the model defaults
Expand Down Expand Up @@ -159,6 +162,9 @@ def is_configured(self) -> bool:
return OpenIDConnectEHerkenningConfig.get_solo().enabled

def configure(self):
if not getattr(settings, "EHERKENNING_OIDC_CONFIG_ENABLE", None):
return

config = OpenIDConnectEHerkenningConfig.get_solo()

# Use the model defaults
Expand Down Expand Up @@ -250,6 +256,9 @@ def is_configured(self) -> bool:
return OpenIDConnectConfig.get_solo().enabled

def configure(self):
if not getattr(settings, "ADMIN_OIDC_CONFIG_ENABLE", None):
return

config = OpenIDConnectConfig.get_solo()

# Use the model defaults
Expand Down Expand Up @@ -353,6 +362,9 @@ def is_configured(self) -> bool:
)

def configure(self):
if not getattr(settings, "DIGID_SAML_CONFIG_ENABLE", None):
return

config = DigidConfiguration.get_solo()

# Use the model defaults
Expand Down Expand Up @@ -494,6 +506,9 @@ def is_configured(self) -> bool:
)

def configure(self):
if not getattr(settings, "EHERKENNING_SAML_CONFIG_ENABLE", None):
return

config = EherkenningConfiguration.get_solo()

# Use the model defaults
Expand Down
12 changes: 10 additions & 2 deletions src/open_inwoner/configurations/bootstrap/cms.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ def is_configured(self):
Pattern for enable setting: CMS_CONFIG_APPNAME_ENABLE
"""
return (
return bool(
getattr(settings, f"CMS_CONFIG_{self.app_name.upper()}_ENABLE", None)
is not None
)

def configure(self):
Expand All @@ -52,6 +51,12 @@ def configure(self):
configuration beyond the commonextension. Override to provide additional
arguments to :func:`create_apphook_page`.
"""
enable_setting = getattr(
settings, f"CMS_CONFIG_{self.app_name.upper()}_ENABLE", None
)
if not enable_setting:
return

extension_args = create_apphook_page_args(
self.config_settings.extension_settings_mapping
)
Expand Down Expand Up @@ -255,6 +260,9 @@ def __init__(self):
self.app_name = "profile"

def configure(self):
if not getattr(settings, "CMS_CONFIG_PROFILE_ENABLE", None):
return

extension_settings = [
"CMS_PROFILE_REQUIRES_AUTH",
"CMS_PROFILE_REQUIRES_AUTH_BSN_OR_KVK",
Expand Down
9 changes: 9 additions & 0 deletions src/open_inwoner/configurations/bootstrap/kic.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def is_configured(self) -> bool:
).exists()

def configure(self):
if not getattr(settings, "KIC_CONFIG_ENABLE", None):
return

organization = settings.OIP_ORGANIZATION or settings.ENVIRONMENT
org_label = f"Open Inwoner {organization}".strip()

Expand Down Expand Up @@ -136,6 +139,9 @@ def is_configured(self) -> bool:
).exists()

def configure(self):
if not getattr(settings, "KIC_CONFIG_ENABLE", None):
return

organization = settings.OIP_ORGANIZATION or settings.ENVIRONMENT
org_label = f"Open Inwoner {organization}".strip()

Expand Down Expand Up @@ -206,6 +212,9 @@ def is_configured(self) -> bool:
)

def configure(self):
if not getattr(settings, "KIC_CONFIG_ENABLE", None):
return

config = OpenKlantConfig.get_solo()
config.klanten_service = Service.objects.get(
api_root=settings.KIC_KLANTEN_SERVICE_API_ROOT
Expand Down
3 changes: 3 additions & 0 deletions src/open_inwoner/configurations/bootstrap/siteconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def is_configured(self):
return True

def configure(self):
if not getattr(settings, "SITE_CONFIG_ENABLE", None):
return

config = SiteConfiguration.get_solo()

all_settings = (
Expand Down
15 changes: 15 additions & 0 deletions src/open_inwoner/configurations/bootstrap/zgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def is_configured(self) -> bool:
).exists()

def configure(self):
if not getattr(settings, "ZGW_CONFIG_ENABLE", None):
return

organization = settings.OIP_ORGANIZATION or settings.ENVIRONMENT
org_label = f"Open Inwoner {organization}".strip()

Expand Down Expand Up @@ -142,6 +145,9 @@ def is_configured(self) -> bool:
).exists()

def configure(self):
if not getattr(settings, "ZGW_CONFIG_ENABLE", None):
return

organization = settings.OIP_ORGANIZATION or settings.ENVIRONMENT
org_label = f"Open Inwoner {organization}".strip()

Expand Down Expand Up @@ -223,6 +229,9 @@ def is_configured(self) -> bool:
).exists()

def configure(self):
if not getattr(settings, "ZGW_CONFIG_ENABLE", None):
return

organization = settings.OIP_ORGANIZATION or settings.ENVIRONMENT
org_label = f"Open Inwoner {organization}".strip()

Expand Down Expand Up @@ -304,6 +313,9 @@ def is_configured(self) -> bool:
).exists()

def configure(self):
if not getattr(settings, "ZGW_CONFIG_ENABLE", None):
return

organization = settings.OIP_ORGANIZATION or settings.ENVIRONMENT
org_label = f"Open Inwoner {organization}".strip()

Expand Down Expand Up @@ -379,6 +391,9 @@ def is_configured(self) -> bool:
return ZGWApiGroupConfig.objects.filter(open_zaak_config=zgw_config).exists()

def configure(self):
if not getattr(settings, "ZGW_CONFIG_ENABLE", None):
return

config = OpenZaakConfig.get_solo()
ZGWApiGroupConfig.objects.create(
open_zaak_config=config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def test_configuration_check_ok(self, m):
def test_configuration_check_failures(self, m):
raise NotImplementedError

@override_settings(DIGID_OIDC_CONFIG_ENABLE=True)
def test_is_configured(self):
config = DigiDOIDCConfigurationStep()

Expand All @@ -277,6 +278,14 @@ def test_is_configured(self):

self.assertTrue(config.is_configured())

@override_settings(DIGID_OIDC_CONFIG_ENABLE=False)
def test_disable_digid_oidc_config(self):
config = DigiDOIDCConfigurationStep()

config.configure()

self.assertFalse(config.is_configured())


@override_settings(
EHERKENNING_OIDC_OIDC_RP_CLIENT_ID="client-id",
Expand Down Expand Up @@ -483,6 +492,7 @@ def test_configuration_check_ok(self, m):
def test_configuration_check_failures(self, m):
raise NotImplementedError

@override_settings(DIGID_SAML_CONFIG_ENABLE=True)
def test_is_configured(self):
config = eHerkenningOIDCConfigurationStep()

Expand All @@ -492,6 +502,14 @@ def test_is_configured(self):

self.assertTrue(config.is_configured())

@override_settings(EHERKENNING_OIDC_CONFIG_ENABLE=False)
def test_disable_eherkenning_oidc_config(self):
config = eHerkenningOIDCConfigurationStep()

config.configure()

self.assertFalse(config.is_configured())


@override_settings(
ADMIN_OIDC_OIDC_RP_CLIENT_ID="client-id",
Expand Down Expand Up @@ -709,6 +727,7 @@ def test_configuration_check_ok(self, m):
def test_configuration_check_failures(self, m):
raise NotImplementedError

@override_settings(ADMIN_OIDC_CONFIG_ENABLE=True)
def test_is_configured(self):
config = AdminOIDCConfigurationStep()

Expand All @@ -718,6 +737,14 @@ def test_is_configured(self):

self.assertTrue(config.is_configured())

@override_settings(ADMIN_OIDC_CONFIG_ENABLE=False)
def test_disable_admin_oidc_config(self):
config = AdminOIDCConfigurationStep()

config.configure()

self.assertFalse(config.is_configured())


@temp_private_root()
@override_settings(
Expand Down Expand Up @@ -852,6 +879,7 @@ def test_configuration_check_failures(self, m):
raise NotImplementedError

@requests_mock.Mocker()
@override_settings(DIGID_SAML_CONFIG_ENABLE=True)
def test_is_configured(self, m):
config = DigiDSAMLConfigurationStep()

Expand All @@ -863,6 +891,14 @@ def test_is_configured(self, m):

self.assertTrue(config.is_configured())

@override_settings(DIGID_SAML_CONFIG_ENABLE=False)
def test_disable_digid_saml_config(self):
config = DigiDSAMLConfigurationStep()

config.configure()

self.assertFalse(config.is_configured())


@temp_private_root()
@override_settings(
Expand Down Expand Up @@ -1040,6 +1076,7 @@ def test_configuration_check_failures(self, m):
raise NotImplementedError

@requests_mock.Mocker()
@override_settings(EHERKENNING_SAML_CONFIG_ENABLE=True)
def test_is_configured(self, m):
config = eHerkenningSAMLConfigurationStep()

Expand All @@ -1051,3 +1088,11 @@ def test_is_configured(self, m):
config.configure()

self.assertTrue(config.is_configured())

@override_settings(EHERKENNING_SAML_CONFIG_ENABLE=False)
def test_disable_eherkenning_saml_config(self):
config = eHerkenningSAMLConfigurationStep()

config.configure()

self.assertFalse(config.is_configured())
48 changes: 48 additions & 0 deletions src/open_inwoner/configurations/tests/bootstrap/test_setup_cms.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ def test_cms_profile_not_configured(self):

self.assertFalse(profile_page_is_published())

@override_settings(CMS_CONFIG_PROFILE_ENABLE=False)
def test_cms_profile_config_disable(self):
configuration_step = CMSProfileConfigurationStep()

configuration_step.configure()

self.assertFalse(configuration_step.is_configured())

@override_settings(
ROOT_URLCONF="open_inwoner.cms.tests.urls",
CMS_CONFIG_SSD_ENABLE=True,
Expand Down Expand Up @@ -162,6 +170,14 @@ def test_cms_ssd_override_settings(self):
self.assertEqual(extension.menu_indicator, "arrow")
self.assertEqual(extension.menu_icon, "smiley")

@override_settings(CMS_CONFIG_SSD_ENABLE=False)
def test_disable_ssd_config(self):
configuration_step = CMSBenefitsConfigurationStep()

configuration_step.configure()

self.assertFalse(configuration_step.is_configured())

@override_settings(
ROOT_URLCONF="open_inwoner.cms.tests.urls",
CMS_CONFIG_CASES_ENABLE=True,
Expand Down Expand Up @@ -205,6 +221,14 @@ def test_cms_cases_override_settings(self):
self.assertEqual(extension.menu_indicator, "arrow")
self.assertEqual(extension.menu_icon, "smiley")

@override_settings(CMS_CONFIG_CASES_ENABLE=False)
def test_disable_cms_cases_config(self):
configuration_step = CMSCasesConfigurationStep()

configuration_step.configure()

self.assertFalse(configuration_step.is_configured())

@override_settings(
ROOT_URLCONF="open_inwoner.cms.tests.urls",
CMS_CONFIG_COLLABORATE_ENABLE=True,
Expand Down Expand Up @@ -248,6 +272,14 @@ def test_cms_collaborate_override_settings(self):
self.assertEqual(extension.menu_indicator, "arrow")
self.assertEqual(extension.menu_icon, "smiley")

@override_settings(CMS_CONFIG_COLLABORATE_ENABLE=False)
def test_disable_cms_collaborate_config(self):
configuration_step = CMSCollaborateConfigurationStep()

configuration_step.configure()

self.assertFalse(configuration_step.is_configured())

@override_settings(
ROOT_URLCONF="open_inwoner.cms.tests.urls",
CMS_CONFIG_INBOX_ENABLE=True,
Expand Down Expand Up @@ -291,6 +323,14 @@ def test_cms_inbox_override_settings(self):
self.assertEqual(extension.menu_indicator, "arrow")
self.assertEqual(extension.menu_icon, "smiley")

@override_settings(CMS_CONFIG_INBOX_ENABLE=False)
def test_disable_cms_inbox_config(self):
configuration_step = CMSInboxConfigurationStep()

configuration_step.configure()

self.assertFalse(configuration_step.is_configured())

@override_settings(
ROOT_URLCONF="open_inwoner.cms.tests.urls",
CMS_CONFIG_PRODUCTS_ENABLE=True,
Expand Down Expand Up @@ -333,3 +373,11 @@ def test_cms_products_override_settings(self):
self.assertTrue(extension.requires_auth_bsn_or_kvk)
self.assertEqual(extension.menu_indicator, "arrow")
self.assertEqual(extension.menu_icon, "smiley")

@override_settings(CMS_CONFIG_PRODUCTS_ENABLE=False)
def test_disable_cms_profucts_config(self):
configuration_step = CMSProductsConfigurationStep()

configuration_step.configure()

self.assertFalse(configuration_step.is_configured())
Loading

0 comments on commit 57250a6

Please sign in to comment.