diff --git a/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php b/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php index ca7a69d3d3..b9219d87b2 100644 --- a/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php +++ b/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php @@ -315,19 +315,23 @@ private function loadSavedSettings(): void { } return $carry; }, []); + foreach ($this->availableSignatureMethods as $signatureMethodName) { + $this->signatureMethods[$signatureMethodName] = + $this->getEmptyInstanceOfSignatureMethodByName($signatureMethodName); + } if (!isset($this->settings['signatureMethods']) || !is_array($this->settings['signatureMethods'])) { return; } - foreach ($this->settings['signatureMethods'] as $method => $settings) { - if (!in_array($method, $this->availableSignatureMethods)) { - unset($this->settings['signatureMethods'][$method]); + foreach ($this->settings['signatureMethods'] as $signatureMethodName => $settings) { + if (!in_array($signatureMethodName, $this->availableSignatureMethods)) { + unset($this->settings['signatureMethods'][$signatureMethodName]); continue; } - $signatureMethod = $this->getEmptyInstanceOfSignatureMethodByName($method); + $signatureMethod = $this->getEmptyInstanceOfSignatureMethodByName($signatureMethodName); if (isset($settings['enabled']) && $settings['enabled']) { $signatureMethod->enable(); } - $this->signatureMethods[$method] = $signatureMethod; + $this->signatureMethods[$signatureMethodName] = $signatureMethod; } } diff --git a/tests/integration/features/admin/initial_state.feature b/tests/integration/features/admin/initial_state.feature index 9648c0d60c..fc49785548 100644 --- a/tests/integration/features/admin/initial_state.feature +++ b/tests/integration/features/admin/initial_state.feature @@ -6,8 +6,8 @@ Feature: admin/initial_state Then the response should contain the initial state "libresign-identify_methods" with the following values: """ [ - {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"},"password":{"enabled":false,"label":"Certificate with password"}}}, - {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"}}} + {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"},"password":{"enabled":false,"label":"Certificate with password","name":"password"}}}, + {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"}}} ] """ @@ -20,8 +20,8 @@ Feature: admin/initial_state And the response should contain the initial state "libresign-identify_methods" with the following values: """ [ - {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"},"password":{"enabled":false,"label":"Certificate with password"}}}, - {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"}}} + {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"},"password":{"enabled":false,"label":"Certificate with password","name":"password"}}}, + {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"}}} ] """ @@ -34,8 +34,8 @@ Feature: admin/initial_state And the response should contain the initial state "libresign-identify_methods" with the following values: """ [ - {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"},"password":{"enabled":false,"label":"Certificate with password"}}}, - {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"}}} + {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"},"password":{"enabled":false,"label":"Certificate with password","name":"password"}}}, + {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"}}} ] """ @@ -48,8 +48,8 @@ Feature: admin/initial_state And the response should contain the initial state "libresign-identify_methods" with the following values: """ [ - {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"},"password":{"enabled":false,"label":"Certificate with password"}}}, - {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"}}} + {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"},"password":{"enabled":false,"label":"Certificate with password","name":"password"}}}, + {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"}}} ] """ @@ -62,8 +62,8 @@ Feature: admin/initial_state And the response should contain the initial state "libresign-identify_methods" with the following values: """ [ - {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"},"password":{"enabled":false,"label":"Certificate with password"}}}, - {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"}}} + {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"},"password":{"enabled":false,"label":"Certificate with password","name":"password"}}}, + {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"}}} ] """ @@ -75,7 +75,7 @@ Feature: admin/initial_state And the response should contain the initial state "libresign-identify_methods" with the following values: """ [ - {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"},"password":{"enabled":false,"label":"Certificate with password"}}}, - {"name":"email","friendly_name":"Email","enabled":false,"mandatory":false,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"}}} + {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"},"password":{"enabled":false,"label":"Certificate with password","name":"password"}}}, + {"name":"email","friendly_name":"Email","enabled":false,"mandatory":false,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"}}} ] """ diff --git a/tests/integration/features/page/index.feature b/tests/integration/features/page/index.feature index e12fe2f521..ce624488ab 100644 --- a/tests/integration/features/page/index.feature +++ b/tests/integration/features/page/index.feature @@ -10,7 +10,7 @@ Feature: page/sign_identify_default And the response should contain the initial state "libresign-identify_methods" with the following values: """ [ - {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"},"password":{"enabled":false,"label":"Certificate with password"}}}, - {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign"},"emailToken":{"enabled":false,"label":"Email token"}}} + {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"},"password":{"enabled":false,"label":"Certificate with password","name":"password"}}}, + {"name":"email","friendly_name":"Email","enabled":false,"mandatory":true,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"}}} ] """