diff --git a/src/open_inwoner/configurations/bootstrap/auth.py b/src/open_inwoner/configurations/bootstrap/auth.py index b30a89fcb6..ac7fdf38a3 100644 --- a/src/open_inwoner/configurations/bootstrap/auth.py +++ b/src/open_inwoner/configurations/bootstrap/auth.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/open_inwoner/configurations/bootstrap/cms.py b/src/open_inwoner/configurations/bootstrap/cms.py index 5326b131c8..b92884d514 100644 --- a/src/open_inwoner/configurations/bootstrap/cms.py +++ b/src/open_inwoner/configurations/bootstrap/cms.py @@ -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): @@ -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 ) @@ -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", diff --git a/src/open_inwoner/configurations/bootstrap/kic.py b/src/open_inwoner/configurations/bootstrap/kic.py index 638fd6d386..b08bc29b2f 100644 --- a/src/open_inwoner/configurations/bootstrap/kic.py +++ b/src/open_inwoner/configurations/bootstrap/kic.py @@ -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() @@ -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() @@ -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 diff --git a/src/open_inwoner/configurations/bootstrap/siteconfig.py b/src/open_inwoner/configurations/bootstrap/siteconfig.py index ff67463851..d9e934f4df 100644 --- a/src/open_inwoner/configurations/bootstrap/siteconfig.py +++ b/src/open_inwoner/configurations/bootstrap/siteconfig.py @@ -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 = ( diff --git a/src/open_inwoner/configurations/bootstrap/zgw.py b/src/open_inwoner/configurations/bootstrap/zgw.py index 254ed2e8f0..f4a9119911 100644 --- a/src/open_inwoner/configurations/bootstrap/zgw.py +++ b/src/open_inwoner/configurations/bootstrap/zgw.py @@ -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() @@ -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() @@ -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() @@ -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() @@ -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, diff --git a/src/open_inwoner/configurations/tests/bootstrap/test_setup_auth_config.py b/src/open_inwoner/configurations/tests/bootstrap/test_setup_auth_config.py index 169057cfe5..c1e8d576d7 100644 --- a/src/open_inwoner/configurations/tests/bootstrap/test_setup_auth_config.py +++ b/src/open_inwoner/configurations/tests/bootstrap/test_setup_auth_config.py @@ -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() @@ -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", @@ -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() @@ -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", @@ -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() @@ -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( @@ -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() @@ -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( @@ -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() @@ -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()) diff --git a/src/open_inwoner/configurations/tests/bootstrap/test_setup_cms.py b/src/open_inwoner/configurations/tests/bootstrap/test_setup_cms.py index e83bd67e0c..7812088e27 100644 --- a/src/open_inwoner/configurations/tests/bootstrap/test_setup_cms.py +++ b/src/open_inwoner/configurations/tests/bootstrap/test_setup_cms.py @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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()) diff --git a/src/open_inwoner/configurations/tests/bootstrap/test_setup_kic_config.py b/src/open_inwoner/configurations/tests/bootstrap/test_setup_kic_config.py index fbe3d862dd..c164a27fb0 100644 --- a/src/open_inwoner/configurations/tests/bootstrap/test_setup_kic_config.py +++ b/src/open_inwoner/configurations/tests/bootstrap/test_setup_kic_config.py @@ -27,6 +27,7 @@ @override_settings( OIP_ORGANIZATION="Maykin", + KIC_CONFIG_ENABLE=True, KIC_SERVER_CERTIFICATE_LABEL="KIC services server certificate", KIC_SERVER_CERTIFICATE_TYPE=CertificateTypes.cert_only, KIC_SERVER_CERTIFICATE_PUBLIC_CERTIFICATE=PUBLIC_CERT_FILE.name, @@ -95,6 +96,7 @@ def test_configure(self): @override_settings( OIP_ORGANIZATION=None, + KIC_CONFIG_ENABLE=True, KIC_REGISTER_EMAIL=None, KIC_REGISTER_CONTACT_MOMENT=None, KIC_REGISTER_BRONORGANISATIE_RSIN=None, @@ -132,6 +134,7 @@ def test_configure_use_defaults(self): self.assertEqual(config.use_rsin_for_innNnpId_query_parameter, False) @requests_mock.Mocker() + @override_settings(KIC_CONFIG_ENABLE=True) def test_configuration_check_ok(self, m): KlantenAPIConfigurationStep().configure() ContactmomentenAPIConfigurationStep().configure() @@ -156,6 +159,7 @@ def test_configuration_check_ok(self, m): ) @requests_mock.Mocker() + @override_settings(KIC_CONFIG_ENABLE=True) def test_configuration_check_failures(self, m): KlantenAPIConfigurationStep().configure() ContactmomentenAPIConfigurationStep().configure() @@ -176,6 +180,7 @@ def test_configuration_check_failures(self, m): with self.assertRaises(SelfTestFailed): configuration.test_configuration() + @override_settings(KIC_CONFIG_ENABLE=True) def test_is_configured(self): configs = [ KlantenAPIConfigurationStep(), @@ -189,3 +194,12 @@ def test_is_configured(self): config.configure() self.assertTrue(config.is_configured()) + + @override_settings(KIC_CONFIG_ENABLE=False) + def test_disable_kic_config(self): + KlantenAPIConfigurationStep().configure() + ContactmomentenAPIConfigurationStep().configure() + configuration = KICAPIsConfigurationStep() + configuration.configure() + + self.assertFalse(configuration.is_configured()) diff --git a/src/open_inwoner/configurations/tests/bootstrap/test_setup_site_config.py b/src/open_inwoner/configurations/tests/bootstrap/test_setup_site_config.py index 871cc21ef5..6f54efaf09 100644 --- a/src/open_inwoner/configurations/tests/bootstrap/test_setup_site_config.py +++ b/src/open_inwoner/configurations/tests/bootstrap/test_setup_site_config.py @@ -212,3 +212,11 @@ def test_site_configure_error(self): with self.assertRaises(ValidationError): configuration_step.configure() + + @override_settings(SITE_CONFIG_ENABLE=False) + def test_disable_siteconfig(self): + configuration_step = SiteConfigurationStep() + + configuration_step.configure() + + self.assertFalse(configuration_step.is_configured()) diff --git a/src/open_inwoner/configurations/tests/bootstrap/test_setup_zgw_config.py b/src/open_inwoner/configurations/tests/bootstrap/test_setup_zgw_config.py index 80c3c5c05b..0df3b11e00 100644 --- a/src/open_inwoner/configurations/tests/bootstrap/test_setup_zgw_config.py +++ b/src/open_inwoner/configurations/tests/bootstrap/test_setup_zgw_config.py @@ -261,6 +261,7 @@ def test_configuration_check_failures(self, m): with self.assertRaises(SelfTestFailed): configuration.test_configuration() + @override_settings(ZGW_CONFIG_ENABLE=True) def test_is_configured(self): configs = [ ZakenAPIConfigurationStep(), @@ -276,3 +277,15 @@ def test_is_configured(self): config.configure() self.assertTrue(config.is_configured()) + + @override_settings(ZGW_CONFIG_ENABLE=False) + def test_zgw__config_disable(self): + ZakenAPIConfigurationStep().configure() + CatalogiAPIConfigurationStep().configure() + DocumentenAPIConfigurationStep().configure() + FormulierenAPIConfigurationStep().configure() + configuration = ZGWAPIsConfigurationStep() + + configuration.configure() + + self.assertFalse(configuration.is_configured())