diff --git a/digid_eherkenning/management/commands/update_stored_metadata.py b/digid_eherkenning/management/commands/update_stored_metadata.py index 78f3831..4c09518 100644 --- a/digid_eherkenning/management/commands/update_stored_metadata.py +++ b/digid_eherkenning/management/commands/update_stored_metadata.py @@ -1,7 +1,11 @@ from django.core.management import BaseCommand -from digid_eherkenning.models.digid import DigidConfiguration -from digid_eherkenning.models.eherkenning import EherkenningConfiguration +from ...models import DigidConfiguration, EherkenningConfiguration + +MODEL_MAP = { + "digid": DigidConfiguration, + "eherkenning": EherkenningConfiguration, +} class Command(BaseCommand): @@ -11,15 +15,13 @@ def add_arguments(self, parser): parser.add_argument( "config_model", type=str, - choices=["digid", "eherkenning"], + choices=list(MODEL_MAP.keys()), help="Update the DigiD or Eherkenning configuration metadata.", ) def handle(self, **options): - if options["config_model"] == "digid": - config = DigidConfiguration.get_solo() - elif options["config_model"] == "eherkenning": - config = EherkenningConfiguration.get_solo() + config_model = MODEL_MAP[options["config_model"]] + config = config_model.get_solo() if config.metadata_file_source: config.save(force_metadata_update=True) diff --git a/tests/test_migrations.py b/tests/test_migrations.py index b10086a..b25edf9 100644 --- a/tests/test_migrations.py +++ b/tests/test_migrations.py @@ -7,7 +7,6 @@ import pytest from cryptography.hazmat.primitives.asymmetric import rsa from simple_certmanager.constants import CertificateTypes -from simple_certmanager.models import Certificate from simple_certmanager.test.certificate_generation import key_to_pem from simple_certmanager.utils import load_pem_x509_private_key @@ -43,7 +42,7 @@ def test_fixing_misconfigured_eherkenning(migrator): @pytest.mark.django_db def test_decrypt_private_keys_with_passphrase( - migrator, encrypted_keypair: tuple[bytes, bytes] + temp_private_root, migrator, encrypted_keypair: tuple[bytes, bytes] ): old_state = migrator.apply_initial_migration( ("digid_eherkenning", "0008_update_loa_fields") @@ -163,6 +162,7 @@ def _decryption_skip_cases_idfn(case): ) @pytest.mark.django_db def test_decryption_migration_robustness( + temp_private_root, migrator, leaf_keypair: tuple[rsa.RSAPrivateKey, bytes], encrypted_keypair: tuple[bytes, bytes],