Ga hier maar eens op kliken! {{ selfServiceUrl }}{% if isRevokedByRa %}The registration of your {{ tokenType }} with ID {{ tokenIdentifier }} was deleted by an administrator.{% else %}You have deleted the registration of your {{ tokenType }} token with ID {{ tokenIdentifier }}. If you did not delete your token you must immediately contact the support desk of your institution, as this may indicate that your account has been compromised.{% endif %}
You can no longer use this token to access SURFconext services that require two-step authentication.
Do you want to replace your token? Please visit {{ selfServiceUrl }} and register a new token.
Bedankt voor het registreren van je [recovery token]. Je token is nu klaar voor gebruik. Je kunt dit token gebruiken wanneer je een second factor token dat je verloren bent opnieuw wilt activeren.
Met vriendelijke groet,
SURFnet
",
+ "en_GB": "
Dear {{ commonName }},
Thank you for registering your [recovery token]. Your token is ready to use. You can use this token to restore a second factor token that you lost.
Best regards,
SURFnet
"
+ },
+ "recovery_token_revoked": {
+ "nl_NL": "
Beste {{ commonName }},
{% if isRevokedByRa %}De registratie van je {{ tokenType }} recovery token met ID {{ tokenIdentifier }} is verwijderd door een beheerder.{% else %}Je hebt de registratie voor je {{ tokenType }} recovery token met ID {{ tokenIdentifier }} verwijderd. Neem direct contact op met de helpdesk van je instelling als je dit zelf niet gedaan hebt, omdat dit kan betekenen dat je account gecompromitteerd is.{% endif %}
Je kunt dit token niet meer gebruiken om second factor tokens te recoveren.
Met vriendelijke groet,
SURFnet
",
+ "en_GB": "
Dear {{ commonName }},
{% if isRevokedByRa %}The registration of your [recovery token] {{ tokenType }} with ID {{ tokenIdentifier }} was deleted by an administrator.{% else %}You have deleted the registration of your {{ tokenType }} token with ID {{ tokenIdentifier }}. If you did not delete your [recovery token] you must immediately contact the support desk of your institution, as this may indicate that your account has been compromised.{% endif %}
You can no longer use this [recovery token] to restore a lost second factor token.
Ga hier maar eens op kliken! {{ selfServiceUrl }} Bedankt voor het registreren van je token. Je token is bijna klaar voor gebruik. Ga uiterlijk {{ expirationDate|localizeddate('full', 'none', locale) }} naar de Service Desk om je token te laten activeren.
\\n
Neem aub het volgende mee:
\\n
\\n
Je token
\\n
Een geldig legitimatiebewijs (paspoort, rijbewijs of nationale ID-kaart)
\\n
De registratiecode uit deze e-mail
\\n
\\n\\n
\\n {{ registrationCode }}\\n
\\n\\n
Service Desk medewerkers die je token kunnen activeren:
\\n\\n{% if ras is empty %}\\n
Er zijn geen Service Desk medewerkers beschikbaar.
Ga hier maar eens op kliken! {{ selfServiceUrl }} Thank you for registering your token, you are almost ready now. Please visit the Service Desk no later than {{ expirationDate|localizeddate('full', 'none', locale) }} to activate your token up.
\\n
Please bring the following:
\\n
\\n
Your token
\\n
A valid identity document (passport, drivers license or national ID-card)
\\n
The registration code from this e-mail
\\n
\\n\\n
\\n {{ registrationCode }}\\n
\\n\\n
Service Desk employees authorized to activate your token:
Ga hier maar eens op kliken! {{ selfServiceUrl }} Bedankt voor het registreren van je token. Je token is bijna klaar voor gebruik. Ga uiterlijk {{ expirationDate|localizeddate('full', 'none', locale) }} naar de Service Desk om je token te laten activeren.
\\n
Neem aub het volgende mee:
\\n
\\n
Je token
\\n
Een geldig legitimatiebewijs (paspoort, rijbewijs of nationale ID-kaart)
Ga hier maar eens op kliken! {{ selfServiceUrl }} Thank you for registering your token, you are almost ready now. Please visit the Service Desk no later than {{ expirationDate|localizeddate('full', 'none', locale) }} to activate your token.
\\n
Please bring the following:
\\n
\\n
Your token
\\n
A valid identity document (passport, drivers license or national ID-card)
Ga hier maar eens op kliken! {{ selfServiceUrl }} Een week geleden heb je een token geregistreerd. Ga uiterlijk {{ expirationDate|localizeddate('full', 'none', locale) }} naar de Service Desk om je token te laten activeren.
\\n
Neem aub het volgende mee:
\\n
\\n
Je token
\\n
Een geldig legitimatiebewijs (paspoort, rijbewijs of nationale ID-kaart)
\\n
De registratiecode uit deze e-mail
\\n
\\n\\n
\\n {{ registrationCode }}\\n
\\n\\n
Service Desk medewerkers die je token kunnen activeren:
\\n\\n{% if ras is empty %}\\n
Er zijn geen Service Desk medewerkers beschikbaar.
Ga hier maar eens op kliken! {{ selfServiceUrl }} One week ago, you registered a token. Please visit the Service Desk no later than {{ expirationDate|localizeddate('full', 'none', locale) }} to activate your token.
\\n
Please bring the following:
\\n
\\n
Your token
\\n
A valid identity document (passport, drivers license or national ID-card)
\\n
The registration code from this e-mail
\\n
\\n\\n
\\n {{ registrationCode }}\\n
\\n\\n
Service Desk employees authorized to activate your token:
Ga hier maar eens op kliken! {{ selfServiceUrl }} Een week geleden heb je een token geregistreerd. Ga uiterlijk {{ expirationDate|localizeddate('full', 'none', locale) }} naar de Service Desk om je token te laten activeren.
\\n
Neem aub het volgende mee:
\\n
\\n
Je token
\\n
Een geldig legitimatiebewijs (paspoort, rijbewijs of nationale ID-kaart)
Ga hier maar eens op kliken! {{ selfServiceUrl }} One week ago, you registered a token. Please visit the Service Desk no later than {{ expirationDate|localizeddate('full', 'none', locale) }} to activate your token.
\\n
Please bring the following:
\\n
\\n
Your token
\\n
A valid identity document (passport, drivers license or national ID-card)
Ga hier maar eens op kliken! {{ selfServiceUrl }}{% if isRevokedByRa %}De registratie van je {{ tokenType }} token met ID {{ tokenIdentifier }} is verwijderd door een beheerder.{% else %}Je hebt de registratie voor je {{ tokenType }} token met ID {{ tokenIdentifier }} verwijderd. Neem direct contact op met de helpdesk van je instelling als je dit zelf niet gedaan hebt, omdat dit kan betekenen dat je account gecompromitteerd is.{% endif %}
Je kunt dit token niet meer gebruiken om in te loggen bij op SURFconext aangesloten services die een tweede inlogstap vereisen.
Wil je een nieuw token aanvragen? Ga dan naar {{ selfServiceUrl }} en doorloop het registratieproces opnieuw.
Ga hier maar eens op kliken! {{ selfServiceUrl }}{% if isRevokedByRa %}The registration of your {{ tokenType }} with ID {{ tokenIdentifier }} was deleted by an administrator.{% else %}You have deleted the registration of your {{ tokenType }} token with ID {{ tokenIdentifier }}. If you did not delete your token you must immediately contact the support desk of your institution, as this may indicate that your account has been compromised.{% endif %}
You can no longer use this token to access SURFconext services that require two-step authentication.
Do you want to replace your token? Please visit {{ selfServiceUrl }} and register a new token.
Bedankt voor het registreren van je [recovery token]. Je token is nu klaar voor gebruik. Je kunt dit token gebruiken wanneer je een second factor token dat je verloren bent opnieuw wilt activeren.
Met vriendelijke groet,
SURFnet
\",\n \"en_GB\": \"
Dear {{ commonName }},
Thank you for registering your [recovery token]. Your token is ready to use. You can use this token to restore a second factor token that you lost.
{% if isRevokedByRa %}De registratie van je {{ tokenType }} recovery token met ID {{ tokenIdentifier }} is verwijderd door een beheerder.{% else %}Je hebt de registratie voor je {{ tokenType }} recovery token met ID {{ tokenIdentifier }} verwijderd. Neem direct contact op met de helpdesk van je instelling als je dit zelf niet gedaan hebt, omdat dit kan betekenen dat je account gecompromitteerd is.{% endif %}
Je kunt dit token niet meer gebruiken om second factor tokens te recoveren.
Met vriendelijke groet,
SURFnet
\",\n \"en_GB\": \"
Dear {{ commonName }},
{% if isRevokedByRa %}The registration of your [recovery token] {{ tokenType }} with ID {{ tokenIdentifier }} was deleted by an administrator.{% else %}You have deleted the registration of your {{ tokenType }} token with ID {{ tokenIdentifier }}. If you did not delete your [recovery token] you must immediately contact the support desk of your institution, as this may indicate that your account has been compromised.{% endif %}
You can no longer use this [recovery token] to restore a lost second factor token.
Best regards,
SURFnet
\"\n }\n\n },\n \"gateway\": {\n \"identity_providers\": [],\n \"service_providers\": [\n {\n \"entity_id\": \"https://ss-dev.stepup.coin.surf.net/app_dev.php/authentication/metadata\",\n \"public_key\": \"MIIEJTCCAw2gAwIBAgIJANug+o++1X5IMA0GCSqGSIb3DQEBCwUAMIGoMQswCQYDVQQGEwJOTDEQMA4GA1UECAwHVXRyZWNodDEQMA4GA1UEBwwHVXRyZWNodDEVMBMGA1UECgwMU1VSRm5ldCBCLlYuMRMwEQYDVQQLDApTVVJGY29uZXh0MRwwGgYDVQQDDBNTVVJGbmV0IERldmVsb3BtZW50MSswKQYJKoZIhvcNAQkBFhxzdXJmY29uZXh0LWJlaGVlckBzdXJmbmV0Lm5sMB4XDTE0MTAyMDEyMzkxMVoXDTE0MTExOTEyMzkxMVowgagxCzAJBgNVBAYTAk5MMRAwDgYDVQQIDAdVdHJlY2h0MRAwDgYDVQQHDAdVdHJlY2h0MRUwEwYDVQQKDAxTVVJGbmV0IEIuVi4xEzARBgNVBAsMClNVUkZjb25leHQxHDAaBgNVBAMME1NVUkZuZXQgRGV2ZWxvcG1lbnQxKzApBgkqhkiG9w0BCQEWHHN1cmZjb25leHQtYmVoZWVyQHN1cmZuZXQubmwwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDXuSSBeNJY3d4p060oNRSuAER5nLWT6AIVbv3XrXhcgSwc9m2b8u3ksp14pi8FbaNHAYW3MjlKgnLlopYIylzKD/6Ut/clEx67aO9Hpqsc0HmIP0It6q2bf5yUZ71E4CN2HtQceO5DsEYpe5M7D5i64kS2A7e2NYWVdA5Z01DqUpQGRBc+uMzOwyif6StBiMiLrZH3n2r5q5aVaXU4Vy5EE4VShv3Mp91sgXJj/v155fv0wShgl681v8yf2u2ZMb7NKnQRA4zM2Ng2EUAyy6PQ+Jbn+rALSm1YgiJdVuSlTLhvgwbiHGO2XgBi7bTHhlqSrJFK3Gs4zwIsop/XqQRBAgMBAAGjUDBOMB0GA1UdDgQWBBQCJmcoa/F7aM3jIFN7Bd4uzWRgzjAfBgNVHSMEGDAWgBQCJmcoa/F7aM3jIFN7Bd4uzWRgzjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBd80GpWKjp1J+Dgp0blVAox1s/WPWQlex9xrx1GEYbc5elp3svS+S82s7dFm2llHrrNOBt1HZVC+TdW4f+MR1xq8O5lOYjDRsosxZc/u9jVsYWYc3M9bQAx8VyJ8VGpcAK+fLqRNabYlqTnj/t9bzX8fS90sp8JsALV4g84Aj0G8RpYJokw+pJUmOpuxsZN5U84MmLPnVfmrnuCVh/HkiLNV2c8Pk8LSomg6q1M1dQUTsz/HVxcOhHLj/owwh3IzXf/KXV/E8vSYW8o4WWCAnruYOWdJMI4Z8NG1Mfv7zvb7U3FL1C/KLV04DqzALXGj+LVmxtDvuxqC042apoIDQV\",\n \"acs\": [\n \"https://ss-dev.stepup.coin.surf.net/app_dev.php/authentication/consume-assertion\"\n ], \n \"loa\": {\n \"__default__\": \"https://gw-dev.stepup.coin.surf.net/authentication/loa1\"\n },\n \"assertion_encryption_enabled\": false,\n \"blacklisted_encryption_algorithms\": [],\n \"second_factor_only\": false,\n \"second_factor_only_nameid_patterns\": []\n },\n {\n \"entity_id\": \"https://ss-dev.stepup.coin.surf.net/app_dev.php/registration/gssf/tiqr/metadata\",\n \"public_key\": \"MIIEJTCCAw2gAwIBAgIJANug+o++1X5IMA0GCSqGSIb3DQEBCwUAMIGoMQswCQYDVQQGEwJOTDEQMA4GA1UECAwHVXRyZWNodDEQMA4GA1UEBwwHVXRyZWNodDEVMBMGA1UECgwMU1VSRm5ldCBCLlYuMRMwEQYDVQQLDApTVVJGY29uZXh0MRwwGgYDVQQDDBNTVVJGbmV0IERldmVsb3BtZW50MSswKQYJKoZIhvcNAQkBFhxzdXJmY29uZXh0LWJlaGVlckBzdXJmbmV0Lm5sMB4XDTE0MTAyMDEyMzkxMVoXDTE0MTExOTEyMzkxMVowgagxCzAJBgNVBAYTAk5MMRAwDgYDVQQIDAdVdHJlY2h0MRAwDgYDVQQHDAdVdHJlY2h0MRUwEwYDVQQKDAxTVVJGbmV0IEIuVi4xEzARBgNVBAsMClNVUkZjb25leHQxHDAaBgNVBAMME1NVUkZuZXQgRGV2ZWxvcG1lbnQxKzApBgkqhkiG9w0BCQEWHHN1cmZjb25leHQtYmVoZWVyQHN1cmZuZXQubmwwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDXuSSBeNJY3d4p060oNRSuAER5nLWT6AIVbv3XrXhcgSwc9m2b8u3ksp14pi8FbaNHAYW3MjlKgnLlopYIylzKD/6Ut/clEx67aO9Hpqsc0HmIP0It6q2bf5yUZ71E4CN2HtQceO5DsEYpe5M7D5i64kS2A7e2NYWVdA5Z01DqUpQGRBc+uMzOwyif6StBiMiLrZH3n2r5q5aVaXU4Vy5EE4VShv3Mp91sgXJj/v155fv0wShgl681v8yf2u2ZMb7NKnQRA4zM2Ng2EUAyy6PQ+Jbn+rALSm1YgiJdVuSlTLhvgwbiHGO2XgBi7bTHhlqSrJFK3Gs4zwIsop/XqQRBAgMBAAGjUDBOMB0GA1UdDgQWBBQCJmcoa/F7aM3jIFN7Bd4uzWRgzjAfBgNVHSMEGDAWgBQCJmcoa/F7aM3jIFN7Bd4uzWRgzjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBd80GpWKjp1J+Dgp0blVAox1s/WPWQlex9xrx1GEYbc5elp3svS+S82s7dFm2llHrrNOBt1HZVC+TdW4f+MR1xq8O5lOYjDRsosxZc/u9jVsYWYc3M9bQAx8VyJ8VGpcAK+fLqRNabYlqTnj/t9bzX8fS90sp8JsALV4g84Aj0G8RpYJokw+pJUmOpuxsZN5U84MmLPnVfmrnuCVh/HkiLNV2c8Pk8LSomg6q1M1dQUTsz/HVxcOhHLj/owwh3IzXf/KXV/E8vSYW8o4WWCAnruYOWdJMI4Z8NG1Mfv7zvb7U3FL1C/KLV04DqzALXGj+LVmxtDvuxqC042apoIDQV\",\n \"acs\": [\n \"https://ss-dev.stepup.coin.surf.net/app_dev.php/registration/gssf/tiqr/consume-assertion\"\n ], \n \"loa\": {\n \"__default__\": \"https://gw-dev.stepup.coin.surf.net/authentication/loa1\"\n },\n \"assertion_encryption_enabled\": false,\n \"blacklisted_encryption_algorithms\": [],\n \"second_factor_only\": false,\n \"second_factor_only_nameid_patterns\": []\n },\n {\n \"entity_id\": \"https://ra-dev.stepup.coin.surf.net/app_dev.php/vetting-procedure/gssf/tiqr/metadata\",\n \"public_key\": \"MIIEJTCCAw2gAwIBAgIJANug+o++1X5IMA0GCSqGSIb3DQEBCwUAMIGoMQswCQYDVQQGEwJOTDEQMA4GA1UECAwHVXRyZWNodDEQMA4GA1UEBwwHVXRyZWNodDEVMBMGA1UECgwMU1VSRm5ldCBCLlYuMRMwEQYDVQQLDApTVVJGY29uZXh0MRwwGgYDVQQDDBNTVVJGbmV0IERldmVsb3BtZW50MSswKQYJKoZIhvcNAQkBFhxzdXJmY29uZXh0LWJlaGVlckBzdXJmbmV0Lm5sMB4XDTE0MTAyMDEyMzkxMVoXDTE0MTExOTEyMzkxMVowgagxCzAJBgNVBAYTAk5MMRAwDgYDVQQIDAdVdHJlY2h0MRAwDgYDVQQHDAdVdHJlY2h0MRUwEwYDVQQKDAxTVVJGbmV0IEIuVi4xEzARBgNVBAsMClNVUkZjb25leHQxHDAaBgNVBAMME1NVUkZuZXQgRGV2ZWxvcG1lbnQxKzApBgkqhkiG9w0BCQEWHHN1cmZjb25leHQtYmVoZWVyQHN1cmZuZXQubmwwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDXuSSBeNJY3d4p060oNRSuAER5nLWT6AIVbv3XrXhcgSwc9m2b8u3ksp14pi8FbaNHAYW3MjlKgnLlopYIylzKD/6Ut/clEx67aO9Hpqsc0HmIP0It6q2bf5yUZ71E4CN2HtQceO5DsEYpe5M7D5i64kS2A7e2NYWVdA5Z01DqUpQGRBc+uMzOwyif6StBiMiLrZH3n2r5q5aVaXU4Vy5EE4VShv3Mp91sgXJj/v155fv0wShgl681v8yf2u2ZMb7NKnQRA4zM2Ng2EUAyy6PQ+Jbn+rALSm1YgiJdVuSlTLhvgwbiHGO2XgBi7bTHhlqSrJFK3Gs4zwIsop/XqQRBAgMBAAGjUDBOMB0GA1UdDgQWBBQCJmcoa/F7aM3jIFN7Bd4uzWRgzjAfBgNVHSMEGDAWgBQCJmcoa/F7aM3jIFN7Bd4uzWRgzjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBd80GpWKjp1J+Dgp0blVAox1s/WPWQlex9xrx1GEYbc5elp3svS+S82s7dFm2llHrrNOBt1HZVC+TdW4f+MR1xq8O5lOYjDRsosxZc/u9jVsYWYc3M9bQAx8VyJ8VGpcAK+fLqRNabYlqTnj/t9bzX8fS90sp8JsALV4g84Aj0G8RpYJokw+pJUmOpuxsZN5U84MmLPnVfmrnuCVh/HkiLNV2c8Pk8LSomg6q1M1dQUTsz/HVxcOhHLj/owwh3IzXf/KXV/E8vSYW8o4WWCAnruYOWdJMI4Z8NG1Mfv7zvb7U3FL1C/KLV04DqzALXGj+LVmxtDvuxqC042apoIDQV\",\n \"acs\": [\n \"https://ra-dev.stepup.coin.surf.net/app_dev.php/vetting-procedure/gssf/tiqr/verify\"\n ], \n \"loa\": {\n \"__default__\": \"https://gw-dev.stepup.coin.surf.net/authentication/loa1\"\n },\n \"assertion_encryption_enabled\": false,\n \"blacklisted_encryption_algorithms\": [],\n \"second_factor_only\": false,\n \"second_factor_only_nameid_patterns\": []\n },\n {\n \"entity_id\": \"https://ra-dev.stepup.coin.surf.net/app_dev.php/authentication/metadata\",\n \"public_key\": \"MIIEJTCCAw2gAwIBAgIJANug+o++1X5IMA0GCSqGSIb3DQEBCwUAMIGoMQswCQYDVQQGEwJOTDEQMA4GA1UECAwHVXRyZWNodDEQMA4GA1UEBwwHVXRyZWNodDEVMBMGA1UECgwMU1VSRm5ldCBCLlYuMRMwEQYDVQQLDApTVVJGY29uZXh0MRwwGgYDVQQDDBNTVVJGbmV0IERldmVsb3BtZW50MSswKQYJKoZIhvcNAQkBFhxzdXJmY29uZXh0LWJlaGVlckBzdXJmbmV0Lm5sMB4XDTE0MTAyMDEyMzkxMVoXDTE0MTExOTEyMzkxMVowgagxCzAJBgNVBAYTAk5MMRAwDgYDVQQIDAdVdHJlY2h0MRAwDgYDVQQHDAdVdHJlY2h0MRUwEwYDVQQKDAxTVVJGbmV0IEIuVi4xEzARBgNVBAsMClNVUkZjb25leHQxHDAaBgNVBAMME1NVUkZuZXQgRGV2ZWxvcG1lbnQxKzApBgkqhkiG9w0BCQEWHHN1cmZjb25leHQtYmVoZWVyQHN1cmZuZXQubmwwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDXuSSBeNJY3d4p060oNRSuAER5nLWT6AIVbv3XrXhcgSwc9m2b8u3ksp14pi8FbaNHAYW3MjlKgnLlopYIylzKD/6Ut/clEx67aO9Hpqsc0HmIP0It6q2bf5yUZ71E4CN2HtQceO5DsEYpe5M7D5i64kS2A7e2NYWVdA5Z01DqUpQGRBc+uMzOwyif6StBiMiLrZH3n2r5q5aVaXU4Vy5EE4VShv3Mp91sgXJj/v155fv0wShgl681v8yf2u2ZMb7NKnQRA4zM2Ng2EUAyy6PQ+Jbn+rALSm1YgiJdVuSlTLhvgwbiHGO2XgBi7bTHhlqSrJFK3Gs4zwIsop/XqQRBAgMBAAGjUDBOMB0GA1UdDgQWBBQCJmcoa/F7aM3jIFN7Bd4uzWRgzjAfBgNVHSMEGDAWgBQCJmcoa/F7aM3jIFN7Bd4uzWRgzjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBd80GpWKjp1J+Dgp0blVAox1s/WPWQlex9xrx1GEYbc5elp3svS+S82s7dFm2llHrrNOBt1HZVC+TdW4f+MR1xq8O5lOYjDRsosxZc/u9jVsYWYc3M9bQAx8VyJ8VGpcAK+fLqRNabYlqTnj/t9bzX8fS90sp8JsALV4g84Aj0G8RpYJokw+pJUmOpuxsZN5U84MmLPnVfmrnuCVh/HkiLNV2c8Pk8LSomg6q1M1dQUTsz/HVxcOhHLj/owwh3IzXf/KXV/E8vSYW8o4WWCAnruYOWdJMI4Z8NG1Mfv7zvb7U3FL1C/KLV04DqzALXGj+LVmxtDvuxqC042apoIDQV\",\n \"acs\": [\n \"https://ra-dev.stepup.coin.surf.net/app_dev.php/authentication/consume-assertion\"\n ], \n \"loa\": {\n \"__default__\": \"https://gw-dev.stepup.coin.surf.net/authentication/loa3\"\n },\n \"assertion_encryption_enabled\": false,\n \"blacklisted_encryption_algorithms\": [],\n \"second_factor_only\": false,\n \"second_factor_only_nameid_patterns\": []\n }\n ]\n }\n}"
- },
- "url": "http://middleware.stepup.example.com/management/configuration",
- "description": "POST the configuration\n"
- },
- "response": []
- },
- {
- "name": "/management/whitelist",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Accept",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "value": "application/json"
- }
- ],
- "url": "http://middleware.stepup.example.com/management/whitelist",
- "description": "Get whitelist\n"
- },
- "response": []
- },
- {
- "name": "/management/whitelist/add",
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "Accept",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "value": "application/json"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"institutions\": [\n \"institution-a.example.com\",\n \"institution-b.example.com\",\n \"institution-c.example.com\",\n \"institution-d.example.com\",\n \"institution-e.example.com\",\n \"institution-f.example.com\",\n \"institution-g.example.com\",\n \"institution-h.example.com\",\n \"institution-i.example.com\",\n \"institution-j.example.com\"\n ]\n}"
- },
- "url": "http://middleware.stepup.example.com/management/whitelist/add",
- "description": "Add institutions to the whitelist"
- },
- "response": []
- },
- {
- "name": "/management/whitelist/remove",
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "Accept",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "value": "application/json"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"institutions\": [\n \"miko.organisation.example.commm\"\n ]\n}"
- },
- "url": "http://middleware.stepup.example.com/management/whitelist/remove",
- "description": "Remove an institution from the whitelist"
- },
- "response": []
- },
- {
- "name": "/management/whitelist/replace",
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "Accept",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "value": "application/json"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"institutions\": [\n \"dev.organisation.example\",\n \"institution-a.example.com\",\n \"institution-b.example.com\",\n \"institution-c.example.com\",\n \"institution-d.example.com\",\n \"institution-e.example.com\",\n \"institution-f.example.com\",\n \"institution-g.example.com\",\n \"institution-h.example.com\",\n \"institution-i.example.com\",\n \"institution-j.example.com\"\n ]\n}"
- },
- "url": "http://middleware.stepup.example.com/management/whitelist/replace",
- "description": "Replace the Institution Whitelist\n"
- },
- "response": []
- },
- {
- "name": "/management/forget-identity",
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "Accept",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "value": "application/json"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"name_id\": \"2592ab2afb52eea9a61f5db90febd631966d49f5\",\n \"institution\": \"Ibuildings\"\n}"
- },
- "url": "http://middleware.stepup.example.com/management/forget-identity",
- "description": "- POST body must contain `name_id` and `institution`"
- },
- "response": []
- },
- {
- "name": "/management/institution-configuration",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Accept",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "http://middleware.stepup.example.com/management/institution-configuration?XDEBUG_SESSION_START=PHPSTORM",
- "protocol": "http",
- "host": [
- "middleware",
- "stepup",
- "example",
- "com"
- ],
- "path": [
- "management",
- "institution-configuration"
- ],
- "query": [
- {
- "key": "XDEBUG_SESSION_START",
- "value": "PHPSTORM"
- }
- ]
- },
- "description": "GET the institution configuration options"
- },
- "response": []
- },
- {
- "name": "/management/institution-configuration",
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "Accept",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "value": "application/json"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"institution-a.example.com\": {\n \"use_ra_locations\": true,\n \"show_raa_contact_information\": true,\n \"verify_email\": false,\n \"self_vet\": true,\n \"number_of_tokens_per_identity\": 2,\n \"allowed_second_factors\": []\n }\n}"
- },
- "url": {
- "raw": "http://middleware.stepup.example.com/management/institution-configuration?XDEBUG_SESSION_START=PHPSTORM",
- "protocol": "http",
- "host": [
- "middleware",
- "stepup",
- "example",
- "com"
- ],
- "path": [
- "management",
- "institution-configuration"
- ],
- "query": [
- {
- "key": "XDEBUG_SESSION_START",
- "value": "PHPSTORM"
- }
- ]
- },
- "description": "POST the institution configuration options to reconfigure\n"
- },
- "response": []
- }
- ],
- "event": [
- {
- "listen": "prerequest",
- "script": {
- "type": "text/javascript",
- "exec": [
- ""
- ]
- }
- },
- {
- "listen": "test",
- "script": {
- "type": "text/javascript",
- "exec": [
- ""
- ]
- }
- }
- ]
-}
diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png
deleted file mode 100644
index 8c0753a46..000000000
Binary files a/public/apple-touch-icon.png and /dev/null differ
diff --git a/public/index.php b/public/index.php
index 5a1dd66d4..0d0178f6d 100644
--- a/public/index.php
+++ b/public/index.php
@@ -1,26 +1,9 @@
handle($request);
-$response->send();
-$kernel->terminate($request, $response);
+return function (array $context) {
+ return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
+};
diff --git a/src/Kernel.php b/src/Kernel.php
deleted file mode 100644
index 1cd05726a..000000000
--- a/src/Kernel.php
+++ /dev/null
@@ -1,54 +0,0 @@
-getProjectDir().'/config/bundles.php';
- foreach ($contents as $class => $envs) {
- if ($envs[$this->environment] ?? $envs['all'] ?? false) {
- yield new $class();
- }
- }
- }
-
- public function getProjectDir(): string
- {
- return \dirname(__DIR__);
- }
-
- protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
- {
- $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
- $container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug);
- $container->setParameter('container.dumper.inline_factories', true);
- $confDir = $this->getProjectDir().'/config';
-
- $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
- $loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob');
- $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
- $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
- }
-
- protected function configureRoutes(RouteCollectionBuilder $routes): void
- {
- $confDir = $this->getProjectDir().'/config';
-
- $routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob');
- $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
- $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
- }
-}
diff --git a/src/Surfnet/DataFixtures/AppFixtures.php b/src/Surfnet/DataFixtures/AppFixtures.php
index 7df73384d..80479f788 100644
--- a/src/Surfnet/DataFixtures/AppFixtures.php
+++ b/src/Surfnet/DataFixtures/AppFixtures.php
@@ -1,5 +1,21 @@
flush();
}
diff --git a/src/Surfnet/Migrations/Version20141031133057.php b/src/Surfnet/Migrations/Version20141031133057.php
index 8fecc0274..fcd621039 100644
--- a/src/Surfnet/Migrations/Version20141031133057.php
+++ b/src/Surfnet/Migrations/Version20141031133057.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$sql = <<abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE event_stream');
}
diff --git a/src/Surfnet/Migrations/Version20141031144721.php b/src/Surfnet/Migrations/Version20141031144721.php
index 16edeba26..3e3dd53d9 100644
--- a/src/Surfnet/Migrations/Version20141031144721.php
+++ b/src/Surfnet/Migrations/Version20141031144721.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('CREATE TABLE identity (name_id VARCHAR(255) NOT NULL, PRIMARY KEY(name_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'CREATE TABLE identity (name_id VARCHAR(255) NOT NULL, PRIMARY KEY(name_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('DROP TABLE identity');
}
}
diff --git a/src/Surfnet/Migrations/Version20141031163549.php b/src/Surfnet/Migrations/Version20141031163549.php
index a14bf1fa5..e0abedaa1 100644
--- a/src/Surfnet/Migrations/Version20141031163549.php
+++ b/src/Surfnet/Migrations/Version20141031163549.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE identity DROP PRIMARY KEY');
$this->addSql('ALTER TABLE identity ADD id VARCHAR(36) NOT NULL FIRST');
$this->addSql('ALTER TABLE identity ADD PRIMARY KEY (id)');
@@ -23,8 +42,11 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE identity DROP PRIMARY KEY');
$this->addSql('ALTER TABLE identity DROP id');
$this->addSql('ALTER TABLE identity ADD PRIMARY KEY (name_id)');
diff --git a/src/Surfnet/Migrations/Version20141031164140.php b/src/Surfnet/Migrations/Version20141031164140.php
index b6309a7b5..cf2861bdc 100644
--- a/src/Surfnet/Migrations/Version20141031164140.php
+++ b/src/Surfnet/Migrations/Version20141031164140.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql("ALTER TABLE event_stream CHANGE type type varchar(255)");
$this->addSql("ALTER TABLE event_stream DROP INDEX unique_playhead");
@@ -24,7 +43,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql("ALTER TABLE event_stream CHANGE type type varchar(150)");
$this->addSql("ALTER TABLE event_stream DROP INDEX type");
diff --git a/src/Surfnet/Migrations/Version20141112093720.php b/src/Surfnet/Migrations/Version20141112093720.php
index 086076a35..2388dcd9c 100644
--- a/src/Surfnet/Migrations/Version20141112093720.php
+++ b/src/Surfnet/Migrations/Version20141112093720.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('CREATE TABLE second_factor (id VARCHAR(36) NOT NULL, identity_id VARCHAR(36) DEFAULT NULL, type VARCHAR(16) NOT NULL, second_factor_identifier VARCHAR(32) NOT NULL, INDEX IDX_1806C29EFF3ED4A8 (identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
- $this->addSql('ALTER TABLE second_factor ADD CONSTRAINT FK_1806C29EFF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'CREATE TABLE second_factor (id VARCHAR(36) NOT NULL, identity_id VARCHAR(36) DEFAULT NULL, type VARCHAR(16) NOT NULL, second_factor_identifier VARCHAR(32) NOT NULL, INDEX IDX_1806C29EFF3ED4A8 (identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
+ $this->addSql(
+ 'ALTER TABLE second_factor ADD CONSTRAINT FK_1806C29EFF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('DROP TABLE second_factor');
}
}
diff --git a/src/Surfnet/Migrations/Version20141112094457.php b/src/Surfnet/Migrations/Version20141112094457.php
index 6b0a081df..0d183dca7 100644
--- a/src/Surfnet/Migrations/Version20141112094457.php
+++ b/src/Surfnet/Migrations/Version20141112094457.php
@@ -1,9 +1,25 @@
abortIf(
$this->connection->getDatabasePlatform()->getName() != 'mysql',
- 'Migration can only be executed safely on \'mysql\'.'
+ 'Migration can only be executed safely on \'mysql\'.',
);
$this->addSql('ALTER TABLE event_stream DROP PRIMARY KEY');
$this->addSql('ALTER TABLE event_stream DROP INDEX unique_uuid_playhead');
$this->addSql(
- 'ALTER TABLE event_stream ADD CONSTRAINT pk_event_stream_uuid_playhead PRIMARY KEY (uuid, playhead)'
+ 'ALTER TABLE event_stream ADD CONSTRAINT pk_event_stream_uuid_playhead PRIMARY KEY (uuid, playhead)',
);
}
@@ -31,7 +47,7 @@ public function down(Schema $schema): void
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() != 'mysql',
- 'Migration can only be executed safely on \'mysql\'.'
+ 'Migration can only be executed safely on \'mysql\'.',
);
$this->addSql('ALTER TABLE event_stream DROP PRIMARY KEY');
diff --git a/src/Surfnet/Migrations/Version20141114095245.php b/src/Surfnet/Migrations/Version20141114095245.php
index d62409999..db0fca27c 100644
--- a/src/Surfnet/Migrations/Version20141114095245.php
+++ b/src/Surfnet/Migrations/Version20141114095245.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('CREATE TABLE unverified_second_factor (id VARCHAR(36) NOT NULL, identity_id VARCHAR(36) DEFAULT NULL, type VARCHAR(16) NOT NULL, second_factor_identifier VARCHAR(32) NOT NULL, INDEX IDX_D79226A2FF3ED4A8 (identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
- $this->addSql('ALTER TABLE unverified_second_factor ADD CONSTRAINT FK_D79226A2FF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'CREATE TABLE unverified_second_factor (id VARCHAR(36) NOT NULL, identity_id VARCHAR(36) DEFAULT NULL, type VARCHAR(16) NOT NULL, second_factor_identifier VARCHAR(32) NOT NULL, INDEX IDX_D79226A2FF3ED4A8 (identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor ADD CONSTRAINT FK_D79226A2FF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('DROP TABLE unverified_second_factor');
}
}
diff --git a/src/Surfnet/Migrations/Version20141117230116.php b/src/Surfnet/Migrations/Version20141117230116.php
index 3407915ad..2c97e5947 100644
--- a/src/Surfnet/Migrations/Version20141117230116.php
+++ b/src/Surfnet/Migrations/Version20141117230116.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE identity ADD institution VARCHAR(255) NOT NULL, ADD email VARCHAR(255) NOT NULL');
$this->addSql('CREATE INDEX idx_identity_institution ON identity (institution)');
@@ -23,7 +42,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP INDEX idxft_identity_email ON identity');
$this->addSql('DROP INDEX idx_identity_institution ON identity');
diff --git a/src/Surfnet/Migrations/Version20141118114026.php b/src/Surfnet/Migrations/Version20141118114026.php
index aaca16129..ae90e61eb 100644
--- a/src/Surfnet/Migrations/Version20141118114026.php
+++ b/src/Surfnet/Migrations/Version20141118114026.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE identity ADD common_name VARCHAR(255) NOT NULL');
$this->addSql('CREATE FULLTEXT INDEX idxft_identity_commonname ON identity (common_name)');
@@ -22,9 +41,14 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP INDEX idxft_identity_commonname ON identity');
- $this->addSql('ALTER TABLE identity DROP common_name, CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
+ $this->addSql(
+ 'ALTER TABLE identity DROP common_name, CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20141119093423.php b/src/Surfnet/Migrations/Version20141119093423.php
index d20eb3c7e..b7d6b81ea 100644
--- a/src/Surfnet/Migrations/Version20141119093423.php
+++ b/src/Surfnet/Migrations/Version20141119093423.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE unverified_second_factor ADD verification_code_nonce VARCHAR(64) NOT NULL, ADD email_verified TINYINT(1) NOT NULL');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor ADD verification_code_nonce VARCHAR(64) NOT NULL, ADD email_verified TINYINT(1) NOT NULL',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE unverified_second_factor DROP verification_code_nonce, DROP email_verified');
}
}
diff --git a/src/Surfnet/Migrations/Version20141119113444.php b/src/Surfnet/Migrations/Version20141119113444.php
index 1e445ca3f..9227046b0 100644
--- a/src/Surfnet/Migrations/Version20141119113444.php
+++ b/src/Surfnet/Migrations/Version20141119113444.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE unverified_second_factor CHANGE verification_code_nonce email_verification_code_nonce VARCHAR(64) NOT NULL');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor CHANGE verification_code_nonce email_verification_code_nonce VARCHAR(64) NOT NULL',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE unverified_second_factor CHANGE email_verification_code_nonce verification_code_nonce VARCHAR(64) NOT NULL');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor CHANGE email_verification_code_nonce verification_code_nonce VARCHAR(64) NOT NULL',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20141119113553.php b/src/Surfnet/Migrations/Version20141119113553.php
index 3cbcc192f..9219c2c06 100644
--- a/src/Surfnet/Migrations/Version20141119113553.php
+++ b/src/Surfnet/Migrations/Version20141119113553.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE unverified_second_factor CHANGE email_verification_code_nonce email_verification_code_nonce VARCHAR(64) DEFAULT NULL');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor CHANGE email_verification_code_nonce email_verification_code_nonce VARCHAR(64) DEFAULT NULL',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE unverified_second_factor CHANGE email_verification_code_nonce email_verification_code_nonce VARCHAR(64) NOT NULL');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor CHANGE email_verification_code_nonce email_verification_code_nonce VARCHAR(64) NOT NULL',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20141120150430.php b/src/Surfnet/Migrations/Version20141120150430.php
index b14d9c800..8052f5031 100644
--- a/src/Surfnet/Migrations/Version20141120150430.php
+++ b/src/Surfnet/Migrations/Version20141120150430.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE unverified_second_factor CHANGE email_verification_code_nonce email_verification_nonce VARCHAR(64) DEFAULT NULL');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor CHANGE email_verification_code_nonce email_verification_nonce VARCHAR(64) DEFAULT NULL',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE unverified_second_factor CHANGE email_verification_nonce email_verification_code_nonce VARCHAR(64) DEFAULT NULL');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor CHANGE email_verification_nonce email_verification_code_nonce VARCHAR(64) DEFAULT NULL',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20141120152310.php b/src/Surfnet/Migrations/Version20141120152310.php
index 322f2d0fa..4801976d6 100644
--- a/src/Surfnet/Migrations/Version20141120152310.php
+++ b/src/Surfnet/Migrations/Version20141120152310.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE unverified_second_factor DROP email_verification_nonce');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE unverified_second_factor ADD email_verification_nonce VARCHAR(64) DEFAULT NULL');
}
}
diff --git a/src/Surfnet/Migrations/Version20141125154133.php b/src/Surfnet/Migrations/Version20141125154133.php
index d4f9b2944..f26870c78 100644
--- a/src/Surfnet/Migrations/Version20141125154133.php
+++ b/src/Surfnet/Migrations/Version20141125154133.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE unverified_second_factor ADD email_verification_nonce VARCHAR(32) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE unverified_second_factor DROP email_verification_nonce');
}
}
diff --git a/src/Surfnet/Migrations/Version20141125154214.php b/src/Surfnet/Migrations/Version20141125154214.php
index 399e2b0fb..be52f6174 100644
--- a/src/Surfnet/Migrations/Version20141125154214.php
+++ b/src/Surfnet/Migrations/Version20141125154214.php
@@ -1,9 +1,24 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE identity CHANGE institution institution VARCHAR(255) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE identity CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'ALTER TABLE identity CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20141125155001.php b/src/Surfnet/Migrations/Version20141125155001.php
index e29a5e1e1..731e9e24e 100644
--- a/src/Surfnet/Migrations/Version20141125155001.php
+++ b/src/Surfnet/Migrations/Version20141125155001.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE unverified_second_factor DROP email_verified');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE unverified_second_factor ADD email_verified TINYINT(1) NOT NULL');
}
}
diff --git a/src/Surfnet/Migrations/Version20141125173004.php b/src/Surfnet/Migrations/Version20141125173004.php
index 0026a52ec..f8df2b3a6 100644
--- a/src/Surfnet/Migrations/Version20141125173004.php
+++ b/src/Surfnet/Migrations/Version20141125173004.php
@@ -18,25 +18,17 @@
namespace Surfnet\Migrations;
-use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
-use Symfony\Component\DependencyInjection\ContainerAwareInterface;
-use Symfony\Component\DependencyInjection\ContainerInterface;
+use Doctrine\Migrations\AbstractMigration;
+use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationInterface;
+use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationTrait;
/**
* Auto-generated Migration: Please modify to your needs!
*/
-class Version20141125173004 extends AbstractMigration implements ContainerAwareInterface
+class Version20141125173004 extends AbstractMigration implements ConfigurationAwareMigrationInterface
{
- /**
- * @var ContainerInterface
- */
- private $container;
-
- public function setContainer(ContainerInterface $container = null)
- {
- $this->container = $container;
- }
+ use ConfigurationAwareMigrationTrait;
public function up(Schema $schema): void
{
@@ -44,31 +36,36 @@ public function up(Schema $schema): void
$middlewareUser = $this->getMiddlewareUser();
// this up() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql(sprintf('CREATE TABLE %s.saml_entity (entity_id VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, configuration LONGTEXT NOT NULL, PRIMARY KEY(entity_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB', $gatewaySchema));
- $this->addSql(sprintf("GRANT DELETE,INSERT,SELECT,UPDATE ON %s.saml_entity TO %s", $gatewaySchema, $middlewareUser));
+ $this->addSql(
+ sprintf(
+ 'CREATE TABLE %s.saml_entity (entity_id VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, configuration LONGTEXT NOT NULL, PRIMARY KEY(entity_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ $gatewaySchema,
+ ),
+ );
+ $this->addSql(
+ sprintf("GRANT DELETE,INSERT,SELECT,UPDATE ON %s.saml_entity TO %s", $gatewaySchema, $middlewareUser),
+ );
}
public function down(Schema $schema): void
{
- $gatewaySchema = $this->getGatewaySchema();
+ $gatewaySchema = $this->getGatewaySchema();
$middlewareUser = $this->getMiddlewareUser();
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql(sprintf("REVOKE DELETE,INSERT,SELECT,UPDATE ON %s.saml_entity FROM %s", $gatewaySchema, $middlewareUser));
+ $this->addSql(
+ sprintf("REVOKE DELETE,INSERT,SELECT,UPDATE ON %s.saml_entity FROM %s", $gatewaySchema, $middlewareUser),
+ );
$this->addSql(sprintf('DROP TABLE %s.saml_entity', $gatewaySchema));
}
-
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
-
- private function getMiddlewareUser()
- {
- return $this->container->getParameter('database_middleware_user');
- }
}
diff --git a/src/Surfnet/Migrations/Version20141128143908.php b/src/Surfnet/Migrations/Version20141128143908.php
index 0c59c46f9..3473c4d01 100644
--- a/src/Surfnet/Migrations/Version20141128143908.php
+++ b/src/Surfnet/Migrations/Version20141128143908.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('CREATE TABLE verified_second_factor (id VARCHAR(36) NOT NULL, identity_id VARCHAR(36) DEFAULT NULL, type VARCHAR(16) NOT NULL, second_factor_identifier VARCHAR(32) NOT NULL, INDEX IDX_7964F91CFF3ED4A8 (identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
- $this->addSql('ALTER TABLE verified_second_factor ADD CONSTRAINT FK_7964F91CFF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'CREATE TABLE verified_second_factor (id VARCHAR(36) NOT NULL, identity_id VARCHAR(36) DEFAULT NULL, type VARCHAR(16) NOT NULL, second_factor_identifier VARCHAR(32) NOT NULL, INDEX IDX_7964F91CFF3ED4A8 (identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
+ $this->addSql(
+ 'ALTER TABLE verified_second_factor ADD CONSTRAINT FK_7964F91CFF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)',
+ );
$this->addSql('ALTER TABLE unverified_second_factor DROP email_verification_nonce');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('DROP TABLE verified_second_factor');
- $this->addSql('ALTER TABLE unverified_second_factor ADD email_verification_nonce VARCHAR(32) NOT NULL COLLATE utf8_unicode_ci');
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor ADD email_verification_nonce VARCHAR(32) NOT NULL COLLATE utf8_unicode_ci',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20141128143946.php b/src/Surfnet/Migrations/Version20141128143946.php
index abfc0f4b2..3a4763528 100644
--- a/src/Surfnet/Migrations/Version20141128143946.php
+++ b/src/Surfnet/Migrations/Version20141128143946.php
@@ -1,9 +1,24 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE identity CHANGE institution institution VARCHAR(255) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE identity CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'ALTER TABLE identity CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20141202121811.php b/src/Surfnet/Migrations/Version20141202121811.php
index deb04e016..0fa7aeac4 100644
--- a/src/Surfnet/Migrations/Version20141202121811.php
+++ b/src/Surfnet/Migrations/Version20141202121811.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('DROP TABLE second_factor');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('CREATE TABLE second_factor (id VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci, identity_id VARCHAR(36) DEFAULT NULL COLLATE utf8_unicode_ci, type VARCHAR(16) NOT NULL COLLATE utf8_unicode_ci, second_factor_identifier VARCHAR(32) NOT NULL COLLATE utf8_unicode_ci, INDEX IDX_1806C29EFF3ED4A8 (identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
- $this->addSql('ALTER TABLE second_factor ADD CONSTRAINT FK_1806C29EFF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'CREATE TABLE second_factor (id VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci, identity_id VARCHAR(36) DEFAULT NULL COLLATE utf8_unicode_ci, type VARCHAR(16) NOT NULL COLLATE utf8_unicode_ci, second_factor_identifier VARCHAR(32) NOT NULL COLLATE utf8_unicode_ci, INDEX IDX_1806C29EFF3ED4A8 (identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
+ $this->addSql(
+ 'ALTER TABLE second_factor ADD CONSTRAINT FK_1806C29EFF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20141204140639.php b/src/Surfnet/Migrations/Version20141204140639.php
index 69082e89b..1952502ff 100644
--- a/src/Surfnet/Migrations/Version20141204140639.php
+++ b/src/Surfnet/Migrations/Version20141204140639.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE verified_second_factor ADD registration_code VARCHAR(8) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE verified_second_factor DROP registration_code');
}
}
diff --git a/src/Surfnet/Migrations/Version20141205112641.php b/src/Surfnet/Migrations/Version20141205112641.php
index bb879c9e3..6567d3889 100644
--- a/src/Surfnet/Migrations/Version20141205112641.php
+++ b/src/Surfnet/Migrations/Version20141205112641.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE raa (id INT AUTO_INCREMENT NOT NULL, institution VARCHAR(150) NOT NULL, name_id VARCHAR(150) NOT NULL, location LONGTEXT DEFAULT NULL, contact_information LONGTEXT DEFAULT NULL, INDEX idx_raa_institution (institution), INDEX idx_raa_institution_nameid (institution, name_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE raa (id INT AUTO_INCREMENT NOT NULL, institution VARCHAR(150) NOT NULL, name_id VARCHAR(150) NOT NULL, location LONGTEXT DEFAULT NULL, contact_information LONGTEXT DEFAULT NULL, INDEX idx_raa_institution (institution), INDEX idx_raa_institution_nameid (institution, name_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE raa');
}
diff --git a/src/Surfnet/Migrations/Version20141208121040.php b/src/Surfnet/Migrations/Version20141208121040.php
index 90fbc1363..170013440 100644
--- a/src/Surfnet/Migrations/Version20141208121040.php
+++ b/src/Surfnet/Migrations/Version20141208121040.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE sraa (name_id VARCHAR(200) NOT NULL, PRIMARY KEY(name_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE sraa (name_id VARCHAR(200) NOT NULL, PRIMARY KEY(name_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE sraa');
}
diff --git a/src/Surfnet/Migrations/Version20141208162045.php b/src/Surfnet/Migrations/Version20141208162045.php
index 965523040..3f56ce5ba 100644
--- a/src/Surfnet/Migrations/Version20141208162045.php
+++ b/src/Surfnet/Migrations/Version20141208162045.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('CREATE TABLE vetted_second_factor (id VARCHAR(36) NOT NULL, identity_id VARCHAR(36) DEFAULT NULL, type VARCHAR(16) NOT NULL, second_factor_identifier VARCHAR(32) NOT NULL, INDEX IDX_29F96B72FF3ED4A8 (identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
- $this->addSql('ALTER TABLE vetted_second_factor ADD CONSTRAINT FK_29F96B72FF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'CREATE TABLE vetted_second_factor (id VARCHAR(36) NOT NULL, identity_id VARCHAR(36) DEFAULT NULL, type VARCHAR(16) NOT NULL, second_factor_identifier VARCHAR(32) NOT NULL, INDEX IDX_29F96B72FF3ED4A8 (identity_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
+ $this->addSql(
+ 'ALTER TABLE vetted_second_factor ADD CONSTRAINT FK_29F96B72FF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('DROP TABLE vetted_second_factor');
}
}
diff --git a/src/Surfnet/Migrations/Version20141208172438.php b/src/Surfnet/Migrations/Version20141208172438.php
index 3df379086..dc8afb8ea 100644
--- a/src/Surfnet/Migrations/Version20141208172438.php
+++ b/src/Surfnet/Migrations/Version20141208172438.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE ra (id INT AUTO_INCREMENT NOT NULL, institution VARCHAR(150) NOT NULL, name_id VARCHAR(150) NOT NULL, location LONGTEXT DEFAULT NULL, contact_information LONGTEXT DEFAULT NULL, INDEX idx_ra_institution (institution), INDEX idx_ra_institution_nameid (institution, name_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE ra (id INT AUTO_INCREMENT NOT NULL, institution VARCHAR(150) NOT NULL, name_id VARCHAR(150) NOT NULL, location LONGTEXT DEFAULT NULL, contact_information LONGTEXT DEFAULT NULL, INDEX idx_ra_institution (institution), INDEX idx_ra_institution_nameid (institution, name_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE ra');
}
diff --git a/src/Surfnet/Migrations/Version20141209150426.php b/src/Surfnet/Migrations/Version20141209150426.php
index 241b96afc..3bb0ee217 100644
--- a/src/Surfnet/Migrations/Version20141209150426.php
+++ b/src/Surfnet/Migrations/Version20141209150426.php
@@ -1,67 +1,79 @@
container = $container;
- }
public function up(Schema $schema): void
{
- $gatewaySchema = $this->getGatewaySchema();
+ $gatewaySchema = $this->getGatewaySchema();
$middlewareUser = $this->getMiddlewareUser();
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql(sprintf(
- 'CREATE TABLE %s.second_factor (identity_id VARCHAR(36) NOT NULL, name_id VARCHAR(200) NOT NULL, institution VARCHAR(200) NOT NULL, second_factor_id VARCHAR(36) NOT NULL, second_factor_type VARCHAR(50) NOT NULL, second_factor_identifier VARCHAR(100) NOT NULL, INDEX idx_secondfactor_nameid (name_id), PRIMARY KEY(identity_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
- $gatewaySchema
- ));
- $this->addSql(sprintf(
- 'GRANT DELETE,INSERT,SELECT,UPDATE ON %s.second_factor TO %s',
- $gatewaySchema,
- $middlewareUser
- ));
+ $this->addSql(
+ sprintf(
+ 'CREATE TABLE %s.second_factor (identity_id VARCHAR(36) NOT NULL, name_id VARCHAR(200) NOT NULL, institution VARCHAR(200) NOT NULL, second_factor_id VARCHAR(36) NOT NULL, second_factor_type VARCHAR(50) NOT NULL, second_factor_identifier VARCHAR(100) NOT NULL, INDEX idx_secondfactor_nameid (name_id), PRIMARY KEY(identity_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ $gatewaySchema,
+ ),
+ );
+ $this->addSql(
+ sprintf(
+ 'GRANT DELETE,INSERT,SELECT,UPDATE ON %s.second_factor TO %s',
+ $gatewaySchema,
+ $middlewareUser,
+ ),
+ );
}
public function down(Schema $schema): void
{
- $gatewaySchema = $this->getGatewaySchema();
+ $gatewaySchema = $this->getGatewaySchema();
$middlewareUser = $this->getMiddlewareUser();
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql(sprintf(
- 'REVOKE DELETE,INSERT,SELECT,UPDATE ON %s.second_factor FROM %s',
- $gatewaySchema,
- $middlewareUser
- ));
+ $this->addSql(
+ sprintf(
+ 'REVOKE DELETE,INSERT,SELECT,UPDATE ON %s.second_factor FROM %s',
+ $gatewaySchema,
+ $middlewareUser,
+ ),
+ );
$this->addSql('DROP TABLE second_factor');
}
-
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
-
- private function getMiddlewareUser()
- {
- return $this->container->getParameter('database_middleware_user');
- }
}
diff --git a/src/Surfnet/Migrations/Version20141210174213.php b/src/Surfnet/Migrations/Version20141210174213.php
index ceeaba13a..d0a4ff6ab 100644
--- a/src/Surfnet/Migrations/Version20141210174213.php
+++ b/src/Surfnet/Migrations/Version20141210174213.php
@@ -1,54 +1,65 @@
getGatewaySchema();
+ $gatewaySchema = $this->getGatewaySchema();
// this up() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql(sprintf('ALTER TABLE %s.second_factor DROP PRIMARY KEY', $gatewaySchema));
$this->addSql(sprintf('ALTER TABLE %s.second_factor ADD id INT NOT NULL FIRST', $gatewaySchema));
$this->addSql(sprintf('ALTER TABLE %s.second_factor ADD PRIMARY KEY (id)', $gatewaySchema));
- $this->addSql(sprintf('ALTER TABLE %s.second_factor CHANGE id id INT AUTO_INCREMENT NOT NULL FIRST', $gatewaySchema));
+ $this->addSql(
+ sprintf('ALTER TABLE %s.second_factor CHANGE id id INT AUTO_INCREMENT NOT NULL FIRST', $gatewaySchema),
+ );
}
public function down(Schema $schema): void
{
- $gatewaySchema = $this->getGatewaySchema();
+ $gatewaySchema = $this->getGatewaySchema();
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql(sprintf('ALTER TABLE %s.second_factor DROP PRIMARY KEY', $gatewaySchema));
$this->addSql(sprintf('ALTER TABLE %s.second_factor DROP id', $gatewaySchema));
$this->addSql(sprintf('ALTER TABLE %s.second_factor ADD PRIMARY KEY (identity_id)', $gatewaySchema));
}
-
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
-
- public function setContainer(ContainerInterface $container = null)
- {
- $this->container = $container;
- }
}
diff --git a/src/Surfnet/Migrations/Version20141215150518.php b/src/Surfnet/Migrations/Version20141215150518.php
index 3974a3855..97f046187 100644
--- a/src/Surfnet/Migrations/Version20141215150518.php
+++ b/src/Surfnet/Migrations/Version20141215150518.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE unverified_second_factor ADD verification_nonce VARCHAR(32) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE unverified_second_factor DROP verification_nonce');
}
}
diff --git a/src/Surfnet/Migrations/Version20150217122017.php b/src/Surfnet/Migrations/Version20150217122017.php
index 878a85844..5b8bfea1b 100644
--- a/src/Surfnet/Migrations/Version20150217122017.php
+++ b/src/Surfnet/Migrations/Version20150217122017.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE unverified_second_factor ADD verification_nonce_valid_until DATETIME NOT NULL');
}
@@ -21,7 +40,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE unverified_second_factor DROP verification_nonce_valid_until');
}
diff --git a/src/Surfnet/Migrations/Version20150225155343.php b/src/Surfnet/Migrations/Version20150225155343.php
index b93b57747..07f7c92c6 100644
--- a/src/Surfnet/Migrations/Version20150225155343.php
+++ b/src/Surfnet/Migrations/Version20150225155343.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('CREATE TABLE ra_second_factor (id VARCHAR(36) NOT NULL, type VARCHAR(16) NOT NULL, second_factor_id VARCHAR(36) NOT NULL, status VARCHAR(10) NOT NULL, identity_id VARCHAR(36) NOT NULL, institution VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, INDEX idx_ra_second_factor_type (type), INDEX idx_ra_second_factor_second_factor_id (second_factor_id), INDEX idx_ra_second_factor_status (status), INDEX idx_ra_second_factor_identity_id (identity_id), INDEX idx_ra_second_factor_institution (institution), INDEX idx_ra_second_factor_name (name), INDEX idx_ra_second_factor_email (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'CREATE TABLE ra_second_factor (id VARCHAR(36) NOT NULL, type VARCHAR(16) NOT NULL, second_factor_id VARCHAR(36) NOT NULL, status VARCHAR(10) NOT NULL, identity_id VARCHAR(36) NOT NULL, institution VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, INDEX idx_ra_second_factor_type (type), INDEX idx_ra_second_factor_second_factor_id (second_factor_id), INDEX idx_ra_second_factor_status (status), INDEX idx_ra_second_factor_identity_id (identity_id), INDEX idx_ra_second_factor_institution (institution), INDEX idx_ra_second_factor_name (name), INDEX idx_ra_second_factor_email (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('DROP TABLE ra_second_factor');
}
}
diff --git a/src/Surfnet/Migrations/Version20150305114932.php b/src/Surfnet/Migrations/Version20150305114932.php
index 6c4b83f9c..25d09c2f6 100644
--- a/src/Surfnet/Migrations/Version20150305114932.php
+++ b/src/Surfnet/Migrations/Version20150305114932.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('DROP INDEX idx_ra_second_factor_type ON ra_second_factor');
$this->addSql('DROP INDEX idx_ra_second_factor_status ON ra_second_factor');
$this->addSql('DROP INDEX idx_ra_second_factor_name ON ra_second_factor');
@@ -24,8 +43,11 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('CREATE INDEX idx_ra_second_factor_type ON ra_second_factor (type)');
$this->addSql('CREATE INDEX idx_ra_second_factor_status ON ra_second_factor (status)');
$this->addSql('CREATE INDEX idx_ra_second_factor_name ON ra_second_factor (name)');
diff --git a/src/Surfnet/Migrations/Version20150305115030.php b/src/Surfnet/Migrations/Version20150305115030.php
index b695f0ec7..f2c58e05e 100644
--- a/src/Surfnet/Migrations/Version20150305115030.php
+++ b/src/Surfnet/Migrations/Version20150305115030.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('CREATE FULLTEXT INDEX idx_ra_second_factor_name ON ra_second_factor (name)');
$this->addSql('CREATE FULLTEXT INDEX idx_ra_second_factor_email ON ra_second_factor (email)');
}
@@ -22,8 +41,11 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('DROP INDEX idx_ra_second_factor_name ON ra_second_factor');
$this->addSql('DROP INDEX idx_ra_second_factor_email ON ra_second_factor');
}
diff --git a/src/Surfnet/Migrations/Version20150305134846.php b/src/Surfnet/Migrations/Version20150305134846.php
index a7dffdd5f..9ecfc3b85 100644
--- a/src/Surfnet/Migrations/Version20150305134846.php
+++ b/src/Surfnet/Migrations/Version20150305134846.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE ra_second_factor ADD status_int INT NOT NULL');
$this->addSql('UPDATE ra_second_factor SET status_int=0 WHERE `status`="unverified"');
$this->addSql('UPDATE ra_second_factor SET status_int=10 WHERE `status`="verified"');
@@ -27,9 +46,14 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('ALTER TABLE ra_second_factor CHANGE `status` `status` VARCHAR(10) NOT NULL COLLATE utf8_unicode_ci');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'ALTER TABLE ra_second_factor CHANGE `status` `status` VARCHAR(10) NOT NULL COLLATE utf8_unicode_ci',
+ );
$this->addSql('ALTER TABLE ra_second_factor ADD status_string VARCHAR(10) NOT NULL COLLATE utf8_unicode_ci');
$this->addSql('UPDATE ra_second_factor SET status_string="unverified" WHERE `status`=0');
@@ -37,6 +61,8 @@ public function down(Schema $schema): void
$this->addSql('UPDATE ra_second_factor SET status_string="vetted" WHERE `status`=20');
$this->addSql('UPDATE ra_second_factor SET status_string="revoked" WHERE `status`=30');
$this->addSql('ALTER TABLE ra_second_factor DROP `status`');
- $this->addSql('ALTER TABLE ra_second_factor CHANGE status_string `status` VARCHAR(10) NOT NULL COLLATE utf8_unicode_ci');
+ $this->addSql(
+ 'ALTER TABLE ra_second_factor CHANGE status_string `status` VARCHAR(10) NOT NULL COLLATE utf8_unicode_ci',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20150312134629.php b/src/Surfnet/Migrations/Version20150312134629.php
index 4a9e21420..f1b78a853 100644
--- a/src/Surfnet/Migrations/Version20150312134629.php
+++ b/src/Surfnet/Migrations/Version20150312134629.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE ra_second_factor CHANGE second_factor_id second_factor_id VARCHAR(255) NOT NULL');
- $this->addSql('ALTER TABLE verified_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(255) NOT NULL');
- $this->addSql('ALTER TABLE unverified_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(255) NOT NULL');
- $this->addSql('ALTER TABLE vetted_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(255) NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE verified_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(255) NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(255) NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE vetted_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(255) NOT NULL',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('ALTER TABLE ra_second_factor CHANGE second_factor_id second_factor_id VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE unverified_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(32) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE verified_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(32) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE vetted_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(32) NOT NULL COLLATE utf8_unicode_ci');
+ $this->addSql(
+ 'ALTER TABLE ra_second_factor CHANGE second_factor_id second_factor_id VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(32) NOT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE verified_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(32) NOT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE vetted_second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(32) NOT NULL COLLATE utf8_unicode_ci',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20150312162849.php b/src/Surfnet/Migrations/Version20150312162849.php
index d64679266..170300ecf 100644
--- a/src/Surfnet/Migrations/Version20150312162849.php
+++ b/src/Surfnet/Migrations/Version20150312162849.php
@@ -1,48 +1,66 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $gatewaySchema = $this->container->getParameter('database_gateway_name');
- $this->addSql(sprintf(
- 'ALTER TABLE %s.second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(255) NOT NULL',
- $gatewaySchema
- ));
+ $gatewaySchema = $this->getGatewaySchema();
+ $this->addSql(
+ sprintf(
+ 'ALTER TABLE %s.second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(255) NOT NULL',
+ $gatewaySchema,
+ ),
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $gatewaySchema = $this->container->getParameter('database_gateway_name');
- $this->addSql(sprintf(
- 'ALTER TABLE %s.second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci',
- $gatewaySchema
- ));
- }
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- public function setContainer(ContainerInterface $container = null)
- {
- $this->container = $container;
+ $gatewaySchema = $this->getGatewaySchema();
+ $this->addSql(
+ sprintf(
+ 'ALTER TABLE %s.second_factor CHANGE second_factor_identifier second_factor_identifier VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci',
+ $gatewaySchema,
+ ),
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20150330160809.php b/src/Surfnet/Migrations/Version20150330160809.php
index 860e24ea7..4bb54cecc 100644
--- a/src/Surfnet/Migrations/Version20150330160809.php
+++ b/src/Surfnet/Migrations/Version20150330160809.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('CREATE TABLE audit_log (id INT AUTO_INCREMENT NOT NULL, actor_id VARCHAR(36) DEFAULT NULL, actor_institution VARCHAR(255) DEFAULT NULL, identity_id VARCHAR(36) NOT NULL, identity_institution VARCHAR(255) NOT NULL, second_factor_id VARCHAR(36) DEFAULT NULL, second_factor_type VARCHAR(36) DEFAULT NULL, action VARCHAR(255) NOT NULL, recorded_on DATETIME NOT NULL, INDEX idx_auditlog_actorid (actor_id), INDEX idx_auditlog_identityid (identity_id), INDEX idx_auditlog_identityinstitution (identity_institution), INDEX idx_auditlog_secondfactorid (second_factor_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'CREATE TABLE audit_log (id INT AUTO_INCREMENT NOT NULL, actor_id VARCHAR(36) DEFAULT NULL, actor_institution VARCHAR(255) DEFAULT NULL, identity_id VARCHAR(36) NOT NULL, identity_institution VARCHAR(255) NOT NULL, second_factor_id VARCHAR(36) DEFAULT NULL, second_factor_type VARCHAR(36) DEFAULT NULL, action VARCHAR(255) NOT NULL, recorded_on DATETIME NOT NULL, INDEX idx_auditlog_actorid (actor_id), INDEX idx_auditlog_identityid (identity_id), INDEX idx_auditlog_identityinstitution (identity_institution), INDEX idx_auditlog_secondfactorid (second_factor_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('DROP TABLE audit_log');
}
}
diff --git a/src/Surfnet/Migrations/Version20150407103950.php b/src/Surfnet/Migrations/Version20150407103950.php
index 43c12e88f..c8e92a004 100644
--- a/src/Surfnet/Migrations/Version20150407103950.php
+++ b/src/Surfnet/Migrations/Version20150407103950.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE audit_log CHANGE action event VARCHAR(255) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('ALTER TABLE audit_log CHANGE event action VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
}
}
diff --git a/src/Surfnet/Migrations/Version20150408122247.php b/src/Surfnet/Migrations/Version20150408122247.php
index f4246dd90..8cfb9fef3 100644
--- a/src/Surfnet/Migrations/Version20150408122247.php
+++ b/src/Surfnet/Migrations/Version20150408122247.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE identity_identifying_data (id VARCHAR(36) NOT NULL, common_name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE identity_identifying_data (id VARCHAR(36) NOT NULL, common_name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE identity_identifying_data');
}
diff --git a/src/Surfnet/Migrations/Version20150409142404.php b/src/Surfnet/Migrations/Version20150409142404.php
index 648242cbe..c64f5fc02 100644
--- a/src/Surfnet/Migrations/Version20150409142404.php
+++ b/src/Surfnet/Migrations/Version20150409142404.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
- $this->addSql('CREATE TABLE email_templates (id VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, locale VARCHAR(255) NOT NULL, html_content LONGTEXT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
+ $this->addSql(
+ 'CREATE TABLE email_templates (id VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, locale VARCHAR(255) NOT NULL, html_content LONGTEXT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
-
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+
$this->addSql('DROP TABLE email_templates');
}
}
diff --git a/src/Surfnet/Migrations/Version20150422162952.php b/src/Surfnet/Migrations/Version20150422162952.php
index dafdf7a67..4919e38ec 100644
--- a/src/Surfnet/Migrations/Version20150422162952.php
+++ b/src/Surfnet/Migrations/Version20150422162952.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE ra_listing (identity_id VARCHAR(36) NOT NULL, institution VARCHAR(255) NOT NULL, common_name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, role VARCHAR(20) NOT NULL, location LONGTEXT DEFAULT NULL, contact_information LONGTEXT DEFAULT NULL, INDEX idx_ra_listing_institution (institution), PRIMARY KEY(identity_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE ra_listing (identity_id VARCHAR(36) NOT NULL, institution VARCHAR(255) NOT NULL, common_name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, role VARCHAR(20) NOT NULL, location LONGTEXT DEFAULT NULL, contact_information LONGTEXT DEFAULT NULL, INDEX idx_ra_listing_institution (institution), PRIMARY KEY(identity_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
/**
@@ -27,7 +48,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE ra_listing');
}
diff --git a/src/Surfnet/Migrations/Version20150428153351.php b/src/Surfnet/Migrations/Version20150428153351.php
index 94951e476..a3864a6e2 100644
--- a/src/Surfnet/Migrations/Version20150428153351.php
+++ b/src/Surfnet/Migrations/Version20150428153351.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE ra_candidate (identity_id VARCHAR(36) NOT NULL, institution VARCHAR(255) NOT NULL, common_name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, INDEX idx_ra_candidate_institution (institution), FULLTEXT INDEX idxft_ra_candidate_email (email), FULLTEXT INDEX idxft_ra_candidate_commonname (common_name), PRIMARY KEY(identity_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE ra_candidate (identity_id VARCHAR(36) NOT NULL, institution VARCHAR(255) NOT NULL, common_name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, INDEX idx_ra_candidate_institution (institution), FULLTEXT INDEX idxft_ra_candidate_email (email), FULLTEXT INDEX idxft_ra_candidate_commonname (common_name), PRIMARY KEY(identity_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
/**
@@ -27,7 +48,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE ra_candidate');
}
diff --git a/src/Surfnet/Migrations/Version20150428174400.php b/src/Surfnet/Migrations/Version20150428174400.php
index b97ae1c11..e1bbbb113 100644
--- a/src/Surfnet/Migrations/Version20150428174400.php
+++ b/src/Surfnet/Migrations/Version20150428174400.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE institution_listing (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE institution_listing (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
/**
@@ -27,7 +48,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE institution_listing');
}
diff --git a/src/Surfnet/Migrations/Version20150501123735.php b/src/Surfnet/Migrations/Version20150501123735.php
index 8de4fa345..fc2221cd7 100644
--- a/src/Surfnet/Migrations/Version20150501123735.php
+++ b/src/Surfnet/Migrations/Version20150501123735.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE audit_log ADD COLUMN uuid VARCHAR(36) DEFAULT NULL');
$this->addSql('UPDATE audit_log set uuid = UUID() WHERE 1 = 1');
@@ -33,7 +52,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE audit_log DROP PRIMARY KEY');
$this->addSql('ALTER TABLE audit_log CHANGE id uuid VARCHAR(36)');
diff --git a/src/Surfnet/Migrations/Version20150504102420.php b/src/Surfnet/Migrations/Version20150504102420.php
index 191d75e72..968e9b8ad 100644
--- a/src/Surfnet/Migrations/Version20150504102420.php
+++ b/src/Surfnet/Migrations/Version20150504102420.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE ra_candidate ADD name_id VARCHAR(255) NOT NULL');
$this->addSql('CREATE INDEX idx_ra_candidate_name_id ON ra_candidate (name_id)');
@@ -28,7 +47,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP INDEX idx_ra_candidate_name_id ON ra_candidate');
$this->addSql('ALTER TABLE ra_candidate DROP name_id');
diff --git a/src/Surfnet/Migrations/Version20150507124421.php b/src/Surfnet/Migrations/Version20150507124421.php
index 2f9f754ac..a04bda692 100644
--- a/src/Surfnet/Migrations/Version20150507124421.php
+++ b/src/Surfnet/Migrations/Version20150507124421.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE raa ADD COLUMN uuid VARCHAR(36) DEFAULT NULL');
$this->addSql('UPDATE raa set uuid = UUID() WHERE 1 = 1');
@@ -34,8 +53,12 @@ public function up(Schema $schema): void
$this->addSql('ALTER TABLE ra CHANGE uuid id VARCHAR(36) NOT NULL');
$this->addSql('ALTER TABLE ra ADD PRIMARY KEY (id)');
- $this->addSql('ALTER TABLE raa CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE name_id name_id VARCHAR(255) NOT NULL');
- $this->addSql('ALTER TABLE ra CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE name_id name_id VARCHAR(255) NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE raa CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE name_id name_id VARCHAR(255) NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE ra CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE name_id name_id VARCHAR(255) NOT NULL',
+ );
}
/**
@@ -44,7 +67,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE ra DROP PRIMARY KEY');
$this->addSql('ALTER TABLE ra CHANGE id uuid VARCHAR(36)');
@@ -56,7 +82,11 @@ public function down(Schema $schema): void
$this->addSql('ALTER TABLE raa ADD id INT PRIMARY KEY AUTO_INCREMENT');
$this->addSql('ALTER TABLE raa DROP COLUMN uuid');
- $this->addSql('ALTER TABLE ra CHANGE institution institution VARCHAR(150) NOT NULL COLLATE utf8_unicode_ci, CHANGE name_id name_id VARCHAR(150) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE raa CHANGE institution institution VARCHAR(150) NOT NULL COLLATE utf8_unicode_ci, CHANGE name_id name_id VARCHAR(150) NOT NULL COLLATE utf8_unicode_ci');
+ $this->addSql(
+ 'ALTER TABLE ra CHANGE institution institution VARCHAR(150) NOT NULL COLLATE utf8_unicode_ci, CHANGE name_id name_id VARCHAR(150) NOT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE raa CHANGE institution institution VARCHAR(150) NOT NULL COLLATE utf8_unicode_ci, CHANGE name_id name_id VARCHAR(150) NOT NULL COLLATE utf8_unicode_ci',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20150508085838.php b/src/Surfnet/Migrations/Version20150508085838.php
index 00e42a776..43b0c7c65 100644
--- a/src/Surfnet/Migrations/Version20150508085838.php
+++ b/src/Surfnet/Migrations/Version20150508085838.php
@@ -1,26 +1,34 @@
container = $container;
- }
+ use ConfigurationAwareMigrationTrait;
/**
* @param Schema $schema
@@ -28,7 +36,10 @@ public function setContainer(ContainerInterface $container = null)
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$gatewaySchema = $this->getGatewaySchema();
@@ -47,7 +58,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$gatewaySchema = $this->getGatewaySchema();
@@ -56,12 +70,4 @@ public function down(Schema $schema): void
$this->addSql(sprintf('ALTER TABLE %s.second_factor ADD id INT PRIMARY KEY AUTO_INCREMENT', $gatewaySchema));
$this->addSql(sprintf('ALTER TABLE %s.second_factor DROP COLUMN uuid', $gatewaySchema));
}
-
- /**
- * @return string
- */
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
}
diff --git a/src/Surfnet/Migrations/Version20150518152006.php b/src/Surfnet/Migrations/Version20150518152006.php
index b170bf8f9..9b68543d2 100644
--- a/src/Surfnet/Migrations/Version20150518152006.php
+++ b/src/Surfnet/Migrations/Version20150518152006.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('ALTER TABLE audit_log ADD actor_common_name VARCHAR(255) DEFAULT NULL, ADD second_factor_identifier VARCHAR(255) DEFAULT NULL');
+ $this->addSql(
+ 'ALTER TABLE audit_log ADD actor_common_name VARCHAR(255) DEFAULT NULL, ADD second_factor_identifier VARCHAR(255) DEFAULT NULL',
+ );
}
/**
@@ -27,7 +48,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE audit_log DROP actor_common_name, DROP second_factor_identifier');
}
diff --git a/src/Surfnet/Migrations/Version20150522163053.php b/src/Surfnet/Migrations/Version20150522163053.php
index 7c63440a4..c121b3ab1 100644
--- a/src/Surfnet/Migrations/Version20150522163053.php
+++ b/src/Surfnet/Migrations/Version20150522163053.php
@@ -1,26 +1,34 @@
container = $container;
- }
/**
* @param Schema $schema
@@ -30,7 +38,10 @@ public function up(Schema $schema): void
$gatewaySchema = $this->getGatewaySchema();
// this up() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql(sprintf('ALTER TABLE %s.saml_entity ADD id VARCHAR(36) DEFAULT NULL', $gatewaySchema));
$this->addSql(sprintf('UPDATE %s.saml_entity SET id = UUID() WHERE id IS NULL', $gatewaySchema));
@@ -47,15 +58,14 @@ public function down(Schema $schema): void
$gatewaySchema = $this->getGatewaySchema();
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql(sprintf('ALTER TABLE %s.saml_entity DROP PRIMARY KEY', $gatewaySchema));
$this->addSql(sprintf('ALTER TABLE %s.saml_entity DROP id', $gatewaySchema));
$this->addSql(sprintf('ALTER TABLE %s.saml_entity ADD PRIMARY KEY (entity_id)', $gatewaySchema));
}
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
}
diff --git a/src/Surfnet/Migrations/Version20150522164907.php b/src/Surfnet/Migrations/Version20150522164907.php
index d23388301..9b679a350 100644
--- a/src/Surfnet/Migrations/Version20150522164907.php
+++ b/src/Surfnet/Migrations/Version20150522164907.php
@@ -1,26 +1,34 @@
container = $container;
- }
+ use ConfigurationAwareMigrationTrait;
/**
* @param Schema $schema
@@ -30,9 +38,17 @@ public function up(Schema $schema): void
$gatewaySchema = $this->getGatewaySchema();
// this up() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql(sprintf('CREATE UNIQUE INDEX unq_saml_entity_entity_id_type ON %s.saml_entity (entity_id, type)', $gatewaySchema));
+ $this->addSql(
+ sprintf(
+ 'CREATE UNIQUE INDEX unq_saml_entity_entity_id_type ON %s.saml_entity (entity_id, type)',
+ $gatewaySchema,
+ ),
+ );
}
/**
@@ -43,13 +59,11 @@ public function down(Schema $schema): void
$gatewaySchema = $this->getGatewaySchema();
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql(sprintf('DROP INDEX unq_saml_entity_entity_id_type ON %s.saml_entity', $gatewaySchema));
}
-
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
}
diff --git a/src/Surfnet/Migrations/Version20150526152956.php b/src/Surfnet/Migrations/Version20150526152956.php
index 5c1dbc57c..501dca23f 100644
--- a/src/Surfnet/Migrations/Version20150526152956.php
+++ b/src/Surfnet/Migrations/Version20150526152956.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE identity ADD preferred_locale VARCHAR(255) NOT NULL');
}
@@ -27,7 +46,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE identity DROP preferred_locale');
}
diff --git a/src/Surfnet/Migrations/Version20150528154959.php b/src/Surfnet/Migrations/Version20150528154959.php
index ea2d32e9e..abce6140d 100644
--- a/src/Surfnet/Migrations/Version20150528154959.php
+++ b/src/Surfnet/Migrations/Version20150528154959.php
@@ -1,26 +1,34 @@
container = $container;
- }
+ use ConfigurationAwareMigrationTrait;
/**
* @param Schema $schema
@@ -28,7 +36,10 @@ public function setContainer(ContainerInterface $container = null)
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$gatewaySchema = $this->getGatewaySchema();
@@ -41,18 +52,13 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$gatewaySchema = $this->getGatewaySchema();
$this->addSql(sprintf('ALTER TABLE %s.second_factor DROP display_locale', $gatewaySchema));
}
-
- /**
- * @return string
- */
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
}
diff --git a/src/Surfnet/Migrations/Version20150601154557.php b/src/Surfnet/Migrations/Version20150601154557.php
index f5b39cd64..051ad51d3 100644
--- a/src/Surfnet/Migrations/Version20150601154557.php
+++ b/src/Surfnet/Migrations/Version20150601154557.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE ra');
}
@@ -27,8 +46,13 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE ra (id VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci, institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, location LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, contact_information LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, INDEX idx_ra_institution (institution), INDEX idx_ra_institution_nameid (institution, name_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE ra (id VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci, institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, location LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, contact_information LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, INDEX idx_ra_institution (institution), INDEX idx_ra_institution_nameid (institution, name_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20150601154942.php b/src/Surfnet/Migrations/Version20150601154942.php
index 52f783270..cf8ea69e6 100644
--- a/src/Surfnet/Migrations/Version20150601154942.php
+++ b/src/Surfnet/Migrations/Version20150601154942.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE raa');
}
@@ -27,8 +46,13 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE raa (id VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci, institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, location LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, contact_information LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, INDEX idx_raa_institution (institution), INDEX idx_raa_institution_nameid (institution, name_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE raa (id VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci, institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, location LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, contact_information LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, INDEX idx_raa_institution (institution), INDEX idx_raa_institution_nameid (institution, name_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20150604143755.php b/src/Surfnet/Migrations/Version20150604143755.php
index a6a72a242..4230552cd 100644
--- a/src/Surfnet/Migrations/Version20150604143755.php
+++ b/src/Surfnet/Migrations/Version20150604143755.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('
+ $this->addSql(
+ '
CREATE TABLE sensitive_data_stream (
id VARCHAR(36) NOT NULL,
identity_id VARCHAR(36) NOT NULL,
@@ -26,7 +46,8 @@ public function up(Schema $schema): void
sensitive_data LONGTEXT DEFAULT NULL,
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
- ');
+ ',
+ );
}
/**
@@ -35,7 +56,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE sensitive_data_stream');
}
diff --git a/src/Surfnet/Migrations/Version20150604143756.php b/src/Surfnet/Migrations/Version20150604143756.php
index c99d5ac8f..21cc0a045 100644
--- a/src/Surfnet/Migrations/Version20150604143756.php
+++ b/src/Surfnet/Migrations/Version20150604143756.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE sensitive_data_stream');
- $this->addSql('
+ $this->addSql(
+ '
CREATE TABLE event_stream_sensitive_data (
identity_id VARCHAR(36) NOT NULL,
playhead INT NOT NULL,
sensitive_data LONGTEXT NOT NULL,
PRIMARY KEY (identity_id, playhead)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
- ');
+ ',
+ );
}
/**
@@ -35,10 +56,14 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE event_stream_sensitive_data');
- $this->addSql('
+ $this->addSql(
+ '
CREATE TABLE sensitive_data_stream (
id VARCHAR(36) NOT NULL,
identity_id VARCHAR(36) NOT NULL,
@@ -46,6 +71,7 @@ public function down(Schema $schema): void
sensitive_data LONGTEXT DEFAULT NULL,
PRIMARY KEY (id)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
- ');
+ ',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20150604143757.php b/src/Surfnet/Migrations/Version20150604143757.php
index b4a0068ef..7d39a0717 100644
--- a/src/Surfnet/Migrations/Version20150604143757.php
+++ b/src/Surfnet/Migrations/Version20150604143757.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE event_stream CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci');
}
@@ -27,7 +46,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE event_stream CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci');
}
diff --git a/src/Surfnet/Migrations/Version20150604143758.php b/src/Surfnet/Migrations/Version20150604143758.php
index 73d5f714a..2a4ea45ea 100644
--- a/src/Surfnet/Migrations/Version20150604143758.php
+++ b/src/Surfnet/Migrations/Version20150604143758.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE identity_identifying_data');
}
@@ -27,8 +46,13 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE identity_identifying_data (id VARCHAR(36) NOT NULL, common_name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE identity_identifying_data (id VARCHAR(36) NOT NULL, common_name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20150611105956.php b/src/Surfnet/Migrations/Version20150611105956.php
index 5715427a4..12c126b17 100644
--- a/src/Surfnet/Migrations/Version20150611105956.php
+++ b/src/Surfnet/Migrations/Version20150611105956.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE unverified_second_factor DROP FOREIGN KEY FK_D79226A2FF3ED4A8');
$this->addSql('ALTER TABLE verified_second_factor DROP FOREIGN KEY FK_7964F91CFF3ED4A8');
$this->addSql('ALTER TABLE vetted_second_factor DROP FOREIGN KEY FK_29F96B72FF3ED4A8');
- $this->addSql('ALTER TABLE unverified_second_factor ADD CONSTRAINT fk_unverified_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE');
- $this->addSql('ALTER TABLE verified_second_factor ADD CONSTRAINT fk_verified_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE');
- $this->addSql('ALTER TABLE vetted_second_factor ADD CONSTRAINT fk_vetted_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE');
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor ADD CONSTRAINT fk_unverified_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE',
+ );
+ $this->addSql(
+ 'ALTER TABLE verified_second_factor ADD CONSTRAINT fk_verified_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE',
+ );
+ $this->addSql(
+ 'ALTER TABLE vetted_second_factor ADD CONSTRAINT fk_vetted_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE',
+ );
}
/**
@@ -32,13 +57,22 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE unverified_second_factor DROP FOREIGN KEY fk_unverified_second_factor_identity');
$this->addSql('ALTER TABLE verified_second_factor DROP FOREIGN KEY fk_verified_second_factor_identity');
$this->addSql('ALTER TABLE vetted_second_factor DROP FOREIGN KEY fk_vetted_second_factor_identity');
- $this->addSql('ALTER TABLE unverified_second_factor ADD CONSTRAINT FK_D79226A2FF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)');
- $this->addSql('ALTER TABLE verified_second_factor ADD CONSTRAINT FK_7964F91CFF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)');
- $this->addSql('ALTER TABLE vetted_second_factor ADD CONSTRAINT FK_29F96B72FF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)');
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor ADD CONSTRAINT FK_D79226A2FF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)',
+ );
+ $this->addSql(
+ 'ALTER TABLE verified_second_factor ADD CONSTRAINT FK_7964F91CFF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)',
+ );
+ $this->addSql(
+ 'ALTER TABLE vetted_second_factor ADD CONSTRAINT FK_29F96B72FF3ED4A8 FOREIGN KEY (identity_id) REFERENCES identity (id)',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20150611163038.php b/src/Surfnet/Migrations/Version20150611163038.php
index 1a6d05f86..27040d946 100644
--- a/src/Surfnet/Migrations/Version20150611163038.php
+++ b/src/Surfnet/Migrations/Version20150611163038.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE verified_second_factor DROP FOREIGN KEY fk_verified_second_factor_identity');
$this->addSql('DROP INDEX IDX_7964F91CFF3ED4A8 ON verified_second_factor');
- $this->addSql('ALTER TABLE verified_second_factor ADD institution VARCHAR(255) NOT NULL, ADD common_name VARCHAR(255) NOT NULL, CHANGE identity_id identity_id VARCHAR(36) NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE verified_second_factor ADD institution VARCHAR(255) NOT NULL, ADD common_name VARCHAR(255) NOT NULL, CHANGE identity_id identity_id VARCHAR(36) NOT NULL',
+ );
$this->addSql('ALTER TABLE vetted_second_factor DROP FOREIGN KEY fk_vetted_second_factor_identity');
$this->addSql('DROP INDEX IDX_29F96B72FF3ED4A8 ON vetted_second_factor');
$this->addSql('ALTER TABLE unverified_second_factor DROP FOREIGN KEY fk_unverified_second_factor_identity');
@@ -33,14 +54,25 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('ALTER TABLE unverified_second_factor ADD CONSTRAINT fk_unverified_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE');
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor ADD CONSTRAINT fk_unverified_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE',
+ );
$this->addSql('CREATE INDEX IDX_D79226A2FF3ED4A8 ON unverified_second_factor (identity_id)');
- $this->addSql('ALTER TABLE verified_second_factor DROP institution, DROP common_name, CHANGE identity_id identity_id VARCHAR(36) DEFAULT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE verified_second_factor ADD CONSTRAINT fk_verified_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE');
+ $this->addSql(
+ 'ALTER TABLE verified_second_factor DROP institution, DROP common_name, CHANGE identity_id identity_id VARCHAR(36) DEFAULT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE verified_second_factor ADD CONSTRAINT fk_verified_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE',
+ );
$this->addSql('CREATE INDEX IDX_7964F91CFF3ED4A8 ON verified_second_factor (identity_id)');
- $this->addSql('ALTER TABLE vetted_second_factor ADD CONSTRAINT fk_vetted_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE');
+ $this->addSql(
+ 'ALTER TABLE vetted_second_factor ADD CONSTRAINT fk_vetted_second_factor_identity FOREIGN KEY (identity_id) REFERENCES identity (id) ON DELETE CASCADE',
+ );
$this->addSql('CREATE INDEX IDX_29F96B72FF3ED4A8 ON vetted_second_factor (identity_id)');
}
}
diff --git a/src/Surfnet/Migrations/Version20150615114646.php b/src/Surfnet/Migrations/Version20150615114646.php
index 4023ab26a..f784f9c46 100644
--- a/src/Surfnet/Migrations/Version20150615114646.php
+++ b/src/Surfnet/Migrations/Version20150615114646.php
@@ -1,81 +1,88 @@
container = $container;
- }
+ use ConfigurationAwareMigrationTrait;
public function up(Schema $schema): void
{
- $gatewaySchema = $this->getGatewaySchema();
+ $gatewaySchema = $this->getGatewaySchema();
$middlewareSchema = $this->getMiddlewareSchema();
- $middlewareUser = $this->getMiddlewareUser();
+ $middlewareUser = $this->getMiddlewareUser();
// this up() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql(sprintf(
- 'CREATE TABLE %s.whitelist_entry (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
- $middlewareSchema
- ));
- $this->addSql(sprintf(
- 'CREATE TABLE %s.whitelist_entry (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
- $gatewaySchema
- ));
- $this->addSql(sprintf(
- 'GRANT DELETE,INSERT,SELECT,UPDATE ON %s.whitelist_entry TO %s',
- $gatewaySchema,
- $middlewareUser
- ));
+ $this->addSql(
+ sprintf(
+ 'CREATE TABLE %s.whitelist_entry (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ $middlewareSchema,
+ ),
+ );
+ $this->addSql(
+ sprintf(
+ 'CREATE TABLE %s.whitelist_entry (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ $gatewaySchema,
+ ),
+ );
+ $this->addSql(
+ sprintf(
+ 'GRANT DELETE,INSERT,SELECT,UPDATE ON %s.whitelist_entry TO %s',
+ $gatewaySchema,
+ $middlewareUser,
+ ),
+ );
}
public function down(Schema $schema): void
{
- $gatewaySchema = $this->getGatewaySchema();
+ $gatewaySchema = $this->getGatewaySchema();
$middlewareSchema = $this->getMiddlewareSchema();
- $middlewareUser = $this->getMiddlewareUser();
+ $middlewareUser = $this->getMiddlewareUser();
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql(sprintf(
- 'REVOKE DELETE,INSERT,SELECT,UPDATE ON %s.whitelist_entry FROM %s',
- $gatewaySchema,
- $middlewareUser
- ));
+ $this->addSql(
+ sprintf(
+ 'REVOKE DELETE,INSERT,SELECT,UPDATE ON %s.whitelist_entry FROM %s',
+ $gatewaySchema,
+ $middlewareUser,
+ ),
+ );
$this->addSql(sprintf('DROP TABLE %s.saml_entity', $middlewareSchema));
$this->addSql(sprintf('DROP TABLE %s.saml_entity', $gatewaySchema));
}
-
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
-
- private function getMiddlewareUser()
- {
- return $this->container->getParameter('database_middleware_user');
- }
-
- private function getMiddlewareSchema()
- {
- return $this->container->getParameter('database_middleware_name');
- }
}
diff --git a/src/Surfnet/Migrations/Version20150617141129.php b/src/Surfnet/Migrations/Version20150617141129.php
index 75ab1812e..17e9e9bb8 100644
--- a/src/Surfnet/Migrations/Version20150617141129.php
+++ b/src/Surfnet/Migrations/Version20150617141129.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE second_factor_revocation (id VARCHAR(36) NOT NULL, institution VARCHAR(255) NOT NULL, second_factor_type VARCHAR(36) DEFAULT NULL, recorded_on DATETIME NOT NULL, INDEX idx_secondfactorrevocation_recordedon (recorded_on), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE second_factor_revocation (id VARCHAR(36) NOT NULL, institution VARCHAR(255) NOT NULL, second_factor_type VARCHAR(36) DEFAULT NULL, recorded_on DATETIME NOT NULL, INDEX idx_secondfactorrevocation_recordedon (recorded_on), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
/**
@@ -27,7 +48,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE second_factor_revocation');
}
diff --git a/src/Surfnet/Migrations/Version20150618121907.php b/src/Surfnet/Migrations/Version20150618121907.php
index a3a460d61..96d033b63 100644
--- a/src/Surfnet/Migrations/Version20150618121907.php
+++ b/src/Surfnet/Migrations/Version20150618121907.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE second_factor_revocation ADD revoked_by VARCHAR(255) NOT NULL');
}
@@ -27,7 +46,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE second_factor_revocation DROP revoked_by');
}
diff --git a/src/Surfnet/Migrations/Version20160219133522.php b/src/Surfnet/Migrations/Version20160219133522.php
index a57bc3e02..87fdd6986 100644
--- a/src/Surfnet/Migrations/Version20160219133522.php
+++ b/src/Surfnet/Migrations/Version20160219133522.php
@@ -1,9 +1,25 @@
addSql('ALTER TABLE event_stream CHANGE payload payload LONGTEXT NOT NULL'); }
+ $this->addSql('ALTER TABLE event_stream CHANGE payload payload LONGTEXT NOT NULL');
+ }
/**
* @param Schema $schema
diff --git a/src/Surfnet/Migrations/Version20160607142244.php b/src/Surfnet/Migrations/Version20160607142244.php
index 58e7425a7..f6d3dad93 100644
--- a/src/Surfnet/Migrations/Version20160607142244.php
+++ b/src/Surfnet/Migrations/Version20160607142244.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE ra_second_factor ADD document_number VARCHAR(255)');
}
diff --git a/src/Surfnet/Migrations/Version20160617163830.php b/src/Surfnet/Migrations/Version20160617163830.php
index 837e6ace6..af7f45469 100644
--- a/src/Surfnet/Migrations/Version20160617163830.php
+++ b/src/Surfnet/Migrations/Version20160617163830.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE ra_location (ra_location_id VARCHAR(36) NOT NULL, institution VARCHAR(255) NOT NULL, ra_location_name VARCHAR(255) NOT NULL, location LONGTEXT NOT NULL, contact_information LONGTEXT NOT NULL, INDEX idx_ra_location_institution (institution), PRIMARY KEY(ra_location_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
- $this->addSql('ALTER TABLE audit_log CHANGE actor_institution actor_institution VARCHAR(255) DEFAULT NULL, CHANGE identity_institution identity_institution VARCHAR(255) NOT NULL, CHANGE recorded_on recorded_on DATETIME NOT NULL, CHANGE actor_common_name actor_common_name VARCHAR(255) DEFAULT NULL');
- $this->addSql('ALTER TABLE identity CHANGE name_id name_id VARCHAR(255) NOT NULL, CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE preferred_locale preferred_locale VARCHAR(255) NOT NULL');
+ $this->addSql(
+ 'CREATE TABLE ra_location (ra_location_id VARCHAR(36) NOT NULL, institution VARCHAR(255) NOT NULL, ra_location_name VARCHAR(255) NOT NULL, location LONGTEXT NOT NULL, contact_information LONGTEXT NOT NULL, INDEX idx_ra_location_institution (institution), PRIMARY KEY(ra_location_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
+ $this->addSql(
+ 'ALTER TABLE audit_log CHANGE actor_institution actor_institution VARCHAR(255) DEFAULT NULL, CHANGE identity_institution identity_institution VARCHAR(255) NOT NULL, CHANGE recorded_on recorded_on DATETIME NOT NULL, CHANGE actor_common_name actor_common_name VARCHAR(255) DEFAULT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE identity CHANGE name_id name_id VARCHAR(255) NOT NULL, CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE preferred_locale preferred_locale VARCHAR(255) NOT NULL',
+ );
$this->addSql('ALTER TABLE institution_listing CHANGE institution institution VARCHAR(255) NOT NULL');
- $this->addSql('ALTER TABLE ra_candidate CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE name_id name_id VARCHAR(255) NOT NULL');
- $this->addSql('ALTER TABLE ra_listing CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE role role VARCHAR(20) NOT NULL, CHANGE location location LONGTEXT DEFAULT NULL, CHANGE contact_information contact_information LONGTEXT DEFAULT NULL');
- $this->addSql('ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE status status INT NOT NULL, CHANGE document_number document_number VARCHAR(255) NOT NULL');
- $this->addSql('ALTER TABLE second_factor_revocation CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE recorded_on recorded_on DATETIME NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE ra_candidate CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE name_id name_id VARCHAR(255) NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE ra_listing CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE role role VARCHAR(20) NOT NULL, CHANGE location location LONGTEXT DEFAULT NULL, CHANGE contact_information contact_information LONGTEXT DEFAULT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE status status INT NOT NULL, CHANGE document_number document_number VARCHAR(255) NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE second_factor_revocation CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE recorded_on recorded_on DATETIME NOT NULL',
+ );
$this->addSql('ALTER TABLE sraa CHANGE name_id name_id VARCHAR(200) NOT NULL');
- $this->addSql('ALTER TABLE unverified_second_factor CHANGE identity_id identity_id VARCHAR(36) NOT NULL, CHANGE verification_nonce_valid_until verification_nonce_valid_until DATETIME NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor CHANGE identity_id identity_id VARCHAR(36) NOT NULL, CHANGE verification_nonce_valid_until verification_nonce_valid_until DATETIME NOT NULL',
+ );
$this->addSql('ALTER TABLE vetted_second_factor CHANGE identity_id identity_id VARCHAR(36) NOT NULL');
$this->addSql('ALTER TABLE whitelist_entry CHANGE institution institution VARCHAR(255) NOT NULL');
}
@@ -38,19 +73,42 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE ra_location');
- $this->addSql('ALTER TABLE audit_log CHANGE actor_common_name actor_common_name VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE actor_institution actor_institution VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE identity_institution identity_institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE recorded_on recorded_on DATETIME NOT NULL');
- $this->addSql('ALTER TABLE identity CHANGE name_id name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE preferred_locale preferred_locale VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE institution_listing CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE ra_candidate CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE name_id name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE ra_listing CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE role role VARCHAR(20) NOT NULL COLLATE utf8_unicode_ci, CHANGE location location LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE contact_information contact_information LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE name name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE document_number document_number VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE status status INT NOT NULL');
- $this->addSql('ALTER TABLE second_factor_revocation CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE recorded_on recorded_on DATETIME NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE audit_log CHANGE actor_common_name actor_common_name VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE actor_institution actor_institution VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE identity_institution identity_institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE recorded_on recorded_on DATETIME NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE identity CHANGE name_id name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE preferred_locale preferred_locale VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE institution_listing CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE ra_candidate CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE name_id name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE ra_listing CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE role role VARCHAR(20) NOT NULL COLLATE utf8_unicode_ci, CHANGE location location LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE contact_information contact_information LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE name name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE document_number document_number VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE status status INT NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE second_factor_revocation CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE recorded_on recorded_on DATETIME NOT NULL',
+ );
$this->addSql('ALTER TABLE sraa CHANGE name_id name_id VARCHAR(200) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE unverified_second_factor CHANGE identity_id identity_id VARCHAR(36) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE verification_nonce_valid_until verification_nonce_valid_until DATETIME NOT NULL');
- $this->addSql('ALTER TABLE vetted_second_factor CHANGE identity_id identity_id VARCHAR(36) DEFAULT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE whitelist_entry CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
+ $this->addSql(
+ 'ALTER TABLE unverified_second_factor CHANGE identity_id identity_id VARCHAR(36) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE verification_nonce_valid_until verification_nonce_valid_until DATETIME NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE vetted_second_factor CHANGE identity_id identity_id VARCHAR(36) DEFAULT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE whitelist_entry CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20160620090507.php b/src/Surfnet/Migrations/Version20160620090507.php
index b7ea9d7ef..9b1929938 100644
--- a/src/Surfnet/Migrations/Version20160620090507.php
+++ b/src/Surfnet/Migrations/Version20160620090507.php
@@ -1,9 +1,25 @@
addSql('ALTER TABLE unverified_second_factor ADD verification_nonce_valid_until DATETIME');
-
}
}
diff --git a/src/Surfnet/Migrations/Version20160620153812.php b/src/Surfnet/Migrations/Version20160620153812.php
index 1e6af7e95..ac08989ce 100644
--- a/src/Surfnet/Migrations/Version20160620153812.php
+++ b/src/Surfnet/Migrations/Version20160620153812.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE ra_location DROP PRIMARY KEY');
- $this->addSql('ALTER TABLE ra_location ADD name VARCHAR(255) NOT NULL, DROP ra_location_name, CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE location location LONGTEXT NOT NULL, CHANGE contact_information contact_information LONGTEXT NOT NULL, CHANGE ra_location_id id VARCHAR(36) NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE ra_location ADD name VARCHAR(255) NOT NULL, DROP ra_location_name, CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE location location LONGTEXT NOT NULL, CHANGE contact_information contact_information LONGTEXT NOT NULL, CHANGE ra_location_id id VARCHAR(36) NOT NULL',
+ );
$this->addSql('ALTER TABLE ra_location ADD PRIMARY KEY (id)');
- $this->addSql('ALTER TABLE audit_log CHANGE actor_institution actor_institution VARCHAR(255) DEFAULT NULL, CHANGE identity_institution identity_institution VARCHAR(255) NOT NULL, CHANGE recorded_on recorded_on DATETIME NOT NULL, CHANGE actor_common_name actor_common_name VARCHAR(255) DEFAULT NULL');
- $this->addSql('ALTER TABLE identity CHANGE name_id name_id VARCHAR(255) NOT NULL, CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE preferred_locale preferred_locale VARCHAR(255) NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE audit_log CHANGE actor_institution actor_institution VARCHAR(255) DEFAULT NULL, CHANGE identity_institution identity_institution VARCHAR(255) NOT NULL, CHANGE recorded_on recorded_on DATETIME NOT NULL, CHANGE actor_common_name actor_common_name VARCHAR(255) DEFAULT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE identity CHANGE name_id name_id VARCHAR(255) NOT NULL, CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE preferred_locale preferred_locale VARCHAR(255) NOT NULL',
+ );
$this->addSql('ALTER TABLE institution_listing CHANGE institution institution VARCHAR(255) NOT NULL');
- $this->addSql('ALTER TABLE ra_candidate CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE name_id name_id VARCHAR(255) NOT NULL');
- $this->addSql('ALTER TABLE ra_listing CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE role role VARCHAR(20) NOT NULL, CHANGE location location LONGTEXT DEFAULT NULL, CHANGE contact_information contact_information LONGTEXT DEFAULT NULL');
- $this->addSql('ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE status status INT NOT NULL, CHANGE document_number document_number VARCHAR(255) NOT NULL');
- $this->addSql('ALTER TABLE second_factor_revocation CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE recorded_on recorded_on DATETIME NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE ra_candidate CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE name_id name_id VARCHAR(255) NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE ra_listing CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE common_name common_name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE role role VARCHAR(20) NOT NULL, CHANGE location location LONGTEXT DEFAULT NULL, CHANGE contact_information contact_information LONGTEXT DEFAULT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE status status INT NOT NULL, CHANGE document_number document_number VARCHAR(255) NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE second_factor_revocation CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE recorded_on recorded_on DATETIME NOT NULL',
+ );
$this->addSql('ALTER TABLE sraa CHANGE name_id name_id VARCHAR(200) NOT NULL');
$this->addSql('ALTER TABLE whitelist_entry CHANGE institution institution VARCHAR(255) NOT NULL');
}
@@ -38,19 +71,40 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('ALTER TABLE audit_log CHANGE actor_common_name actor_common_name VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE actor_institution actor_institution VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE identity_institution identity_institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE recorded_on recorded_on DATETIME NOT NULL');
- $this->addSql('ALTER TABLE identity CHANGE name_id name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE preferred_locale preferred_locale VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE institution_listing CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE ra_candidate CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE name_id name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE ra_listing CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE role role VARCHAR(20) NOT NULL COLLATE utf8_unicode_ci, CHANGE location location LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE contact_information contact_information LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci');
+ $this->addSql(
+ 'ALTER TABLE audit_log CHANGE actor_common_name actor_common_name VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE actor_institution actor_institution VARCHAR(255) DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE identity_institution identity_institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE recorded_on recorded_on DATETIME NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE identity CHANGE name_id name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE preferred_locale preferred_locale VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE institution_listing CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE ra_candidate CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE name_id name_id VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci',
+ );
+ $this->addSql(
+ 'ALTER TABLE ra_listing CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE common_name common_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE role role VARCHAR(20) NOT NULL COLLATE utf8_unicode_ci, CHANGE location location LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, CHANGE contact_information contact_information LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci',
+ );
$this->addSql('ALTER TABLE ra_location DROP PRIMARY KEY');
- $this->addSql('ALTER TABLE ra_location ADD ra_location_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, DROP name, CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE location location LONGTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE contact_information contact_information LONGTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE id ra_location_id VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci');
+ $this->addSql(
+ 'ALTER TABLE ra_location ADD ra_location_name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, DROP name, CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE location location LONGTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE contact_information contact_information LONGTEXT NOT NULL COLLATE utf8_unicode_ci, CHANGE id ra_location_id VARCHAR(36) NOT NULL COLLATE utf8_unicode_ci',
+ );
$this->addSql('ALTER TABLE ra_location ADD PRIMARY KEY (ra_location_id)');
- $this->addSql('ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE name name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE document_number document_number VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE status status INT NOT NULL');
- $this->addSql('ALTER TABLE second_factor_revocation CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE recorded_on recorded_on DATETIME NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE name name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE document_number document_number VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE status status INT NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE second_factor_revocation CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE recorded_on recorded_on DATETIME NOT NULL',
+ );
$this->addSql('ALTER TABLE sraa CHANGE name_id name_id VARCHAR(200) NOT NULL COLLATE utf8_unicode_ci');
- $this->addSql('ALTER TABLE whitelist_entry CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci');
+ $this->addSql(
+ 'ALTER TABLE whitelist_entry CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20160621112027.php b/src/Surfnet/Migrations/Version20160621112027.php
index 51a4276e7..5177f42b5 100644
--- a/src/Surfnet/Migrations/Version20160621112027.php
+++ b/src/Surfnet/Migrations/Version20160621112027.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE institution_with_personal_ra_details (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE institution_with_personal_ra_details (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
/**
@@ -27,7 +48,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE institution_with_personal_ra_details');
}
diff --git a/src/Surfnet/Migrations/Version20160622100140.php b/src/Surfnet/Migrations/Version20160622100140.php
index 18db5b037..d89237784 100644
--- a/src/Surfnet/Migrations/Version20160622100140.php
+++ b/src/Surfnet/Migrations/Version20160622100140.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE status status INT NOT NULL, CHANGE document_number document_number VARCHAR(255) DEFAULT NULL');
+ $this->addSql(
+ 'ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL, CHANGE status status INT NOT NULL, CHANGE document_number document_number VARCHAR(255) DEFAULT NULL',
+ );
}
/**
@@ -27,8 +48,13 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE name name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE document_number document_number VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE status status INT NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE ra_second_factor CHANGE institution institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE name name VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE email email VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE document_number document_number VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, CHANGE status status INT NOT NULL',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20160622160146.php b/src/Surfnet/Migrations/Version20160622160146.php
index 265713225..5343cbaf5 100644
--- a/src/Surfnet/Migrations/Version20160622160146.php
+++ b/src/Surfnet/Migrations/Version20160622160146.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE institution_with_ra_locations (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE institution_with_ra_locations (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
$this->addSql('DROP TABLE institution_with_personal_ra_details');
}
@@ -28,9 +49,14 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE institution_with_personal_ra_details (institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE institution_with_personal_ra_details (institution VARCHAR(255) NOT NULL COLLATE utf8_unicode_ci, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
$this->addSql('DROP TABLE institution_with_ra_locations');
}
}
diff --git a/src/Surfnet/Migrations/Version20160719090050.php b/src/Surfnet/Migrations/Version20160719090050.php
index 64568f612..d5ae89866 100644
--- a/src/Surfnet/Migrations/Version20160719090050.php
+++ b/src/Surfnet/Migrations/Version20160719090050.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE configured_institution (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE configured_institution (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
/**
@@ -27,7 +48,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE configured_institution');
}
diff --git a/src/Surfnet/Migrations/Version20160719090051.php b/src/Surfnet/Migrations/Version20160719090051.php
index 85ba5369b..c534a9d61 100644
--- a/src/Surfnet/Migrations/Version20160719090051.php
+++ b/src/Surfnet/Migrations/Version20160719090051.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE institution_configuration_options (institution VARCHAR(255) NOT NULL, use_ra_locations_option TINYINT(1) NOT NULL, show_raa_contact_information_option TINYINT(1) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE institution_configuration_options (institution VARCHAR(255) NOT NULL, use_ra_locations_option TINYINT(1) NOT NULL, show_raa_contact_information_option TINYINT(1) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
/**
@@ -27,7 +48,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE institution_configuration_options');
}
diff --git a/src/Surfnet/Migrations/Version20160719090052.php b/src/Surfnet/Migrations/Version20160719090052.php
index 3f2fc9fd5..417f45479 100644
--- a/src/Surfnet/Migrations/Version20160719090052.php
+++ b/src/Surfnet/Migrations/Version20160719090052.php
@@ -1,9 +1,25 @@
abortIf(
$this->connection->getDatabasePlatform()->getName() != 'mysql',
- 'Migration can only be executed safely on \'mysql\'.'
+ 'Migration can only be executed safely on \'mysql\'.',
);
$this->addSql(
- 'CREATE TABLE allowed_second_factor (institution VARCHAR(255) NOT NULL, second_factor_type VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
+ 'CREATE TABLE allowed_second_factor (institution VARCHAR(255) NOT NULL, second_factor_type VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
);
}
@@ -32,7 +48,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE allowed_second_factor');
}
diff --git a/src/Surfnet/Migrations/Version20170216085513.php b/src/Surfnet/Migrations/Version20170216085513.php
index d008abdac..ff79dd3d0 100644
--- a/src/Surfnet/Migrations/Version20170216085513.php
+++ b/src/Surfnet/Migrations/Version20170216085513.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE allowed_second_factor DROP PRIMARY KEY');
$this->addSql('ALTER TABLE allowed_second_factor ADD PRIMARY KEY (institution, second_factor_type)');
@@ -28,7 +47,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE allowed_second_factor DROP PRIMARY KEY');
$this->addSql('ALTER TABLE allowed_second_factor ADD PRIMARY KEY (institution)');
diff --git a/src/Surfnet/Migrations/Version20171113123232.php b/src/Surfnet/Migrations/Version20171113123232.php
index 27b68ef44..309e4447c 100644
--- a/src/Surfnet/Migrations/Version20171113123232.php
+++ b/src/Surfnet/Migrations/Version20171113123232.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE verified_second_factor ADD registration_requested_at DATETIME NOT NULL');
$this->addSql('UPDATE verified_second_factor SET registration_requested_at = NOW()');
@@ -28,7 +47,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE verified_second_factor DROP registration_requested_at');
}
diff --git a/src/Surfnet/Migrations/Version20180116091349.php b/src/Surfnet/Migrations/Version20180116091349.php
index d55626103..13dd0cc0e 100644
--- a/src/Surfnet/Migrations/Version20180116091349.php
+++ b/src/Surfnet/Migrations/Version20180116091349.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('ALTER TABLE institution_configuration_options ADD verify_email_option TINYINT(1) NOT NULL COLLATE utf8_unicode_ci');
+ $this->addSql(
+ 'ALTER TABLE institution_configuration_options ADD verify_email_option TINYINT(1) NOT NULL COLLATE utf8_unicode_ci',
+ );
}
/**
@@ -27,7 +48,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE institution_configuration_options DROP verify_email_option');
}
diff --git a/src/Surfnet/Migrations/Version20180131150800.php b/src/Surfnet/Migrations/Version20180131150800.php
index 208a73947..005e978bf 100644
--- a/src/Surfnet/Migrations/Version20180131150800.php
+++ b/src/Surfnet/Migrations/Version20180131150800.php
@@ -1,26 +1,34 @@
container = $container;
- }
+ use ConfigurationAwareMigrationTrait;
/**
* @param Schema $schema
@@ -28,7 +36,10 @@ public function setContainer(ContainerInterface $container = null)
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$gatewaySchema = $this->getGatewaySchema();
@@ -42,19 +53,14 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$gatewaySchema = $this->getGatewaySchema();
$this->addSql(sprintf('ALTER TABLE %s.second_factor DROP PRIMARY KEY', $gatewaySchema));
$this->addSql(sprintf('ALTER TABLE %s.second_factor ADD PRIMARY KEY (id)', $gatewaySchema));
}
-
- /**
- * @return string
- */
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
}
diff --git a/src/Surfnet/Migrations/Version20180330094402.php b/src/Surfnet/Migrations/Version20180330094402.php
index befc5c315..9805c85ff 100644
--- a/src/Surfnet/Migrations/Version20180330094402.php
+++ b/src/Surfnet/Migrations/Version20180330094402.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('ALTER TABLE institution_configuration_options CHANGE verify_email_option verify_email_option TINYINT(1) DEFAULT \'1\' NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE institution_configuration_options CHANGE verify_email_option verify_email_option TINYINT(1) DEFAULT \'1\' NOT NULL',
+ );
}
/**
@@ -27,8 +48,13 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('ALTER TABLE institution_configuration_options CHANGE verify_email_option verify_email_option TINYINT(1) NOT NULL');
+ $this->addSql(
+ 'ALTER TABLE institution_configuration_options CHANGE verify_email_option verify_email_option TINYINT(1) NOT NULL',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20180409100948.php b/src/Surfnet/Migrations/Version20180409100948.php
index e8d906780..47cde0ba0 100644
--- a/src/Surfnet/Migrations/Version20180409100948.php
+++ b/src/Surfnet/Migrations/Version20180409100948.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql(
sprintf(
- "ALTER TABLE institution_configuration_options ADD number_of_tokens_per_identity_option TINYINT(1) DEFAULT '%d' NOT NULL",
- NumberOfTokensPerIdentityOption::DISABLED
- )
+ "ALTER TABLE institution_configuration_options ADD number_of_tokens_per_identity_option TINYINT(1) DEFAULT '%d' NOT NULL",
+ NumberOfTokensPerIdentityOption::DISABLED,
+ ),
);
}
@@ -33,7 +52,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() != 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE institution_configuration_options DROP number_of_tokens_per_identity_option');
}
}
diff --git a/src/Surfnet/Migrations/Version20180926144517.php b/src/Surfnet/Migrations/Version20180926144517.php
index 1687d889d..180e5d7f8 100644
--- a/src/Surfnet/Migrations/Version20180926144517.php
+++ b/src/Surfnet/Migrations/Version20180926144517.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
- $this->addSql('CREATE TABLE institution_authorization (institution VARCHAR(255) NOT NULL COMMENT \'(DC2Type:stepup_configuration_institution)\', institution_relation VARCHAR(255) NOT NULL COMMENT \'(DC2Type:stepup_configuration_institution)\', institution_role VARCHAR(10) NOT NULL COMMENT \'(DC2Type:stepup_institution_role)\', PRIMARY KEY(institution, institution_relation, institution_role)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
+ $this->addSql(
+ 'CREATE TABLE institution_authorization (institution VARCHAR(255) NOT NULL COMMENT \'(DC2Type:stepup_configuration_institution)\', institution_relation VARCHAR(255) NOT NULL COMMENT \'(DC2Type:stepup_configuration_institution)\', institution_role VARCHAR(10) NOT NULL COMMENT \'(DC2Type:stepup_institution_role)\', PRIMARY KEY(institution, institution_relation, institution_role)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
+ );
}
/**
@@ -27,7 +48,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP TABLE institution_authorization');
}
diff --git a/src/Surfnet/Migrations/Version20181001082254.php b/src/Surfnet/Migrations/Version20181001082254.php
index 9edbfccbf..d0b529a86 100644
--- a/src/Surfnet/Migrations/Version20181001082254.php
+++ b/src/Surfnet/Migrations/Version20181001082254.php
@@ -1,9 +1,25 @@
addSql(
"INSERT IGNORE INTO institution_authorization(institution, institution_relation, institution_role)
- SELECT institution, institution, '{$roleType}' FROM institution_configuration_options;"
+ SELECT institution, institution, '{$roleType}' FROM institution_configuration_options;",
);
$this->addSql(
"INSERT IGNORE INTO institution_authorization(institution, institution_relation, institution_role)
- SELECT institution, institution, '{$roleType}' FROM whitelist_entry;"
+ SELECT institution, institution, '{$roleType}' FROM whitelist_entry;",
);
}
}
diff --git a/src/Surfnet/Migrations/Version20181023151546.php b/src/Surfnet/Migrations/Version20181023151546.php
index df13ed45c..34107ca4d 100644
--- a/src/Surfnet/Migrations/Version20181023151546.php
+++ b/src/Surfnet/Migrations/Version20181023151546.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE ra_listing DROP PRIMARY KEY');
- $this->addSql('ALTER TABLE ra_listing ADD id INT AUTO_INCREMENT PRIMARY KEY NOT NULL FIRST, ADD ra_institution VARCHAR(255) NOT NULL COMMENT \'(DC2Type:institution)\'');
- $this->addSql('CREATE UNIQUE INDEX idx_ra_listing_unique_identity_institution ON ra_listing (identity_id, ra_institution)');
+ $this->addSql(
+ 'ALTER TABLE ra_listing ADD id INT AUTO_INCREMENT PRIMARY KEY NOT NULL FIRST, ADD ra_institution VARCHAR(255) NOT NULL COMMENT \'(DC2Type:institution)\'',
+ );
+ $this->addSql(
+ 'CREATE UNIQUE INDEX idx_ra_listing_unique_identity_institution ON ra_listing (identity_id, ra_institution)',
+ );
$this->addSql('ALTER TABLE ra_candidate DROP PRIMARY KEY');
- $this->addSql('ALTER TABLE ra_candidate ADD ra_institution VARCHAR(255) NOT NULL COMMENT \'(DC2Type:institution)\'');
- $this->addSql('CREATE UNIQUE INDEX idx_ra_candidate_unique_identity_institution ON ra_candidate (identity_id, ra_institution)');
+ $this->addSql(
+ 'ALTER TABLE ra_candidate ADD ra_institution VARCHAR(255) NOT NULL COMMENT \'(DC2Type:institution)\'',
+ );
+ $this->addSql(
+ 'CREATE UNIQUE INDEX idx_ra_candidate_unique_identity_institution ON ra_candidate (identity_id, ra_institution)',
+ );
$this->addSql('ALTER TABLE ra_candidate ADD id INT FIRST');
$this->addSql('ALTER TABLE ra_candidate ADD INDEX(`id`)');
$this->addSql('ALTER TABLE ra_candidate CHANGE id id INT NOT NULL AUTO_INCREMENT');
@@ -35,10 +62,15 @@ public function up(Schema $schema): void
*/
public function down(Schema $schema): void
{
- $this->throwIrreversibleMigrationException('This migration is irreversible and cannot be reverted due to Fine Grained Authorization BC changes.');
+ $this->throwIrreversibleMigrationException(
+ 'This migration is irreversible and cannot be reverted due to Fine Grained Authorization BC changes.',
+ );
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE ra_candidate MODIFY id INT NOT NULL');
$this->addSql('DROP INDEX idx_ra_candidate_unique_identity_institution ON ra_candidate');
diff --git a/src/Surfnet/Migrations/Version20181101103348.php b/src/Surfnet/Migrations/Version20181101103348.php
index abee72335..5dcb5067e 100644
--- a/src/Surfnet/Migrations/Version20181101103348.php
+++ b/src/Surfnet/Migrations/Version20181101103348.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE audit_log ADD ra_institution VARCHAR(255) DEFAULT NULL');
}
@@ -32,7 +51,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE audit_log DROP ra_institution;');
}
diff --git a/src/Surfnet/Migrations/Version20190211163604.php b/src/Surfnet/Migrations/Version20190211163604.php
index 3fa26e205..25db5f005 100644
--- a/src/Surfnet/Migrations/Version20190211163604.php
+++ b/src/Surfnet/Migrations/Version20190211163604.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('CREATE INDEX idx_ra_listing_ra_institution ON ra_listing (ra_institution)');
$this->addSql('CREATE INDEX idx_auditlog_ra_institution ON audit_log (ra_institution)');
$this->addSql('CREATE INDEX idx_institution ON verified_second_factor (institution)');
$this->addSql('DROP INDEX id ON ra_candidate');
$this->addSql('CREATE INDEX idx_ra_institution ON ra_candidate (ra_institution)');
- $this->addSql('CREATE INDEX idx_authorization ON institution_authorization (institution, institution_relation, institution_role)');
+ $this->addSql(
+ 'CREATE INDEX idx_authorization ON institution_authorization (institution, institution_relation, institution_role)',
+ );
}
/**
@@ -32,7 +53,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('DROP INDEX idx_auditlog_ra_institution ON audit_log');
$this->addSql('DROP INDEX idx_authorization ON institution_authorization');
diff --git a/src/Surfnet/Migrations/Version20200114161618.php b/src/Surfnet/Migrations/Version20200114161618.php
index 321b3754d..267d0c01a 100644
--- a/src/Surfnet/Migrations/Version20200114161618.php
+++ b/src/Surfnet/Migrations/Version20200114161618.php
@@ -1,26 +1,34 @@
container = $container;
- }
+ use ConfigurationAwareMigrationTrait;
/**
* @param Schema $schema
@@ -51,7 +59,7 @@ public function up(Schema $schema): void
$this->addSql('UPDATE ra_location SET institution=LOWER(institution)');
// Convert all GW institutions to lowercase
- $gatewaySchema = $this->getGatewaySchema();
+ $gatewaySchema = $this->getGatewaySchema();
$this->addSql(sprintf('UPDATE %s.whitelist_entry SET institution=LOWER(institution)', $gatewaySchema));
$this->addSql(sprintf('UPDATE %s.second_factor SET institution=LOWER(institution)', $gatewaySchema));
}
@@ -65,9 +73,4 @@ public function down(Schema $schema): void
$this->throwIrreversibleMigrationException('This migration is irreversible');
}
-
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
}
diff --git a/src/Surfnet/Migrations/Version20200416135127.php b/src/Surfnet/Migrations/Version20200416135127.php
index bb9d5decd..65fb9e749 100644
--- a/src/Surfnet/Migrations/Version20200416135127.php
+++ b/src/Surfnet/Migrations/Version20200416135127.php
@@ -1,9 +1,25 @@
abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('CREATE INDEX idx_vetted_second_factor_type ON vetted_second_factor (type)');
$this->addSql('DROP TABLE ra_candidate');
@@ -23,6 +42,8 @@ public function up(Schema $schema): void
*/
public function down(Schema $schema): void
{
- $this->throwIrreversibleMigrationException('This migration is irreversible and cannot be reverted because it will need a replay on the RACandidateProjector.');
+ $this->throwIrreversibleMigrationException(
+ 'This migration is irreversible and cannot be reverted because it will need a replay on the RACandidateProjector.',
+ );
}
}
diff --git a/src/Surfnet/Migrations/Version20210308092347.php b/src/Surfnet/Migrations/Version20210308092347.php
index b75c51fd4..1fe1f1417 100644
--- a/src/Surfnet/Migrations/Version20210308092347.php
+++ b/src/Surfnet/Migrations/Version20210308092347.php
@@ -1,4 +1,22 @@
-abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE institution_configuration_options ADD self_vet_option INT DEFAULT \'0\' NOT NULL');
}
- public function down(Schema $schema) : void
+ public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE institution_configuration_options DROP self_vet_option');
}
}
diff --git a/src/Surfnet/Migrations/Version20210610131957.php b/src/Surfnet/Migrations/Version20210610131957.php
index c9c17af7e..f463e4586 100644
--- a/src/Surfnet/Migrations/Version20210610131957.php
+++ b/src/Surfnet/Migrations/Version20210610131957.php
@@ -1,11 +1,27 @@
-addSql('# Updating entities.');
- $affectedEventStreamRows = $this->connection->executeQuery(self::$select);
+ $result = $this->connection->executeQuery(self::$select);
- $this->write("Affected records: {$affectedEventStreamRows->rowCount()}");
+ $affectedEventStreamRows = $result->fetchAllAssociative();
+ $this->write("Affected records: {$result->rowCount()}");
- if ($affectedEventStreamRows->rowCount() === 0) {
+ if ($result->rowCount() === 0) {
return;
}
@@ -57,12 +74,12 @@ public function up(Schema $schema) : void
'payload' => $payload,
'uuid' => $uuid,
'playhead' => $playhead,
- ]
+ ],
);
}
}
- public function down(Schema $schema) : void
+ public function down(Schema $schema): void
{
// This migration can not be undone.
}
diff --git a/src/Surfnet/Migrations/Version20220519134637.php b/src/Surfnet/Migrations/Version20220519134637.php
index 265b35657..1eba25a72 100644
--- a/src/Surfnet/Migrations/Version20220519134637.php
+++ b/src/Surfnet/Migrations/Version20220519134637.php
@@ -1,58 +1,85 @@
-container = $container;
- }
+ use ConfigurationAwareMigrationTrait;
- public function up(Schema $schema) : void
+ public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
- $this->addSql('ALTER TABLE institution_configuration_options ADD self_asserted_tokens_option INT DEFAULT \'0\' NOT NULL');
- $this->addSql('CREATE TABLE recovery_token (id VARCHAR(36) NOT NULL, identity_id VARCHAR(36) NOT NULL, type VARCHAR(16) NOT NULL, recovery_method_identifier VARCHAR(255) NOT NULL, INDEX idx_recovery_method_type (type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
- $this->addSql('CREATE TABLE identity_self_asserted_token_options (identity_id VARCHAR(36) NOT NULL, possessed_token TINYINT(1) NOT NULL, possessed_self_asserted_token TINYINT(1) NOT NULL, PRIMARY KEY(identity_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
+ $this->addSql(
+ 'ALTER TABLE institution_configuration_options ADD self_asserted_tokens_option INT DEFAULT \'0\' NOT NULL',
+ );
+ $this->addSql(
+ 'CREATE TABLE recovery_token (id VARCHAR(36) NOT NULL, identity_id VARCHAR(36) NOT NULL, type VARCHAR(16) NOT NULL, recovery_method_identifier VARCHAR(255) NOT NULL, INDEX idx_recovery_method_type (type), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB',
+ );
+ $this->addSql(
+ 'CREATE TABLE identity_self_asserted_token_options (identity_id VARCHAR(36) NOT NULL, possessed_token TINYINT(1) NOT NULL, possessed_self_asserted_token TINYINT(1) NOT NULL, PRIMARY KEY(identity_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB',
+ );
// The unknown vetting type is set on the vetted_second_factor::vetting_type column for the existing second
// factors. This to inform consumers of the projection, that the vetting type was recorded at a time before we
// tracked the vetting type of the vetted second factors. It is safe to assume the vetting type is either
// on-premise or self-vetted (both vetting types where the identity of the user was verified at the service desk
// at some point).
$this->addSql('ALTER TABLE vetted_second_factor ADD vetting_type VARCHAR(255) DEFAULT \'unknown\'');
- $this->addSql('ALTER TABLE recovery_token ADD institution VARCHAR(255) NOT NULL, ADD name VARCHAR(255) NOT NULL, ADD email VARCHAR(255) NOT NULL, ADD status INT NOT NULL');
- $this->addSql('ALTER TABLE audit_log ADD recovery_token_identifier VARCHAR(255) DEFAULT NULL, ADD recovery_token_type VARCHAR(36) DEFAULT NULL');
- $this->addSql('CREATE TABLE vetting_type_hint (institution VARCHAR(36) NOT NULL, hints LONGTEXT NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
+ $this->addSql(
+ 'ALTER TABLE recovery_token ADD institution VARCHAR(255) NOT NULL, ADD name VARCHAR(255) NOT NULL, ADD email VARCHAR(255) NOT NULL, ADD status INT NOT NULL',
+ );
+ $this->addSql(
+ 'ALTER TABLE audit_log ADD recovery_token_identifier VARCHAR(255) DEFAULT NULL, ADD recovery_token_type VARCHAR(36) DEFAULT NULL',
+ );
+ $this->addSql(
+ 'CREATE TABLE vetting_type_hint (institution VARCHAR(36) NOT NULL, hints LONGTEXT NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB',
+ );
$gatewaySchema = $this->getGatewaySchema();
$this->addSql(
sprintf(
'ALTER TABLE %s.second_factor ADD identity_vetted TINYINT(1) DEFAULT \'1\'',
- $gatewaySchema
- )
+ $gatewaySchema,
+ ),
);
-
}
- public function down(Schema $schema) : void
+ public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
$this->addSql('ALTER TABLE institution_configuration_options DROP self_asserted_tokens_option');
$this->addSql('DROP TABLE recovery_token');
$this->addSql('DROP TABLE identity_self_asserted_token_options');
@@ -63,9 +90,4 @@ public function down(Schema $schema) : void
$gatewaySchema = $this->getGatewaySchema();
$this->addSql(sprintf('ALTER TABLE %s.second_factor DROP identity_vetted', $gatewaySchema));
}
-
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
}
diff --git a/src/Surfnet/Migrations/Version20221102143350.php b/src/Surfnet/Migrations/Version20221102143350.php
index 829023b6a..5da598094 100644
--- a/src/Surfnet/Migrations/Version20221102143350.php
+++ b/src/Surfnet/Migrations/Version20221102143350.php
@@ -1,46 +1,62 @@
-container = $container;
- }
+ use ConfigurationAwareMigrationTrait;
- public function up(Schema $schema) : void
+ public function up(Schema $schema): void
{
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
// Create the new sso_on_2fa option, note the name conversion 'error' made by doctrine.
$this->addSql('ALTER TABLE institution_configuration_options ADD sso_on2fa_option INT DEFAULT \'0\' NOT NULL');
// Create the institution_configuration gateway schema
$gatewaySchema = $this->getGatewaySchema();
- $this->addSql(sprintf('CREATE TABLE %s.institution_configuration (institution VARCHAR(255) NOT NULL, sso_on2fa_enabled TINYINT(1) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB', $gatewaySchema));
+ $this->addSql(
+ sprintf(
+ 'CREATE TABLE %s.institution_configuration (institution VARCHAR(255) NOT NULL, sso_on2fa_enabled TINYINT(1) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB',
+ $gatewaySchema,
+ ),
+ );
}
- public function down(Schema $schema) : void
+ public function down(Schema $schema): void
{
- $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+ $this->abortIf(
+ $this->connection->getDatabasePlatform()->getName() !== 'mysql',
+ 'Migration can only be executed safely on \'mysql\'.',
+ );
// Down the Middleware schema change
$this->addSql('ALTER TABLE institution_configuration_options DROP sso_on2fa_option');
// Gateway schema change (remove the institution_configuration)
$gatewaySchema = $this->getGatewaySchema();
$this->addSql(sprintf('DROP TABLE %s.institution_configuration', $gatewaySchema));
}
-
- private function getGatewaySchema()
- {
- return $this->container->getParameter('database_gateway_name');
- }
}
diff --git a/src/Surfnet/Migrations/Version20241128131107.php b/src/Surfnet/Migrations/Version20241128131107.php
new file mode 100644
index 000000000..c045d9107
--- /dev/null
+++ b/src/Surfnet/Migrations/Version20241128131107.php
@@ -0,0 +1,55 @@
+addSql('DROP TABLE institution_with_ra_locations');
+ $this->addSql('ALTER TABLE institution_configuration_options CHANGE number_of_tokens_per_identity_option number_of_tokens_per_identity_option INT DEFAULT 0 NOT NULL');
+ $this->addSql('ALTER TABLE vetted_second_factor CHANGE vetting_type vetting_type VARCHAR(255) DEFAULT NULL');
+ $this->addSql('CREATE INDEX idx_vetted_second_factor_vetting_type ON vetted_second_factor (vetting_type)');
+ $this->addSql('ALTER TABLE vetting_type_hint CHANGE hints hints JSON NOT NULL COMMENT \'(DC2Type:stepup_vetting_type_hints)\'');
+ }
+
+ public function down(Schema $schema): void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->addSql('CREATE TABLE institution_with_ra_locations (institution VARCHAR(255) CHARACTER SET utf8mb3 NOT NULL COLLATE `utf8mb3_unicode_ci`, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8mb3 COLLATE `utf8mb3_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
+ $this->addSql('ALTER TABLE institution_configuration_options CHANGE number_of_tokens_per_identity_option number_of_tokens_per_identity_option TINYINT(1) DEFAULT 0 NOT NULL');
+ $this->addSql('DROP INDEX idx_vetted_second_factor_vetting_type ON vetted_second_factor');
+ $this->addSql('ALTER TABLE vetted_second_factor CHANGE vetting_type vetting_type VARCHAR(255) DEFAULT \'unknown\'');
+ $this->addSql('ALTER TABLE vetting_type_hint CHANGE hints hints LONGTEXT NOT NULL');
+ }
+}
diff --git a/src/Surfnet/Migrations/Version20241128131108.php b/src/Surfnet/Migrations/Version20241128131108.php
new file mode 100644
index 000000000..62529e049
--- /dev/null
+++ b/src/Surfnet/Migrations/Version20241128131108.php
@@ -0,0 +1,55 @@
+getGatewaySchema();
+
+ // this up() migration is auto-generated, please modify it to your needs
+ $this->addSql(sprintf('ALTER TABLE %s.second_factor CHANGE identity_vetted identity_vetted TINYINT(1) DEFAULT 1 NOT NULL', $gatewaySchema));
+ }
+
+ public function down(Schema $schema): void
+ {
+ $gatewaySchema = $this->getGatewaySchema();
+
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->addSql(sprintf('ALTER TABLE %s.second_factor CHANGE identity_vetted identity_vetted TINYINT(1) DEFAULT 1', $gatewaySchema));
+ }
+}
diff --git a/src/Surfnet/Stepup/Configuration/Api/Configuration.php b/src/Surfnet/Stepup/Configuration/Api/Configuration.php
index 5d77d8281..b14e39c83 100644
--- a/src/Surfnet/Stepup/Configuration/Api/Configuration.php
+++ b/src/Surfnet/Stepup/Configuration/Api/Configuration.php
@@ -25,11 +25,10 @@ interface Configuration extends AggregateRoot
/**
* @return Configuration
*/
- public static function create();
+ public static function create(): Configuration;
/**
- * @param string $newConfiguration
* @return void
*/
- public function update($newConfiguration);
+ public function update(string $newConfiguration): void;
}
diff --git a/src/Surfnet/Stepup/Configuration/Api/InstitutionConfiguration.php b/src/Surfnet/Stepup/Configuration/Api/InstitutionConfiguration.php
index 0d3635402..5c8a1b7d3 100644
--- a/src/Surfnet/Stepup/Configuration/Api/InstitutionConfiguration.php
+++ b/src/Surfnet/Stepup/Configuration/Api/InstitutionConfiguration.php
@@ -30,63 +30,32 @@
interface InstitutionConfiguration extends AggregateRoot
{
- /**
- * @param InstitutionConfigurationId $institutionConfigurationId
- * @param Institution $institution
- * @return InstitutionConfiguration
- */
- public static function create(InstitutionConfigurationId $institutionConfigurationId, Institution $institution);
+ public static function create(InstitutionConfigurationId $institutionConfigurationId, Institution $institution): InstitutionConfiguration;
- /**
- * @param UseRaLocationsOption $useRaLocationsOption
- * @return void
- */
- public function configureUseRaLocationsOption(UseRaLocationsOption $useRaLocationsOption);
+ public function configureUseRaLocationsOption(UseRaLocationsOption $useRaLocationsOption): void;
- /**
- * @param ShowRaaContactInformationOption $showRaaContactInformationOption
- * @return void
- */
public function configureShowRaaContactInformationOption(
- ShowRaaContactInformationOption $showRaaContactInformationOption
- );
+ ShowRaaContactInformationOption $showRaaContactInformationOption,
+ ): void;
- /**
- * @param RaLocationId $raLocationId
- * @param RaLocationName $raLocationName
- * @param Location $location
- * @param ContactInformation $contactInformation
- * @return void
- */
public function addRaLocation(
RaLocationId $raLocationId,
RaLocationName $raLocationName,
Location $location,
- ContactInformation $contactInformation
- );
+ ContactInformation $contactInformation,
+ ): void;
- /**
- * @param RaLocationId $raLocationId
- * @param RaLocationName $raLocationName
- * @param Location $location
- * @param ContactInformation $contactInformation
- * @return void
- */
public function changeRaLocation(
RaLocationId $raLocationId,
RaLocationName $raLocationName,
Location $location,
- ContactInformation $contactInformation
- );
+ ContactInformation $contactInformation,
+ ): void;
- /**
- * @param RaLocationId $raLocationId
- * @return void
- */
- public function removeRaLocation(RaLocationId $raLocationId);
+ public function removeRaLocation(RaLocationId $raLocationId): void;
/**
* @return void
*/
- public function destroy();
+ public function destroy(): void;
}
diff --git a/src/Surfnet/Stepup/Configuration/Configuration.php b/src/Surfnet/Stepup/Configuration/Configuration.php
index d12670924..5981eb8bc 100644
--- a/src/Surfnet/Stepup/Configuration/Configuration.php
+++ b/src/Surfnet/Stepup/Configuration/Configuration.php
@@ -33,14 +33,14 @@ class Configuration extends EventSourcedAggregateRoot implements ConfigurationIn
/**
* There can ever be only one configuration, so using a fixed UUIDv4
*/
- const CONFIGURATION_ID = '12345678-abcd-4321-abcd-123456789012';
+ public const CONFIGURATION_ID = '12345678-abcd-4321-abcd-123456789012';
/**
* @var array
*/
- private $configuration;
+ private array|null $configuration = null;
- public static function create()
+ public static function create(): self
{
$configuration = new self();
$configuration->apply(new NewConfigurationCreatedEvent(self::CONFIGURATION_ID));
@@ -48,24 +48,30 @@ public static function create()
return $configuration;
}
- public function update($configurationAsJson)
+ public function update(string $newConfiguration): void
{
- $decodedConfiguration = JsonHelper::decode($configurationAsJson);
+ $decodedConfiguration = JsonHelper::decode($newConfiguration);
- $this->apply(new ConfigurationUpdatedEvent(
- self::CONFIGURATION_ID,
- $decodedConfiguration,
- $this->configuration
- ));
+ $this->apply(
+ new ConfigurationUpdatedEvent(
+ self::CONFIGURATION_ID,
+ $decodedConfiguration,
+ $this->configuration,
+ ),
+ );
- $this->apply(new ServiceProvidersUpdatedEvent(
- self::CONFIGURATION_ID,
- $decodedConfiguration['gateway']['service_providers']
- ));
- $this->apply(new IdentityProvidersUpdatedEvent(
- self::CONFIGURATION_ID,
- $decodedConfiguration['gateway']['identity_providers']
- ));
+ $this->apply(
+ new ServiceProvidersUpdatedEvent(
+ self::CONFIGURATION_ID,
+ $decodedConfiguration['gateway']['service_providers'],
+ ),
+ );
+ $this->apply(
+ new IdentityProvidersUpdatedEvent(
+ self::CONFIGURATION_ID,
+ $decodedConfiguration['gateway']['identity_providers'],
+ ),
+ );
$this->apply(new SraaUpdatedEvent(self::CONFIGURATION_ID, $decodedConfiguration['sraa']));
$this->apply(new EmailTemplatesUpdatedEvent(self::CONFIGURATION_ID, $decodedConfiguration['email_templates']));
}
@@ -75,7 +81,7 @@ public function getAggregateRootId(): string
return self::CONFIGURATION_ID;
}
- public function applyConfigurationUpdatedEvent(ConfigurationUpdatedEvent $event)
+ public function applyConfigurationUpdatedEvent(ConfigurationUpdatedEvent $event): void
{
$this->configuration = $event->newConfiguration;
}
diff --git a/src/Surfnet/Stepup/Configuration/Entity/RaLocation.php b/src/Surfnet/Stepup/Configuration/Entity/RaLocation.php
index b08c4306b..73b4bb69d 100644
--- a/src/Surfnet/Stepup/Configuration/Entity/RaLocation.php
+++ b/src/Surfnet/Stepup/Configuration/Entity/RaLocation.php
@@ -25,83 +25,39 @@
class RaLocation
{
- /**
- * @var RaLocationId
- */
- private $id;
-
- /**
- * @var RaLocationName
- */
- private $name;
-
- /**
- * @var Location
- */
- private $location;
-
- /**
- * @var ContactInformation
- */
- private $contactInformation;
-
- /**
- * @param RaLocationId $id
- * @param RaLocationName $name
- * @param Location $location
- * @param ContactInformation $contactInformation
- * @return RaLocation
- */
public static function create(
RaLocationId $id,
RaLocationName $name,
Location $location,
- ContactInformation $contactInformation
- ) {
+ ContactInformation $contactInformation,
+ ): self {
return new self($id, $name, $location, $contactInformation);
}
private function __construct(
- RaLocationId $id,
- RaLocationName $name,
- Location $location,
- ContactInformation $contactInformation
+ private readonly RaLocationId $id,
+ private RaLocationName $name,
+ private Location $location,
+ private ContactInformation $contactInformation,
) {
- $this->id = $id;
- $this->name = $name;
- $this->location = $location;
- $this->contactInformation = $contactInformation;
}
- /**
- * @param RaLocationName $name
- */
- public function rename(RaLocationName $name)
+ public function rename(RaLocationName $name): void
{
$this->name = $name;
}
- /**
- * @param Location $location
- */
- public function relocate(Location $location)
+ public function relocate(Location $location): void
{
$this->location = $location;
}
- /**
- * @param ContactInformation $contactInformation
- */
- public function changeContactInformation(ContactInformation $contactInformation)
+ public function changeContactInformation(ContactInformation $contactInformation): void
{
$this->contactInformation = $contactInformation;
}
- /**
- * @param RaLocationId $otherId
- * @return bool
- */
- public function hasId(RaLocationId $otherId)
+ public function hasId(RaLocationId $otherId): bool
{
return $this->id->equals($otherId);
}
@@ -109,7 +65,7 @@ public function hasId(RaLocationId $otherId)
/**
* @return RaLocationId
*/
- public function getId()
+ public function getId(): RaLocationId
{
return $this->id;
}
@@ -117,7 +73,7 @@ public function getId()
/**
* @return RaLocationName
*/
- public function getName()
+ public function getName(): RaLocationName
{
return $this->name;
}
@@ -125,7 +81,7 @@ public function getName()
/**
* @return Location
*/
- public function getLocation()
+ public function getLocation(): Location
{
return $this->location;
}
@@ -133,7 +89,7 @@ public function getLocation()
/**
* @return ContactInformation
*/
- public function getContactInformation()
+ public function getContactInformation(): ContactInformation
{
return $this->contactInformation;
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/AllowedSecondFactorListUpdatedEvent.php b/src/Surfnet/Stepup/Configuration/Event/AllowedSecondFactorListUpdatedEvent.php
index 1b6d4d098..cb3dd00cc 100644
--- a/src/Surfnet/Stepup/Configuration/Event/AllowedSecondFactorListUpdatedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/AllowedSecondFactorListUpdatedEvent.php
@@ -25,37 +25,19 @@
final class AllowedSecondFactorListUpdatedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var Institution
- */
- public $institution;
-
- /**
- * @var AllowedSecondFactorList
- */
- public $allowedSecondFactorList;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- Institution $institution,
- AllowedSecondFactorList $allowedSecondFactorList
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public Institution $institution,
+ public AllowedSecondFactorList $allowedSecondFactorList,
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->allowedSecondFactorList = $allowedSecondFactorList;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
new Institution($data['institution']),
- AllowedSecondFactorList::deserialize($data['allowed_second_factor_list'])
+ AllowedSecondFactorList::deserialize($data['allowed_second_factor_list']),
);
}
@@ -63,8 +45,8 @@ public function serialize(): array
{
return [
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'institution' => $this->institution->getInstitution(),
- 'allowed_second_factor_list' => $this->allowedSecondFactorList->serialize(),
+ 'institution' => $this->institution->getInstitution(),
+ 'allowed_second_factor_list' => $this->allowedSecondFactorList->serialize(),
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/ConfigurationEvent.php b/src/Surfnet/Stepup/Configuration/Event/ConfigurationEvent.php
index 3080aaf9d..b3ff80122 100644
--- a/src/Surfnet/Stepup/Configuration/Event/ConfigurationEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/ConfigurationEvent.php
@@ -24,17 +24,10 @@
abstract class ConfigurationEvent implements SerializableInterface
{
- /**
- * @var string
- */
- public $id;
+ public string $id;
- public function __construct($id)
+ public function __construct(string $id)
{
- if ($id !== Configuration::CONFIGURATION_ID) {
- throw new LogicException('Configuration Events must use the fixed Configuration::CONFIGURATION_ID as id');
- }
-
$this->id = $id;
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/ConfigurationUpdatedEvent.php b/src/Surfnet/Stepup/Configuration/Event/ConfigurationUpdatedEvent.php
index 12c21b665..4d3ed8f9f 100644
--- a/src/Surfnet/Stepup/Configuration/Event/ConfigurationUpdatedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/ConfigurationUpdatedEvent.php
@@ -20,44 +20,31 @@
class ConfigurationUpdatedEvent extends ConfigurationEvent
{
- /**
- * @var array
- */
- public $newConfiguration;
-
- /**
- * @var array|null
- */
- public $oldConfiguration;
-
/**
* @param string $id
* @param array $newConfiguration
* @param array|null $oldConfiguration
*/
- public function __construct($id, array $newConfiguration, array $oldConfiguration = null)
+ public function __construct($id, public array $newConfiguration, public ?array $oldConfiguration = null)
{
parent::__construct($id);
-
- $this->newConfiguration = $newConfiguration;
- $this->oldConfiguration = $oldConfiguration;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
$data['id'],
$data['new_configuration'],
- $data['old_configuration']
+ $data['old_configuration'],
);
}
public function serialize(): array
{
return [
- 'id' => $this->id,
+ 'id' => $this->id,
'new_configuration' => $this->newConfiguration,
- 'old_configuration' => $this->oldConfiguration
+ 'old_configuration' => $this->oldConfiguration,
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/EmailTemplatesUpdatedEvent.php b/src/Surfnet/Stepup/Configuration/Event/EmailTemplatesUpdatedEvent.php
index 95b755e5e..d01ebcd71 100644
--- a/src/Surfnet/Stepup/Configuration/Event/EmailTemplatesUpdatedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/EmailTemplatesUpdatedEvent.php
@@ -20,23 +20,16 @@
class EmailTemplatesUpdatedEvent extends ConfigurationEvent
{
- /**
- * @var array
- */
- public $emailTemplates;
-
/**
* @param string $configurationId
- * @param array $emailTemplates
+ * @param array $emailTemplates
*/
- public function __construct($configurationId, array $emailTemplates)
+ public function __construct($configurationId, public array $emailTemplates)
{
parent::__construct($configurationId);
-
- $this->emailTemplates = $emailTemplates;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self($data['id'], $data['email_templates']);
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/IdentityProvidersUpdatedEvent.php b/src/Surfnet/Stepup/Configuration/Event/IdentityProvidersUpdatedEvent.php
index 760e3ce7a..4d77840e0 100644
--- a/src/Surfnet/Stepup/Configuration/Event/IdentityProvidersUpdatedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/IdentityProvidersUpdatedEvent.php
@@ -20,23 +20,16 @@
class IdentityProvidersUpdatedEvent extends ConfigurationEvent
{
- /**
- * @var array
- */
- public $identityProviders;
-
/**
* @param string $configurationId
- * @param array $identityProviders
+ * @param array $identityProviders
*/
- public function __construct($configurationId, array $identityProviders)
+ public function __construct($configurationId, public array $identityProviders)
{
parent::__construct($configurationId);
-
- $this->identityProviders = $identityProviders;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self($data['id'], $data['identity_providers']);
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/InstitutionConfigurationRemovedEvent.php b/src/Surfnet/Stepup/Configuration/Event/InstitutionConfigurationRemovedEvent.php
index eb7c8a6f2..3818087d6 100644
--- a/src/Surfnet/Stepup/Configuration/Event/InstitutionConfigurationRemovedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/InstitutionConfigurationRemovedEvent.php
@@ -24,31 +24,19 @@
class InstitutionConfigurationRemovedEvent implements SerializableInterface
{
- /**
- * @var Institution
- */
- public $institution;
-
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- public function __construct(InstitutionConfigurationId $institutionConfigurationId, Institution $institution)
+ public function __construct(public InstitutionConfigurationId $institutionConfigurationId, public Institution $institution)
{
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
}
/**
* @param array $data
* @return InstitutionConfigurationRemovedEvent
*/
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
- new Institution($data['institution'])
+ new Institution($data['institution']),
);
}
@@ -59,7 +47,7 @@ public function serialize(): array
{
return [
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'institution' => $this->institution->getInstitution()
+ 'institution' => $this->institution->getInstitution(),
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/NewConfigurationCreatedEvent.php b/src/Surfnet/Stepup/Configuration/Event/NewConfigurationCreatedEvent.php
index 9e7b9fea2..889565b47 100644
--- a/src/Surfnet/Stepup/Configuration/Event/NewConfigurationCreatedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/NewConfigurationCreatedEvent.php
@@ -20,17 +20,11 @@
class NewConfigurationCreatedEvent extends ConfigurationEvent
{
- /**
- * @return mixed The object instance
- */
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self($data['id']);
}
- /**
- * @return array
- */
public function serialize(): array
{
return ['id' => $this->id];
diff --git a/src/Surfnet/Stepup/Configuration/Event/NewInstitutionConfigurationCreatedEvent.php b/src/Surfnet/Stepup/Configuration/Event/NewInstitutionConfigurationCreatedEvent.php
index 10535b1fc..5f13ec8f1 100644
--- a/src/Surfnet/Stepup/Configuration/Event/NewInstitutionConfigurationCreatedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/NewInstitutionConfigurationCreatedEvent.php
@@ -35,73 +35,20 @@
*/
class NewInstitutionConfigurationCreatedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var Institution
- */
- public $institution;
- /**
- * @var UseRaLocationsOption
- */
- public $useRaLocationsOption;
-
- /**
- * @var ShowRaaContactInformationOption
- */
- public $showRaaContactInformationOption;
-
- /**
- * @var VerifyEmailOption
- */
- public $verifyEmailOption;
-
- /**
- * @var NumberOfTokensPerIdentityOption
- */
- public $numberOfTokensPerIdentityOption;
-
- /**
- * @var SelfVetOption
- */
- public $selfVetOption;
-
- /**
- * @var SelfAssertedTokensOption
- */
- public $selfAssertedTokensOption;
-
- /**
- * @var SsoOn2faOption
- */
- public $ssoOn2faOption;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- Institution $institution,
- UseRaLocationsOption $useRaLocationsOption,
- ShowRaaContactInformationOption $showRaaContactInformationOption,
- VerifyEmailOption $verifyEmailOption,
- NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption,
- SsoOn2faOption $ssoOn2faOption,
- SelfVetOption $selfVetOption,
- SelfAssertedTokensOption $selfAssertedTokensOption
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public Institution $institution,
+ public UseRaLocationsOption $useRaLocationsOption,
+ public ShowRaaContactInformationOption $showRaaContactInformationOption,
+ public VerifyEmailOption $verifyEmailOption,
+ public NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption,
+ public SsoOn2faOption $ssoOn2faOption,
+ public SelfVetOption $selfVetOption,
+ public SelfAssertedTokensOption $selfAssertedTokensOption
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->useRaLocationsOption = $useRaLocationsOption;
- $this->showRaaContactInformationOption = $showRaaContactInformationOption;
- $this->verifyEmailOption = $verifyEmailOption;
- $this->numberOfTokensPerIdentityOption = $numberOfTokensPerIdentityOption;
- $this->ssoOn2faOption = $ssoOn2faOption;
- $this->selfVetOption = $selfVetOption;
- $this->selfAssertedTokensOption = $selfAssertedTokensOption;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
if (!isset($data['verify_email_option'])) {
$data['verify_email_option'] = true;
@@ -130,18 +77,18 @@ public static function deserialize(array $data)
new NumberOfTokensPerIdentityOption($data['number_of_tokens_per_identity_option']),
new SsoOn2faOption($data['sso_on_2fa_option']),
new SelfVetOption($data['self_vet_option']),
- new SelfAssertedTokensOption($data['self_asserted_tokens_option'])
+ new SelfAssertedTokensOption($data['self_asserted_tokens_option']),
);
}
public function serialize(): array
{
return [
- 'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'institution' => $this->institution->getInstitution(),
- 'use_ra_locations_option' => $this->useRaLocationsOption->isEnabled(),
+ 'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
+ 'institution' => $this->institution->getInstitution(),
+ 'use_ra_locations_option' => $this->useRaLocationsOption->isEnabled(),
'show_raa_contact_information_option' => $this->showRaaContactInformationOption->isEnabled(),
- 'verify_email_option' => $this->verifyEmailOption->isEnabled(),
+ 'verify_email_option' => $this->verifyEmailOption->isEnabled(),
'number_of_tokens_per_identity_option' => $this->numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity(),
'sso_on_2fa_option' => $this->ssoOn2faOption->isEnabled(),
'self_vet_option' => $this->selfVetOption->isEnabled(),
diff --git a/src/Surfnet/Stepup/Configuration/Event/NumberOfTokensPerIdentityOptionChangedEvent.php b/src/Surfnet/Stepup/Configuration/Event/NumberOfTokensPerIdentityOptionChangedEvent.php
index c52527f9e..efac0cda8 100644
--- a/src/Surfnet/Stepup/Configuration/Event/NumberOfTokensPerIdentityOptionChangedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/NumberOfTokensPerIdentityOptionChangedEvent.php
@@ -25,37 +25,19 @@
final class NumberOfTokensPerIdentityOptionChangedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var Institution
- */
- public $institution;
-
- /**
- * @var NumberOfTokensPerIdentityOption
- */
- public $numberOfTokensPerIdentityOption;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- Institution $institution,
- NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public Institution $institution,
+ public NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption,
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->numberOfTokensPerIdentityOption = $numberOfTokensPerIdentityOption;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
new Institution($data['institution']),
- new NumberOfTokensPerIdentityOption($data['number_of_tokens_per_identity_option'])
+ new NumberOfTokensPerIdentityOption($data['number_of_tokens_per_identity_option']),
);
}
@@ -63,8 +45,9 @@ public function serialize(): array
{
return [
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'institution' => $this->institution->getInstitution(),
- 'number_of_tokens_per_identity_option' => $this->numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity(),
+ 'institution' => $this->institution->getInstitution(),
+ 'number_of_tokens_per_identity_option' => $this->numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity(
+ ),
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/RaLocationAddedEvent.php b/src/Surfnet/Stepup/Configuration/Event/RaLocationAddedEvent.php
index f00452b06..0faaeb315 100644
--- a/src/Surfnet/Stepup/Configuration/Event/RaLocationAddedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/RaLocationAddedEvent.php
@@ -28,52 +28,17 @@
class RaLocationAddedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var Institution
- */
- public $institution;
-
- /**
- * @var RaLocationId
- */
- public $raLocationId;
-
- /**
- * @var RaLocationName
- */
- public $raLocationName;
-
- /**
- * @var Location
- */
- public $location;
- /**
- * @var ContactInformation
- */
- public $contactInformation;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- Institution $institution,
- RaLocationId $raLocationId,
- RaLocationName $raLocationName,
- Location $location,
- ContactInformation $contactInformation
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public Institution $institution,
+ public RaLocationId $raLocationId,
+ public RaLocationName $raLocationName,
+ public Location $location,
+ public ContactInformation $contactInformation
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->raLocationId = $raLocationId;
- $this->raLocationName = $raLocationName;
- $this->location = $location;
- $this->contactInformation = $contactInformation;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
@@ -81,7 +46,7 @@ public static function deserialize(array $data)
new RaLocationId($data['ra_location_id']),
new RaLocationName($data['ra_location_name']),
new Location($data['location']),
- new ContactInformation($data['contact_information'])
+ new ContactInformation($data['contact_information']),
);
}
@@ -89,11 +54,11 @@ public function serialize(): array
{
return [
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'institution' => $this->institution->getInstitution(),
- 'ra_location_id' => $this->raLocationId->getRaLocationId(),
- 'ra_location_name' => $this->raLocationName->getRaLocationName(),
- 'location' => $this->location->getLocation(),
- 'contact_information' => $this->contactInformation->getContactInformation(),
+ 'institution' => $this->institution->getInstitution(),
+ 'ra_location_id' => $this->raLocationId->getRaLocationId(),
+ 'ra_location_name' => $this->raLocationName->getRaLocationName(),
+ 'location' => $this->location->getLocation(),
+ 'contact_information' => $this->contactInformation->getContactInformation(),
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/RaLocationContactInformationChangedEvent.php b/src/Surfnet/Stepup/Configuration/Event/RaLocationContactInformationChangedEvent.php
index 425d6e1f0..bc102b5af 100644
--- a/src/Surfnet/Stepup/Configuration/Event/RaLocationContactInformationChangedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/RaLocationContactInformationChangedEvent.php
@@ -25,37 +25,19 @@
class RaLocationContactInformationChangedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var RaLocationId
- */
- public $raLocationId;
-
- /**
- * @var ContactInformation
- */
- public $contactInformation;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- RaLocationId $raLocationId,
- ContactInformation $contactInformation
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public RaLocationId $raLocationId,
+ public ContactInformation $contactInformation
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->raLocationId = $raLocationId;
- $this->contactInformation = $contactInformation;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
new RaLocationId($data['ra_location_id']),
- new ContactInformation($data['contact_information'])
+ new ContactInformation($data['contact_information']),
);
}
@@ -63,8 +45,8 @@ public function serialize(): array
{
return [
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'ra_location_id' => $this->raLocationId->getRaLocationId(),
- 'contact_information' => $this->contactInformation->getContactInformation(),
+ 'ra_location_id' => $this->raLocationId->getRaLocationId(),
+ 'contact_information' => $this->contactInformation->getContactInformation(),
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/RaLocationRelocatedEvent.php b/src/Surfnet/Stepup/Configuration/Event/RaLocationRelocatedEvent.php
index 904bf0be8..5aa13e4d6 100644
--- a/src/Surfnet/Stepup/Configuration/Event/RaLocationRelocatedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/RaLocationRelocatedEvent.php
@@ -25,37 +25,19 @@
class RaLocationRelocatedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var RaLocationId
- */
- public $raLocationId;
-
- /**
- * @var Location
- */
- public $location;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- RaLocationId $raLocationId,
- Location $location
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public RaLocationId $raLocationId,
+ public Location $location
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->raLocationId = $raLocationId;
- $this->location = $location;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
new RaLocationId($data['ra_location_id']),
- new Location($data['location'])
+ new Location($data['location']),
);
}
@@ -63,8 +45,8 @@ public function serialize(): array
{
return [
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'ra_location_id' => $this->raLocationId->getRaLocationId(),
- 'location' => $this->location->getLocation(),
+ 'ra_location_id' => $this->raLocationId->getRaLocationId(),
+ 'location' => $this->location->getLocation(),
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/RaLocationRemovedEvent.php b/src/Surfnet/Stepup/Configuration/Event/RaLocationRemovedEvent.php
index 956d39ddb..2784fbcfe 100644
--- a/src/Surfnet/Stepup/Configuration/Event/RaLocationRemovedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/RaLocationRemovedEvent.php
@@ -25,34 +25,20 @@
class RaLocationRemovedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
/**
* @var Institution
*/
- public $institution;
+ public Institution $institution;
- /**
- * @var RaLocationId
- */
- public $raLocationId;
-
- public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- RaLocationId $raLocationId
- ) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->raLocationId = $raLocationId;
+ public function __construct(public InstitutionConfigurationId $institutionConfigurationId, public RaLocationId $raLocationId)
+ {
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
- new RaLocationId($data['ra_location_id'])
+ new RaLocationId($data['ra_location_id']),
);
}
@@ -60,7 +46,7 @@ public function serialize(): array
{
return [
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'ra_location_id' => $this->raLocationId->getRaLocationId(),
+ 'ra_location_id' => $this->raLocationId->getRaLocationId(),
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/RaLocationRenamedEvent.php b/src/Surfnet/Stepup/Configuration/Event/RaLocationRenamedEvent.php
index c76ab3829..4c023d18d 100644
--- a/src/Surfnet/Stepup/Configuration/Event/RaLocationRenamedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/RaLocationRenamedEvent.php
@@ -25,37 +25,19 @@
class RaLocationRenamedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var RaLocationId
- */
- public $raLocationId;
-
- /**
- * @var RaLocationName
- */
- public $raLocationName;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- RaLocationId $raLocationId,
- RaLocationName $raLocationName
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public RaLocationId $raLocationId,
+ public RaLocationName $raLocationName
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->raLocationId = $raLocationId;
- $this->raLocationName = $raLocationName;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
new RaLocationId($data['ra_location_id']),
- new RaLocationName($data['ra_location_name'])
+ new RaLocationName($data['ra_location_name']),
);
}
@@ -63,8 +45,8 @@ public function serialize(): array
{
return [
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'ra_location_id' => $this->raLocationId->getRaLocationId(),
- 'ra_location_name' => $this->raLocationName->getRaLocationName(),
+ 'ra_location_id' => $this->raLocationId->getRaLocationId(),
+ 'ra_location_name' => $this->raLocationName->getRaLocationName(),
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/SelectRaaOptionChangedEvent.php b/src/Surfnet/Stepup/Configuration/Event/SelectRaaOptionChangedEvent.php
index 3b37c8d08..a56e95a24 100644
--- a/src/Surfnet/Stepup/Configuration/Event/SelectRaaOptionChangedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/SelectRaaOptionChangedEvent.php
@@ -20,44 +20,29 @@
use Broadway\Serializer\Serializable as SerializableInterface;
use Surfnet\Stepup\Configuration\Value\Institution;
-use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
+use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
final class SelectRaaOptionChangedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var Institution
- */
- public $institution;
-
- /**
- * @var InstitutionAuthorizationOption
- */
- public $selectRaaOption;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- Institution $institution,
- InstitutionAuthorizationOption $selectRaaOption
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public Institution $institution,
+ public InstitutionAuthorizationOption $selectRaaOption,
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->selectRaaOption = $selectRaaOption;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
$institution = new Institution($data['institution']);
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
$institution,
- InstitutionAuthorizationOption::fromInstitutionConfig(InstitutionRole::selectRaa(), $data['select_raa_option'])
+ InstitutionAuthorizationOption::fromInstitutionConfig(
+ InstitutionRole::selectRaa(),
+ $data['select_raa_option'],
+ ),
);
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/SelfAssertedTokensOptionChangedEvent.php b/src/Surfnet/Stepup/Configuration/Event/SelfAssertedTokensOptionChangedEvent.php
index b8fa23128..9480a068d 100644
--- a/src/Surfnet/Stepup/Configuration/Event/SelfAssertedTokensOptionChangedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/SelfAssertedTokensOptionChangedEvent.php
@@ -1,7 +1,7 @@
institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->selfAssertedTokensOption = $selfVetOption;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
new Institution($data['institution']),
- new SelfAssertedTokensOption($data['self_asserted_tokens_option'])
+ new SelfAssertedTokensOption($data['self_asserted_tokens_option']),
);
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/SelfVetOptionChangedEvent.php b/src/Surfnet/Stepup/Configuration/Event/SelfVetOptionChangedEvent.php
index 1d0251903..d5a457139 100644
--- a/src/Surfnet/Stepup/Configuration/Event/SelfVetOptionChangedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/SelfVetOptionChangedEvent.php
@@ -1,7 +1,7 @@
institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->selfVetOption = $selfVetOption;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
new Institution($data['institution']),
- new SelfVetOption($data['self_vet_option'])
+ new SelfVetOption($data['self_vet_option']),
);
}
@@ -63,8 +45,8 @@ public function serialize(): array
{
return [
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'institution' => $this->institution->getInstitution(),
- 'self_vet_option' => $this->selfVetOption->isEnabled(),
+ 'institution' => $this->institution->getInstitution(),
+ 'self_vet_option' => $this->selfVetOption->isEnabled(),
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/ServiceProvidersUpdatedEvent.php b/src/Surfnet/Stepup/Configuration/Event/ServiceProvidersUpdatedEvent.php
index f9b018d65..e6a165466 100644
--- a/src/Surfnet/Stepup/Configuration/Event/ServiceProvidersUpdatedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/ServiceProvidersUpdatedEvent.php
@@ -20,26 +20,16 @@
class ServiceProvidersUpdatedEvent extends ConfigurationEvent
{
- /**
- * @var array
- */
- public $serviceProviders;
-
/**
* @param string $configurationId
- * @param array $serviceProviders
+ * @param array $serviceProviders
*/
- public function __construct($configurationId, array $serviceProviders)
+ public function __construct($configurationId, public array $serviceProviders)
{
parent::__construct($configurationId);
-
- $this->serviceProviders = $serviceProviders;
}
- /**
- * @return mixed The object instance
- */
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self($data['id'], $data['service_providers']);
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/ShowRaaContactInformationOptionChangedEvent.php b/src/Surfnet/Stepup/Configuration/Event/ShowRaaContactInformationOptionChangedEvent.php
index 020f4681f..d49c34299 100644
--- a/src/Surfnet/Stepup/Configuration/Event/ShowRaaContactInformationOptionChangedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/ShowRaaContactInformationOptionChangedEvent.php
@@ -25,45 +25,27 @@
final class ShowRaaContactInformationOptionChangedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var Institution
- */
- public $institution;
-
- /**
- * @var ShowRaaContactInformationOption
- */
- public $showRaaContactInformationOption;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- Institution $institution,
- ShowRaaContactInformationOption $showRaaContactInformationOption
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public Institution $institution,
+ public ShowRaaContactInformationOption $showRaaContactInformationOption,
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->showRaaContactInformationOption = $showRaaContactInformationOption;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
new Institution($data['institution']),
- new ShowRaaContactInformationOption($data['show_raa_contact_information_option'])
+ new ShowRaaContactInformationOption($data['show_raa_contact_information_option']),
);
}
public function serialize(): array
{
return [
- 'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'institution' => $this->institution->getInstitution(),
+ 'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
+ 'institution' => $this->institution->getInstitution(),
'show_raa_contact_information_option' => $this->showRaaContactInformationOption->isEnabled(),
];
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/SraaUpdatedEvent.php b/src/Surfnet/Stepup/Configuration/Event/SraaUpdatedEvent.php
index 7bc991550..7c3d41502 100644
--- a/src/Surfnet/Stepup/Configuration/Event/SraaUpdatedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/SraaUpdatedEvent.php
@@ -20,23 +20,16 @@
class SraaUpdatedEvent extends ConfigurationEvent
{
- /**
- * @var array
- */
- public $sraaList;
-
/**
* @param string $configurationId
- * @param array $sraaList
+ * @param array $sraaList
*/
- public function __construct($configurationId, array $sraaList)
+ public function __construct($configurationId, public array $sraaList)
{
parent::__construct($configurationId);
-
- $this->sraaList = $sraaList;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self($data['id'], $data['sraa_list']);
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/SsoOn2faOptionChangedEvent.php b/src/Surfnet/Stepup/Configuration/Event/SsoOn2faOptionChangedEvent.php
index a096fdc86..e2c288066 100644
--- a/src/Surfnet/Stepup/Configuration/Event/SsoOn2faOptionChangedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/SsoOn2faOptionChangedEvent.php
@@ -3,7 +3,7 @@
declare(strict_types=1);
/**
- * Copyright 2022 SURF B.V.
+ * Copyright 2022 SURFnet B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,29 +27,11 @@
final class SsoOn2faOptionChangedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var Institution
- */
- public $institution;
-
- /**
- * @var SsoOn2faOption
- */
- public $ssoOn2faOption;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- Institution $institution,
- SsoOn2faOption $ssoOn2faOption
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public Institution $institution,
+ public SsoOn2faOption $ssoOn2faOption,
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->ssoOn2faOption = $ssoOn2faOption;
}
public static function deserialize(array $data): self
@@ -57,7 +39,7 @@ public static function deserialize(array $data): self
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
new Institution($data['institution']),
- new SsoOn2faOption($data['sso_on_2fa_option'])
+ new SsoOn2faOption($data['sso_on_2fa_option']),
);
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/UseRaLocationsOptionChangedEvent.php b/src/Surfnet/Stepup/Configuration/Event/UseRaLocationsOptionChangedEvent.php
index fa73490cd..9c8833bb3 100644
--- a/src/Surfnet/Stepup/Configuration/Event/UseRaLocationsOptionChangedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/UseRaLocationsOptionChangedEvent.php
@@ -25,37 +25,19 @@
final class UseRaLocationsOptionChangedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var Institution
- */
- public $institution;
-
- /**
- * @var UseRaLocationsOption
- */
- public $useRaLocationsOption;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- Institution $institution,
- UseRaLocationsOption $useRaLocationsOption
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public Institution $institution,
+ public UseRaLocationsOption $useRaLocationsOption,
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->useRaLocationsOption = $useRaLocationsOption;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
new Institution($data['institution']),
- new UseRaLocationsOption($data['use_ra_locations_option'])
+ new UseRaLocationsOption($data['use_ra_locations_option']),
);
}
@@ -63,8 +45,8 @@ public function serialize(): array
{
return [
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'institution' => $this->institution->getInstitution(),
- 'use_ra_locations_option' => $this->useRaLocationsOption->isEnabled(),
+ 'institution' => $this->institution->getInstitution(),
+ 'use_ra_locations_option' => $this->useRaLocationsOption->isEnabled(),
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/UseRaOptionChangedEvent.php b/src/Surfnet/Stepup/Configuration/Event/UseRaOptionChangedEvent.php
index 3f4286c04..4a8e439d5 100644
--- a/src/Surfnet/Stepup/Configuration/Event/UseRaOptionChangedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/UseRaOptionChangedEvent.php
@@ -20,45 +20,26 @@
use Broadway\Serializer\Serializable as SerializableInterface;
use Surfnet\Stepup\Configuration\Value\Institution;
-use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
+use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
-use Surfnet\Stepup\Configuration\Value\InstitutionSet;
final class UseRaOptionChangedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var Institution
- */
- public $institution;
-
- /**
- * @var InstitutionAuthorizationOption
- */
- public $useRaOption;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- Institution $institution,
- InstitutionAuthorizationOption $useRaOption
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public Institution $institution,
+ public InstitutionAuthorizationOption $useRaOption,
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->useRaOption = $useRaOption;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
$institution = new Institution($data['institution']);
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
$institution,
- InstitutionAuthorizationOption::fromInstitutionConfig(InstitutionRole::useRa(), $data['use_ra_option'])
+ InstitutionAuthorizationOption::fromInstitutionConfig(InstitutionRole::useRa(), $data['use_ra_option']),
);
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/UseRaaOptionChangedEvent.php b/src/Surfnet/Stepup/Configuration/Event/UseRaaOptionChangedEvent.php
index d5e59ec48..8771c6a3d 100644
--- a/src/Surfnet/Stepup/Configuration/Event/UseRaaOptionChangedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/UseRaaOptionChangedEvent.php
@@ -20,44 +20,26 @@
use Broadway\Serializer\Serializable as SerializableInterface;
use Surfnet\Stepup\Configuration\Value\Institution;
-use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
+use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
final class UseRaaOptionChangedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var Institution
- */
- public $institution;
-
- /**
- * @var InstitutionAuthorizationOption
- */
- public $useRaaOption;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- Institution $institution,
- InstitutionAuthorizationOption $useRaaOption
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public Institution $institution,
+ public InstitutionAuthorizationOption $useRaaOption,
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->useRaaOption = $useRaaOption;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
$institution = new Institution($data['institution']);
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
$institution,
- InstitutionAuthorizationOption::fromInstitutionConfig(InstitutionRole::useRaa(), $data['use_raa_option'])
+ InstitutionAuthorizationOption::fromInstitutionConfig(InstitutionRole::useRaa(), $data['use_raa_option']),
);
}
diff --git a/src/Surfnet/Stepup/Configuration/Event/VerifyEmailOptionChangedEvent.php b/src/Surfnet/Stepup/Configuration/Event/VerifyEmailOptionChangedEvent.php
index e90a31c8a..5ce13aaa0 100644
--- a/src/Surfnet/Stepup/Configuration/Event/VerifyEmailOptionChangedEvent.php
+++ b/src/Surfnet/Stepup/Configuration/Event/VerifyEmailOptionChangedEvent.php
@@ -25,37 +25,19 @@
final class VerifyEmailOptionChangedEvent implements SerializableInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- public $institutionConfigurationId;
-
- /**
- * @var Institution
- */
- public $institution;
-
- /**
- * @var VerifyEmailOption
- */
- public $verifyEmailOption;
-
public function __construct(
- InstitutionConfigurationId $institutionConfigurationId,
- Institution $institution,
- VerifyEmailOption $verifyEmailOption
+ public InstitutionConfigurationId $institutionConfigurationId,
+ public Institution $institution,
+ public VerifyEmailOption $verifyEmailOption,
) {
- $this->institutionConfigurationId = $institutionConfigurationId;
- $this->institution = $institution;
- $this->verifyEmailOption = $verifyEmailOption;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new InstitutionConfigurationId($data['institution_configuration_id']),
new Institution($data['institution']),
- new VerifyEmailOption($data['verify_email_option'])
+ new VerifyEmailOption($data['verify_email_option']),
);
}
@@ -63,8 +45,8 @@ public function serialize(): array
{
return [
'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
- 'institution' => $this->institution->getInstitution(),
- 'verify_email_option' => $this->verifyEmailOption->isEnabled(),
+ 'institution' => $this->institution->getInstitution(),
+ 'verify_email_option' => $this->verifyEmailOption->isEnabled(),
];
}
}
diff --git a/src/Surfnet/Stepup/Configuration/EventSourcing/ConfigurationRepository.php b/src/Surfnet/Stepup/Configuration/EventSourcing/ConfigurationRepository.php
index 516eb370d..61bd0e1f9 100644
--- a/src/Surfnet/Stepup/Configuration/EventSourcing/ConfigurationRepository.php
+++ b/src/Surfnet/Stepup/Configuration/EventSourcing/ConfigurationRepository.php
@@ -19,7 +19,7 @@
namespace Surfnet\Stepup\Configuration\EventSourcing;
use Broadway\EventHandling\EventBus as EventBusInterface;
-use Broadway\EventSourcing\AggregateFactory\AggregateFactory as AggregateFactoryInterface;
+use Broadway\EventSourcing\AggregateFactory\AggregateFactory as AggregateFactoryInterface;
use Broadway\EventSourcing\EventSourcingRepository;
use Broadway\EventStore\EventStore as EventStoreInterface;
use Surfnet\Stepup\Configuration\Configuration;
@@ -29,7 +29,7 @@ class ConfigurationRepository extends EventSourcingRepository
public function __construct(
EventStoreInterface $eventStore,
EventBusInterface $eventBus,
- AggregateFactoryInterface $aggregateFactory
+ AggregateFactoryInterface $aggregateFactory,
) {
parent::__construct($eventStore, $eventBus, Configuration::class, $aggregateFactory);
}
diff --git a/src/Surfnet/Stepup/Configuration/EventSourcing/InstitutionConfigurationRepository.php b/src/Surfnet/Stepup/Configuration/EventSourcing/InstitutionConfigurationRepository.php
index 6fa4d00d2..846f6d827 100644
--- a/src/Surfnet/Stepup/Configuration/EventSourcing/InstitutionConfigurationRepository.php
+++ b/src/Surfnet/Stepup/Configuration/EventSourcing/InstitutionConfigurationRepository.php
@@ -19,7 +19,7 @@
namespace Surfnet\Stepup\Configuration\EventSourcing;
use Broadway\EventHandling\EventBus as EventBusInterface;
-use Broadway\EventSourcing\AggregateFactory\AggregateFactory as AggregateFactoryInterface;
+use Broadway\EventSourcing\AggregateFactory\AggregateFactory as AggregateFactoryInterface;
use Broadway\EventSourcing\EventSourcingRepository;
use Broadway\EventStore\EventStore as EventStoreInterface;
use Surfnet\Stepup\Configuration\InstitutionConfiguration;
@@ -29,13 +29,13 @@ class InstitutionConfigurationRepository extends EventSourcingRepository
public function __construct(
EventStoreInterface $eventStore,
EventBusInterface $eventBus,
- AggregateFactoryInterface $aggregateFactory
+ AggregateFactoryInterface $aggregateFactory,
) {
parent::__construct(
$eventStore,
$eventBus,
InstitutionConfiguration::class,
- $aggregateFactory
+ $aggregateFactory,
);
}
}
diff --git a/src/Surfnet/Stepup/Configuration/InstitutionConfiguration.php b/src/Surfnet/Stepup/Configuration/InstitutionConfiguration.php
index 0e7273d3d..82f7fede0 100644
--- a/src/Surfnet/Stepup/Configuration/InstitutionConfiguration.php
+++ b/src/Surfnet/Stepup/Configuration/InstitutionConfiguration.php
@@ -75,89 +75,40 @@
*/
class InstitutionConfiguration extends EventSourcedAggregateRoot implements InstitutionConfigurationInterface
{
- /**
- * @var InstitutionConfigurationId
- */
- private $institutionConfigurationId;
+ private InstitutionConfigurationId $institutionConfigurationId;
- /**
- * @var Institution
- */
- private $institution;
+ private Institution $institution;
- /**
- * @var RaLocationList
- */
- private $raLocations;
+ private ?RaLocationList $raLocations = null;
- /**
- * @var UseRaLocationsOption
- */
- private $useRaLocationsOption;
+ private UseRaLocationsOption $useRaLocationsOption;
- /**
- * @var ShowRaaContactInformationOption
- */
- private $showRaaContactInformationOption;
-
- /**
- * @var VerifyEmailOption
- */
- private $verifyEmailOption;
+ private ShowRaaContactInformationOption $showRaaContactInformationOption;
- /**
- * @var NumberOfTokensPerIdentityOption
- */
- private $numberOfTokensPerIdentityOption;
+ private VerifyEmailOption $verifyEmailOption;
- /**
- * @var SelfVetOption
- */
- private $selfVetOption;
+ private NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption;
- /**
- * @var SsoOn2faOption
- */
- private $ssoOn2faOption;
+ private SelfVetOption $selfVetOption;
- /**
- * @var SelfAssertedTokensOption
- */
- private $selfAssertedTokensOption;
+ private ?SsoOn2faOption $ssoOn2faOption = null;
- /**
- * @var InstitutionAuthorizationOption
- */
- private $useRaOption;
+ private ?SelfAssertedTokensOption $selfAssertedTokensOption = null;
- /**
- * @var InstitutionAuthorizationOption
- */
+ private ?InstitutionAuthorizationOption $useRaOption = null;
- private $useRaaOption;
+ private ?InstitutionAuthorizationOption $useRaaOption = null;
- /**
- * @var InstitutionAuthorizationOption
- */
- private $selectRaaOption;
+ private ?InstitutionAuthorizationOption $selectRaaOption = null;
- /**
- * @var AllowedSecondFactorList
- */
- private $allowedSecondFactorList;
+ private ?AllowedSecondFactorList $allowedSecondFactorList = null;
- /**
- * @var boolean
- */
- private $isMarkedAsDestroyed;
+ private ?bool $isMarkedAsDestroyed = null;
- /**
- * @param InstitutionConfigurationId $institutionConfigurationId
- * @param Institution $institution
- * @return InstitutionConfiguration
- */
- public static function create(InstitutionConfigurationId $institutionConfigurationId, Institution $institution)
- {
+ public static function create(
+ InstitutionConfigurationId $institutionConfigurationId,
+ Institution $institution,
+ ): self {
$institutionConfiguration = new self;
$institutionConfiguration->apply(
new NewInstitutionConfigurationCreatedEvent(
@@ -169,43 +120,42 @@ public static function create(InstitutionConfigurationId $institutionConfigurati
NumberOfTokensPerIdentityOption::getDefault(),
SsoOn2faOption::getDefault(),
SelfVetOption::getDefault(),
- SelfAssertedTokensOption::getDefault()
- )
+ SelfAssertedTokensOption::getDefault(),
+ ),
+ );
+ $institutionConfiguration->apply(
+ new AllowedSecondFactorListUpdatedEvent(
+ $institutionConfigurationId,
+ $institution,
+ AllowedSecondFactorList::blank(),
+ ),
);
- $institutionConfiguration->apply(new AllowedSecondFactorListUpdatedEvent(
- $institutionConfigurationId,
- $institution,
- AllowedSecondFactorList::blank()
- ));
$institutionConfiguration->apply(
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa())
- )
+ InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa()),
+ ),
);
$institutionConfiguration->apply(
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa())
- )
+ InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa()),
+ ),
);
$institutionConfiguration->apply(
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa())
- )
+ InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa()),
+ ),
);
return $institutionConfiguration;
}
- /**
- * @return InstitutionConfiguration
- */
- public function rebuild()
+ public function rebuild(): self
{
// We can only rebuild a destroyed InstitutionConfiguration, all other cases are not valid
if ($this->isMarkedAsDestroyed !== true) {
@@ -220,35 +170,38 @@ public function rebuild()
ShowRaaContactInformationOption::getDefault(),
VerifyEmailOption::getDefault(),
NumberOfTokensPerIdentityOption::getDefault(),
+ SsoOn2faOption::getDefault(),
SelfVetOption::getDefault(),
- SelfAssertedTokensOption::getDefault()
- )
+ SelfAssertedTokensOption::getDefault(),
+ ),
+ );
+ $this->apply(
+ new AllowedSecondFactorListUpdatedEvent(
+ $this->institutionConfigurationId,
+ $this->institution,
+ AllowedSecondFactorList::blank(),
+ ),
);
- $this->apply(new AllowedSecondFactorListUpdatedEvent(
- $this->institutionConfigurationId,
- $this->institution,
- AllowedSecondFactorList::blank()
- ));
$this->apply(
new UseRaOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa())
- )
+ InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa()),
+ ),
);
$this->apply(
new UseRaaOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa())
- )
+ InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa()),
+ ),
);
$this->apply(
new SelectRaaOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa())
- )
+ InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa()),
+ ),
);
return $this;
@@ -258,7 +211,7 @@ final public function __construct()
{
}
- public function configureUseRaLocationsOption(UseRaLocationsOption $useRaLocationsOption)
+ public function configureUseRaLocationsOption(UseRaLocationsOption $useRaLocationsOption): void
{
if ($this->useRaLocationsOption->equals($useRaLocationsOption)) {
return;
@@ -268,13 +221,14 @@ public function configureUseRaLocationsOption(UseRaLocationsOption $useRaLocatio
new UseRaLocationsOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- $useRaLocationsOption
- )
+ $useRaLocationsOption,
+ ),
);
}
- public function configureShowRaaContactInformationOption(ShowRaaContactInformationOption $showRaaContactInformationOption)
- {
+ public function configureShowRaaContactInformationOption(
+ ShowRaaContactInformationOption $showRaaContactInformationOption,
+ ): void {
if ($this->showRaaContactInformationOption->equals($showRaaContactInformationOption)) {
return;
}
@@ -283,12 +237,12 @@ public function configureShowRaaContactInformationOption(ShowRaaContactInformati
new ShowRaaContactInformationOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- $showRaaContactInformationOption
- )
+ $showRaaContactInformationOption,
+ ),
);
}
- public function configureVerifyEmailOption(VerifyEmailOption $verifyEmailOption)
+ public function configureVerifyEmailOption(VerifyEmailOption $verifyEmailOption): void
{
if ($this->verifyEmailOption->equals($verifyEmailOption)) {
return;
@@ -298,14 +252,14 @@ public function configureVerifyEmailOption(VerifyEmailOption $verifyEmailOption)
new VerifyEmailOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- $verifyEmailOption
- )
+ $verifyEmailOption,
+ ),
);
}
public function configureNumberOfTokensPerIdentityOption(
- NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption
- ) {
+ NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption,
+ ): void {
if ($this->numberOfTokensPerIdentityOption->equals($numberOfTokensPerIdentityOption)) {
return;
}
@@ -314,12 +268,12 @@ public function configureNumberOfTokensPerIdentityOption(
new NumberOfTokensPerIdentityOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- $numberOfTokensPerIdentityOption
- )
+ $numberOfTokensPerIdentityOption,
+ ),
);
}
- public function configureSelfVetOption(SelfVetOption $selfVetOption)
+ public function configureSelfVetOption(SelfVetOption $selfVetOption): void
{
if ($this->selfVetOption->equals($selfVetOption)) {
return;
@@ -329,14 +283,14 @@ public function configureSelfVetOption(SelfVetOption $selfVetOption)
new SelfVetOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- $selfVetOption
- )
+ $selfVetOption,
+ ),
);
}
- public function configureSelfAssertedTokensOption(SelfAssertedTokensOption $selfAssertedTokensOption)
+ public function configureSelfAssertedTokensOption(SelfAssertedTokensOption $selfAssertedTokensOption): void
{
- if ($this->selfAssertedTokensOption !== null &&
+ if ($this->selfAssertedTokensOption instanceof \Surfnet\Stepup\Configuration\Value\SelfAssertedTokensOption &&
$this->selfAssertedTokensOption->equals($selfAssertedTokensOption)
) {
return;
@@ -346,14 +300,14 @@ public function configureSelfAssertedTokensOption(SelfAssertedTokensOption $self
new SelfAssertedTokensOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- $selfAssertedTokensOption
- )
+ $selfAssertedTokensOption,
+ ),
);
}
- public function configureSsoOn2faOption(SsoOn2faOption $ssoOn2faOption)
+ public function configureSsoOn2faOption(SsoOn2faOption $ssoOn2faOption): void
{
- if ($this->ssoOn2faOption !== null && $this->ssoOn2faOption->equals($ssoOn2faOption)) {
+ if ($this->ssoOn2faOption instanceof \Surfnet\Stepup\Configuration\Value\SsoOn2faOption && $this->ssoOn2faOption->equals($ssoOn2faOption)) {
return;
}
@@ -361,14 +315,14 @@ public function configureSsoOn2faOption(SsoOn2faOption $ssoOn2faOption)
new SsoOn2faOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- $ssoOn2faOption
- )
+ $ssoOn2faOption,
+ ),
);
}
- public function updateUseRaOption(InstitutionAuthorizationOption $useRaOption)
+ public function updateUseRaOption(InstitutionAuthorizationOption $useRaOption): void
{
- if ($this->useRaOption !== null
+ if ($this->useRaOption instanceof \Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption
&& $this->useRaOption->equals($useRaOption)
) {
return;
@@ -378,14 +332,14 @@ public function updateUseRaOption(InstitutionAuthorizationOption $useRaOption)
new UseRaOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- $useRaOption
- )
+ $useRaOption,
+ ),
);
}
- public function updateUseRaaOption(InstitutionAuthorizationOption $useRaaOption)
+ public function updateUseRaaOption(InstitutionAuthorizationOption $useRaaOption): void
{
- if ($this->useRaaOption !== null
+ if ($this->useRaaOption instanceof \Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption
&& $this->useRaaOption->equals($useRaaOption)
) {
return;
@@ -395,14 +349,14 @@ public function updateUseRaaOption(InstitutionAuthorizationOption $useRaaOption)
new UseRaaOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- $useRaaOption
- )
+ $useRaaOption,
+ ),
);
}
- public function updateSelectRaaOption(InstitutionAuthorizationOption $selectRaaOption)
+ public function updateSelectRaaOption(InstitutionAuthorizationOption $selectRaaOption): void
{
- if ($this->selectRaaOption !== null
+ if ($this->selectRaaOption instanceof \Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption
&& $this->selectRaaOption->equals($selectRaaOption)
) {
return;
@@ -412,15 +366,15 @@ public function updateSelectRaaOption(InstitutionAuthorizationOption $selectRaaO
new SelectRaaOptionChangedEvent(
$this->institutionConfigurationId,
$this->institution,
- $selectRaaOption
- )
+ $selectRaaOption,
+ ),
);
}
- public function updateAllowedSecondFactorList(AllowedSecondFactorList $allowedSecondFactorList)
+ public function updateAllowedSecondFactorList(AllowedSecondFactorList $allowedSecondFactorList): void
{
// AllowedSecondFactorList can be null for InstitutionConfigurations for which this functionality did not exist
- if ($this->allowedSecondFactorList !== null
+ if ($this->allowedSecondFactorList instanceof \Surfnet\Stepup\Configuration\Value\AllowedSecondFactorList
&& $this->allowedSecondFactorList->equals($allowedSecondFactorList)
) {
return;
@@ -430,8 +384,8 @@ public function updateAllowedSecondFactorList(AllowedSecondFactorList $allowedSe
new AllowedSecondFactorListUpdatedEvent(
$this->institutionConfigurationId,
$this->institution,
- $allowedSecondFactorList
- )
+ $allowedSecondFactorList,
+ ),
);
}
@@ -445,25 +399,29 @@ public function addRaLocation(
RaLocationId $raLocationId,
RaLocationName $raLocationName,
Location $location,
- ContactInformation $contactInformation
- ) {
+ ContactInformation $contactInformation,
+ ): void {
if ($this->raLocations->containsWithId($raLocationId)) {
- throw new DomainException(sprintf(
- 'Cannot add RaLocation with RaLocationId "%s" to RaLocations of InstitutionConfiguration "%s":'
- . ' it is already present',
- $raLocationId,
- $this->getAggregateRootId()
- ));
+ throw new DomainException(
+ sprintf(
+ 'Cannot add RaLocation with RaLocationId "%s" to RaLocations of InstitutionConfiguration "%s":'
+ . ' it is already present',
+ $raLocationId,
+ $this->getAggregateRootId(),
+ ),
+ );
}
- $this->apply(new RaLocationAddedEvent(
- $this->institutionConfigurationId,
- $this->institution,
- $raLocationId,
- $raLocationName,
- $location,
- $contactInformation
- ));
+ $this->apply(
+ new RaLocationAddedEvent(
+ $this->institutionConfigurationId,
+ $this->institution,
+ $raLocationId,
+ $raLocationName,
+ $location,
+ $contactInformation,
+ ),
+ );
}
/**
@@ -476,27 +434,29 @@ public function changeRaLocation(
RaLocationId $raLocationId,
RaLocationName $raLocationName,
Location $location,
- ContactInformation $contactInformation
- ) {
+ ContactInformation $contactInformation,
+ ): void {
if (!$this->raLocations->containsWithId($raLocationId)) {
- throw new DomainException(sprintf(
- 'Cannot change RaLocation with RaLocationId "%s" in RaLocations of InstitutionConfiguration "%s":'
- . ' it is not present',
- $raLocationId,
- $this->getAggregateRootId()
- ));
+ throw new DomainException(
+ sprintf(
+ 'Cannot change RaLocation with RaLocationId "%s" in RaLocations of InstitutionConfiguration "%s":'
+ . ' it is not present',
+ $raLocationId,
+ $this->getAggregateRootId(),
+ ),
+ );
}
$raLocation = $this->raLocations->getById($raLocationId);
if (!$raLocation->getName()->equals($raLocationName)) {
$this->apply(
- new RaLocationRenamedEvent($this->institutionConfigurationId, $raLocationId, $raLocationName)
+ new RaLocationRenamedEvent($this->institutionConfigurationId, $raLocationId, $raLocationName),
);
}
if (!$raLocation->getLocation()->equals($location)) {
$this->apply(
- new RaLocationRelocatedEvent($this->institutionConfigurationId, $raLocationId, $location)
+ new RaLocationRelocatedEvent($this->institutionConfigurationId, $raLocationId, $location),
);
}
if (!$raLocation->getContactInformation()->equals($contactInformation)) {
@@ -504,8 +464,8 @@ public function changeRaLocation(
new RaLocationContactInformationChangedEvent(
$this->institutionConfigurationId,
$raLocationId,
- $contactInformation
- )
+ $contactInformation,
+ ),
);
}
}
@@ -513,15 +473,17 @@ public function changeRaLocation(
/**
* @param RaLocationId $raLocationId
*/
- public function removeRaLocation(RaLocationId $raLocationId)
+ public function removeRaLocation(RaLocationId $raLocationId): void
{
if (!$this->raLocations->containsWithId($raLocationId)) {
- throw new DomainException(sprintf(
- 'Cannot remove RaLocation with RaLocationId "%s" in RaLocations of InstitutionConfiguration "%s":'
- . ' it is not present',
- $raLocationId,
- $this->getAggregateRootId()
- ));
+ throw new DomainException(
+ sprintf(
+ 'Cannot remove RaLocation with RaLocationId "%s" in RaLocations of InstitutionConfiguration "%s":'
+ . ' it is not present',
+ $raLocationId,
+ $this->getAggregateRootId(),
+ ),
+ );
}
$this->apply(new RaLocationRemovedEvent($this->institutionConfigurationId, $raLocationId));
@@ -530,7 +492,7 @@ public function removeRaLocation(RaLocationId $raLocationId)
/**
* @return void
*/
- public function destroy()
+ public function destroy(): void
{
$this->apply(new InstitutionConfigurationRemovedEvent($this->institutionConfigurationId, $this->institution));
}
@@ -543,10 +505,8 @@ public function getAggregateRootId(): string
/**
* Check if role from institution is allowed to accredit roles
*
- * @param Institution $institution
- * @return bool
*/
- public function isInstitutionAllowedToAccreditRoles(Institution $institution)
+ public function isInstitutionAllowedToAccreditRoles(Institution $institution): bool
{
// This method is needed to support the situation pre FGA. In that situation the SelectRaaOptionChanged wasn't
// fired and that would result in a situation were $this->selectRaaOption is null. If that occurs we should check
@@ -554,27 +514,22 @@ public function isInstitutionAllowedToAccreditRoles(Institution $institution)
if ($this->selectRaaOption == null) {
return $this->institution->equals($institution);
}
-
- if ($this->selectRaaOption->hasInstitution($institution, $this->institution)) {
- return true;
- }
-
- return false;
+ return $this->selectRaaOption->hasInstitution($institution, $this->institution);
}
- protected function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event)
+ protected function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event): void
{
- $this->institutionConfigurationId = $event->institutionConfigurationId;
- $this->institution = $event->institution;
- $this->useRaLocationsOption = $event->useRaLocationsOption;
+ $this->institutionConfigurationId = $event->institutionConfigurationId;
+ $this->institution = $event->institution;
+ $this->useRaLocationsOption = $event->useRaLocationsOption;
$this->showRaaContactInformationOption = $event->showRaaContactInformationOption;
- $this->verifyEmailOption = $event->verifyEmailOption;
+ $this->verifyEmailOption = $event->verifyEmailOption;
$this->selfVetOption = $event->selfVetOption;
$this->ssoOn2faOption = $event->ssoOn2faOption;
$this->selfAssertedTokensOption = $event->selfAssertedTokensOption;
$this->numberOfTokensPerIdentityOption = $event->numberOfTokensPerIdentityOption;
- $this->raLocations = new RaLocationList([]);
- $this->isMarkedAsDestroyed = false;
+ $this->raLocations = new RaLocationList([]);
+ $this->isMarkedAsDestroyed = false;
}
/**
@@ -586,122 +541,119 @@ protected function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionCo
* the fields where null'ed (removed from configuration).
*
* This also applies for applyUseRaaOptionChangedEvent & applySelectRaaOptionChangedEvent
- *
- * @param UseRaOptionChangedEvent $event
*/
- protected function applyUseRaOptionChangedEvent(UseRaOptionChangedEvent $event)
+ protected function applyUseRaOptionChangedEvent(UseRaOptionChangedEvent $event): void
{
$this->useRaOption = $event->useRaOption;
}
- protected function applyUseRaaOptionChangedEvent(UseRaaOptionChangedEvent $event)
+ protected function applyUseRaaOptionChangedEvent(UseRaaOptionChangedEvent $event): void
{
$this->useRaaOption = $event->useRaaOption;
}
- protected function applySelectRaaOptionChangedEvent(SelectRaaOptionChangedEvent $event)
+ protected function applySelectRaaOptionChangedEvent(SelectRaaOptionChangedEvent $event): void
{
$this->selectRaaOption = $event->selectRaaOption;
}
- protected function applyUseRaLocationsOptionChangedEvent(UseRaLocationsOptionChangedEvent $event)
+ protected function applyUseRaLocationsOptionChangedEvent(UseRaLocationsOptionChangedEvent $event): void
{
$this->useRaLocationsOption = $event->useRaLocationsOption;
}
protected function applyShowRaaContactInformationOptionChangedEvent(
- ShowRaaContactInformationOptionChangedEvent $event
- ) {
+ ShowRaaContactInformationOptionChangedEvent $event,
+ ): void {
$this->showRaaContactInformationOption = $event->showRaaContactInformationOption;
}
protected function applyVerifyEmailOptionChangedEvent(
- VerifyEmailOptionChangedEvent $event
- ) {
+ VerifyEmailOptionChangedEvent $event,
+ ): void {
$this->verifyEmailOption = $event->verifyEmailOption;
}
protected function applySelfVetOptionChangedEvent(
- SelfVetOptionChangedEvent $event
- ) {
+ SelfVetOptionChangedEvent $event,
+ ): void {
$this->selfVetOption = $event->selfVetOption;
}
protected function applySelfAssertedTokensOptionChangedEvent(
- SelfAssertedTokensOptionChangedEvent $event
- ) {
+ SelfAssertedTokensOptionChangedEvent $event,
+ ): void {
$this->selfAssertedTokensOption = $event->selfAssertedTokensOption;
}
protected function applySsoOn2faOptionChangedEvent(
- SsoOn2faOptionChangedEvent $event
- ) {
+ SsoOn2faOptionChangedEvent $event,
+ ): void {
$this->ssoOn2faOption = $event->ssoOn2faOption;
}
protected function applyNumberOfTokensPerIdentityOptionChangedEvent(
- NumberOfTokensPerIdentityOptionChangedEvent $event
- ) {
+ NumberOfTokensPerIdentityOptionChangedEvent $event,
+ ): void {
$this->numberOfTokensPerIdentityOption = $event->numberOfTokensPerIdentityOption;
}
- protected function applyAllowedSecondFactorListUpdatedEvent(AllowedSecondFactorListUpdatedEvent $event)
+ protected function applyAllowedSecondFactorListUpdatedEvent(AllowedSecondFactorListUpdatedEvent $event): void
{
$this->allowedSecondFactorList = $event->allowedSecondFactorList;
}
- protected function applyRaLocationAddedEvent(RaLocationAddedEvent $event)
+ protected function applyRaLocationAddedEvent(RaLocationAddedEvent $event): void
{
$this->raLocations->add(
RaLocation::create(
$event->raLocationId,
$event->raLocationName,
$event->location,
- $event->contactInformation
- )
+ $event->contactInformation,
+ ),
);
}
- protected function applyRaLocationRenamedEvent(RaLocationRenamedEvent $event)
+ protected function applyRaLocationRenamedEvent(RaLocationRenamedEvent $event): void
{
$raLocation = $this->raLocations->getById($event->raLocationId);
$raLocation->rename($event->raLocationName);
}
- protected function applyRaLocationRelocatedEvent(RaLocationRelocatedEvent $event)
+ protected function applyRaLocationRelocatedEvent(RaLocationRelocatedEvent $event): void
{
$raLocation = $this->raLocations->getById($event->raLocationId);
$raLocation->relocate($event->location);
}
- protected function applyRaLocationContactInformationChangedEvent(RaLocationContactInformationChangedEvent $event)
+ protected function applyRaLocationContactInformationChangedEvent(RaLocationContactInformationChangedEvent $event): void
{
$raLocation = $this->raLocations->getById($event->raLocationId);
$raLocation->changeContactInformation($event->contactInformation);
}
- protected function applyRaLocationRemovedEvent(RaLocationRemovedEvent $event)
+ protected function applyRaLocationRemovedEvent(RaLocationRemovedEvent $event): void
{
$this->raLocations->removeWithId($event->raLocationId);
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
- * @param InstitutionConfigurationRemovedEvent $event
*/
- protected function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event)
+ protected function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event): void
{
// reset all configuration to defaults. This way, should it be rebuild, it seems like it is new again
- $this->raLocations = new RaLocationList([]);
- $this->useRaLocationsOption = UseRaLocationsOption::getDefault();
+ $this->raLocations = new RaLocationList([]);
+ $this->useRaLocationsOption = UseRaLocationsOption::getDefault();
$this->showRaaContactInformationOption = ShowRaaContactInformationOption::getDefault();
- $this->verifyEmailOption = VerifyEmailOption::getDefault();
+ $this->verifyEmailOption = VerifyEmailOption::getDefault();
$this->numberOfTokensPerIdentityOption = NumberOfTokensPerIdentityOption::getDefault();
- $this->allowedSecondFactorList = AllowedSecondFactorList::blank();
+ $this->allowedSecondFactorList = AllowedSecondFactorList::blank();
$this->useRaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa());
$this->useRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa());
$this->selectRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa());
- $this->isMarkedAsDestroyed = true;
+ $this->isMarkedAsDestroyed = true;
}
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/AllowedSecondFactorList.php b/src/Surfnet/Stepup/Configuration/Value/AllowedSecondFactorList.php
index b0e98443c..4c62fa56b 100644
--- a/src/Surfnet/Stepup/Configuration/Value/AllowedSecondFactorList.php
+++ b/src/Surfnet/Stepup/Configuration/Value/AllowedSecondFactorList.php
@@ -20,16 +20,20 @@
use ArrayIterator;
use Broadway\Serializer\Serializable as SerializableInterface;
+use Iterator;
use IteratorAggregate;
use JsonSerializable;
use Surfnet\StepupBundle\Value\SecondFactorType;
+/**
+ * @implements IteratorAggregate
+ */
final class AllowedSecondFactorList implements JsonSerializable, IteratorAggregate, SerializableInterface
{
/**
* @var SecondFactorType[]
*/
- private $allowedSecondFactors = [];
+ private array $allowedSecondFactors = [];
private function __construct(array $allowedSecondFactors)
{
@@ -41,42 +45,27 @@ private function __construct(array $allowedSecondFactors)
/**
* @return AllowedSecondFactorList
*/
- public static function blank()
+ public static function blank(): self
{
return new self([]);
}
- /**
- * @param $allowedSecondFactors
- * @return AllowedSecondFactorList
- */
- public static function ofTypes($allowedSecondFactors)
+ public static function ofTypes(array $allowedSecondFactors): self
{
return new self($allowedSecondFactors);
}
- /**
- * @param SecondFactorType $secondFactor
- * @return bool
- */
- public function allows(SecondFactorType $secondFactor)
+ public function allows(SecondFactorType $secondFactor): bool
{
return $this->isBlank() || $this->contains($secondFactor);
}
- /**
- * @return bool
- */
- public function isBlank()
+ public function isBlank(): bool
{
- return empty($this->allowedSecondFactors);
+ return $this->allowedSecondFactors === [];
}
- /**
- * @param SecondFactorType $secondFactor
- * @return bool
- */
- public function contains(SecondFactorType $secondFactor)
+ public function contains(SecondFactorType $secondFactor): bool
{
foreach ($this->allowedSecondFactors as $allowedSecondFactor) {
if ($allowedSecondFactor->equals($secondFactor)) {
@@ -87,7 +76,7 @@ public function contains(SecondFactorType $secondFactor)
return false;
}
- public function equals(AllowedSecondFactorList $other)
+ public function equals(AllowedSecondFactorList $other): bool
{
if (count($other->allowedSecondFactors) !== count($this->allowedSecondFactors)) {
return false;
@@ -102,13 +91,11 @@ public function equals(AllowedSecondFactorList $other)
return true;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
$secondFactorTypes = array_map(
- function ($secondFactorString) {
- return new SecondFactorType($secondFactorString);
- },
- $data['allowed_second_factors']
+ fn($secondFactorString): SecondFactorType => new SecondFactorType($secondFactorString),
+ $data['allowed_second_factors'],
);
return new self($secondFactorTypes);
@@ -117,10 +104,8 @@ function ($secondFactorString) {
public function serialize(): array
{
$allowedSecondFactors = array_map(
- function (SecondFactorType $secondFactorType) {
- return $secondFactorType->getSecondFactorType();
- },
- $this->allowedSecondFactors
+ fn(SecondFactorType $secondFactorType): string => $secondFactorType->getSecondFactorType(),
+ $this->allowedSecondFactors,
);
return [
@@ -128,17 +113,17 @@ function (SecondFactorType $secondFactorType) {
];
}
- public function getIterator()
+ public function getIterator(): Iterator
{
return new ArrayIterator($this->allowedSecondFactors);
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return $this->allowedSecondFactors;
}
- private function initializeWith(SecondFactorType $allowedSecondFactor)
+ private function initializeWith(SecondFactorType $allowedSecondFactor): void
{
if (!$this->contains($allowedSecondFactor)) {
$this->allowedSecondFactors[] = $allowedSecondFactor;
diff --git a/src/Surfnet/Stepup/Configuration/Value/ContactInformation.php b/src/Surfnet/Stepup/Configuration/Value/ContactInformation.php
index fbe04ef1d..34c1ebc10 100644
--- a/src/Surfnet/Stepup/Configuration/Value/ContactInformation.php
+++ b/src/Surfnet/Stepup/Configuration/Value/ContactInformation.php
@@ -1,5 +1,7 @@
contactInformation = trim($contactInformation);
}
- /**
- * @param ContactInformation $otherContactInformation
- * @return bool
- */
- public function equals(ContactInformation $otherContactInformation)
+ public function equals(ContactInformation $otherContactInformation): bool
{
return $this->contactInformation === $otherContactInformation->contactInformation;
}
@@ -52,17 +41,17 @@ public function equals(ContactInformation $otherContactInformation)
/**
* @return string
*/
- public function getContactInformation()
+ public function getContactInformation(): string
{
return $this->contactInformation;
}
- public function __toString()
+ public function __toString(): string
{
return $this->contactInformation;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->contactInformation;
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/Institution.php b/src/Surfnet/Stepup/Configuration/Value/Institution.php
index 1053899da..aad065a9a 100644
--- a/src/Surfnet/Stepup/Configuration/Value/Institution.php
+++ b/src/Surfnet/Stepup/Configuration/Value/Institution.php
@@ -1,5 +1,7 @@
institution;
}
- /**
- * @param Institution $otherInstitution
- * @return bool
- */
- public function equals(Institution $otherInstitution)
+ public function equals(Institution $otherInstitution): bool
{
return $this->institution === $otherInstitution->institution;
}
- public function __toString()
+ public function __toString(): string
{
return $this->institution;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->institution;
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/InstitutionAuthorizationOption.php b/src/Surfnet/Stepup/Configuration/Value/InstitutionAuthorizationOption.php
index 808f73c6e..ea9e71087 100644
--- a/src/Surfnet/Stepup/Configuration/Value/InstitutionAuthorizationOption.php
+++ b/src/Surfnet/Stepup/Configuration/Value/InstitutionAuthorizationOption.php
@@ -22,67 +22,41 @@
final class InstitutionAuthorizationOption implements JsonSerializable
{
- /**
- * @var InstitutionRole
- */
- private $institutionRole;
-
- /**
- * @var InstitutionSet
- */
- private $institutionSet;
-
- /**
- * @var boolean
- */
- private $isDefault;
+ private readonly bool $isDefault;
/**
* If the default is set to true then the object will use the old default behaviour. That behaviour is that it
* will take the current institution into account when returning institutions.
*
* AbstractRoleOption constructor.
- * @param InstitutionRole $role
- * @param InstitutionSet $institutionSet
- * @param bool $isDefault
*/
- private function __construct(InstitutionRole $role, InstitutionSet $institutionSet, $isDefault)
- {
- $this->institutionRole = $role;
- $this->institutionSet = $institutionSet;
- $this->isDefault = (bool)$isDefault;
+ private function __construct(
+ private readonly InstitutionRole $institutionRole,
+ private readonly InstitutionSet $institutionSet,
+ bool $isDefault,
+ ) {
+ $this->isDefault = $isDefault;
}
- /**
- * @param InstitutionRole $role
- * @param string[]|null
- * @return InstitutionAuthorizationOption
- */
- public static function fromInstitutionConfig(InstitutionRole $role, $institutions = null)
- {
+ public static function fromInstitutionConfig(
+ InstitutionRole $role,
+ ?array $institutions = null
+ ): InstitutionAuthorizationOption {
if (is_null($institutions)) {
return self::getDefault($role);
}
- if (!is_array($institutions)) {
- throw InvalidArgumentException::invalidType(
- 'array',
- 'institutions',
- $institutions
- );
- }
-
array_walk(
$institutions,
- function ($institution, $key) use ($institutions) {
- if (!is_string($institution) || strlen(trim($institution)) === 0) {
+ function ($institution, $key) use ($institutions): void {
+ if (!is_string($institution) || trim($institution) === '') {
throw InvalidArgumentException::invalidType(
'string',
'institutions',
- $institutions[$key]
+ $institutions[$key],
);
}
- }
+ },
);
$set = [];
@@ -96,12 +70,9 @@ function ($institution, $key) use ($institutions) {
}
/**
- * @param InstitutionRole $role
- * @param Institution $institution
* @param Institution[] $institutions
- * @return InstitutionAuthorizationOption
*/
- public static function fromInstitutions(InstitutionRole $role, Institution $institution, array $institutions)
+ public static function fromInstitutions(InstitutionRole $role, Institution $institution, array $institutions): self
{
if (count($institutions) == 1 && current($institutions)->getInstitution() === $institution->getInstitution()) {
return new self($role, InstitutionSet::create([]), true);
@@ -109,39 +80,22 @@ public static function fromInstitutions(InstitutionRole $role, Institution $inst
return new self($role, InstitutionSet::create($institutions), false);
}
- /**
- * @param InstitutionRole $role
- * @param string[]|null
- * @return InstitutionAuthorizationOption
- */
- public static function getDefault(InstitutionRole $role)
+ public static function getDefault(InstitutionRole $role): self
{
return new self($role, InstitutionSet::create([]), true);
}
- /**
- * @param InstitutionRole $role
- * @param string[]|null
- * @return InstitutionAuthorizationOption
- */
- public static function getEmpty(InstitutionRole $role)
+ public static function getEmpty(InstitutionRole $role): self
{
return new self($role, InstitutionSet::create([]), false);
}
- /**
- * @return null
- */
- public static function blank()
+ public static function blank(): null
{
return null;
}
- /**
- * @param InstitutionAuthorizationOption $option
- * @return bool
- */
- public function equals(InstitutionAuthorizationOption $option)
+ public function equals(InstitutionAuthorizationOption $option): bool
{
return
$this->institutionRole->equals($option->getInstitutionRole()) &&
@@ -149,18 +103,12 @@ public function equals(InstitutionAuthorizationOption $option)
$this->isDefault === $option->isDefault();
}
- /**
- * @return InstitutionRole
- */
- public function getInstitutionRole()
+ public function getInstitutionRole(): InstitutionRole
{
return $this->institutionRole;
}
- /**
- * @return InstitutionSet
- */
- public function getInstitutionSet()
+ public function getInstitutionSet(): InstitutionSet
{
return $this->institutionSet;
}
@@ -169,10 +117,9 @@ public function getInstitutionSet()
* If the default is set to true then the object will use the old default behaviour. That behaviour is that it
* will take the current institution into account and this method will return the current institution.
*
- * @param Institution $institution
* @return Institution[]
*/
- public function getInstitutions(Institution $institution)
+ public function getInstitutions(Institution $institution): array
{
if ($this->isDefault) {
return [$institution];
@@ -180,37 +127,22 @@ public function getInstitutions(Institution $institution)
return $this->institutionSet->getInstitutions();
}
- /**
- * @param Institution $institution
- * @param Institution $default
- * @return bool
- */
- public function hasInstitution(Institution $institution, Institution $default)
+ public function hasInstitution(Institution $institution, Institution $default): bool
{
$institutions = $this->getInstitutions($default);
$list = array_map(
- function (Institution $institution) {
- return $institution->getInstitution();
- },
- $institutions
+ fn(Institution $institution): string => $institution->getInstitution(),
+ $institutions,
);
-
- if (!in_array($institution->getInstitution(), $list)) {
- return false;
- }
-
- return true;
+ return in_array($institution->getInstitution(), $list);
}
- /**
- * @return bool
- */
- public function isDefault()
+ public function isDefault(): bool
{
return $this->isDefault;
}
- public function jsonSerialize()
+ public function jsonSerialize(): ?array
{
if ($this->isDefault) {
return null;
diff --git a/src/Surfnet/Stepup/Configuration/Value/InstitutionConfigurationId.php b/src/Surfnet/Stepup/Configuration/Value/InstitutionConfigurationId.php
index 3819b0013..702d5ef69 100644
--- a/src/Surfnet/Stepup/Configuration/Value/InstitutionConfigurationId.php
+++ b/src/Surfnet/Stepup/Configuration/Value/InstitutionConfigurationId.php
@@ -19,42 +19,36 @@
namespace Surfnet\Stepup\Configuration\Value;
use JsonSerializable;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
+use Stringable;
use Surfnet\Stepup\Exception\InvalidArgumentException;
-final class InstitutionConfigurationId implements JsonSerializable
+final class InstitutionConfigurationId implements JsonSerializable, Stringable
{
- const UUID_NAMESPACE = '09876543-abcd-0987-abcd-098765432109';
+ public const UUID_NAMESPACE = '09876543-abcd-0987-abcd-098765432109';
- private $institutionConfigurationId;
+ private readonly string $institutionConfigurationId;
/**
* @deprecated To be removed in next release; use normalizedFrom method to account for case-(in)sensitivity issues
- *
- * @param Institution $institution
- * @return InstitutionConfigurationId
*/
- public static function from(Institution $institution)
+ public static function from(Institution $institution): self
{
- return new self((string) Uuid::uuid5(self::UUID_NAMESPACE, $institution->getInstitution()));
+ return new self((string)Uuid::uuid5(self::UUID_NAMESPACE, $institution->getInstitution()));
}
- /**
- * @param Institution $institution
- * @return InstitutionConfigurationId
- */
- public static function normalizedFrom(Institution $institution)
+ public static function normalizedFrom(Institution $institution): self
{
- return new self((string) Uuid::uuid5(self::UUID_NAMESPACE, strtolower($institution->getInstitution())));
+ return new self((string)Uuid::uuid5(self::UUID_NAMESPACE, strtolower($institution->getInstitution())));
}
- public function __construct($institutionConfigurationId)
+ public function __construct(string $institutionConfigurationId)
{
- if (!is_string($institutionConfigurationId) || strlen(trim($institutionConfigurationId)) === 0) {
+ if (trim($institutionConfigurationId) === '') {
throw InvalidArgumentException::invalidType(
'non-empty string',
'institutionConfigurationId',
- $institutionConfigurationId
+ $institutionConfigurationId,
);
}
@@ -62,36 +56,29 @@ public function __construct($institutionConfigurationId)
throw InvalidArgumentException::invalidType(
'UUID',
'institutionConfigurationId',
- $institutionConfigurationId
+ $institutionConfigurationId,
);
}
$this->institutionConfigurationId = $institutionConfigurationId;
}
- /**
- * @param InstitutionConfigurationId $otherInstitutionConfigurationId
- * @return bool
- */
- public function equals(InstitutionConfigurationId $otherInstitutionConfigurationId)
+ public function equals(InstitutionConfigurationId $otherInstitutionConfigurationId): bool
{
return $this->institutionConfigurationId === $otherInstitutionConfigurationId->institutionConfigurationId;
}
- /**
- * @return string
- */
- public function getInstitutionConfigurationId()
+ public function getInstitutionConfigurationId(): string
{
return $this->institutionConfigurationId;
}
- public function __toString()
+ public function __toString(): string
{
return $this->institutionConfigurationId;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->institutionConfigurationId;
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/InstitutionRole.php b/src/Surfnet/Stepup/Configuration/Value/InstitutionRole.php
index 44dec2929..fb67efd30 100644
--- a/src/Surfnet/Stepup/Configuration/Value/InstitutionRole.php
+++ b/src/Surfnet/Stepup/Configuration/Value/InstitutionRole.php
@@ -1,9 +1,10 @@
type = $type;
}
- /**
- * @return InstitutionRole
- */
- public static function useRa()
+ public static function useRa(): self
{
return new self(self::ROLE_USE_RA);
}
- /**
- * @return InstitutionRole
- */
- public static function useRaa()
+ public static function useRaa(): self
{
return new self(self::ROLE_USE_RAA);
}
- /**
- * @return InstitutionRole
- */
- public static function selectRaa()
+ public static function selectRaa(): self
{
return new self(self::ROLE_SELECT_RAA);
}
- /**
- * @param InstitutionRole $role
- * @return bool
- */
- public function equals(InstitutionRole $role)
+ public function equals(InstitutionRole $role): bool
{
- return $this->type == $role->getType();
+ return $this->type === $role->getType();
}
- /**
- * @return string
- */
- public function getType()
+ public function getType(): string
{
return $this->type;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->type;
}
- /**
- * @return string
- */
- public function __toString()
+ public function __toString(): string
{
return $this->type;
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/InstitutionSet.php b/src/Surfnet/Stepup/Configuration/Value/InstitutionSet.php
index 31dbb5760..ac697de4a 100644
--- a/src/Surfnet/Stepup/Configuration/Value/InstitutionSet.php
+++ b/src/Surfnet/Stepup/Configuration/Value/InstitutionSet.php
@@ -1,5 +1,7 @@
toScalarArray() === $other->toScalarArray();
}
- /**
- * @param Institution $institution
- * @return bool
- */
- public function isOption(Institution $institution)
+ public function isOption(Institution $institution): bool
{
return in_array($institution->getInstitution(), $this->institutions);
}
@@ -81,12 +76,12 @@ public function isOption(Institution $institution)
/**
* @return Institution[]
*/
- public function getInstitutions()
+ public function getInstitutions(): array
{
return $this->institutions;
}
- public function toScalarArray()
+ public function toScalarArray(): array
{
return array_map('strval', $this->institutions);
}
@@ -95,11 +90,12 @@ public function toScalarArray()
* @param Institution[] $institutions
* @return Institution[]
*/
- private function sort(array $institutions)
+ private function sort(array $institutions): array
{
- usort($institutions, function (Institution $a, Institution $b) {
- return strcmp($a->getInstitution(), $b->getInstitution());
- });
+ usort(
+ $institutions,
+ fn(Institution $a, Institution $b): int => strcmp($a->getInstitution(), $b->getInstitution()),
+ );
return $institutions;
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/Location.php b/src/Surfnet/Stepup/Configuration/Value/Location.php
index cb3965c83..ebd280928 100644
--- a/src/Surfnet/Stepup/Configuration/Value/Location.php
+++ b/src/Surfnet/Stepup/Configuration/Value/Location.php
@@ -1,5 +1,7 @@
location = trim($location);
}
- /**
- * @param Location $otherLocation
- * @return bool
- */
- public function equals(Location $otherLocation)
+ public function equals(Location $otherLocation): bool
{
return $this->location === $otherLocation->location;
}
@@ -52,17 +41,17 @@ public function equals(Location $otherLocation)
/**
* @return string
*/
- public function getLocation()
+ public function getLocation(): string
{
return $this->location;
}
- public function __toString()
+ public function __toString(): string
{
return $this->location;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->location;
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/NumberOfTokensPerIdentityOption.php b/src/Surfnet/Stepup/Configuration/Value/NumberOfTokensPerIdentityOption.php
index fde2ea653..be205d30e 100644
--- a/src/Surfnet/Stepup/Configuration/Value/NumberOfTokensPerIdentityOption.php
+++ b/src/Surfnet/Stepup/Configuration/Value/NumberOfTokensPerIdentityOption.php
@@ -23,36 +23,21 @@
class NumberOfTokensPerIdentityOption implements JsonSerializable
{
- const DISABLED = 0;
-
- /**
- * @var int
- */
- private $numberOfTokensPerIdentity;
+ public const DISABLED = 0;
+
+ private readonly int $numberOfTokensPerIdentity;
- public static function getDefault()
+ public static function getDefault(): self
{
return new self(self::DISABLED);
}
- public function __construct($numberOfTokensPerIdentity)
+ public function __construct(int $numberOfTokensPerIdentity)
{
- if (!is_numeric($numberOfTokensPerIdentity)) {
- throw InvalidArgumentException::invalidType(
- 'integer',
- 'numberOfTokensPerIdentity',
- $numberOfTokensPerIdentity
- );
- }
-
$this->numberOfTokensPerIdentity = $numberOfTokensPerIdentity;
}
- /**
- * @param NumberOfTokensPerIdentityOption $other
- * @return bool
- */
- public function equals(NumberOfTokensPerIdentityOption $other)
+ public function equals(NumberOfTokensPerIdentityOption $other): bool
{
return $this->numberOfTokensPerIdentity === $other->numberOfTokensPerIdentity;
}
@@ -60,20 +45,17 @@ public function equals(NumberOfTokensPerIdentityOption $other)
/**
* @return bool
*/
- public function isEnabled()
+ public function isEnabled(): bool
{
return $this->numberOfTokensPerIdentity > self::DISABLED;
}
- /**
- * @return int
- */
- public function getNumberOfTokensPerIdentity()
+ public function getNumberOfTokensPerIdentity(): int
{
return $this->numberOfTokensPerIdentity;
}
- public function jsonSerialize()
+ public function jsonSerialize(): int
{
return $this->numberOfTokensPerIdentity;
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/RaLocationId.php b/src/Surfnet/Stepup/Configuration/Value/RaLocationId.php
index 6bb942316..59a5430e9 100644
--- a/src/Surfnet/Stepup/Configuration/Value/RaLocationId.php
+++ b/src/Surfnet/Stepup/Configuration/Value/RaLocationId.php
@@ -1,5 +1,7 @@
raLocationId = $raLocationId;
}
- /**
- * @param RaLocationId $otherRaLocationId
- * @return bool
- */
- public function equals(RaLocationId $otherRaLocationId)
+ public function equals(RaLocationId $otherRaLocationId): bool
{
return $this->raLocationId === $otherRaLocationId->raLocationId;
}
@@ -65,17 +58,17 @@ public function equals(RaLocationId $otherRaLocationId)
/**
* @return string
*/
- public function getRaLocationId()
+ public function getRaLocationId(): string
{
return $this->raLocationId;
}
- public function __toString()
+ public function __toString(): string
{
return $this->raLocationId;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->raLocationId;
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/RaLocationList.php b/src/Surfnet/Stepup/Configuration/Value/RaLocationList.php
index db5b109fc..70fd31172 100644
--- a/src/Surfnet/Stepup/Configuration/Value/RaLocationList.php
+++ b/src/Surfnet/Stepup/Configuration/Value/RaLocationList.php
@@ -19,16 +19,20 @@
namespace Surfnet\Stepup\Configuration\Value;
use ArrayIterator;
+use Iterator;
use IteratorAggregate;
-use Surfnet\Stepup\Exception\LogicException;
use Surfnet\Stepup\Configuration\Entity\RaLocation;
+use Surfnet\Stepup\Exception\LogicException;
+/**
+ * @implements IteratorAggregate
+ */
final class RaLocationList implements IteratorAggregate
{
/**
* @var RaLocation[]
*/
- private $raLocations = [];
+ private array $raLocations = [];
public function __construct(array $raLocations)
{
@@ -37,11 +41,7 @@ public function __construct(array $raLocations)
}
}
- /**
- * @param RaLocationId $raLocationId
- * @return bool
- */
- public function containsWithId(RaLocationId $raLocationId)
+ public function containsWithId(RaLocationId $raLocationId): bool
{
foreach ($this->raLocations as $raLocation) {
if ($raLocation->hasId($raLocationId)) {
@@ -52,25 +52,21 @@ public function containsWithId(RaLocationId $raLocationId)
return false;
}
- /**
- * @param RaLocation $raLocation
- */
- public function add(RaLocation $raLocation)
+ public function add(RaLocation $raLocation): void
{
if ($this->containsWithId($raLocation->getId())) {
- throw new LogicException(sprintf(
- 'Cannot add RaLocation with id "%s" to RaLocationList: it is already present',
- $raLocation->getId()
- ));
+ throw new LogicException(
+ sprintf(
+ 'Cannot add RaLocation with id "%s" to RaLocationList: it is already present',
+ $raLocation->getId(),
+ ),
+ );
}
$this->raLocations[] = $raLocation;
}
- /**
- * @param RaLocationId $raLocationId
- */
- public function removeWithId(RaLocationId $raLocationId)
+ public function removeWithId(RaLocationId $raLocationId): void
{
foreach ($this->raLocations as $key => $raLocation) {
if ($raLocation->hasId($raLocationId)) {
@@ -81,17 +77,15 @@ public function removeWithId(RaLocationId $raLocationId)
}
}
- throw new LogicException(sprintf(
- 'Cannot remove RaLocation with id "%s" from RaLocationList: it is not present',
- $raLocationId
- ));
+ throw new LogicException(
+ sprintf(
+ 'Cannot remove RaLocation with id "%s" from RaLocationList: it is not present',
+ $raLocationId,
+ ),
+ );
}
- /**
- * @param RaLocationId $raLocationId
- * @return RaLocation
- */
- public function getById(RaLocationId $raLocationId)
+ public function getById(RaLocationId $raLocationId): RaLocation
{
foreach ($this->raLocations as $raLocation) {
if ($raLocation->hasId($raLocationId)) {
@@ -99,13 +93,15 @@ public function getById(RaLocationId $raLocationId)
}
}
- throw new LogicException(sprintf(
- 'Cannot get RaLocation by id "%s" from RaLocationList: RaLocationId not found',
- $raLocationId
- ));
+ throw new LogicException(
+ sprintf(
+ 'Cannot get RaLocation by id "%s" from RaLocationList: RaLocationId not found',
+ $raLocationId,
+ ),
+ );
}
- public function getIterator()
+ public function getIterator(): Iterator
{
return new ArrayIterator($this->raLocations);
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/RaLocationName.php b/src/Surfnet/Stepup/Configuration/Value/RaLocationName.php
index 2809dbfd0..3cb6572f6 100644
--- a/src/Surfnet/Stepup/Configuration/Value/RaLocationName.php
+++ b/src/Surfnet/Stepup/Configuration/Value/RaLocationName.php
@@ -1,5 +1,7 @@
raLocationName = $raLocationName;
}
- /**
- * @param RaLocationName $otherRaLocationName
- * @return bool
- */
- public function equals(RaLocationName $otherRaLocationName)
+ public function equals(RaLocationName $otherRaLocationName): bool
{
return $this->raLocationName === $otherRaLocationName->raLocationName;
}
@@ -52,17 +45,17 @@ public function equals(RaLocationName $otherRaLocationName)
/**
* @return string
*/
- public function getRaLocationName()
+ public function getRaLocationName(): string
{
return $this->raLocationName;
}
- public function __toString()
+ public function __toString(): string
{
return $this->raLocationName;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->raLocationName;
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/SelfAssertedTokensOption.php b/src/Surfnet/Stepup/Configuration/Value/SelfAssertedTokensOption.php
index e271a4943..df29b5776 100644
--- a/src/Surfnet/Stepup/Configuration/Value/SelfAssertedTokensOption.php
+++ b/src/Surfnet/Stepup/Configuration/Value/SelfAssertedTokensOption.php
@@ -1,7 +1,7 @@
allowed = $selfAssertedTokensAllowed;
+ public function __construct(
+ private bool $allowed
+ ) {
}
public function equals(SelfAssertedTokensOption $other): bool
diff --git a/src/Surfnet/Stepup/Configuration/Value/SelfVetOption.php b/src/Surfnet/Stepup/Configuration/Value/SelfVetOption.php
index 9109ed6f0..106d36581 100644
--- a/src/Surfnet/Stepup/Configuration/Value/SelfVetOption.php
+++ b/src/Surfnet/Stepup/Configuration/Value/SelfVetOption.php
@@ -1,7 +1,7 @@
selfVetOption = $selfVetOption;
+ public function __construct(
+ private bool $selfVetOption
+ ) {
}
public function equals(SelfVetOption $other): bool
diff --git a/src/Surfnet/Stepup/Configuration/Value/ShowRaaContactInformationOption.php b/src/Surfnet/Stepup/Configuration/Value/ShowRaaContactInformationOption.php
index 7cde32a50..fb791c3a7 100644
--- a/src/Surfnet/Stepup/Configuration/Value/ShowRaaContactInformationOption.php
+++ b/src/Surfnet/Stepup/Configuration/Value/ShowRaaContactInformationOption.php
@@ -23,34 +23,19 @@
final class ShowRaaContactInformationOption implements JsonSerializable
{
- /**
- * @var bool
- */
- private $showRaaContactInformationOption;
- public static function getDefault()
+
+ public static function getDefault(): self
{
return new self(true);
}
- public function __construct($showRaaContactInformationOption)
- {
- if (!is_bool($showRaaContactInformationOption)) {
- throw InvalidArgumentException::invalidType(
- 'boolean',
- 'showRaaContactInformationOption',
- $showRaaContactInformationOption
- );
- }
-
- $this->showRaaContactInformationOption = $showRaaContactInformationOption;
+ public function __construct(
+ private readonly bool $showRaaContactInformationOption
+ ) {
}
- /**
- * @param ShowRaaContactInformationOption $other
- * @return bool
- */
- public function equals(ShowRaaContactInformationOption $other)
+ public function equals(ShowRaaContactInformationOption $other): bool
{
return $this->showRaaContactInformationOption === $other->showRaaContactInformationOption;
}
@@ -58,12 +43,12 @@ public function equals(ShowRaaContactInformationOption $other)
/**
* @return boolean
*/
- public function isEnabled()
+ public function isEnabled(): bool
{
return $this->showRaaContactInformationOption;
}
- public function jsonSerialize()
+ public function jsonSerialize(): bool
{
return $this->showRaaContactInformationOption;
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/SsoOn2faOption.php b/src/Surfnet/Stepup/Configuration/Value/SsoOn2faOption.php
index b35f28b81..fbacf05e2 100644
--- a/src/Surfnet/Stepup/Configuration/Value/SsoOn2faOption.php
+++ b/src/Surfnet/Stepup/Configuration/Value/SsoOn2faOption.php
@@ -3,7 +3,7 @@
declare(strict_types=1);
/**
- * Copyright 2022 SURF B.V.
+ * Copyright 2022 SURFnet B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,21 +22,16 @@
use JsonSerializable;
-final class SsoOn2faOption implements JsonSerializable
+final readonly class SsoOn2faOption implements JsonSerializable
{
- /**
- * @var bool
- */
- private $ssoOn2faOption;
-
public static function getDefault(): self
{
return new self(false);
}
- public function __construct(bool $ssoOn2faOption)
- {
- $this->ssoOn2faOption = $ssoOn2faOption;
+ public function __construct(
+ private bool $ssoOn2faOption
+ ) {
}
public function equals(SsoOn2faOption $other): bool
diff --git a/src/Surfnet/Stepup/Configuration/Value/UseRaLocationsOption.php b/src/Surfnet/Stepup/Configuration/Value/UseRaLocationsOption.php
index d1d6442e2..4d10a31ee 100644
--- a/src/Surfnet/Stepup/Configuration/Value/UseRaLocationsOption.php
+++ b/src/Surfnet/Stepup/Configuration/Value/UseRaLocationsOption.php
@@ -23,50 +23,27 @@
final class UseRaLocationsOption implements JsonSerializable
{
- /**
- * @var bool
- */
- private $useRaLocationsOption;
-
- /**
- * @return UseRaLocationsOption
- */
- public static function getDefault()
+ public static function getDefault(): self
{
return new self(false);
}
- public function __construct($useRaLocationsOption)
- {
- if (!is_bool($useRaLocationsOption)) {
- throw InvalidArgumentException::invalidType(
- 'boolean',
- 'useRaLocationsOption',
- $useRaLocationsOption
- );
- }
-
- $this->useRaLocationsOption = $useRaLocationsOption;
+ public function __construct(
+ private readonly bool $useRaLocationsOption
+ ) {
}
- /**
- * @param UseRaLocationsOption $other
- * @return bool
- */
- public function equals(UseRaLocationsOption $other)
+ public function equals(UseRaLocationsOption $other): bool
{
return $this->useRaLocationsOption === $other->useRaLocationsOption;
}
- /**
- * @return boolean
- */
- public function isEnabled()
+ public function isEnabled(): bool
{
return $this->useRaLocationsOption;
}
- public function jsonSerialize()
+ public function jsonSerialize(): bool
{
return $this->useRaLocationsOption;
}
diff --git a/src/Surfnet/Stepup/Configuration/Value/VerifyEmailOption.php b/src/Surfnet/Stepup/Configuration/Value/VerifyEmailOption.php
index e2253d749..4422063f4 100644
--- a/src/Surfnet/Stepup/Configuration/Value/VerifyEmailOption.php
+++ b/src/Surfnet/Stepup/Configuration/Value/VerifyEmailOption.php
@@ -23,34 +23,17 @@
final class VerifyEmailOption implements JsonSerializable
{
- /**
- * @var bool
- */
- private $verifyEmailOption;
-
- public static function getDefault()
+ public static function getDefault(): self
{
return new self(true);
}
- public function __construct($verifyEmailOption)
- {
- if (!is_bool($verifyEmailOption)) {
- throw InvalidArgumentException::invalidType(
- 'boolean',
- 'verifyEmailOption',
- $verifyEmailOption
- );
- }
-
- $this->verifyEmailOption = $verifyEmailOption;
+ public function __construct(
+ private readonly bool $verifyEmailOption
+ ) {
}
- /**
- * @param VerifyEmailOption $other
- * @return bool
- */
- public function equals(VerifyEmailOption $other)
+ public function equals(VerifyEmailOption $other): bool
{
return $this->verifyEmailOption === $other->verifyEmailOption;
}
@@ -58,12 +41,12 @@ public function equals(VerifyEmailOption $other)
/**
* @return boolean
*/
- public function isEnabled()
+ public function isEnabled(): bool
{
return $this->verifyEmailOption;
}
- public function jsonSerialize()
+ public function jsonSerialize(): bool
{
return $this->verifyEmailOption;
}
diff --git a/src/Surfnet/Stepup/DateTime/DateTime.php b/src/Surfnet/Stepup/DateTime/DateTime.php
index 19874f598..4a038ec1b 100644
--- a/src/Surfnet/Stepup/DateTime/DateTime.php
+++ b/src/Surfnet/Stepup/DateTime/DateTime.php
@@ -20,36 +20,36 @@
use DateInterval;
use DateTime as CoreDateTime;
+use Stringable;
use Surfnet\Stepup\Exception\InvalidArgumentException;
+use TypeError;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
-class DateTime
+class DateTime implements Stringable
{
/**
* The 'c' format, expanded in separate format characters. This string can also be used with
* `DateTime::createFromString()`.
*/
- const FORMAT = 'Y-m-d\\TH:i:sP';
+ public const FORMAT = 'Y-m-d\\TH:i:sP';
/**
* Allows for mocking of time.
- *
+ * @see DateTimeHelper::setCurrentTime here you can see how now can be overridden using reflection
* @var self|null
*/
- private static $now;
+ private static ?DateTime $now = null;
- /**
- * @var CoreDateTime
- */
- private $dateTime;
+ private readonly CoreDateTime $dateTime;
/**
+ * @see DateTimeHelper::setCurrentTime here you can see how now can be overridden using reflection
* @return self
*/
- public static function now()
+ public static function now(): DateTime
{
return self::$now ?: new self(new CoreDateTime);
}
@@ -58,12 +58,8 @@ public static function now()
* @param string $string A date-time string formatted using `self::FORMAT` (eg. '2014-11-26T15:20:43+01:00').
* @return self
*/
- public static function fromString($string)
+ public static function fromString(string $string): self
{
- if (!is_string($string)) {
- InvalidArgumentException::invalidType('string', 'dateTime', $string);
- }
-
$dateTime = CoreDateTime::createFromFormat(self::FORMAT, $string);
if ($dateTime === false) {
@@ -81,11 +77,7 @@ public function __construct(CoreDateTime $dateTime = null)
$this->dateTime = $dateTime ?: new CoreDateTime();
}
- /**
- * @param DateInterval $interval
- * @return DateTime
- */
- public function add(DateInterval $interval)
+ public function add(DateInterval $interval): self
{
$dateTime = clone $this->dateTime;
$dateTime->add($interval);
@@ -93,11 +85,7 @@ public function add(DateInterval $interval)
return new self($dateTime);
}
- /**
- * @param DateInterval $interval
- * @return DateTime
- */
- public function sub(DateInterval $interval)
+ public function sub(DateInterval $interval): self
{
$dateTime = clone $this->dateTime;
$dateTime->sub($interval);
@@ -108,7 +96,7 @@ public function sub(DateInterval $interval)
/**
* @return DateTime
*/
- public function endOfDay()
+ public function endOfDay(): self
{
$dateTime = clone $this->dateTime;
$dateTime->setTime(23, 59, 59);
@@ -116,64 +104,35 @@ public function endOfDay()
return new self($dateTime);
}
- /**
- * @param DateTime $dateTime
- * @return boolean
- */
- public function comesBefore(DateTime $dateTime)
+ public function comesBefore(DateTime $dateTime): bool
{
return $this->dateTime < $dateTime->dateTime;
}
- /**
- * @param DateTime $dateTime
- * @return boolean
- */
- public function comesBeforeOrIsEqual(DateTime $dateTime)
+ public function comesBeforeOrIsEqual(DateTime $dateTime): bool
{
return $this->dateTime <= $dateTime->dateTime;
}
- /**
- * @param DateTime $dateTime
- * @return boolean
- */
- public function comesAfter(DateTime $dateTime)
+ public function comesAfter(DateTime $dateTime): bool
{
return $this->dateTime > $dateTime->dateTime;
}
- /**
- * @param DateTime $dateTime
- * @return boolean
- */
- public function comesAfterOrIsEqual(DateTime $dateTime)
+ public function comesAfterOrIsEqual(DateTime $dateTime): bool
{
return $this->dateTime >= $dateTime->dateTime;
}
- /**
- * @param $format
- * @return string
- */
- public function format($format)
+ public function format(string $format): string
{
- $formatted = $this->dateTime->format($format);
-
- if ($formatted === false) {
- throw new InvalidArgumentException(sprintf(
- 'Given format "%s" is not a valid format for DateTime',
- $format
- ));
- }
-
- return $formatted;
+ return $this->dateTime->format($format);
}
/**
* @return string An ISO 8601 representation of this DateTime.
*/
- public function __toString()
+ public function __toString(): string
{
return $this->format(self::FORMAT);
}
diff --git a/src/Surfnet/Stepup/Exception/InvalidArgumentException.php b/src/Surfnet/Stepup/Exception/InvalidArgumentException.php
index 8645dfd3f..dbe864320 100644
--- a/src/Surfnet/Stepup/Exception/InvalidArgumentException.php
+++ b/src/Surfnet/Stepup/Exception/InvalidArgumentException.php
@@ -20,20 +20,13 @@
class InvalidArgumentException extends \InvalidArgumentException implements Exception
{
- /**
- * @param string $expected description of expected type
- * @param string $parameterName
- * @param mixed $parameter the parameter that is not of the expected type.
- *
- * @return self
- */
- public static function invalidType($expected, $parameterName, $parameter)
+ public static function invalidType(string $expected, string $parameterName, mixed $parameter): self
{
$message = sprintf(
'Invalid argument type: "%s" expected, "%s" given for "%s"',
$expected,
- is_object($parameter) ? get_class($parameter) : gettype($parameter),
- $parameterName
+ get_debug_type($parameter),
+ $parameterName,
);
return new self($message);
diff --git a/src/Surfnet/Stepup/Exception/JsonException.php b/src/Surfnet/Stepup/Exception/JsonException.php
index 0d0128ee1..c454b8ebf 100644
--- a/src/Surfnet/Stepup/Exception/JsonException.php
+++ b/src/Surfnet/Stepup/Exception/JsonException.php
@@ -20,7 +20,7 @@
final class JsonException extends RuntimeException
{
- public static function withMessage($errorMessage)
+ public static function withMessage(string $errorMessage): self
{
return new self(sprintf('Unable to parse JSON data: %s', $errorMessage));
}
diff --git a/src/Surfnet/Stepup/Helper/JsonHelper.php b/src/Surfnet/Stepup/Helper/JsonHelper.php
index 35cc6c166..02e2acf45 100644
--- a/src/Surfnet/Stepup/Helper/JsonHelper.php
+++ b/src/Surfnet/Stepup/Helper/JsonHelper.php
@@ -23,24 +23,20 @@
final class JsonHelper
{
- private static $jsonErrors = [
- JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded',
+ private static array $jsonErrors = [
+ JSON_ERROR_DEPTH => 'JSON_ERROR_DEPTH - Maximum stack depth exceeded',
JSON_ERROR_STATE_MISMATCH => 'JSON_ERROR_STATE_MISMATCH - Underflow or the modes mismatch',
- JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found',
- JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON',
- JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded',
+ JSON_ERROR_CTRL_CHAR => 'JSON_ERROR_CTRL_CHAR - Unexpected control character found',
+ JSON_ERROR_SYNTAX => 'JSON_ERROR_SYNTAX - Syntax error, malformed JSON',
+ JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded',
];
- public static function decode($json)
+ public static function decode(string $json): mixed
{
- if (!is_string($json)) {
- throw InvalidArgumentException::invalidType('string', 'json', $json);
- }
-
$data = json_decode($json, true);
if (JSON_ERROR_NONE !== json_last_error()) {
- $last = json_last_error();
+ $last = json_last_error();
$errorMessage = 'Unknown error';
if (array_key_exists($last, self::$jsonErrors)) {
diff --git a/src/Surfnet/Stepup/Helper/SecondFactorProvePossessionHelper.php b/src/Surfnet/Stepup/Helper/SecondFactorProvePossessionHelper.php
index 945414320..8d89048fd 100644
--- a/src/Surfnet/Stepup/Helper/SecondFactorProvePossessionHelper.php
+++ b/src/Surfnet/Stepup/Helper/SecondFactorProvePossessionHelper.php
@@ -23,33 +23,22 @@
class SecondFactorProvePossessionHelper
{
- /**
- * @var array
- */
- private $skipProvePossessionSecondFactorTypes;
+ private readonly array $skipProvePossessionSecondFactorTypes;
- /**
- * @param SecondFactorTypeService $secondFactorTypeService
- * @param array $skipProvePossessionSecondFactorTypes
- */
public function __construct(
SecondFactorTypeService $secondFactorTypeService,
- array $skipProvePossessionSecondFactorTypes
+ array $skipProvePossessionSecondFactorTypes,
) {
Assert::allInArray(
$skipProvePossessionSecondFactorTypes,
$secondFactorTypeService->getAvailableSecondFactorTypes(),
- 'Unsupported second factor type configured to skip prove possession'
+ 'Unsupported second factor type configured to skip prove possession',
);
$this->skipProvePossessionSecondFactorTypes = $skipProvePossessionSecondFactorTypes;
}
- /**
- * @param SecondFactorType $secondFactorType
- * @return bool
- */
- public function canSkipProvePossession(SecondFactorType $secondFactorType)
+ public function canSkipProvePossession(SecondFactorType $secondFactorType): bool
{
return in_array($secondFactorType->getSecondFactorType(), $this->skipProvePossessionSecondFactorTypes);
}
diff --git a/src/Surfnet/Stepup/Helper/UserDataFormatter.php b/src/Surfnet/Stepup/Helper/UserDataFormatter.php
index 610a55210..dc8b32bee 100644
--- a/src/Surfnet/Stepup/Helper/UserDataFormatter.php
+++ b/src/Surfnet/Stepup/Helper/UserDataFormatter.php
@@ -19,11 +19,8 @@
class UserDataFormatter implements UserDataFormatterInterface
{
- private $applicationName;
-
- public function __construct(string $applicationName)
+ public function __construct(private readonly string $applicationName)
{
- $this->applicationName = $applicationName;
}
public function format(array $userData, array $errors): array
@@ -32,8 +29,8 @@ public function format(array $userData, array $errors): array
foreach ($userData as $name => $event) {
$name = explode('-', $name)[1];
$data[] = [
- 'name' => $name,
- 'value' => $event
+ 'name' => $name,
+ 'value' => $event,
];
}
return $this->formatResponse($data, $errors);
@@ -43,11 +40,11 @@ private function formatResponse(array $userData, array $errors): array
{
$status = 'OK';
$data = [
- 'name' => $this->applicationName,
- 'data' => $userData,
+ 'name' => $this->applicationName,
+ 'data' => $userData,
];
- if (!empty($errors)) {
+ if ($errors !== []) {
$data['message'] = $errors;
$status = 'FAILED';
}
diff --git a/src/Surfnet/Stepup/Identity/Api/Id.php b/src/Surfnet/Stepup/Identity/Api/Id.php
index b60c59097..24ec29f17 100644
--- a/src/Surfnet/Stepup/Identity/Api/Id.php
+++ b/src/Surfnet/Stepup/Identity/Api/Id.php
@@ -18,22 +18,19 @@
namespace Surfnet\Stepup\Identity\Api;
+use InvalidArgumentException;
+
interface Id
{
/**
- * @param mixed $value
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*/
- public function __construct($value);
+ public function __construct(string $value);
/**
* @return string
*/
public function __toString();
- /**
- * @param Id $other
- * @return bool
- */
- public function equals(Id $other);
+ public function equals(Id $other): bool;
}
diff --git a/src/Surfnet/Stepup/Identity/Api/Identity.php b/src/Surfnet/Stepup/Identity/Api/Identity.php
index a0cfc2ed9..9027e291c 100644
--- a/src/Surfnet/Stepup/Identity/Api/Identity.php
+++ b/src/Surfnet/Stepup/Identity/Api/Identity.php
@@ -19,6 +19,7 @@
namespace Surfnet\Stepup\Identity\Api;
use Broadway\Domain\AggregateRoot;
+use Broadway\EventSourcing\EventSourcedAggregateRoot;
use Surfnet\Stepup\Configuration\InstitutionConfiguration;
use Surfnet\Stepup\Exception\DomainException;
use Surfnet\Stepup\Helper\SecondFactorProvePossessionHelper;
@@ -51,155 +52,93 @@
interface Identity extends AggregateRoot
{
- /**
- * @param IdentityId $id
- * @param Institution $institution
- * @param NameId $nameId
- * @param CommonName $commonName
- * @param Email $email
- * @param Locale $preferredLocale
- * @return Identity
- */
public static function create(
IdentityId $id,
Institution $institution,
NameId $nameId,
CommonName $commonName,
Email $email,
- Locale $preferredLocale
- );
+ Locale $preferredLocale,
+ ): Identity;
/**
* Construct a new aggregate root. Aggregate roots can only be affected by events, so no parameters are allowed.
*/
public function __construct();
- /**
- * @param CommonName $commonName
- * @return void
- */
- public function rename(CommonName $commonName);
+ public function rename(CommonName $commonName): void;
- /**
- * @param Email $email
- * @return void
- */
- public function changeEmail(Email $email);
+ public function changeEmail(Email $email): void;
- /**
- * @param SecondFactorId $secondFactorId
- * @param YubikeyPublicId $yubikeyPublicId
- * @param int $maxNumberOfTokens
- * @return void
- */
public function bootstrapYubikeySecondFactor(
- SecondFactorId $secondFactorId,
+ SecondFactorId $secondFactorId,
YubikeyPublicId $yubikeyPublicId,
- $maxNumberOfTokens
- );
+ int $maxNumberOfTokens,
+ ): void;
- /**
- * @param SecondFactorId $secondFactorId
- * @param YubikeyPublicId $yubikeyPublicId
- * @param bool $emailVerificationRequired
- * @param EmailVerificationWindow $emailVerificationWindow
- * @param int $maxNumberOfTokens
- * @return void
- */
public function provePossessionOfYubikey(
- SecondFactorId $secondFactorId,
- YubikeyPublicId $yubikeyPublicId,
- $emailVerificationRequired,
+ SecondFactorId $secondFactorId,
+ YubikeyPublicId $yubikeyPublicId,
+ bool $emailVerificationRequired,
EmailVerificationWindow $emailVerificationWindow,
- $maxNumberOfTokens
- );
+ int $maxNumberOfTokens,
+ ): void;
- /**
- * @param SecondFactorId $secondFactorId
- * @param PhoneNumber $phoneNumber
- * @param bool $emailVerificationRequired
- * @param EmailVerificationWindow $emailVerificationWindow
- * @param int $maxNumberOfTokens
- * @return void
- */
public function provePossessionOfPhone(
- SecondFactorId $secondFactorId,
- PhoneNumber $phoneNumber,
- $emailVerificationRequired,
+ SecondFactorId $secondFactorId,
+ PhoneNumber $phoneNumber,
+ bool $emailVerificationRequired,
EmailVerificationWindow $emailVerificationWindow,
- $maxNumberOfTokens
- );
+ int $maxNumberOfTokens,
+ ): void;
/**
- * @param SecondFactorId $secondFactorId
- * @param StepupProvider $provider
- * @param GssfId $gssfId
- * @param bool $emailVerificationRequired
- * @param EmailVerificationWindow $emailVerificationWindow
* @parame int $maxNumberOfTokens
- * @return void
*/
public function provePossessionOfGssf(
- SecondFactorId $secondFactorId,
- StepupProvider $provider,
- GssfId $gssfId,
- $emailVerificationRequired,
+ SecondFactorId $secondFactorId,
+ StepupProvider $provider,
+ GssfId $gssfId,
+ bool $emailVerificationRequired,
EmailVerificationWindow $emailVerificationWindow,
- $maxNumberOfTokens
- );
+ int $maxNumberOfTokens,
+ ): void;
/**
- * @param SecondFactorId $secondFactorId
- * @param U2fKeyHandle $keyHandle
- * @param bool $emailVerificationRequired
- * @param EmailVerificationWindow $emailVerificationWindow
* @parame int $maxNumberOfTokens
- * @return void
* @deprecated Built in U2F support is dropped from StepUp, this was not removed to support event replay
*/
public function provePossessionOfU2fDevice(
- SecondFactorId $secondFactorId,
- U2fKeyHandle $keyHandle,
- $emailVerificationRequired,
+ SecondFactorId $secondFactorId,
+ U2fKeyHandle $keyHandle,
+ bool $emailVerificationRequired,
EmailVerificationWindow $emailVerificationWindow,
- $maxNumberOfTokens
- );
+ int $maxNumberOfTokens,
+ ): void;
/**
- * @param string $verificationNonce
* @return void
*/
- public function verifyEmail($verificationNonce);
+ public function verifyEmail(string $verificationNonce): void;
/**
* Attempts to vet another identity's verified second factor.
*
- * @param Identity $registrant
- * @param SecondFactorId $registrantsSecondFactorId
- * @param SecondFactorType $registrantsSecondFactorType
- * @param SecondFactorIdentifier $registrantsSecondFactorIdentifier
- * @param string $registrationCode
- * @param DocumentNumber $documentNumber
- * @param bool $identityVerified
- * @param SecondFactorTypeService $secondFactorTypeService
- * @param SecondFactorProvePossessionHelper $secondFactorProvePossessionHelper
- * @param bool $provePossessionSkipped
- * @return void
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function vetSecondFactor(
- Identity $registrant,
- SecondFactorId $registrantsSecondFactorId,
- SecondFactorType $registrantsSecondFactorType,
- SecondFactorIdentifier $registrantsSecondFactorIdentifier,
- $registrationCode,
- DocumentNumber $documentNumber,
- $identityVerified,
- SecondFactorTypeService $secondFactorTypeService,
+ Identity $registrant,
+ SecondFactorId $registrantsSecondFactorId,
+ SecondFactorType $registrantsSecondFactorType,
+ SecondFactorIdentifier $registrantsSecondFactorIdentifier,
+ string $registrationCode,
+ DocumentNumber $documentNumber,
+ bool $identityVerified,
+ SecondFactorTypeService $secondFactorTypeService,
SecondFactorProvePossessionHelper $secondFactorProvePossessionHelper,
- $provePossessionSkipped
- );
+ bool $provePossessionSkipped,
+ ): void;
/**
* Self vetting, is when the user uses its own token to vet another.
@@ -216,13 +155,13 @@ public function selfVetSecondFactor(
Loa $authoringSecondFactorLoa,
string $registrationCode,
SecondFactorIdentifier $secondFactorIdentifier,
- SecondFactorTypeService $secondFactorTypeService
+ SecondFactorTypeService $secondFactorTypeService,
): void;
public function registerSelfAssertedSecondFactor(
SecondFactorIdentifier $secondFactorIdentifier,
SecondFactorTypeService $secondFactorTypeService,
- RecoveryTokenId $recoveryTokenId
+ RecoveryTokenId $recoveryTokenId,
): void;
/**
@@ -232,42 +171,26 @@ public function migrateVettedSecondFactor(
Identity $sourceIdentity,
SecondFactorId $secondFactorId,
string $targetSecondFactorId,
- int $maxNumberOfTokens
+ int $maxNumberOfTokens,
): void;
/**
* Makes the identity comply with an authority's vetting of a verified second factor.
*
- * @param SecondFactorId $secondFactorId
- * @param SecondFactorType $secondFactorType
- * @param SecondFactorIdentifier $secondFactorIdentifier
- * @param string $registrationCode
- * @param DocumentNumber $documentNumber
- * @param bool $provePossessionSkipped
* @throws DomainException
- * @return void
*/
public function complyWithVettingOfSecondFactor(
- SecondFactorId $secondFactorId,
- SecondFactorType $secondFactorType,
+ SecondFactorId $secondFactorId,
+ SecondFactorType $secondFactorType,
SecondFactorIdentifier $secondFactorIdentifier,
- $registrationCode,
- DocumentNumber $documentNumber,
- $provePossessionSkipped
- );
+ string $registrationCode,
+ DocumentNumber $documentNumber,
+ bool $provePossessionSkipped,
+ ): void;
- /**
- * @param SecondFactorId $secondFactorId
- * @return void
- */
- public function revokeSecondFactor(SecondFactorId $secondFactorId);
+ public function revokeSecondFactor(SecondFactorId $secondFactorId): void;
- /**
- * @param SecondFactorId $secondFactorId
- * @param IdentityId $authorityId
- * @return void
- */
- public function complyWithSecondFactorRevocation(SecondFactorId $secondFactorId, IdentityId $authorityId);
+ public function complyWithSecondFactorRevocation(SecondFactorId $secondFactorId, IdentityId $authorityId): void;
/**
* From SelfService, an Identity is allowed to revoke a recovery token
@@ -280,112 +203,81 @@ public function revokeRecoveryToken(RecoveryTokenId $recoveryTokenId): void;
*/
public function complyWithRecoveryTokenRevocation(RecoveryTokenId $recoveryTokenId, IdentityId $authorityId): void;
- /**
- * @param RegistrationAuthorityRole $role
- * @param Institution $institution
- * @param Location $location
- * @param ContactInformation $contactInformation
- * @param InstitutionConfiguration $institutionConfiguration
- * @return void
- */
public function accreditWith(
RegistrationAuthorityRole $role,
Institution $institution,
Location $location,
ContactInformation $contactInformation,
- InstitutionConfiguration $institutionConfiguration
- );
+ InstitutionConfiguration $institutionConfiguration,
+ ): void;
- /**
- * @param Institution $institution
- * @param RegistrationAuthorityRole $role
- * @param InstitutionConfiguration $institutionConfiguration
- * @return void
- */
- public function appointAs(Institution $institution, RegistrationAuthorityRole $role, InstitutionConfiguration $institutionConfiguration);
+ public function appointAs(
+ Institution $institution,
+ RegistrationAuthorityRole $role,
+ InstitutionConfiguration $institutionConfiguration,
+ ): void;
- /**
- * @param Institution $institution
- * @param Location $location
- * @param ContactInformation $contactInformation
- * @return void
- */
- public function amendRegistrationAuthorityInformation(Institution $institution, Location $location, ContactInformation $contactInformation);
+ public function amendRegistrationAuthorityInformation(
+ Institution $institution,
+ Location $location,
+ ContactInformation $contactInformation,
+ ): void;
- /**
- * @param Institution $institution
- * @return void
- */
- public function retractRegistrationAuthority(Institution $institution);
+ public function retractRegistrationAuthority(Institution $institution): void;
- /**
- * @param Locale $preferredLocale
- * @return void
- */
- public function expressPreferredLocale(Locale $preferredLocale);
+ public function expressPreferredLocale(Locale $preferredLocale): void;
/**
* @return void
*/
- public function forget();
+ public function forget(): void;
/**
* @return IdentityId
*/
- public function getId();
+ public function getId(): IdentityId;
/**
* @return NameId
*/
- public function getNameId();
+ public function getNameId(): NameId;
/**
* @return Institution
*/
- public function getInstitution();
+ public function getInstitution(): Institution;
/**
* @return CommonName
*/
- public function getCommonName();
+ public function getCommonName(): CommonName;
/**
* @return Email
*/
- public function getEmail();
+ public function getEmail(): Email;
/**
* @return Locale
*/
- public function getPreferredLocale();
+ public function getPreferredLocale(): Locale;
- /**
- * @param SecondFactorId $secondFactorId
- * @return VerifiedSecondFactor|null
- */
- public function getVerifiedSecondFactor(SecondFactorId $secondFactorId);
+ public function getVerifiedSecondFactor(SecondFactorId $secondFactorId): ?VerifiedSecondFactor;
- /**
- * @param SecondFactorId $secondFactorId
- * @return VettedSecondFactor|null
- */
public function getVettedSecondFactorById(SecondFactorId $secondFactorId): ?VettedSecondFactor;
- /**
- * @return IdentityId We're deviating from Broadway's official API, as they accept toString-able VOs as IDs, and we
- * require the IdentityId VO in our SensitiveDataEventStoreDecorator.
- */
- public function getAggregateRootId(): string;
-
/**
* Identity proved possession of a phone number by reproducing a secret sent to it via SMS
*/
- public function provePossessionOfPhoneRecoveryToken(RecoveryTokenId $recoveryTokenId, PhoneNumber $phoneNumber): void;
+ public function provePossessionOfPhoneRecoveryToken(
+ RecoveryTokenId $recoveryTokenId,
+ PhoneNumber $phoneNumber,
+ ): void;
/**
* Identity promises it stored the once printed on screen password in a safe location
*/
public function promisePossessionOfSafeStoreSecretRecoveryToken(RecoveryTokenId $tokenId, SafeStore $secret): void;
- public function saveVettingTypeHints(Institution $institution, VettingTypeHintCollection $hints);
+ public function saveVettingTypeHints(Institution $institution, VettingTypeHintCollection $hints): void;
}
diff --git a/src/Surfnet/Stepup/Identity/Api/Whitelist.php b/src/Surfnet/Stepup/Identity/Api/Whitelist.php
index 537d1aba4..40a9097c0 100644
--- a/src/Surfnet/Stepup/Identity/Api/Whitelist.php
+++ b/src/Surfnet/Stepup/Identity/Api/Whitelist.php
@@ -29,33 +29,21 @@ public function __construct();
/**
* Create a new Whitelist instance with the institutions that are on the initial whitelist
- *
- * @param InstitutionCollection $institutionCollection
- * @return Whitelist
*/
- public static function create(InstitutionCollection $institutionCollection);
+ public static function create(InstitutionCollection $institutionCollection): Whitelist;
/**
* Replace all institutions on the whitelist with the institutions in the given collection
- *
- * @param InstitutionCollection $institutionCollection
- * @return void
*/
- public function replaceAll(InstitutionCollection $institutionCollection);
+ public function replaceAll(InstitutionCollection $institutionCollection): void;
/**
* Add the institutions in the given collection to the whitelist
- *
- * @param InstitutionCollection $institutionCollection
- * @return void
*/
- public function add(InstitutionCollection $institutionCollection);
+ public function add(InstitutionCollection $institutionCollection): void;
/**
* Remove the institutions in the given collection from the whitelist
- *
- * @param InstitutionCollection $institutionCollection
- * @return mixed
*/
- public function remove(InstitutionCollection $institutionCollection);
+ public function remove(InstitutionCollection $institutionCollection): void;
}
diff --git a/src/Surfnet/Stepup/Identity/AuditLog/Metadata.php b/src/Surfnet/Stepup/Identity/AuditLog/Metadata.php
index 3d3f29f38..2b965831b 100644
--- a/src/Surfnet/Stepup/Identity/AuditLog/Metadata.php
+++ b/src/Surfnet/Stepup/Identity/AuditLog/Metadata.php
@@ -18,50 +18,41 @@
namespace Surfnet\Stepup\Identity\AuditLog;
+use Surfnet\Stepup\Identity\Value\IdentityId;
+use Surfnet\Stepup\Identity\Value\Institution;
+use Surfnet\Stepup\Identity\Value\RecoveryTokenId;
+use Surfnet\Stepup\Identity\Value\RecoveryTokenType;
+use Surfnet\Stepup\Identity\Value\SecondFactorId;
+use Surfnet\Stepup\Identity\Value\SecondFactorIdentifier;
use Surfnet\Stepup\Identity\Value\VettingType;
+use Surfnet\StepupBundle\Value\SecondFactorType;
final class Metadata
{
/**
- * @var \Surfnet\Stepup\Identity\Value\IdentityId
+ * @var IdentityId
*/
- public $identityId;
+ public IdentityId $identityId;
/**
- * @var \Surfnet\Stepup\Identity\Value\Institution
+ * @var Institution
*/
- public $identityInstitution;
+ public Institution $identityInstitution;
- /**
- * @var \Surfnet\Stepup\Identity\Value\Institution
- */
- public $raInstitution;
+ public ?Institution $raInstitution = null;
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId|null
- */
- public $secondFactorId;
+ public ?SecondFactorId $secondFactorId = null;
- /**
- * @var \Surfnet\StepupBundle\Value\SecondFactorType|null
- */
- public $secondFactorType;
+ public ?SecondFactorType $secondFactorType = null;
/**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier|null
+ * @var SecondFactorIdentifier|null
*/
- public $secondFactorIdentifier;
+ public ?SecondFactorIdentifier $secondFactorIdentifier = null;
- /** @var VettingType */
- public $vettingType;
+ public ?VettingType $vettingType = null;
- /**
- * @var \Surfnet\Stepup\Identity\Value\RecoveryTokenId
- */
- public $recoveryTokenId;
+ public ?RecoveryTokenId $recoveryTokenId = null;
- /**
- * @var \Surfnet\Stepup\Identity\Value\RecoveryTokenType
- */
- public $recoveryTokenType;
+ public ?RecoveryTokenType $recoveryTokenType = null;
}
diff --git a/src/Surfnet/Stepup/Identity/Collection/InstitutionCollection.php b/src/Surfnet/Stepup/Identity/Collection/InstitutionCollection.php
index 776419c76..016765f9e 100644
--- a/src/Surfnet/Stepup/Identity/Collection/InstitutionCollection.php
+++ b/src/Surfnet/Stepup/Identity/Collection/InstitutionCollection.php
@@ -20,14 +20,18 @@
use ArrayIterator;
use Broadway\Serializer\Serializable as SerializableInterface;
+use Iterator;
use IteratorAggregate;
use JsonSerializable;
use Surfnet\Stepup\Exception\RuntimeException;
use Surfnet\Stepup\Identity\Value\Institution;
+/**
+ * @implements IteratorAggregate
+ */
final class InstitutionCollection implements IteratorAggregate, JsonSerializable, SerializableInterface
{
- private $elements = [];
+ private array $elements = [];
public function __construct(array $institutions = [])
{
@@ -36,7 +40,7 @@ public function __construct(array $institutions = [])
}
}
- public function contains(Institution $institution)
+ public function contains(Institution $institution): bool
{
return in_array($institution, $this->elements);
}
@@ -44,16 +48,17 @@ public function contains(Institution $institution)
/**
* Adds the institution to this collection
*
- * @param Institution $institution
* @throws RuntimeException when the institution already exists in this collection
*/
- public function add(Institution $institution)
+ public function add(Institution $institution): void
{
if (in_array($institution, $this->elements)) {
- throw new RuntimeException(sprintf(
- 'Institution "%s" is already in this collection',
- $institution
- ));
+ throw new RuntimeException(
+ sprintf(
+ 'Institution "%s" is already in this collection',
+ $institution,
+ ),
+ );
}
$this->elements[] = $institution;
@@ -61,10 +66,8 @@ public function add(Institution $institution)
/**
* Adds all institutions from the given collection to this collection
- *
- * @param InstitutionCollection $institutionCollection
*/
- public function addAllFrom(InstitutionCollection $institutionCollection)
+ public function addAllFrom(InstitutionCollection $institutionCollection): void
{
foreach ($institutionCollection as $institution) {
$this->add($institution);
@@ -74,58 +77,51 @@ public function addAllFrom(InstitutionCollection $institutionCollection)
/**
* Removes an institution from this collection
*
- * @param Institution $institution
* @throws RuntimeException when the institution to remove is not in this collection
*/
- public function remove(Institution $institution)
+ public function remove(Institution $institution): void
{
if (!in_array($institution, $this->elements)) {
- throw new RuntimeException(sprintf(
- 'Cannot remove Institution "%s" from the collection as it is not in the collection',
- $institution
- ));
+ throw new RuntimeException(
+ sprintf(
+ 'Cannot remove Institution "%s" from the collection as it is not in the collection',
+ $institution,
+ ),
+ );
}
- $elements = array_filter($this->elements, function ($inst) use ($institution) {
- return !$institution->equals($inst);
- });
+ $elements = array_filter($this->elements, fn($inst): bool => !$institution->equals($inst));
$this->elements = $elements;
}
/**
* Removes all Institutions in the given collection from this collection
- *
- * @param InstitutionCollection $institutionCollection
*/
- public function removeAllIn(InstitutionCollection $institutionCollection)
+ public function removeAllIn(InstitutionCollection $institutionCollection): void
{
foreach ($institutionCollection as $institution) {
$this->remove($institution);
}
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return ['institutions' => $this->elements];
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
- $institutions = array_map(function ($institution) {
- return new Institution($institution);
- }, $data);
+ $institutions = array_map(fn($institution): Institution => new Institution($institution), $data);
return new self($institutions);
}
public function serialize(): array
{
- return array_map(function (Institution $institution) {
- return (string) $institution;
- }, $this->elements);
+ return array_map(fn(Institution $institution): string => (string)$institution, $this->elements);
}
- public function getIterator()
+ public function getIterator(): Iterator
{
return new ArrayIterator($this->elements);
}
diff --git a/src/Surfnet/Stepup/Identity/Collection/VettingTypeHintCollection.php b/src/Surfnet/Stepup/Identity/Collection/VettingTypeHintCollection.php
index b1e909684..640e1b746 100644
--- a/src/Surfnet/Stepup/Identity/Collection/VettingTypeHintCollection.php
+++ b/src/Surfnet/Stepup/Identity/Collection/VettingTypeHintCollection.php
@@ -20,13 +20,13 @@
use Broadway\Serializer\Serializable as SerializableInterface;
use JsonSerializable;
+use Stringable;
use Surfnet\Stepup\Exception\RuntimeException;
use Surfnet\Stepup\Identity\Value\VettingTypeHint;
-use function json_encode;
-final class VettingTypeHintCollection implements JsonSerializable, SerializableInterface
+final class VettingTypeHintCollection implements JsonSerializable, SerializableInterface, Stringable
{
- private $elements = [];
+ private array $elements = [];
public function __construct(array $hints = [])
{
@@ -35,56 +35,42 @@ public function __construct(array $hints = [])
}
}
- public function add(VettingTypeHint $hint)
+ public function add(VettingTypeHint $hint): void
{
if (in_array($hint, $this->elements)) {
- throw new RuntimeException(sprintf(
- 'Vetting type hint "%s" is already in this collection',
- $hint
- ));
+ throw new RuntimeException(
+ sprintf(
+ 'Vetting type hint "%s" is already in this collection',
+ $hint,
+ ),
+ );
}
$this->elements[] = $hint;
}
- public function remove(VettingTypeHint $hint)
- {
- if (!in_array($hint, $this->elements)) {
- throw new RuntimeException(sprintf(
- 'Cannot remove vetting type hint "%s" from the collection as it is not in the collection',
- $hint
- ));
- }
-
- $elements = array_filter($this->elements, function ($inst) use ($hint) {
- return !$hint->equals($inst);
- });
- $this->elements = $elements;
- }
-
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return $this->elements;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
- $institutions = array_map(function ($hint) {
- return new VettingTypeHint($hint['locale'], $hint['hint']);
- }, $data);
+ $institutions = array_map(
+ fn(array $hint): VettingTypeHint => new VettingTypeHint($hint['locale'], $hint['hint']),
+ $data,
+ );
return new self($institutions);
}
public function __toString(): string
{
- return (string) json_encode($this->jsonSerialize());
+ return (string)json_encode($this->jsonSerialize());
}
public function serialize(): array
{
- return array_map(function (VettingTypeHint $hint) {
- return $hint->jsonSerialize();
- }, $this->elements);
+ return array_map(fn(VettingTypeHint $hint): array => $hint->jsonSerialize(), $this->elements);
}
}
diff --git a/src/Surfnet/Stepup/Identity/Collection/VettingTypeHintCollection.php~Stashed changes b/src/Surfnet/Stepup/Identity/Collection/VettingTypeHintCollection.php~Stashed changes
deleted file mode 100644
index 8661252fa..000000000
--- a/src/Surfnet/Stepup/Identity/Collection/VettingTypeHintCollection.php~Stashed changes
+++ /dev/null
@@ -1,84 +0,0 @@
-add($hint);
- }
- }
-
- public function add(VettingTypeHint $hint)
- {
- if (in_array($hint, $this->elements)) {
- throw new RuntimeException(sprintf(
- 'Vetting type hint "%s" is already in this collection',
- $hint
- ));
- }
-
- $this->elements[] = $hint;
- }
-
- public function remove(VettingTypeHint $hint)
- {
- if (!in_array($hint, $this->elements)) {
- throw new RuntimeException(sprintf(
- 'Cannot remove vetting type hint "%s" from the collection as it is not in the collection',
- $hint
- ));
- }
-
- $elements = array_filter($this->elements, function ($inst) use ($hint) {
- return !$hint->equals($inst);
- });
- $this->elements = $elements;
- }
-
- public function jsonSerialize()
- {
- return ['hints' => $this->elements];
- }
-
- public static function deserialize(array $data)
- {
- $institutions = array_map(function ($hint) {
- return new VettingTypeHint($hint['locale'], $hint['hint']);
- }, $data);
-
- return new self($institutions);
- }
-
- public function serialize(): array
- {
- return array_map(function (VettingTypeHint $hint) {
- return $hint->jsonSerialize();
- }, $this->elements);
- }
-}
diff --git a/src/Surfnet/Stepup/Identity/Entity/AbstractSecondFactor.php b/src/Surfnet/Stepup/Identity/Entity/AbstractSecondFactor.php
index f54a6f9d8..bf3c9b231 100644
--- a/src/Surfnet/Stepup/Identity/Entity/AbstractSecondFactor.php
+++ b/src/Surfnet/Stepup/Identity/Entity/AbstractSecondFactor.php
@@ -20,19 +20,27 @@
use Broadway\EventSourcing\SimpleEventSourcedEntity;
use Surfnet\Stepup\Identity\Value\SecondFactorIdentifier;
+use Surfnet\Stepup\Identity\Value\UnknownVettingType;
+use Surfnet\Stepup\Identity\Value\VettingType;
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
use Surfnet\StepupBundle\Value\SecondFactorType;
+use Surfnet\StepupBundle\Value\VettingType as StepupBundleVettingType;
abstract class AbstractSecondFactor extends SimpleEventSourcedEntity implements SecondFactor
{
public function hasEqualOrHigherLoaComparedTo(SecondFactor $comparable, SecondFactorTypeService $service): bool
{
- return $comparable->hasTypeWithEqualOrLowerLoaComparedTo($this->getType(), $service);
+ return $comparable->hasTypeWithEqualOrLowerLoaComparedTo($this->getType(), $this->vettingType(), $service);
}
- public function hasTypeWithEqualOrLowerLoaComparedTo(SecondFactorType $type, SecondFactorTypeService $service): bool
+ public function hasTypeWithEqualOrLowerLoaComparedTo(SecondFactorType $type, VettingType $vettingType, SecondFactorTypeService $service): bool
{
- return $service->hasEqualOrLowerLoaComparedTo($this->getType(), $type);
+ // SecondFactorTypeService works with the vetting type value objects
+ // from the stepup bundle, so convert them.
+ $ownVettingType = new StepupBundleVettingType($this->vettingType()->type());
+ $otherVettingType = new StepupBundleVettingType($vettingType->type());
+
+ return $service->hasEqualOrLowerLoaComparedTo($this->getType(), $ownVettingType, $type, $otherVettingType);
}
public function typeAndIdentifierAreEqual(SecondFactorType $type, SecondFactorIdentifier $identifier): bool
@@ -41,4 +49,14 @@ public function typeAndIdentifierAreEqual(SecondFactorType $type, SecondFactorId
$identifierIsEqual = $this->getIdentifier()->equals($identifier);
return $typeIsEqual && $identifierIsEqual;
}
+
+ /**
+ * By default the vetting type of a token is unknown UNITL it has been vetted
+ * So only the VettedSecondFactor implementation returns anything other than
+ * the UnknownVettingType
+ */
+ public function vettingType(): VettingType
+ {
+ return new UnknownVettingType();
+ }
}
diff --git a/src/Surfnet/Stepup/Identity/Entity/ConfigurableSettings.php b/src/Surfnet/Stepup/Identity/Entity/ConfigurableSettings.php
index b202434b2..de692793d 100644
--- a/src/Surfnet/Stepup/Identity/Entity/ConfigurableSettings.php
+++ b/src/Surfnet/Stepup/Identity/Entity/ConfigurableSettings.php
@@ -18,6 +18,7 @@
namespace Surfnet\Stepup\Identity\Entity;
+use Exception;
use Surfnet\Stepup\DateTime\DateTime;
use Surfnet\Stepup\Exception\InvalidArgumentException;
use Surfnet\Stepup\Identity\Value\EmailVerificationWindow;
@@ -29,33 +30,27 @@
*/
final class ConfigurableSettings
{
- /**
- * @var TimeFrame
- */
- private $emailVerificationTimeFrame;
-
/**
* @var Locale[]
*/
- private $locales;
+ private readonly array $locales;
/**
- * @param TimeFrame $timeFrame
- * @param Locale[] $locales
+ * @param Locale[] $locales
*/
- private function __construct(TimeFrame $timeFrame, array $locales)
- {
+ private function __construct(
+ private readonly TimeFrame $emailVerificationTimeFrame,
+ array $locales,
+ ) {
foreach ($locales as $index => $locale) {
if (!$locale instanceof Locale) {
throw InvalidArgumentException::invalidType(
- 'Surfnet\Stepup\Identity\Value\Locale',
+ Locale::class,
sprintf('locales[%s]', $index),
- $locale
+ $locale,
);
}
}
-
- $this->emailVerificationTimeFrame = $timeFrame;
$this->locales = $locales;
}
@@ -63,43 +58,37 @@ private function __construct(TimeFrame $timeFrame, array $locales)
* @param int $emailVerificationTimeFrame positive integer
* @param string[] $locales
* @return ConfigurableSettings
+ * @throws Exception
+ * @throws Exception
*/
- public static function create($emailVerificationTimeFrame, array $locales)
+ public static function create(int $emailVerificationTimeFrame, array $locales): self
{
return new self(
TimeFrame::ofSeconds($emailVerificationTimeFrame),
array_map(
- function ($locale) {
- return new Locale($locale);
- },
- $locales
- )
+ fn($locale): Locale => new Locale($locale),
+ $locales,
+ ),
);
}
/**
* @return EmailVerificationWindow
*/
- public function createNewEmailVerificationWindow()
+ public function createNewEmailVerificationWindow(): EmailVerificationWindow
{
return EmailVerificationWindow::createFromTimeFrameStartingAt(
$this->emailVerificationTimeFrame,
- DateTime::now()
+ DateTime::now(),
);
}
- /**
- * @param Locale $locale
- * @return bool
- */
- public function isSupportedLocale(Locale $locale)
+ public function isSupportedLocale(Locale $locale): bool
{
return array_reduce(
$this->locales,
- function ($supported, Locale $supportedLocale) use ($locale) {
- return $supported || $supportedLocale->equals($locale);
- },
- false
+ fn($supported, Locale $supportedLocale): bool => $supported || $supportedLocale->equals($locale),
+ false,
);
}
}
diff --git a/src/Surfnet/Stepup/Identity/Entity/InstitutionCollection.php b/src/Surfnet/Stepup/Identity/Entity/InstitutionCollection.php
index 809e0f75e..3b319bb15 100644
--- a/src/Surfnet/Stepup/Identity/Entity/InstitutionCollection.php
+++ b/src/Surfnet/Stepup/Identity/Entity/InstitutionCollection.php
@@ -18,73 +18,49 @@
namespace Surfnet\Stepup\Identity\Entity;
-use Surfnet\Stepup\Configuration\Value\InstitutionRole;
+use Surfnet\Stepup\Identity\Collection\InstitutionCollection as Institutions;
use Surfnet\Stepup\Identity\Value\Institution;
-use \Surfnet\Stepup\Identity\Collection\InstitutionCollection as Institutions;
final class InstitutionCollection
{
- /**
- * @var InstitutionRole[]
- */
- private $institutions = [];
+ private array $institutions = [];
- /**
- * @param Institution $institution
- */
- public function set(Institution $institution)
+ public function set(Institution $institution): void
{
$this->institutions[(string)$institution] = $institution;
}
- /**
- * @param Institutions $institutions
- */
- public function update(Institutions $institutions)
+ public function update(Institutions $institutions): void
{
foreach ($institutions as $institution) {
- $this->institutions[(string)$institutions] = $institution;
+ $this->institutions[(string)$institution] = $institution;
}
}
- /**
- * @param Institution $institution
- * @return Institution
- */
- public function get(Institution $institution)
+ public function get(Institution $institution): Institution
{
return $this->institutions[(string)$institution];
}
- /**
- * @param Institution $institution
- * @return Institution
- */
- public function exists(Institution $institution)
+ public function exists(Institution $institution): bool
{
return array_key_exists((string)$institution, $this->institutions);
}
- /**
- * @param Institution $institution
- */
- public function remove(Institution $institution)
+ public function remove(Institution $institution): void
{
unset($this->institutions[(string)$institution]);
}
- /**
- * @return int
- */
- public function count()
+ public function count(): int
{
return count($this->institutions);
}
/**
- * @return InstitutionRole[]
+ * @return Institution[]
*/
- public function institutions()
+ public function institutions(): array
{
return $this->institutions;
}
diff --git a/src/Surfnet/Stepup/Identity/Entity/RecoveryToken.php b/src/Surfnet/Stepup/Identity/Entity/RecoveryToken.php
index c32469983..0790f5096 100644
--- a/src/Surfnet/Stepup/Identity/Entity/RecoveryToken.php
+++ b/src/Surfnet/Stepup/Identity/Entity/RecoveryToken.php
@@ -18,35 +18,27 @@
namespace Surfnet\Stepup\Identity\Entity;
+use Broadway\EventSourcing\EventSourcedAggregateRoot;
use Broadway\EventSourcing\SimpleEventSourcedEntity;
+use Surfnet\Stepup\Identity\Api\Identity;
use Surfnet\Stepup\Identity\Event\CompliedWithRecoveryCodeRevocationEvent;
use Surfnet\Stepup\Identity\Event\RecoveryTokenRevokedEvent;
-use Surfnet\Stepup\Identity\Api\Identity;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\RecoveryTokenId;
use Surfnet\Stepup\Identity\Value\RecoveryTokenType;
final class RecoveryToken extends SimpleEventSourcedEntity
{
- /**
- * @var RecoveryTokenId
- */
- private $tokenId;
+ private ?RecoveryTokenId $tokenId = null;
- /**
- * @var RecoveryTokenType
- */
- private $type;
+ private ?RecoveryTokenType $type = null;
- /**
- * @var Identity
- */
- private $identity;
+ private ?Identity $identity = null;
public static function create(
RecoveryTokenId $id,
RecoveryTokenType $type,
- Identity $identity
+ Identity&EventSourcedAggregateRoot $identity,
): self {
$token = new self;
$token->tokenId = $id;
@@ -70,19 +62,19 @@ public function getType(): RecoveryTokenType
return $this->type;
}
- public function revoke()
+ public function revoke(): void
{
$this->apply(
new RecoveryTokenRevokedEvent(
$this->identity->getId(),
$this->identity->getInstitution(),
$this->tokenId,
- $this->type
- )
+ $this->type,
+ ),
);
}
- public function complyWithRevocation(IdentityId $authorityId)
+ public function complyWithRevocation(IdentityId $authorityId): void
{
$this->apply(
new CompliedWithRecoveryCodeRevocationEvent(
@@ -90,8 +82,8 @@ public function complyWithRevocation(IdentityId $authorityId)
$this->identity->getInstitution(),
$this->tokenId,
$this->type,
- $authorityId
- )
+ $authorityId,
+ ),
);
}
}
diff --git a/src/Surfnet/Stepup/Identity/Entity/RecoveryTokenCollection.php b/src/Surfnet/Stepup/Identity/Entity/RecoveryTokenCollection.php
index ec5042ef8..638558ced 100644
--- a/src/Surfnet/Stepup/Identity/Entity/RecoveryTokenCollection.php
+++ b/src/Surfnet/Stepup/Identity/Entity/RecoveryTokenCollection.php
@@ -27,7 +27,7 @@ final class RecoveryTokenCollection
/**
* @var RecoveryToken[]
*/
- private $recoveryTokens = [];
+ private array $recoveryTokens = [];
public function set(RecoveryToken $recoveryToken): void
{
@@ -42,7 +42,7 @@ public function get(RecoveryTokenId $id): RecoveryToken
return $this->recoveryTokens[(string)$id];
}
- public function hasType(RecoveryTokenType $type)
+ public function hasType(RecoveryTokenType $type): bool
{
foreach ($this->recoveryTokens as $token) {
if ($type->equals($token->getType())) {
@@ -57,7 +57,7 @@ public function count(): int
return count($this->recoveryTokens);
}
- public function remove(RecoveryTokenId $recoveryTokenId)
+ public function remove(RecoveryTokenId $recoveryTokenId): void
{
unset($this->recoveryTokens[(string)$recoveryTokenId]);
}
diff --git a/src/Surfnet/Stepup/Identity/Entity/RegistrationAuthority.php b/src/Surfnet/Stepup/Identity/Entity/RegistrationAuthority.php
index 3822be839..aec69096a 100644
--- a/src/Surfnet/Stepup/Identity/Entity/RegistrationAuthority.php
+++ b/src/Surfnet/Stepup/Identity/Entity/RegistrationAuthority.php
@@ -29,80 +29,49 @@
*/
final class RegistrationAuthority extends SimpleEventSourcedEntity
{
- /**
- * @var \Surfnet\Stepup\Identity\Value\RegistrationAuthorityRole
- */
- private $role;
+ private ?RegistrationAuthorityRole $role = null;
- /**
- * @var \Surfnet\Stepup\Identity\Value\Location
- */
- private $location;
+ // @phpstan-ignore-next-line PHPStan can not see that this field is written when serialized to the database
+ private ?Location $location = null;
- /**
- * @var \Surfnet\Stepup\Identity\Value\ContactInformation
- */
- private $contactInformation;
+ // @phpstan-ignore-next-line PHPStan can not see that this field is written when serialized to the database
+ private ?ContactInformation $contactInformation = null;
- /**
- * @var Institution
- */
- private $institution;
+ // @phpstan-ignore-next-line PHPStan can not see that this field is written when serialized to the database
+ private ?Institution $institution = null;
- /**
- * @param RegistrationAuthorityRole $role
- * @param Location $location
- * @param ContactInformation $contactInformation
- * @param Institution $institution
- * @return RegistrationAuthority
- */
public static function accreditWith(
RegistrationAuthorityRole $role,
Location $location,
ContactInformation $contactInformation,
- Institution $institution
- ) {
- $registrationAuthority = new self();
- $registrationAuthority->role = $role;
- $registrationAuthority->location = $location;
+ Institution $institution,
+ ): self {
+ $registrationAuthority = new self();
+ $registrationAuthority->role = $role;
+ $registrationAuthority->location = $location;
$registrationAuthority->contactInformation = $contactInformation;
- $registrationAuthority->institution = $institution;
+ $registrationAuthority->institution = $institution;
return $registrationAuthority;
}
- /**
- * @param Location $location
- * @param ContactInformation $contactInformation
- */
- public function amendInformation(Location $location, ContactInformation $contactInformation)
+ public function amendInformation(Location $location, ContactInformation $contactInformation): void
{
$this->location = $location;
$this->contactInformation = $contactInformation;
}
- /**
- * @param RegistrationAuthorityRole $role
- * @return void
- */
- public function appointAs(RegistrationAuthorityRole $role)
+ public function appointAs(RegistrationAuthorityRole $role): void
{
$this->role = $role;
}
- /**
- * @param RegistrationAuthorityRole $role
- * @return bool
- */
- public function isAppointedAs(RegistrationAuthorityRole $role)
+ public function isAppointedAs(RegistrationAuthorityRole $role): bool
{
return $this->role->equals($role);
}
- /**
- * @return RegistrationAuthorityRole
- */
- public function getRole()
+ public function getRole(): ?RegistrationAuthorityRole
{
return $this->role;
}
diff --git a/src/Surfnet/Stepup/Identity/Entity/RegistrationAuthorityCollection.php b/src/Surfnet/Stepup/Identity/Entity/RegistrationAuthorityCollection.php
index 827cdaab9..2509471d5 100644
--- a/src/Surfnet/Stepup/Identity/Entity/RegistrationAuthorityCollection.php
+++ b/src/Surfnet/Stepup/Identity/Entity/RegistrationAuthorityCollection.php
@@ -25,47 +25,29 @@ final class RegistrationAuthorityCollection
/**
* @var RegistrationAuthority[]
*/
- private $registrationAuthorities = [];
+ private array $registrationAuthorities = [];
- /**
- * @param Institution $institution
- * @param RegistrationAuthority $registrationAuthority
- */
- public function set(Institution $institution, RegistrationAuthority $registrationAuthority)
+ public function set(Institution $institution, RegistrationAuthority $registrationAuthority): void
{
$this->registrationAuthorities[(string)$institution] = $registrationAuthority;
}
- /**
- * @param Institution $institution
- * @return RegistrationAuthority
- */
- public function get(Institution $institution)
+ public function get(Institution $institution): RegistrationAuthority
{
return $this->registrationAuthorities[(string)$institution];
}
- /**
- * @param Institution $institution
- * @return RegistrationAuthority
- */
- public function exists(Institution $institution)
+ public function exists(Institution $institution): bool
{
return array_key_exists((string)$institution, $this->registrationAuthorities);
}
- /**
- * @param Institution $institution
- */
- public function remove(Institution $institution)
+ public function remove(Institution $institution): void
{
unset($this->registrationAuthorities[(string)$institution]);
}
- /**
- * @return int
- */
- public function count()
+ public function count(): int
{
return count($this->registrationAuthorities);
}
@@ -73,7 +55,7 @@ public function count()
/**
* RegistrationAuthority[]
*/
- public function getValues()
+ public function getValues(): array
{
return array_values($this->registrationAuthorities);
}
diff --git a/src/Surfnet/Stepup/Identity/Entity/SecondFactor.php b/src/Surfnet/Stepup/Identity/Entity/SecondFactor.php
index c981a655b..1ad3ad643 100644
--- a/src/Surfnet/Stepup/Identity/Entity/SecondFactor.php
+++ b/src/Surfnet/Stepup/Identity/Entity/SecondFactor.php
@@ -19,6 +19,7 @@
namespace Surfnet\Stepup\Identity\Entity;
use Surfnet\Stepup\Identity\Value\SecondFactorIdentifier;
+use Surfnet\Stepup\Identity\Value\VettingType;
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
use Surfnet\StepupBundle\Value\SecondFactorType;
@@ -26,11 +27,17 @@ interface SecondFactor
{
public function hasEqualOrHigherLoaComparedTo(SecondFactor $comparable, SecondFactorTypeService $service): bool;
- public function hasTypeWithEqualOrLowerLoaComparedTo(SecondFactorType $type, SecondFactorTypeService $service): bool;
+ public function hasTypeWithEqualOrLowerLoaComparedTo(
+ SecondFactorType $type,
+ VettingType $vettingType,
+ SecondFactorTypeService $service,
+ ): bool;
public function typeAndIdentifierAreEqual(SecondFactorType $type, SecondFactorIdentifier $identifier): bool;
public function getType(): SecondFactorType;
public function getIdentifier(): SecondFactorIdentifier;
+
+ public function vettingType(): VettingType;
}
diff --git a/src/Surfnet/Stepup/Identity/Entity/SecondFactorCollection.php b/src/Surfnet/Stepup/Identity/Entity/SecondFactorCollection.php
index 1a655017d..750cd99b4 100644
--- a/src/Surfnet/Stepup/Identity/Entity/SecondFactorCollection.php
+++ b/src/Surfnet/Stepup/Identity/Entity/SecondFactorCollection.php
@@ -19,22 +19,32 @@
namespace Surfnet\Stepup\Identity\Entity;
use Doctrine\Common\Collections\ArrayCollection;
+use Surfnet\Stepup\Exception\LogicException;
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
+use Surfnet\StepupBundle\Value\VettingType;
+use function array_pop;
final class SecondFactorCollection extends ArrayCollection
{
- /**
- * @param SecondFactorTypeService $service
- * @return null|SecondFactor
- */
- public function getSecondFactorWithHighestLoa(SecondFactorTypeService $service)
+ public function getSecondFactorWithHighestLoa(SecondFactorTypeService $service): ?SecondFactor
{
- return array_reduce(
- $this->toArray(),
- function (SecondFactor $carry, SecondFactor $item) use ($service) {
- return $service->hasEqualOrHigherLoaComparedTo($carry->getType(), $item->getType()) ? $carry : $item;
- },
- $this->first() ?: null
- );
+ // We can only get the highest loa'ed second factor when we have a collection of
+ // VettedSecondFactors. The because that is the only SF type that has a vetting
+ // type, which is required to determine the LoA. As a vetting type can change the
+ // LoA.
+ $items = $this->toArray();
+ if ($items !== [] && array_pop($items) instanceof VettedSecondFactor) {
+ return array_reduce(
+ $this->toArray(),
+ fn(VettedSecondFactor $carry, VettedSecondFactor $item): VettedSecondFactor => $service->hasEqualOrHigherLoaComparedTo(
+ $carry->getType(),
+ new VettingType($carry->vettingType()->type()),
+ $item->getType(),
+ new VettingType($item->vettingType()->type()),
+ ) ? $carry : $item,
+ $this->first() ?: null,
+ );
+ }
+ throw new LogicException('At this moment, only getting the highest loa SF is supported for a collection of Vetted second factors');
}
}
diff --git a/src/Surfnet/Stepup/Identity/Entity/UnverifiedSecondFactor.php b/src/Surfnet/Stepup/Identity/Entity/UnverifiedSecondFactor.php
index 94b7dc5e2..3c9569364 100644
--- a/src/Surfnet/Stepup/Identity/Entity/UnverifiedSecondFactor.php
+++ b/src/Surfnet/Stepup/Identity/Entity/UnverifiedSecondFactor.php
@@ -40,58 +40,30 @@
*/
class UnverifiedSecondFactor extends AbstractSecondFactor
{
- /**
- * @var \Surfnet\Stepup\Identity\Api\Identity
- */
- private $identity;
+ private ?Identity $identity = null;
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- private $id;
+ private ?SecondFactorId $id = null;
- /**
- * @var \Surfnet\StepupBundle\Value\SecondFactorType
- */
- private $type;
+ private ?SecondFactorType $type = null;
/**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier
+ * @var SecondFactorIdentifier
*/
- private $secondFactorIdentifier;
+ private SecondFactorIdentifier $secondFactorIdentifier;
- /**
- * @var \Surfnet\Stepup\Identity\Value\EmailVerificationWindow
- */
- private $verificationWindow;
+ private ?EmailVerificationWindow $verificationWindow = null;
- /**
- * @var string
- */
- private $verificationNonce;
+ private ?string $verificationNonce = null;
- /**
- * @param SecondFactorId $id
- * @param Identity $identity
- * @param SecondFactorType $type
- * @param SecondFactorIdentifier $secondFactorIdentifier
- * @param EmailVerificationWindow $emailVerificationWindow
- * @param string $verificationNonce
- * @return UnverifiedSecondFactor
- */
public static function create(
- SecondFactorId $id,
- Identity $identity,
- SecondFactorType $type,
- $secondFactorIdentifier,
+ SecondFactorId $id,
+ Identity $identity,
+ SecondFactorType $type,
+ SecondFactorIdentifier $secondFactorIdentifier,
EmailVerificationWindow $emailVerificationWindow,
- $verificationNonce
- ) {
- if (!is_string($verificationNonce)) {
- throw InvalidArgumentException::invalidType('string', 'verificationNonce', $verificationNonce);
- }
-
- if (empty($verificationNonce)) {
+ string $verificationNonce,
+ ): self {
+ if ($verificationNonce === '' || $verificationNonce === '0') {
throw new InvalidArgumentException("'verificationNonce' may not be empty");
}
@@ -110,19 +82,15 @@ final public function __construct()
{
}
- /**
- * @return SecondFactorId
- */
- public function getId()
+ public function getId(): ?SecondFactorId
{
return $this->id;
}
/**
- * @param string $verificationNonce
* @return bool
*/
- public function hasNonce($verificationNonce)
+ public function hasNonce(string $verificationNonce): bool
{
return $this->verificationNonce === $verificationNonce;
}
@@ -130,12 +98,12 @@ public function hasNonce($verificationNonce)
/**
* @return bool
*/
- public function canBeVerifiedNow()
+ public function canBeVerifiedNow(): bool
{
return $this->verificationWindow->isOpen();
}
- public function verifyEmail()
+ public function verifyEmail(): void
{
$this->apply(
new EmailVerifiedEvent(
@@ -148,12 +116,12 @@ public function verifyEmail()
OtpGenerator::generate(8),
$this->identity->getCommonName(),
$this->identity->getEmail(),
- $this->identity->getPreferredLocale()
- )
+ $this->identity->getPreferredLocale(),
+ ),
);
}
- public function revoke()
+ public function revoke(): void
{
$this->apply(
new UnverifiedSecondFactorRevokedEvent(
@@ -161,12 +129,12 @@ public function revoke()
$this->identity->getInstitution(),
$this->id,
$this->type,
- $this->secondFactorIdentifier
- )
+ $this->secondFactorIdentifier,
+ ),
);
}
- public function complyWithRevocation(IdentityId $authorityId)
+ public function complyWithRevocation(IdentityId $authorityId): void
{
$this->apply(
new CompliedWithUnverifiedSecondFactorRevocationEvent(
@@ -175,17 +143,12 @@ public function complyWithRevocation(IdentityId $authorityId)
$this->id,
$this->type,
$this->secondFactorIdentifier,
- $authorityId
- )
+ $authorityId,
+ ),
);
}
- /**
- * @param DateTime $registrationRequestedAt
- * @param string $registrationCode
- * @return VerifiedSecondFactor
- */
- public function asVerified($registrationRequestedAt, $registrationCode)
+ public function asVerified(DateTime $registrationRequestedAt, string $registrationCode): VerifiedSecondFactor
{
return VerifiedSecondFactor::create(
$this->id,
@@ -193,13 +156,13 @@ public function asVerified($registrationRequestedAt, $registrationCode)
$this->type,
$this->secondFactorIdentifier,
$registrationRequestedAt,
- $registrationCode
+ $registrationCode,
);
}
- protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
+ protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
- $secondFactorIdentifierClass = get_class($this->secondFactorIdentifier);
+ $secondFactorIdentifierClass = $this->secondFactorIdentifier::class;
$this->secondFactorIdentifier = $secondFactorIdentifierClass::unknown();
}
diff --git a/src/Surfnet/Stepup/Identity/Entity/VerifiedSecondFactor.php b/src/Surfnet/Stepup/Identity/Entity/VerifiedSecondFactor.php
index 138b6c719..478cc917b 100644
--- a/src/Surfnet/Stepup/Identity/Entity/VerifiedSecondFactor.php
+++ b/src/Surfnet/Stepup/Identity/Entity/VerifiedSecondFactor.php
@@ -44,57 +44,29 @@
*/
class VerifiedSecondFactor extends AbstractSecondFactor
{
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- private $id;
+ private ?SecondFactorId $id = null;
- /**
- * @var \Surfnet\Stepup\Identity\Api\Identity
- */
- private $identity;
+ private ?Identity $identity = null;
- /**
- * @var \Surfnet\StepupBundle\Value\SecondFactorType
- */
- private $type;
+ private ?SecondFactorType $type = null;
/**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier
+ * @var SecondFactorIdentifier
*/
- private $secondFactorIdentifier;
+ private SecondFactorIdentifier $secondFactorIdentifier;
- /**
- * @var \Surfnet\Stepup\DateTime\DateTime
- */
- private $registrationRequestedAt;
+ private ?DateTime $registrationRequestedAt = null;
- /**
- * @var string
- */
- private $registrationCode;
+ private ?string $registrationCode = null;
- /**
- * @param SecondFactorId $id
- * @param Identity $identity
- * @param SecondFactorType $type
- * @param SecondFactorIdentifier $secondFactorIdentifier
- * @param DateTime $registrationRequestedAt
- * @param string $registrationCode
- * @return self
- */
public static function create(
- SecondFactorId $id,
- Identity $identity,
- SecondFactorType $type,
+ SecondFactorId $id,
+ Identity $identity,
+ SecondFactorType $type,
SecondFactorIdentifier $secondFactorIdentifier,
- DateTime $registrationRequestedAt,
- $registrationCode
- ) {
- if (!is_string($registrationCode)) {
- throw InvalidArgumentException::invalidType('string', 'registrationCode', $registrationCode);
- }
-
+ DateTime $registrationRequestedAt,
+ string $registrationCode,
+ ): self {
$secondFactor = new self;
$secondFactor->id = $id;
$secondFactor->identity = $identity;
@@ -110,38 +82,32 @@ final private function __construct()
{
}
- /**
- * @return SecondFactorId
- */
- public function getId()
+ public function getId(): ?SecondFactorId
{
return $this->id;
}
- /**
- * @param string $registrationCode
- * @param SecondFactorIdentifier $secondFactorIdentifier
- * @return bool
- */
- public function hasRegistrationCodeAndIdentifier($registrationCode, SecondFactorIdentifier $secondFactorIdentifier)
- {
- return strcasecmp($registrationCode, $this->registrationCode) === 0
+ public function hasRegistrationCodeAndIdentifier(
+ string $registrationCode,
+ SecondFactorIdentifier $secondFactorIdentifier,
+ ): bool {
+ return strcasecmp($registrationCode, (string)$this->registrationCode) === 0
&& $secondFactorIdentifier->equals($this->secondFactorIdentifier);
}
/**
* @return bool
*/
- public function canBeVettedNow()
+ public function canBeVettedNow(): bool
{
return !DateTime::now()->comesAfter(
$this->registrationRequestedAt
->add(new DateInterval('P14D'))
- ->endOfDay()
+ ->endOfDay(),
);
}
- public function vet($provePossessionSkipped, VettingType $type)
+ public function vet(bool $provePossessionSkipped, VettingType $type): void
{
if ($provePossessionSkipped) {
$this->apply(
@@ -155,8 +121,8 @@ public function vet($provePossessionSkipped, VettingType $type)
$this->identity->getCommonName(),
$this->identity->getEmail(),
$this->identity->getPreferredLocale(),
- $type
- )
+ $type,
+ ),
);
return;
}
@@ -172,12 +138,12 @@ public function vet($provePossessionSkipped, VettingType $type)
$this->identity->getCommonName(),
$this->identity->getEmail(),
$this->identity->getPreferredLocale(),
- $type
- )
+ $type,
+ ),
);
}
- public function revoke()
+ public function revoke(): void
{
$this->apply(
new VerifiedSecondFactorRevokedEvent(
@@ -185,12 +151,12 @@ public function revoke()
$this->identity->getInstitution(),
$this->id,
$this->type,
- $this->secondFactorIdentifier
- )
+ $this->secondFactorIdentifier,
+ ),
);
}
- public function complyWithRevocation(IdentityId $authorityId)
+ public function complyWithRevocation(IdentityId $authorityId): void
{
$this->apply(
new CompliedWithVerifiedSecondFactorRevocationEvent(
@@ -199,35 +165,34 @@ public function complyWithRevocation(IdentityId $authorityId)
$this->id,
$this->type,
$this->secondFactorIdentifier,
- $authorityId
- )
+ $authorityId,
+ ),
);
}
- /**
- * @return VettedSecondFactor
- */
- public function asVetted(VettingType $vettingType)
+ public function asVetted(VettingType $vettingType): VettedSecondFactor
{
return VettedSecondFactor::create(
$this->id,
$this->identity,
$this->type,
$this->secondFactorIdentifier,
- $vettingType
+ $vettingType,
);
}
- public function getLoaLevel(SecondFactorTypeService $secondFactorTypeService): int
+ public function getLoaLevel(SecondFactorTypeService $secondFactorTypeService): float
{
return $secondFactorTypeService->getLevel($this->type, new StepupVettingType(VettingType::TYPE_UNKNOWN));
}
- protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
+ protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
- $secondFactorIdentifierClass = get_class($this->secondFactorIdentifier);
+ $secondFactorIdentifierClass = $this->secondFactorIdentifier::class;
- $this->secondFactorIdentifier = $secondFactorIdentifierClass::unknown();
+ $identifier = $secondFactorIdentifierClass::unknown();
+ assert($identifier instanceof SecondFactorIdentifier);
+ $this->secondFactorIdentifier = $identifier;
}
public function getType(): SecondFactorType
diff --git a/src/Surfnet/Stepup/Identity/Entity/VettedSecondFactor.php b/src/Surfnet/Stepup/Identity/Entity/VettedSecondFactor.php
index a330d0818..107a84adc 100644
--- a/src/Surfnet/Stepup/Identity/Entity/VettedSecondFactor.php
+++ b/src/Surfnet/Stepup/Identity/Entity/VettedSecondFactor.php
@@ -35,41 +35,26 @@
*/
class VettedSecondFactor extends AbstractSecondFactor
{
- /**
- * @var \Surfnet\Stepup\Identity\Api\Identity
- */
- private $identity;
+ private ?Identity $identity = null;
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- private $id;
+ private ?SecondFactorId $id = null;
- /**
- * @var \Surfnet\StepupBundle\Value\SecondFactorType
- */
- private $type;
+ private ?SecondFactorType $type = null;
/**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier
+ * @var SecondFactorIdentifier
*/
- private $secondFactorIdentifier;
+ private SecondFactorIdentifier $secondFactorIdentifier;
- /**
- * @var VettingType
- */
- private $vettingType;
+ private ?VettingType $vettingType = null;
- /**
- * @return VettedSecondFactor
- */
public static function create(
SecondFactorId $id,
Identity $identity,
SecondFactorType $type,
SecondFactorIdentifier $secondFactorIdentifier,
- VettingType $vettingType
- ) {
+ VettingType $vettingType,
+ ): self {
$secondFactor = new self();
$secondFactor->id = $id;
$secondFactor->identity = $identity;
@@ -84,15 +69,12 @@ final public function __construct()
{
}
- /**
- * @return SecondFactorId
- */
- public function getId()
+ public function getId(): ?SecondFactorId
{
return $this->id;
}
- public function revoke()
+ public function revoke(): void
{
$this->apply(
new VettedSecondFactorRevokedEvent(
@@ -100,12 +82,12 @@ public function revoke()
$this->identity->getInstitution(),
$this->id,
$this->type,
- $this->secondFactorIdentifier
- )
+ $this->secondFactorIdentifier,
+ ),
);
}
- public function complyWithRevocation(IdentityId $authorityId)
+ public function complyWithRevocation(IdentityId $authorityId): void
{
$this->apply(
new CompliedWithVettedSecondFactorRevocationEvent(
@@ -114,8 +96,8 @@ public function complyWithRevocation(IdentityId $authorityId)
$this->id,
$this->type,
$this->secondFactorIdentifier,
- $authorityId
- )
+ $authorityId,
+ ),
);
}
@@ -124,9 +106,9 @@ public function vettingType(): VettingType
return $this->vettingType;
}
- protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
+ protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
- $secondFactorIdentifierClass = get_class($this->secondFactorIdentifier);
+ $secondFactorIdentifierClass = $this->secondFactorIdentifier::class;
$this->secondFactorIdentifier = $secondFactorIdentifierClass::unknown();
}
diff --git a/src/Surfnet/Stepup/Identity/Event/AppointedAsRaEvent.php b/src/Surfnet/Stepup/Identity/Event/AppointedAsRaEvent.php
index 17cbab8f7..da4b91d7f 100644
--- a/src/Surfnet/Stepup/Identity/Event/AppointedAsRaEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/AppointedAsRaEvent.php
@@ -29,28 +29,24 @@
*/
class AppointedAsRaEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'institution',
'name_id',
];
- /**
- * @var NameId
- */
- public $nameId;
-
public function __construct(
IdentityId $identityId,
Institution $identityInstitution,
- NameId $nameId
+ public NameId $nameId,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->nameId = $nameId;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -59,27 +55,21 @@ public function getAuditLogMetadata()
return $metadata;
}
- /**
- * @return mixed The object instance
- */
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
new Institution($data['institution']),
- new NameId($data['name_id'])
+ new NameId($data['name_id']),
);
}
- /**
- * @return array
- */
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'institution' => (string) $this->identityInstitution,
- 'name_id' => (string) $this->nameId
+ 'identity_id' => (string)$this->identityId,
+ 'institution' => (string)$this->identityInstitution,
+ 'name_id' => (string)$this->nameId,
];
}
@@ -88,6 +78,9 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/AppointedAsRaForInstitutionEvent.php b/src/Surfnet/Stepup/Identity/Event/AppointedAsRaForInstitutionEvent.php
index 31bbd7072..bacc1789b 100644
--- a/src/Surfnet/Stepup/Identity/Event/AppointedAsRaForInstitutionEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/AppointedAsRaForInstitutionEvent.php
@@ -26,36 +26,26 @@
class AppointedAsRaForInstitutionEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'institution',
'name_id',
- 'ra_institution'
+ 'ra_institution',
];
- /**
- * @var NameId
- */
- public $nameId;
-
- /**
- * @var Institution
- */
- public $raInstitution;
-
public function __construct(
IdentityId $identityId,
Institution $identityInstitution,
- NameId $nameId,
- Institution $raInstitution
+ public NameId $nameId,
+ public Institution $raInstitution,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->nameId = $nameId;
- $this->raInstitution = $raInstitution;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -65,29 +55,28 @@ public function getAuditLogMetadata()
return $metadata;
}
- /**
- * @return mixed The object instance
- */
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
new Institution($data['institution']),
new NameId($data['name_id']),
- new Institution($data['ra_institution'])
+ new Institution($data['ra_institution']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'institution' => (string) $this->identityInstitution,
- 'name_id' => (string) $this->nameId,
- 'ra_institution' => (string) $this->raInstitution,
+ 'identity_id' => (string)$this->identityId,
+ 'institution' => (string)$this->identityInstitution,
+ 'name_id' => (string)$this->nameId,
+ 'ra_institution' => (string)$this->raInstitution,
];
}
@@ -96,6 +85,9 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/AppointedAsRaaEvent.php b/src/Surfnet/Stepup/Identity/Event/AppointedAsRaaEvent.php
index 7e056b78b..429a16376 100644
--- a/src/Surfnet/Stepup/Identity/Event/AppointedAsRaaEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/AppointedAsRaaEvent.php
@@ -29,28 +29,24 @@
*/
class AppointedAsRaaEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'institution',
'name_id',
];
- /**
- * @var NameId
- */
- public $nameId;
-
public function __construct(
IdentityId $identityId,
Institution $identityInstitution,
- NameId $nameId
+ public NameId $nameId,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->nameId = $nameId;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -59,27 +55,21 @@ public function getAuditLogMetadata()
return $metadata;
}
- /**
- * @return mixed The object instance
- */
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
new Institution($data['institution']),
- new NameId($data['name_id'])
+ new NameId($data['name_id']),
);
}
- /**
- * @return array
- */
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'institution' => (string) $this->identityInstitution,
- 'name_id' => (string) $this->nameId
+ 'identity_id' => (string)$this->identityId,
+ 'institution' => (string)$this->identityInstitution,
+ 'name_id' => (string)$this->nameId,
];
}
@@ -88,6 +78,9 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/AppointedAsRaaForInstitutionEvent.php b/src/Surfnet/Stepup/Identity/Event/AppointedAsRaaForInstitutionEvent.php
index 354900d03..f54123eee 100644
--- a/src/Surfnet/Stepup/Identity/Event/AppointedAsRaaForInstitutionEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/AppointedAsRaaForInstitutionEvent.php
@@ -26,36 +26,26 @@
class AppointedAsRaaForInstitutionEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'institution',
'name_id',
- 'ra_institution'
+ 'ra_institution',
];
- /**
- * @var NameId
- */
- public $nameId;
-
- /**
- * @var Institution
- */
- public $raInstitution;
-
public function __construct(
IdentityId $identityId,
Institution $identityInstitution,
- NameId $nameId,
- Institution $raInstitution
+ public NameId $nameId,
+ public Institution $raInstitution,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->nameId = $nameId;
- $this->raInstitution = $raInstitution;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -65,29 +55,28 @@ public function getAuditLogMetadata()
return $metadata;
}
- /**
- * @return mixed The object instance
- */
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
new Institution($data['institution']),
new NameId($data['name_id']),
- new Institution($data['ra_institution'])
+ new Institution($data['ra_institution']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'institution' => (string) $this->identityInstitution,
- 'name_id' => (string) $this->nameId,
- 'ra_institution' => (string) $this->raInstitution,
+ 'identity_id' => (string)$this->identityId,
+ 'institution' => (string)$this->identityInstitution,
+ 'name_id' => (string)$this->nameId,
+ 'ra_institution' => (string)$this->raInstitution,
];
}
@@ -96,6 +85,9 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/AuditableEvent.php b/src/Surfnet/Stepup/Identity/Event/AuditableEvent.php
index 55244e611..e62f58111 100644
--- a/src/Surfnet/Stepup/Identity/Event/AuditableEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/AuditableEvent.php
@@ -18,10 +18,12 @@
namespace Surfnet\Stepup\Identity\Event;
+use Surfnet\Stepup\Identity\AuditLog\Metadata;
+
interface AuditableEvent
{
/**
- * @return \Surfnet\Stepup\Identity\AuditLog\Metadata
+ * @return Metadata
*/
- public function getAuditLogMetadata();
+ public function getAuditLogMetadata(): Metadata;
}
diff --git a/src/Surfnet/Stepup/Identity/Event/CompliedWithRecoveryCodeRevocationEvent.php b/src/Surfnet/Stepup/Identity/Event/CompliedWithRecoveryCodeRevocationEvent.php
index 9ea8022ef..fff696365 100644
--- a/src/Surfnet/Stepup/Identity/Event/CompliedWithRecoveryCodeRevocationEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/CompliedWithRecoveryCodeRevocationEvent.php
@@ -28,18 +28,9 @@
class CompliedWithRecoveryCodeRevocationEvent extends IdentityEvent implements RightToObtainDataInterface
{
/**
- * @var IdentityId
+ * @var string[]
*/
- public $authorityId;
- /**
- * @var RecoveryTokenId
- */
- public $recoveryTokenId;
- /**
- * @var RecoveryTokenType
- */
- public $recoveryTokenType;
- private $allowlist = [
+ private array $allowlist = [
'identity_id',
'identity_institution',
'recovery_token_type',
@@ -47,20 +38,16 @@ class CompliedWithRecoveryCodeRevocationEvent extends IdentityEvent implements R
];
final public function __construct(
- IdentityId $identityId,
- Institution $identityInstitution,
- RecoveryTokenId $recoveryTokenId,
- RecoveryTokenType $recoveryTokenType,
- IdentityId $authorityId
+ IdentityId $identityId,
+ Institution $identityInstitution,
+ public RecoveryTokenId $recoveryTokenId,
+ public RecoveryTokenType $recoveryTokenType,
+ public IdentityId $authorityId,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->authorityId = $authorityId;
- $this->recoveryTokenId = $recoveryTokenId;
- $this->recoveryTokenType = $recoveryTokenType;
}
- final public static function deserialize(array $data)
+ final public static function deserialize(array $data): self
{
$recoveryTokenType = new RecoveryTokenType($data['recovery_token_type']);
@@ -69,11 +56,11 @@ final public static function deserialize(array $data)
new Institution($data['identity_institution']),
new RecoveryTokenId($data['recovery_token_id']),
$recoveryTokenType,
- new IdentityId($data['authority_id'])
+ new IdentityId($data['authority_id']),
);
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -103,6 +90,9 @@ final public function serialize(): array
];
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/CompliedWithRevocationEvent.php b/src/Surfnet/Stepup/Identity/Event/CompliedWithRevocationEvent.php
index 28f2c4d9f..5e3c48419 100644
--- a/src/Surfnet/Stepup/Identity/Event/CompliedWithRevocationEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/CompliedWithRevocationEvent.php
@@ -31,7 +31,10 @@
abstract class CompliedWithRevocationEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'second_factor_identifier',
@@ -39,55 +42,30 @@ abstract class CompliedWithRevocationEvent extends IdentityEvent implements Forg
'authority_id',
];
- /**
- * @var \Surfnet\Stepup\Identity\Value\IdentityId
- */
- public $authorityId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\StepupBundle\Value\SecondFactorType
- */
- public $secondFactorType;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier
- */
- public $secondFactorIdentifier;
-
final public function __construct(
IdentityId $identityId,
Institution $identityInstitution,
- SecondFactorId $secondFactorId,
- SecondFactorType $secondFactorType,
- SecondFactorIdentifier $secondFactorIdentifier,
- IdentityId $authorityId
+ public SecondFactorId $secondFactorId,
+ public SecondFactorType $secondFactorType,
+ public SecondFactorIdentifier $secondFactorIdentifier,
+ public IdentityId $authorityId,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->authorityId = $authorityId;
- $this->secondFactorId = $secondFactorId;
- $this->secondFactorType = $secondFactorType;
- $this->secondFactorIdentifier = $secondFactorIdentifier;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
- $metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = $this->secondFactorType;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
+ $metadata->secondFactorId = $this->secondFactorId;
+ $metadata->secondFactorType = $this->secondFactorType;
$metadata->secondFactorIdentifier = $this->secondFactorIdentifier;
return $metadata;
}
- final public static function deserialize(array $data)
+ final public static function deserialize(array $data): self
{
$secondFactorType = new SecondFactorType($data['second_factor_type']);
@@ -97,7 +75,7 @@ final public static function deserialize(array $data)
new SecondFactorId($data['second_factor_id']),
$secondFactorType,
SecondFactorIdentifierFactory::unknownForType($secondFactorType),
- new IdentityId($data['authority_id'])
+ new IdentityId($data['authority_id']),
);
}
@@ -107,21 +85,21 @@ final public static function deserialize(array $data)
final public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'second_factor_type' => (string) $this->secondFactorType,
- 'authority_id' => (string) $this->authorityId,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'second_factor_type' => (string)$this->secondFactorType,
+ 'authority_id' => (string)$this->authorityId,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withSecondFactorIdentifier($this->secondFactorIdentifier, $this->secondFactorType);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
$this->secondFactorIdentifier = $sensitiveData->getSecondFactorIdentifier();
}
@@ -132,6 +110,10 @@ public function obtainUserData(): array
$serializedSensitiveUserData = $this->getSensitiveData()->serialize();
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/EmailVerifiedEvent.php b/src/Surfnet/Stepup/Identity/Event/EmailVerifiedEvent.php
index 40f738ef3..64d8f6dad 100644
--- a/src/Surfnet/Stepup/Identity/Event/EmailVerifiedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/EmailVerifiedEvent.php
@@ -33,9 +33,15 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
-class EmailVerifiedEvent extends IdentityEvent implements Forgettable, PossessionProvenAndVerified, RightToObtainDataInterface
+class EmailVerifiedEvent extends IdentityEvent implements
+ Forgettable,
+ PossessionProvenAndVerified,
+ RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'second_factor_id',
@@ -44,88 +50,39 @@ class EmailVerifiedEvent extends IdentityEvent implements Forgettable, Possessio
'registration_requested_at',
'preferred_locale',
'common_name',
- 'email'
+ 'email',
];
/**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\StepupBundle\Value\SecondFactorType
- */
- public $secondFactorType;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier
- */
- private $secondFactorIdentifier;
-
- /**
- * @var \Surfnet\Stepup\DateTime\DateTime
- */
- public $registrationRequestedAt;
-
- /**
- * @var string
- */
- public $registrationCode;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
- /**
- * @param IdentityId $identityId
- * @param Institution $identityInstitution
- * @param SecondFactorId $secondFactorId
- * @param SecondFactorType $secondFactorType
+ * @param IdentityId $identityId
+ * @param Institution $identityInstitution
+ * @param SecondFactorId $secondFactorId
+ * @param SecondFactorType $secondFactorType
* @param SecondFactorIdentifier $secondFactorIdentifier
- * @param DateTime $registrationRequestedAt
- * @param string $registrationCode
- * @param CommonName $commonName
- * @param Email $email
- * @param Locale $preferredLocale
+ * @param DateTime $registrationRequestedAt
+ * @param string $registrationCode
+ * @param CommonName $commonName
+ * @param Email $email
+ * @param Locale $preferredLocale
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- IdentityId $identityId,
- Institution $identityInstitution,
- SecondFactorId $secondFactorId,
- SecondFactorType $secondFactorType,
- SecondFactorIdentifier $secondFactorIdentifier,
- DateTime $registrationRequestedAt,
- $registrationCode,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale
+ IdentityId $identityId,
+ Institution $identityInstitution,
+ public SecondFactorId $secondFactorId,
+ public SecondFactorType $secondFactorType,
+ private SecondFactorIdentifier $secondFactorIdentifier,
+ public DateTime $registrationRequestedAt,
+ public string $registrationCode,
+ public CommonName $commonName,
+ public Email $email,
+ public Locale $preferredLocale,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->secondFactorId = $secondFactorId;
- $this->secondFactorType = $secondFactorType;
- $this->secondFactorIdentifier = $secondFactorIdentifier;
- $this->registrationRequestedAt = $registrationRequestedAt;
- $this->registrationCode = $registrationCode;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -137,7 +94,7 @@ public function getAuditLogMetadata()
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
$secondFactorType = new SecondFactorType($data['second_factor_type']);
@@ -151,27 +108,29 @@ public static function deserialize(array $data)
$data['registration_code'],
CommonName::unknown(),
Email::unknown(),
- new Locale($data['preferred_locale'])
+ new Locale($data['preferred_locale']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'second_factor_type' => (string) $this->secondFactorType,
- 'registration_requested_at' => (string) $this->registrationRequestedAt,
- 'registration_code' => $this->registrationCode,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'second_factor_type' => (string)$this->secondFactorType,
+ 'registration_requested_at' => (string)$this->registrationRequestedAt,
+ 'registration_code' => $this->registrationCode,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -179,9 +138,9 @@ public function getSensitiveData()
->withSecondFactorIdentifier($this->secondFactorIdentifier, $this->secondFactorType);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->email = $sensitiveData->getEmail();
+ $this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
$this->secondFactorIdentifier = $sensitiveData->getSecondFactorIdentifier();
}
@@ -193,6 +152,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/GssfPossessionProvenAndVerifiedEvent.php b/src/Surfnet/Stepup/Identity/Event/GssfPossessionProvenAndVerifiedEvent.php
index 2e1d9dd63..a516cd6a1 100644
--- a/src/Surfnet/Stepup/Identity/Event/GssfPossessionProvenAndVerifiedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/GssfPossessionProvenAndVerifiedEvent.php
@@ -33,9 +33,15 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
-class GssfPossessionProvenAndVerifiedEvent extends IdentityEvent implements Forgettable, PossessionProvenAndVerified, RightToObtainDataInterface
+class GssfPossessionProvenAndVerifiedEvent extends IdentityEvent implements
+ Forgettable,
+ PossessionProvenAndVerified,
+ RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'stepup_provider',
@@ -48,96 +54,47 @@ class GssfPossessionProvenAndVerifiedEvent extends IdentityEvent implements Forg
];
/**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\StepupProvider
- */
- public $stepupProvider;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\GssfId
- */
- public $gssfId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
- /**
- * @var \Surfnet\Stepup\DateTime\DateTime
- */
- public $registrationRequestedAt;
-
- /**
- * @var string
- */
- public $registrationCode;
-
- /**
- * @param IdentityId $identityId
- * @param Institution $identityInstitution
- * @param SecondFactorId $secondFactorId
- * @param StepupProvider $stepupProvider
- * @param GssfId $gssfId
- * @param CommonName $commonName
- * @param Email $email
- * @param Locale $locale
- * @param DateTime $registrationRequestedAt
- * @param string $registrationCode
+ * @param IdentityId $identityId
+ * @param Institution $identityInstitution
+ * @param SecondFactorId $secondFactorId
+ * @param StepupProvider $stepupProvider
+ * @param GssfId $gssfId
+ * @param CommonName $commonName
+ * @param Email $email
+ * @param Locale $preferredLocale
+ * @param DateTime $registrationRequestedAt
+ * @param string $registrationCode
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- IdentityId $identityId,
- Institution $identityInstitution,
- SecondFactorId $secondFactorId,
- StepupProvider $stepupProvider,
- GssfId $gssfId,
- CommonName $commonName,
- Email $email,
- Locale $locale,
- DateTime $registrationRequestedAt,
- $registrationCode
+ IdentityId $identityId,
+ Institution $identityInstitution,
+ public SecondFactorId $secondFactorId,
+ public StepupProvider $stepupProvider,
+ public GssfId $gssfId,
+ public CommonName $commonName,
+ public Email $email,
+ public Locale $preferredLocale,
+ public DateTime $registrationRequestedAt,
+ public string $registrationCode,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->secondFactorId = $secondFactorId;
- $this->stepupProvider = $stepupProvider;
- $this->gssfId = $gssfId;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $locale;
- $this->registrationRequestedAt = $registrationRequestedAt;
- $this->registrationCode = $registrationCode;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
$metadata->identityInstitution = $this->identityInstitution;
$metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = new SecondFactorType((string) $this->stepupProvider);
+ $metadata->secondFactorType = new SecondFactorType((string)$this->stepupProvider);
$metadata->secondFactorIdentifier = $this->gssfId;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
// BC compatibility for event replay in test-environment only (2.8.0, fixed in 2.8.1)
if (!isset($data['preferred_locale'])) {
@@ -154,37 +111,41 @@ public static function deserialize(array $data)
Email::unknown(),
new Locale($data['preferred_locale']),
DateTime::fromString($data['registration_requested_at']),
- (string) $data['registration_code']
+ (string)$data['registration_code'],
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'stepup_provider' => (string) $this->stepupProvider,
- 'registration_requested_at' => (string) $this->registrationRequestedAt,
- 'registration_code' => $this->registrationCode,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'stepup_provider' => (string)$this->stepupProvider,
+ 'registration_requested_at' => (string)$this->registrationRequestedAt,
+ 'registration_code' => $this->registrationCode,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
->withEmail($this->email)
- ->withSecondFactorIdentifier($this->gssfId, new SecondFactorType((string) $this->stepupProvider));
+ ->withSecondFactorIdentifier($this->gssfId, new SecondFactorType((string)$this->stepupProvider));
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->gssfId = $sensitiveData->getSecondFactorIdentifier();
+ $gssfId = $sensitiveData->getSecondFactorIdentifier();
+ assert($gssfId instanceof GssfId);
+ $this->gssfId = $gssfId;
$this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
}
@@ -196,6 +157,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/GssfPossessionProvenEvent.php b/src/Surfnet/Stepup/Identity/Event/GssfPossessionProvenEvent.php
index 68c0c10ad..63d32f304 100644
--- a/src/Surfnet/Stepup/Identity/Event/GssfPossessionProvenEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/GssfPossessionProvenEvent.php
@@ -35,7 +35,10 @@
class GssfPossessionProvenEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'second_factor_id',
@@ -46,105 +49,41 @@ class GssfPossessionProvenEvent extends IdentityEvent implements Forgettable, Ri
'email',
];
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\StepupProvider
- */
- public $stepupProvider;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\GssfId
- */
- public $gssfId;
-
- /**
- * @var bool
- */
- public $emailVerificationRequired;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\EmailVerificationWindow
- */
- public $emailVerificationWindow;
-
- /**
- * @var string
- */
- public $emailVerificationNonce;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
- *
- * @param IdentityId $identityId
- * @param Institution $identityInstitution
- * @param SecondFactorId $secondFactorId
- * @param StepupProvider $stepupProvider
- * @param GssfId $gssfId
- * @param bool $emailVerificationRequired
- * @param EmailVerificationWindow $emailVerificationWindow
- * @param string $emailVerificationNonce
- * @param CommonName $commonName
- * @param Email $email
- * @param Locale $preferredLocale
*/
public function __construct(
- IdentityId $identityId,
- Institution $identityInstitution,
- SecondFactorId $secondFactorId,
- StepupProvider $stepupProvider,
- GssfId $gssfId,
- $emailVerificationRequired,
- EmailVerificationWindow $emailVerificationWindow,
- $emailVerificationNonce,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale
+ IdentityId $identityId,
+ Institution $identityInstitution,
+ public SecondFactorId $secondFactorId,
+ public StepupProvider $stepupProvider,
+ public GssfId $gssfId,
+ public bool $emailVerificationRequired,
+ public EmailVerificationWindow $emailVerificationWindow,
+ public string $emailVerificationNonce,
+ public CommonName $commonName,
+ public Email $email,
+ /**
+ * @var Locale Eg. "en_GB"
+ */
+ public Locale $preferredLocale,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->secondFactorId = $secondFactorId;
- $this->stepupProvider = $stepupProvider;
- $this->gssfId = $gssfId;
- $this->emailVerificationRequired = $emailVerificationRequired;
- $this->emailVerificationWindow = $emailVerificationWindow;
- $this->emailVerificationNonce = $emailVerificationNonce;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
$metadata->identityInstitution = $this->identityInstitution;
$metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = new SecondFactorType((string) $this->stepupProvider);
+ $metadata->secondFactorType = new SecondFactorType((string)$this->stepupProvider);
$metadata->secondFactorIdentifier = $this->gssfId;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
if (!isset($data['email_verification_required'])) {
$data['email_verification_required'] = true;
@@ -161,40 +100,44 @@ public static function deserialize(array $data)
$data['email_verification_nonce'],
CommonName::unknown(),
Email::unknown(),
- new Locale($data['preferred_locale'])
+ new Locale($data['preferred_locale']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'stepup_provider' => (string) $this->stepupProvider,
- 'email_verification_required' => (bool) $this->emailVerificationRequired,
- 'email_verification_window' => $this->emailVerificationWindow->serialize(),
- 'email_verification_nonce' => (string) $this->emailVerificationNonce,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'stepup_provider' => (string)$this->stepupProvider,
+ 'email_verification_required' => $this->emailVerificationRequired,
+ 'email_verification_window' => $this->emailVerificationWindow->serialize(),
+ 'email_verification_nonce' => $this->emailVerificationNonce,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
->withEmail($this->email)
- ->withSecondFactorIdentifier($this->gssfId, new SecondFactorType((string) $this->stepupProvider));
+ ->withSecondFactorIdentifier($this->gssfId, new SecondFactorType((string)$this->stepupProvider));
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->email = $sensitiveData->getEmail();
+ $this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
- $this->gssfId = $sensitiveData->getSecondFactorIdentifier();
+ $gssfId = $sensitiveData->getSecondFactorIdentifier();
+ assert($gssfId instanceof GssfId);
+ $this->gssfId = $gssfId;
}
public function obtainUserData(): array
@@ -204,6 +147,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaEvent.php b/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaEvent.php
index 44faf26c0..8e9d1300a 100644
--- a/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaEvent.php
@@ -32,7 +32,10 @@
*/
class IdentityAccreditedAsRaEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'name_id',
'institution',
@@ -41,60 +44,35 @@ class IdentityAccreditedAsRaEvent extends IdentityEvent implements RightToObtain
'contact_information',
];
- /**
- * @var NameId
- */
- public $nameId;
-
- /**
- * @var RegistrationAuthorityRole
- */
- public $registrationAuthorityRole;
-
- /**
- * @var Location
- */
- public $location;
-
- /**
- * @var ContactInformation
- */
- public $contactInformation;
-
/**
* @param IdentityId $identityId
* @param NameId $nameId
* @param Institution $institution
- * @param RegistrationAuthorityRole $role
+ * @param RegistrationAuthorityRole $registrationAuthorityRole
* @param Location $location
* @param ContactInformation $contactInformation
*/
public function __construct(
IdentityId $identityId,
- NameId $nameId,
+ public NameId $nameId,
Institution $institution,
- RegistrationAuthorityRole $role,
- Location $location,
- ContactInformation $contactInformation
+ public RegistrationAuthorityRole $registrationAuthorityRole,
+ public Location $location,
+ public ContactInformation $contactInformation,
) {
parent::__construct($identityId, $institution);
-
- $this->nameId = $nameId;
- $this->registrationAuthorityRole = $role;
- $this->location = $location;
- $this->contactInformation = $contactInformation;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
$metadata->identityInstitution = $this->identityInstitution;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
@@ -102,19 +80,19 @@ public static function deserialize(array $data)
new Institution($data['institution']),
RegistrationAuthorityRole::deserialize($data['registration_authority_role']),
new Location($data['location']),
- new ContactInformation($data['contact_information'])
+ new ContactInformation($data['contact_information']),
);
}
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'name_id' => (string) $this->nameId,
- 'institution' => (string) $this->identityInstitution,
+ 'identity_id' => (string)$this->identityId,
+ 'name_id' => (string)$this->nameId,
+ 'institution' => (string)$this->identityInstitution,
'registration_authority_role' => $this->registrationAuthorityRole->serialize(),
- 'location' => (string) $this->location,
- 'contact_information' => (string) $this->contactInformation,
+ 'location' => (string)$this->location,
+ 'contact_information' => (string)$this->contactInformation,
];
}
@@ -123,6 +101,9 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaForInstitutionEvent.php b/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaForInstitutionEvent.php
index 5cbf6e000..1edea699e 100644
--- a/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaForInstitutionEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaForInstitutionEvent.php
@@ -29,79 +29,42 @@
class IdentityAccreditedAsRaForInstitutionEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+/**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'name_id',
'institution',
'registration_authority_role',
'location',
'contact_information',
- 'ra_institution'
+ 'ra_institution',
];
- /**
- * @var NameId
- */
- public $nameId;
-
- /**
- * @var RegistrationAuthorityRole
- */
- public $registrationAuthorityRole;
-
- /**
- * @var Location
- */
- public $location;
-
- /**
- * @var ContactInformation
- */
- public $contactInformation;
-
- /**
- * @var Institution
- */
- public $raInstitution;
-
- /**
- * @param IdentityId $identityId
- * @param NameId $nameId
- * @param Institution $institution
- * @param RegistrationAuthorityRole $role
- * @param Location $location
- * @param ContactInformation $contactInformation
- * @param Institution $raInstitution
- */
public function __construct(
IdentityId $identityId,
- NameId $nameId,
+ public NameId $nameId,
Institution $institution,
- RegistrationAuthorityRole $role,
- Location $location,
- ContactInformation $contactInformation,
- Institution $raInstitution
+ public RegistrationAuthorityRole $registrationAuthorityRole,
+ public Location $location,
+ public ContactInformation $contactInformation,
+ public Institution $raInstitution,
) {
parent::__construct($identityId, $institution);
-
- $this->nameId = $nameId;
- $this->registrationAuthorityRole = $role;
- $this->location = $location;
- $this->contactInformation = $contactInformation;
- $this->raInstitution = $raInstitution;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
$metadata->identityInstitution = $this->identityInstitution;
- $metadata->raInstitution = $this->raInstitution;
+ $metadata->raInstitution = $this->raInstitution;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
@@ -110,31 +73,38 @@ public static function deserialize(array $data)
RegistrationAuthorityRole::deserialize($data['registration_authority_role']),
new Location($data['location']),
new ContactInformation($data['contact_information']),
- new Institution($data['ra_institution'])
+ new Institution($data['ra_institution']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'name_id' => (string) $this->nameId,
- 'institution' => (string) $this->identityInstitution,
+ 'identity_id' => (string)$this->identityId,
+ 'name_id' => (string)$this->nameId,
+ 'institution' => (string)$this->identityInstitution,
'registration_authority_role' => $this->registrationAuthorityRole->serialize(),
- 'location' => (string) $this->location,
- 'contact_information' => (string) $this->contactInformation,
- 'ra_institution' => (string) $this->raInstitution,
+ 'location' => (string)$this->location,
+ 'contact_information' => (string)$this->contactInformation,
+ 'ra_institution' => (string)$this->raInstitution,
];
}
+ /**
+ * @return array
+ */
public function obtainUserData(): array
{
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaaEvent.php b/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaaEvent.php
index d4b871112..f9738c66c 100644
--- a/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaaEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaaEvent.php
@@ -32,7 +32,11 @@
*/
class IdentityAccreditedAsRaaEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /** @var string[] */
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'name_id',
'institution',
@@ -41,60 +45,30 @@ class IdentityAccreditedAsRaaEvent extends IdentityEvent implements RightToObtai
'contact_information',
];
- /**
- * @var NameId
- */
- public $nameId;
-
- /**
- * @var RegistrationAuthorityRole
- */
- public $registrationAuthorityRole;
-
- /**
- * @var Location
- */
- public $location;
-
- /**
- * @var ContactInformation
- */
- public $contactInformation;
-
- /**
- * @param IdentityId $identityId
- * @param NameId $nameId
- * @param Institution $institution
- * @param RegistrationAuthorityRole $role
- * @param Location $location
- * @param ContactInformation $contactInformation
- */
public function __construct(
IdentityId $identityId,
- NameId $nameId,
+ public NameId $nameId,
Institution $institution,
- RegistrationAuthorityRole $role,
- Location $location,
- ContactInformation $contactInformation
+ public RegistrationAuthorityRole $registrationAuthorityRole,
+ public Location $location,
+ public ContactInformation $contactInformation,
) {
parent::__construct($identityId, $institution);
-
- $this->nameId = $nameId;
- $this->registrationAuthorityRole = $role;
- $this->location = $location;
- $this->contactInformation = $contactInformation;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
$metadata->identityInstitution = $this->identityInstitution;
return $metadata;
}
- public static function deserialize(array $data)
+ /**
+ * @param array $data
+ */
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
@@ -102,19 +76,22 @@ public static function deserialize(array $data)
new Institution($data['institution']),
RegistrationAuthorityRole::deserialize($data['registration_authority_role']),
new Location($data['location']),
- new ContactInformation($data['contact_information'])
+ new ContactInformation($data['contact_information']),
);
}
+ /**
+ * @return array
+ */
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'name_id' => (string) $this->nameId,
- 'institution' => (string) $this->identityInstitution,
+ 'identity_id' => (string)$this->identityId,
+ 'name_id' => (string)$this->nameId,
+ 'institution' => (string)$this->identityInstitution,
'registration_authority_role' => $this->registrationAuthorityRole->serialize(),
- 'location' => (string) $this->location,
- 'contact_information' => (string) $this->contactInformation,
+ 'location' => (string)$this->location,
+ 'contact_information' => (string)$this->contactInformation,
];
}
@@ -123,6 +100,9 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaaForInstitutionEvent.php b/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaaForInstitutionEvent.php
index 62b48fa0e..438bc1aa4 100644
--- a/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaaForInstitutionEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/IdentityAccreditedAsRaaForInstitutionEvent.php
@@ -29,78 +29,46 @@
class IdentityAccreditedAsRaaForInstitutionEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /** @var string[] */
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'name_id',
'institution',
'registration_authority_role',
'location',
'contact_information',
- 'ra_institution'
+ 'ra_institution',
];
- /**
- * @var NameId
- */
- public $nameId;
-
- /**
- * @var RegistrationAuthorityRole
- */
- public $registrationAuthorityRole;
-
- /**
- * @var Location
- */
- public $location;
-
- /**
- * @var ContactInformation
- */
- public $contactInformation;
- /**
- * @var Institution
- */
- public $raInstitution;
-
- /**
- * @param IdentityId $identityId
- * @param NameId $nameId
- * @param Institution $institution
- * @param RegistrationAuthorityRole $role
- * @param Location $location
- * @param ContactInformation $contactInformation
- * @param Institution $raInstitution
- */
public function __construct(
IdentityId $identityId,
- NameId $nameId,
+ public NameId $nameId,
Institution $institution,
- RegistrationAuthorityRole $role,
- Location $location,
- ContactInformation $contactInformation,
- Institution $raInstitution
+ public RegistrationAuthorityRole $registrationAuthorityRole,
+ public Location $location,
+ public ContactInformation $contactInformation,
+ public Institution $raInstitution,
) {
parent::__construct($identityId, $institution);
-
- $this->nameId = $nameId;
- $this->registrationAuthorityRole = $role;
- $this->location = $location;
- $this->contactInformation = $contactInformation;
- $this->raInstitution = $raInstitution;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
$metadata->identityInstitution = $this->identityInstitution;
- $metadata->raInstitution = $this->raInstitution;
+ $metadata->raInstitution = $this->raInstitution;
return $metadata;
}
- public static function deserialize(array $data)
+ /**
+ * @param array $data
+ */
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
@@ -109,31 +77,38 @@ public static function deserialize(array $data)
RegistrationAuthorityRole::deserialize($data['registration_authority_role']),
new Location($data['location']),
new ContactInformation($data['contact_information']),
- new Institution($data['ra_institution'])
+ new Institution($data['ra_institution']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'name_id' => (string) $this->nameId,
- 'institution' => (string) $this->identityInstitution,
+ 'identity_id' => (string)$this->identityId,
+ 'name_id' => (string)$this->nameId,
+ 'institution' => (string)$this->identityInstitution,
'registration_authority_role' => $this->registrationAuthorityRole->serialize(),
- 'location' => (string) $this->location,
- 'contact_information' => (string) $this->contactInformation,
- 'ra_institution' => (string) $this->raInstitution,
+ 'location' => (string)$this->location,
+ 'contact_information' => (string)$this->contactInformation,
+ 'ra_institution' => (string)$this->raInstitution,
];
}
+ /**
+ * @return array
+ */
public function obtainUserData(): array
{
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/IdentityCreatedEvent.php b/src/Surfnet/Stepup/Identity/Event/IdentityCreatedEvent.php
index 466c5e0e5..856f8cf4a 100644
--- a/src/Surfnet/Stepup/Identity/Event/IdentityCreatedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/IdentityCreatedEvent.php
@@ -18,7 +18,6 @@
namespace Surfnet\Stepup\Identity\Event;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\Stepup\Identity\AuditLog\Metadata;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
@@ -27,56 +26,35 @@
use Surfnet\Stepup\Identity\Value\Locale;
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
class IdentityCreatedEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'id',
'institution',
'name_id',
'preferred_locale',
'common_name',
- 'email'
+ 'email',
];
- /**
- * @var NameId
- */
- public $nameId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale
- */
- public $preferredLocale;
-
public function __construct(
IdentityId $id,
Institution $institution,
- NameId $nameId,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale
+ public NameId $nameId,
+ public CommonName $commonName,
+ public Email $email,
+ public Locale $preferredLocale,
) {
parent::__construct($id, $institution);
-
- $this->nameId = $nameId;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -85,7 +63,7 @@ public function getAuditLogMetadata()
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['id']),
@@ -93,33 +71,35 @@ public static function deserialize(array $data)
new NameId($data['name_id']),
CommonName::unknown(),
Email::unknown(),
- new Locale($data['preferred_locale'])
+ new Locale($data['preferred_locale']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'id' => (string) $this->identityId,
- 'institution' => (string) $this->identityInstitution,
- 'name_id' => (string) $this->nameId,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'id' => (string)$this->identityId,
+ 'institution' => (string)$this->identityInstitution,
+ 'name_id' => (string)$this->nameId,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
->withEmail($this->email);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->email = $sensitiveData->getEmail();
+ $this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
}
@@ -130,6 +110,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/IdentityEmailChangedEvent.php b/src/Surfnet/Stepup/Identity/Event/IdentityEmailChangedEvent.php
index db4fb0461..ff71f5403 100644
--- a/src/Surfnet/Stepup/Identity/Event/IdentityEmailChangedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/IdentityEmailChangedEvent.php
@@ -28,25 +28,21 @@
class IdentityEmailChangedEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'id',
'identity_institution',
- 'email'
+ 'email',
];
- /**
- * @var Email
- */
- public $email;
-
- public function __construct(IdentityId $identityId, Institution $institution, Email $email)
+ public function __construct(IdentityId $identityId, Institution $institution, public Email $email)
{
parent::__construct($identityId, $institution);
-
- $this->email = $email;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -59,33 +55,35 @@ public function getAuditLogMetadata()
* @param array $data
* @return IdentityEmailChangedEvent
*/
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['id']),
new Institution($data['institution']),
- Email::unknown()
+ Email::unknown(),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'id' => (string) $this->identityId,
- 'institution' => (string) $this->identityInstitution,
+ 'id' => (string)$this->identityId,
+ 'institution' => (string)$this->identityInstitution,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withEmail($this->email);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
$this->email = $sensitiveData->getEmail();
}
@@ -97,6 +95,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/IdentityEvent.php b/src/Surfnet/Stepup/Identity/Event/IdentityEvent.php
index 315d92f3c..952dcd893 100644
--- a/src/Surfnet/Stepup/Identity/Event/IdentityEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/IdentityEvent.php
@@ -27,19 +27,7 @@
*/
abstract class IdentityEvent implements AuditableEvent, SerializableInterface
{
- /**
- * @var IdentityId
- */
- public $identityId;
-
- /**
- * @var Institution
- */
- public $identityInstitution;
-
- public function __construct(IdentityId $identityId, Institution $identityInstitution)
+ public function __construct(public IdentityId $identityId, public Institution $identityInstitution)
{
- $this->identityId = $identityId;
- $this->identityInstitution = $identityInstitution;
}
}
diff --git a/src/Surfnet/Stepup/Identity/Event/IdentityForgottenEvent.php b/src/Surfnet/Stepup/Identity/Event/IdentityForgottenEvent.php
index 3679d94ba..137b3eee6 100644
--- a/src/Surfnet/Stepup/Identity/Event/IdentityForgottenEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/IdentityForgottenEvent.php
@@ -25,7 +25,10 @@
class IdentityForgottenEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'institution',
];
@@ -33,28 +36,30 @@ class IdentityForgottenEvent extends IdentityEvent implements RightToObtainDataI
/**
* @return Metadata
*/
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
$metadata->identityInstitution = $this->identityInstitution;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new IdentityForgottenEvent(new IdentityId($data['identity_id']), new Institution($data['institution']));
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
'identity_id' => $this->identityId,
- 'institution' => $this->identityInstitution
+ 'institution' => $this->identityInstitution,
];
}
@@ -63,6 +68,9 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/IdentityRenamedEvent.php b/src/Surfnet/Stepup/Identity/Event/IdentityRenamedEvent.php
index d3cd89570..00c4aa0b7 100644
--- a/src/Surfnet/Stepup/Identity/Event/IdentityRenamedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/IdentityRenamedEvent.php
@@ -28,25 +28,21 @@
class IdentityRenamedEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'id',
'institution',
'common_name',
];
- /**
- * @var CommonName
- */
- public $commonName;
-
- public function __construct(IdentityId $id, Institution $institution, CommonName $commonName)
+ public function __construct(IdentityId $id, Institution $institution, public CommonName $commonName)
{
parent::__construct($id, $institution);
-
- $this->commonName = $commonName;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -59,33 +55,35 @@ public function getAuditLogMetadata()
* @param array $data
* @return IdentityRenamedEvent The object instance
*/
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['id']),
new Institution($data['institution']),
- CommonName::unknown()
+ CommonName::unknown(),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'id' => (string) $this->identityId,
- 'institution' => (string) $this->identityInstitution,
+ 'id' => (string)$this->identityId,
+ 'institution' => (string)$this->identityInstitution,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
$this->commonName = $sensitiveData->getCommonName();
}
@@ -97,6 +95,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/InstitutionsAddedToWhitelistEvent.php b/src/Surfnet/Stepup/Identity/Event/InstitutionsAddedToWhitelistEvent.php
index 4a99be13e..0d6824c42 100644
--- a/src/Surfnet/Stepup/Identity/Event/InstitutionsAddedToWhitelistEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/InstitutionsAddedToWhitelistEvent.php
@@ -22,21 +22,15 @@
class InstitutionsAddedToWhitelistEvent implements WhitelistEvent
{
- /**
- * @var InstitutionCollection
- */
- public $addedInstitutions;
-
- public function __construct(InstitutionCollection $addedInstitutions)
+ public function __construct(public InstitutionCollection $addedInstitutions)
{
- $this->addedInstitutions = $addedInstitutions;
}
/**
* @param array $data
* @return InstitutionsAddedToWhitelistEvent
*/
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(InstitutionCollection::deserialize($data['added_institutions']));
}
@@ -44,6 +38,8 @@ public static function deserialize(array $data)
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
diff --git a/src/Surfnet/Stepup/Identity/Event/InstitutionsRemovedFromWhitelistEvent.php b/src/Surfnet/Stepup/Identity/Event/InstitutionsRemovedFromWhitelistEvent.php
index a3a382aca..d32d5a281 100644
--- a/src/Surfnet/Stepup/Identity/Event/InstitutionsRemovedFromWhitelistEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/InstitutionsRemovedFromWhitelistEvent.php
@@ -22,21 +22,15 @@
class InstitutionsRemovedFromWhitelistEvent implements WhitelistEvent
{
- /**
- * @var InstitutionCollection
- */
- public $removedInstitutions;
-
- public function __construct(InstitutionCollection $removedInstitutions)
+ public function __construct(public InstitutionCollection $removedInstitutions)
{
- $this->removedInstitutions = $removedInstitutions;
}
/**
* @param array $data
* @return InstitutionsRemovedFromWhitelistEvent
*/
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(InstitutionCollection::deserialize($data['removed_institutions']));
}
@@ -44,6 +38,8 @@ public static function deserialize(array $data)
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
diff --git a/src/Surfnet/Stepup/Identity/Event/LocalePreferenceExpressedEvent.php b/src/Surfnet/Stepup/Identity/Event/LocalePreferenceExpressedEvent.php
index 98949eb88..a24c6a765 100644
--- a/src/Surfnet/Stepup/Identity/Event/LocalePreferenceExpressedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/LocalePreferenceExpressedEvent.php
@@ -26,30 +26,26 @@
class LocalePreferenceExpressedEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'id',
'institution',
'preferred_locale',
];
/**
- * @var Locale
- */
- public $preferredLocale;
-
- /**
- * @param IdentityId $id
+ * @param IdentityId $id
* @param Institution $institution
- * @param Locale $preferredLocale
+ * @param Locale $preferredLocale
*/
- public function __construct(IdentityId $id, Institution $institution, Locale $preferredLocale)
+ public function __construct(IdentityId $id, Institution $institution, public Locale $preferredLocale)
{
parent::__construct($id, $institution);
-
- $this->preferredLocale = $preferredLocale;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -58,28 +54,26 @@ public function getAuditLogMetadata()
return $metadata;
}
- /**
- * @param array $data
- * @return IdentityRenamedEvent The object instance
- */
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['id']),
new Institution($data['institution']),
- new Locale($data['preferred_locale'])
+ new Locale($data['preferred_locale']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'id' => (string) $this->identityId,
- 'institution' => (string) $this->identityInstitution,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'id' => (string)$this->identityId,
+ 'institution' => (string)$this->identityInstitution,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
@@ -88,6 +82,9 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/PhonePossessionProvenAndVerifiedEvent.php b/src/Surfnet/Stepup/Identity/Event/PhonePossessionProvenAndVerifiedEvent.php
index 3b76fe500..1fffea16e 100644
--- a/src/Surfnet/Stepup/Identity/Event/PhonePossessionProvenAndVerifiedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/PhonePossessionProvenAndVerifiedEvent.php
@@ -32,9 +32,15 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
-class PhonePossessionProvenAndVerifiedEvent extends IdentityEvent implements Forgettable, PossessionProvenAndVerified, RightToObtainDataInterface
+class PhonePossessionProvenAndVerifiedEvent extends IdentityEvent implements
+ Forgettable,
+ PossessionProvenAndVerified,
+ RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'second_factor_id',
@@ -46,41 +52,6 @@ class PhonePossessionProvenAndVerifiedEvent extends IdentityEvent implements For
'common_name',
];
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\PhoneNumber
- */
- public $phoneNumber;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
- /**
- * @var \Surfnet\Stepup\DateTime\DateTime
- */
- public $registrationRequestedAt;
-
- /**
- * @var string
- */
- public $registrationCode;
-
/**
* @param IdentityId $identityId
* @param Institution $identityInstitution
@@ -88,45 +59,37 @@ class PhonePossessionProvenAndVerifiedEvent extends IdentityEvent implements For
* @param PhoneNumber $phoneNumber
* @param CommonName $commonName
* @param Email $email
- * @param Locale $locale
+ * @param Locale $preferredLocale
* @param DateTime $registrationRequestedAt
* @param string $registrationCode
*/
public function __construct(
- IdentityId $identityId,
- Institution $identityInstitution,
- SecondFactorId $secondFactorId,
- PhoneNumber $phoneNumber,
- CommonName $commonName,
- Email $email,
- Locale $locale,
- DateTime $registrationRequestedAt,
- $registrationCode
+ IdentityId $identityId,
+ Institution $identityInstitution,
+ public SecondFactorId $secondFactorId,
+ public PhoneNumber $phoneNumber,
+ public CommonName $commonName,
+ public Email $email,
+ public Locale $preferredLocale,
+ public DateTime $registrationRequestedAt,
+ public string $registrationCode,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->secondFactorId = $secondFactorId;
- $this->phoneNumber = $phoneNumber;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $locale;
- $this->registrationRequestedAt = $registrationRequestedAt;
- $this->registrationCode = $registrationCode;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
- $metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = new SecondFactorType('sms');
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
+ $metadata->secondFactorId = $this->secondFactorId;
+ $metadata->secondFactorType = new SecondFactorType('sms');
$metadata->secondFactorIdentifier = $this->phoneNumber;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
// BC compatibility for event replay in test-environment only (2.8.0, fixed in 2.8.1)
if (!isset($data['preferred_locale'])) {
@@ -142,26 +105,28 @@ public static function deserialize(array $data)
Email::unknown(),
new Locale($data['preferred_locale']),
DateTime::fromString($data['registration_requested_at']),
- (string) $data['registration_code']
+ (string)$data['registration_code'],
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'registration_requested_at' => (string) $this->registrationRequestedAt,
- 'registration_code' => $this->registrationCode,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'registration_requested_at' => (string)$this->registrationRequestedAt,
+ 'registration_code' => $this->registrationCode,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -169,9 +134,11 @@ public function getSensitiveData()
->withSecondFactorIdentifier($this->phoneNumber, new SecondFactorType('sms'));
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->phoneNumber = $sensitiveData->getSecondFactorIdentifier();
+ $phoneNumber = $sensitiveData->getSecondFactorIdentifier();
+ assert($phoneNumber instanceof PhoneNumber);
+ $this->phoneNumber = $phoneNumber;
$this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
}
@@ -183,6 +150,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/PhonePossessionProvenEvent.php b/src/Surfnet/Stepup/Identity/Event/PhonePossessionProvenEvent.php
index 661f470ca..e2994aef2 100644
--- a/src/Surfnet/Stepup/Identity/Event/PhonePossessionProvenEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/PhonePossessionProvenEvent.php
@@ -18,7 +18,6 @@
namespace Surfnet\Stepup\Identity\Event;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\Stepup\Identity\AuditLog\Metadata;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
@@ -30,11 +29,15 @@
use Surfnet\Stepup\Identity\Value\SecondFactorId;
use Surfnet\StepupBundle\Value\SecondFactorType;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
class PhonePossessionProvenEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'second_factor_id',
@@ -45,46 +48,6 @@ class PhonePossessionProvenEvent extends IdentityEvent implements Forgettable, R
'common_name',
];
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\PhoneNumber
- */
- public $phoneNumber;
-
- /**
- * @var bool
- */
- public $emailVerificationRequired;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\EmailVerificationWindow
- */
- public $emailVerificationWindow;
-
- /**
- * @var string
- */
- public $emailVerificationNonce;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
/**
* @param IdentityId $identityId
* @param Institution $identityInstitution
@@ -100,42 +63,33 @@ class PhonePossessionProvenEvent extends IdentityEvent implements Forgettable, R
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- IdentityId $identityId,
- Institution $identityInstitution,
- SecondFactorId $secondFactorId,
- PhoneNumber $phoneNumber,
- $emailVerificationRequired,
- EmailVerificationWindow $emailVerificationWindow,
- $emailVerificationNonce,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale
+ IdentityId $identityId,
+ Institution $identityInstitution,
+ public SecondFactorId $secondFactorId,
+ public PhoneNumber $phoneNumber,
+ public bool $emailVerificationRequired,
+ public EmailVerificationWindow $emailVerificationWindow,
+ public string $emailVerificationNonce,
+ public CommonName $commonName,
+ public Email $email,
+ public Locale $preferredLocale,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->secondFactorId = $secondFactorId;
- $this->phoneNumber = $phoneNumber;
- $this->emailVerificationRequired = $emailVerificationRequired;
- $this->emailVerificationWindow = $emailVerificationWindow;
- $this->emailVerificationNonce = $emailVerificationNonce;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
- $metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = new SecondFactorType('sms');
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
+ $metadata->secondFactorId = $this->secondFactorId;
+ $metadata->secondFactorType = new SecondFactorType('sms');
$metadata->secondFactorIdentifier = $this->phoneNumber;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
if (!isset($data['email_verification_required'])) {
$data['email_verification_required'] = true;
@@ -151,27 +105,29 @@ public static function deserialize(array $data)
$data['email_verification_nonce'],
CommonName::unknown(),
Email::unknown(),
- new Locale($data['preferred_locale'])
+ new Locale($data['preferred_locale']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'email_verification_required' => (bool) $this->emailVerificationRequired,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'email_verification_required' => $this->emailVerificationRequired,
'email_verification_window' => $this->emailVerificationWindow->serialize(),
- 'email_verification_nonce' => (string) $this->emailVerificationNonce,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'email_verification_nonce' => $this->emailVerificationNonce,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -179,11 +135,13 @@ public function getSensitiveData()
->withSecondFactorIdentifier($this->phoneNumber, new SecondFactorType('sms'));
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->email = $sensitiveData->getEmail();
- $this->commonName = $sensitiveData->getCommonName();
- $this->phoneNumber = $sensitiveData->getSecondFactorIdentifier();
+ $this->email = $sensitiveData->getEmail();
+ $this->commonName = $sensitiveData->getCommonName();
+ $phoneNumber = $sensitiveData->getSecondFactorIdentifier();
+ assert($phoneNumber instanceof PhoneNumber);
+ $this->phoneNumber = $phoneNumber;
}
public function obtainUserData(): array
@@ -193,6 +151,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/PhoneRecoveryTokenPossessionProvenEvent.php b/src/Surfnet/Stepup/Identity/Event/PhoneRecoveryTokenPossessionProvenEvent.php
index 2982ec450..4c8d9a283 100644
--- a/src/Surfnet/Stepup/Identity/Event/PhoneRecoveryTokenPossessionProvenEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/PhoneRecoveryTokenPossessionProvenEvent.php
@@ -18,9 +18,6 @@
namespace Surfnet\Stepup\Identity\Event;
-use Surfnet\Stepup\Identity\Value\RecoveryTokenId;
-use Surfnet\Stepup\Identity\Value\RecoveryTokenType;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\Stepup\Identity\AuditLog\Metadata;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
@@ -28,7 +25,10 @@
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\Locale;
use Surfnet\Stepup\Identity\Value\PhoneNumber;
+use Surfnet\Stepup\Identity\Value\RecoveryTokenId;
+use Surfnet\Stepup\Identity\Value\RecoveryTokenType;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
/**
@@ -39,7 +39,10 @@
*/
class PhoneRecoveryTokenPossessionProvenEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'recovery_token_id',
@@ -48,60 +51,32 @@ class PhoneRecoveryTokenPossessionProvenEvent extends IdentityEvent implements F
'common_name',
];
- /**
- * @var \Surfnet\Stepup\Identity\Value\RecoveryTokenId
- */
- public $recoveryTokenId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\PhoneNumber
- */
- public $phoneNumber;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
public function __construct(
IdentityId $identityId,
Institution $identityInstitution,
- RecoveryTokenId $recoveryTokenId,
- PhoneNumber $phoneNumber,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale
+ public RecoveryTokenId $recoveryTokenId,
+ public PhoneNumber $phoneNumber,
+ public CommonName $commonName,
+ public Email $email,
+ /**
+ * @var Locale Eg. "en_GB"
+ */
+ public Locale $preferredLocale,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->recoveryTokenId = $recoveryTokenId;
- $this->phoneNumber = $phoneNumber;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
$metadata->identityInstitution = $this->identityInstitution;
- $metadata->recoveryTokenId = (string) $this->phoneNumber;
- $metadata->recoveryTokenType = RecoveryTokenType::TYPE_SMS;
+ $metadata->recoveryTokenId = new RecoveryTokenId((string) $this->phoneNumber);
+ $metadata->recoveryTokenType = RecoveryTokenType::sms();
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
@@ -110,25 +85,27 @@ public static function deserialize(array $data)
PhoneNumber::unknown(),
CommonName::unknown(),
Email::unknown(),
- new Locale($data['preferred_locale'])
+ new Locale($data['preferred_locale']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'recovery_token_id' => (string) $this->recoveryTokenId,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'recovery_token_id' => (string)$this->recoveryTokenId,
'recovery_token_type' => RecoveryTokenType::TYPE_SMS,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -136,11 +113,13 @@ public function getSensitiveData()
->withRecoveryTokenSecret($this->phoneNumber, RecoveryTokenType::sms());
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
$this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
- $this->phoneNumber = $sensitiveData->getRecoveryTokenIdentifier();
+ $phoneNumber = $sensitiveData->getRecoveryTokenIdentifier();
+ assert($phoneNumber instanceof PhoneNumber);
+ $this->phoneNumber = $phoneNumber;
}
public function obtainUserData(): array
@@ -150,6 +129,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/RecoveryTokenRevokedEvent.php b/src/Surfnet/Stepup/Identity/Event/RecoveryTokenRevokedEvent.php
index c8f8363ba..19c8592d9 100644
--- a/src/Surfnet/Stepup/Identity/Event/RecoveryTokenRevokedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/RecoveryTokenRevokedEvent.php
@@ -21,22 +21,16 @@
use Surfnet\Stepup\Identity\AuditLog\Metadata;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
-use Surfnet\Stepup\Identity\Value\recoveryTokenId;
+use Surfnet\Stepup\Identity\Value\RecoveryTokenId;
use Surfnet\Stepup\Identity\Value\RecoveryTokenType;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
class RecoveryTokenRevokedEvent extends IdentityEvent implements RightToObtainDataInterface
{
/**
- * @var RecoveryTokenId
+ * @var string[]
*/
- public $recoveryTokenId;
- /**
- * @var RecoveryTokenType
- */
- public $recoveryTokenType;
-
- private $allowlist = [
+ private array $allowlist = [
'identity_id',
'identity_institution',
'recovery_token_id',
@@ -46,15 +40,13 @@ class RecoveryTokenRevokedEvent extends IdentityEvent implements RightToObtainDa
final public function __construct(
IdentityId $identityId,
Institution $identityInstitution,
- RecoveryTokenId $recoveryTokenId,
- RecoveryTokenType $recoveryTokenType
+ public RecoveryTokenId $recoveryTokenId,
+ public RecoveryTokenType $recoveryTokenType,
) {
parent::__construct($identityId, $identityInstitution);
- $this->recoveryTokenId = $recoveryTokenId;
- $this->recoveryTokenType = $recoveryTokenType;
}
- final public static function deserialize(array $data)
+ final public static function deserialize(array $data): self
{
$recoveryTokenType = new RecoveryTokenType($data['recovery_token_type']);
@@ -62,11 +54,11 @@ final public static function deserialize(array $data)
new IdentityId($data['identity_id']),
new Institution($data['identity_institution']),
new RecoveryTokenId($data['recovery_token_id']),
- $recoveryTokenType
+ $recoveryTokenType,
);
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -95,6 +87,9 @@ final public function serialize(): array
];
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityInformationAmendedEvent.php b/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityInformationAmendedEvent.php
index b34308238..46c013e18 100644
--- a/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityInformationAmendedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityInformationAmendedEvent.php
@@ -31,7 +31,10 @@
*/
class RegistrationAuthorityInformationAmendedEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'name_id',
'institution',
@@ -39,21 +42,6 @@ class RegistrationAuthorityInformationAmendedEvent extends IdentityEvent impleme
'contact_information',
];
- /**
- * @var NameId
- */
- public $nameId;
-
- /**
- * @var Location
- */
- public $location;
-
- /**
- * @var ContactInformation
- */
- public $contactInformation;
-
/**
* @param IdentityId $identityId
* @param Institution $institution
@@ -64,18 +52,14 @@ class RegistrationAuthorityInformationAmendedEvent extends IdentityEvent impleme
public function __construct(
IdentityId $identityId,
Institution $institution,
- NameId $nameId,
- Location $location,
- ContactInformation $contactInformation
+ public NameId $nameId,
+ public Location $location,
+ public ContactInformation $contactInformation,
) {
parent::__construct($identityId, $institution);
-
- $this->nameId = $nameId;
- $this->location = $location;
- $this->contactInformation = $contactInformation;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -84,25 +68,25 @@ public function getAuditLogMetadata()
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
new Institution($data['institution']),
new NameId($data['name_id']),
new Location($data['location']),
- new ContactInformation($data['contact_information'])
+ new ContactInformation($data['contact_information']),
);
}
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'institution' => (string) $this->identityInstitution,
- 'name_id' => (string) $this->nameId,
- 'location' => (string) $this->location,
- 'contact_information' => (string) $this->contactInformation,
+ 'identity_id' => (string)$this->identityId,
+ 'institution' => (string)$this->identityInstitution,
+ 'name_id' => (string)$this->nameId,
+ 'location' => (string)$this->location,
+ 'contact_information' => (string)$this->contactInformation,
];
}
@@ -111,6 +95,9 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityInformationAmendedForInstitutionEvent.php b/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityInformationAmendedForInstitutionEvent.php
index 6a53fcbf2..887318a3f 100644
--- a/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityInformationAmendedForInstitutionEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityInformationAmendedForInstitutionEvent.php
@@ -26,37 +26,21 @@
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
-class RegistrationAuthorityInformationAmendedForInstitutionEvent extends IdentityEvent implements RightToObtainDataInterface
+class RegistrationAuthorityInformationAmendedForInstitutionEvent extends IdentityEvent implements
+ RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'institution',
'name_id',
'location',
'contact_information',
- 'ra_institution'
+ 'ra_institution',
];
- /**
- * @var NameId
- */
- public $nameId;
-
- /**
- * @var Location
- */
- public $location;
-
- /**
- * @var ContactInformation
- */
- public $contactInformation;
-
- /**
- * @var Institution
- */
- public $raInstitution;
-
/**
* @param IdentityId $identityId
* @param Institution $institution
@@ -68,20 +52,15 @@ class RegistrationAuthorityInformationAmendedForInstitutionEvent extends Identit
public function __construct(
IdentityId $identityId,
Institution $institution,
- NameId $nameId,
- Location $location,
- ContactInformation $contactInformation,
- Institution $raInstitution
+ public NameId $nameId,
+ public Location $location,
+ public ContactInformation $contactInformation,
+ public Institution $raInstitution,
) {
parent::__construct($identityId, $institution);
-
- $this->nameId = $nameId;
- $this->location = $location;
- $this->contactInformation = $contactInformation;
- $this->raInstitution = $raInstitution;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -90,7 +69,7 @@ public function getAuditLogMetadata()
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
@@ -98,19 +77,19 @@ public static function deserialize(array $data)
new NameId($data['name_id']),
new Location($data['location']),
new ContactInformation($data['contact_information']),
- new Institution($data['ra_institution'])
+ new Institution($data['ra_institution']),
);
}
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'institution' => (string) $this->identityInstitution,
- 'name_id' => (string) $this->nameId,
- 'location' => (string) $this->location,
- 'contact_information' => (string) $this->contactInformation,
- 'ra_institution' => (string) $this->raInstitution,
+ 'identity_id' => (string)$this->identityId,
+ 'institution' => (string)$this->identityInstitution,
+ 'name_id' => (string)$this->nameId,
+ 'location' => (string)$this->location,
+ 'contact_information' => (string)$this->contactInformation,
+ 'ra_institution' => (string)$this->raInstitution,
];
}
@@ -119,6 +98,9 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityRetractedEvent.php b/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityRetractedEvent.php
index f7616decd..e92961302 100644
--- a/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityRetractedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityRetractedEvent.php
@@ -33,7 +33,10 @@
*/
class RegistrationAuthorityRetractedEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'name_id',
@@ -41,74 +44,55 @@ class RegistrationAuthorityRetractedEvent extends IdentityEvent implements Forge
'email',
];
- /**
- * @var NameId
- */
- public $nameId;
-
- /**
- * @var CommonName
- */
- public $commonName;
-
- /**
- * @var Email
- */
- public $email;
-
public function __construct(
IdentityId $identityId,
Institution $institution,
- NameId $nameId,
- CommonName $commonName,
- Email $email
+ public NameId $nameId,
+ public CommonName $commonName,
+ public Email $email,
) {
parent::__construct($identityId, $institution);
-
- $this->nameId = $nameId;
- $this->commonName = $commonName;
- $this->email = $email;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
new Institution($data['identity_institution']),
new NameId($data['name_id']),
CommonName::unknown(),
- Email::unknown()
+ Email::unknown(),
);
}
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'name_id' => (string) $this->nameId,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'name_id' => (string)$this->nameId,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
->withEmail($this->email);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->email = $sensitiveData->getEmail();
+ $this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
}
@@ -119,6 +103,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityRetractedForInstitutionEvent.php b/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityRetractedForInstitutionEvent.php
index 500fa8355..4aeabc5d9 100644
--- a/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityRetractedForInstitutionEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/RegistrationAuthorityRetractedForInstitutionEvent.php
@@ -28,9 +28,14 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
-class RegistrationAuthorityRetractedForInstitutionEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
+class RegistrationAuthorityRetractedForInstitutionEvent extends IdentityEvent implements
+ Forgettable,
+ RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'name_id',
@@ -39,52 +44,27 @@ class RegistrationAuthorityRetractedForInstitutionEvent extends IdentityEvent im
'common_name',
];
- /**
- * @var NameId
- */
- public $nameId;
-
- /**
- * @var CommonName
- */
- public $commonName;
-
- /**
- * @var Email
- */
- public $email;
-
- /**
- * @var Institution
- */
- public $raInstitution;
-
public function __construct(
IdentityId $identityId,
Institution $institution,
- NameId $nameId,
- CommonName $commonName,
- Email $email,
- Institution $raInstitution
+ public NameId $nameId,
+ public CommonName $commonName,
+ public Email $email,
+ public Institution $raInstitution,
) {
parent::__construct($identityId, $institution);
-
- $this->nameId = $nameId;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->raInstitution = $raInstitution;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
@@ -92,33 +72,35 @@ public static function deserialize(array $data)
new NameId($data['name_id']),
CommonName::unknown(),
Email::unknown(),
- new Institution($data['ra_institution'])
+ new Institution($data['ra_institution']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'name_id' => (string) $this->nameId,
- 'ra_institution' => (string) $this->raInstitution,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'name_id' => (string)$this->nameId,
+ 'ra_institution' => (string)$this->raInstitution,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
->withEmail($this->email);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->email = $sensitiveData->getEmail();
+ $this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
}
@@ -129,6 +111,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/SafeStoreSecretRecoveryTokenPossessionPromisedEvent.php b/src/Surfnet/Stepup/Identity/Event/SafeStoreSecretRecoveryTokenPossessionPromisedEvent.php
index a2a4d618c..7ec7f3149 100644
--- a/src/Surfnet/Stepup/Identity/Event/SafeStoreSecretRecoveryTokenPossessionPromisedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/SafeStoreSecretRecoveryTokenPossessionPromisedEvent.php
@@ -18,19 +18,18 @@
namespace Surfnet\Stepup\Identity\Event;
-use Surfnet\Stepup\Identity\Value\HashableSecret;
-use Surfnet\Stepup\Identity\Value\RecoveryTokenId;
-use Surfnet\Stepup\Identity\Value\RecoveryTokenIdentifier;
-use Surfnet\Stepup\Identity\Value\RecoveryTokenType;
-use Surfnet\Stepup\Identity\Value\SafeStore;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\Stepup\Identity\AuditLog\Metadata;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\Locale;
+use Surfnet\Stepup\Identity\Value\RecoveryTokenId;
+use Surfnet\Stepup\Identity\Value\RecoveryTokenIdentifier;
+use Surfnet\Stepup\Identity\Value\RecoveryTokenType;
+use Surfnet\Stepup\Identity\Value\SafeStore;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
/**
@@ -39,9 +38,14 @@
* This event is recorded when the user promised it stored the password
* (displayed only once to the user) in a safe location.
*/
-class SafeStoreSecretRecoveryTokenPossessionPromisedEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
+class SafeStoreSecretRecoveryTokenPossessionPromisedEvent extends IdentityEvent implements
+ Forgettable,
+ RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'recovery_token_id',
@@ -50,61 +54,30 @@ class SafeStoreSecretRecoveryTokenPossessionPromisedEvent extends IdentityEvent
'common_name',
];
- /**
- * @var \Surfnet\Stepup\Identity\Value\RecoveryTokenId
- */
- public $recoveryTokenId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\HashableSecret
- */
- public $secret;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
public function __construct(
IdentityId $identityId,
Institution $identityInstitution,
- RecoveryTokenId $recoveryTokenId,
- RecoveryTokenIdentifier $secret,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale
+ public RecoveryTokenId $recoveryTokenId,
+ public RecoveryTokenIdentifier $secret,
+ public CommonName $commonName,
+ public Email $email,
+ public Locale $preferredLocale,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->recoveryTokenId = $recoveryTokenId;
- $this->secret = $secret;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
$metadata->identityInstitution = $this->identityInstitution;
// In the audit log we do not show the secret (hashed)
- $metadata->recoveryTokenId = (string) SafeStore::hidden();
- $metadata->recoveryTokenType = RecoveryTokenType::TYPE_SAFE_STORE;
+ $metadata->recoveryTokenId = new RecoveryTokenId((string) SafeStore::hidden());
+ $metadata->recoveryTokenType = RecoveryTokenType::safeStore();
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
@@ -113,25 +86,27 @@ public static function deserialize(array $data)
SafeStore::unknown(),
CommonName::unknown(),
Email::unknown(),
- new Locale($data['preferred_locale'])
+ new Locale($data['preferred_locale']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'recovery_token_id' => (string) $this->recoveryTokenId,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'recovery_token_id' => (string)$this->recoveryTokenId,
'recovery_token_type' => RecoveryTokenType::TYPE_SAFE_STORE,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -139,7 +114,7 @@ public function getSensitiveData()
->withRecoveryTokenSecret($this->secret, RecoveryTokenType::safeStore());
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
$this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
@@ -153,6 +128,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/SecondFactorMigratedEvent.php b/src/Surfnet/Stepup/Identity/Event/SecondFactorMigratedEvent.php
index 28369e8b1..eab9c6949 100644
--- a/src/Surfnet/Stepup/Identity/Event/SecondFactorMigratedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/SecondFactorMigratedEvent.php
@@ -42,7 +42,10 @@
*/
class SecondFactorMigratedEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'source_institution',
'target_name_id',
@@ -56,86 +59,27 @@ class SecondFactorMigratedEvent extends IdentityEvent implements Forgettable, Ri
'email',
];
- /**
- * @var Institution
- */
- private $sourceInstitution;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\NameId
- */
- public $targetNameId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $newSecondFactorId;
-
- /**
- * @var \Surfnet\StepupBundle\Value\SecondFactorType
- */
- public $secondFactorType;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier
- */
- public $secondFactorIdentifier;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale
- */
- public $preferredLocale;
- /**
- * @var VettingType
- */
- public $vettingType;
-
/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
IdentityId $identityId,
- NameId $targetNameId,
+ public NameId $targetNameId,
Institution $targetInstitution,
- Institution $sourceInstitution,
- SecondFactorId $secondFactorId,
- SecondFactorId $newSecondFactorId,
- SecondFactorType $secondFactorType,
- SecondFactorIdentifier $secondFactorIdentifier,
- VettingType $vettingType,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale
+ private Institution $sourceInstitution,
+ public SecondFactorId $secondFactorId,
+ public SecondFactorId $newSecondFactorId,
+ public SecondFactorType $secondFactorType,
+ public SecondFactorIdentifier $secondFactorIdentifier,
+ public VettingType $vettingType,
+ public CommonName $commonName,
+ public Email $email,
+ public Locale $preferredLocale,
) {
parent::__construct($identityId, $targetInstitution);
-
- $this->sourceInstitution = $sourceInstitution;
- $this->targetNameId = $targetNameId;
- $this->secondFactorId = $secondFactorId;
- $this->newSecondFactorId = $newSecondFactorId;
- $this->secondFactorType = $secondFactorType;
- $this->secondFactorIdentifier = $secondFactorIdentifier;
- $this->vettingType = $vettingType;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -147,7 +91,7 @@ public function getAuditLogMetadata()
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
// Events not having a vetting type (recorded pre 5.0) default the
// vetting type to 'unknown'
@@ -169,12 +113,14 @@ public static function deserialize(array $data)
$vettingType,
CommonName::unknown(),
Email::unknown(),
- new Locale($data['preferred_locale'])
+ new Locale($data['preferred_locale']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
@@ -186,12 +132,12 @@ public function serialize(): array
'second_factor_id' => (string)$this->secondFactorId,
'new_second_factor_id' => (string)$this->newSecondFactorId,
'vetting_type' => $this->vettingType->jsonSerialize(),
- 'second_factor_type' => (string) $this->secondFactorType,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'second_factor_type' => (string)$this->secondFactorType,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -200,7 +146,7 @@ public function getSensitiveData()
->withSecondFactorIdentifier($this->secondFactorIdentifier, $this->secondFactorType);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
$this->secondFactorIdentifier = $sensitiveData->getSecondFactorIdentifier();
$this->commonName = $sensitiveData->getCommonName();
@@ -215,6 +161,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/SecondFactorMigratedToEvent.php b/src/Surfnet/Stepup/Identity/Event/SecondFactorMigratedToEvent.php
index 78300d06d..aaf1caa3c 100644
--- a/src/Surfnet/Stepup/Identity/Event/SecondFactorMigratedToEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/SecondFactorMigratedToEvent.php
@@ -34,7 +34,10 @@
*/
class SecondFactorMigratedToEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'second_factor_id',
@@ -44,53 +47,22 @@ class SecondFactorMigratedToEvent extends IdentityEvent implements Forgettable,
'second_factor_identifier',
];
- /**
- * @var \Surfnet\Stepup\Identity\Value\Institution
- */
- public $targetInstitution;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $targetSecondFactorId;
-
- /**
- * @var \Surfnet\StepupBundle\Value\SecondFactorType
- */
- public $secondFactorType;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier
- */
- public $secondFactorIdentifier;
-
/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
IdentityId $identityId,
Institution $institution,
- Institution $targetInstitution,
- SecondFactorId $secondFactorId,
- SecondFactorId $targetSecondFactorId,
- SecondFactorType $secondFactorType,
- SecondFactorIdentifier $secondFactorIdentifier
+ public Institution $targetInstitution,
+ public SecondFactorId $secondFactorId,
+ public SecondFactorId $targetSecondFactorId,
+ public SecondFactorType $secondFactorType,
+ public SecondFactorIdentifier $secondFactorIdentifier,
) {
parent::__construct($identityId, $institution);
-
- $this->secondFactorId = $secondFactorId;
- $this->targetSecondFactorId = $targetSecondFactorId;
- $this->secondFactorType = $secondFactorType;
- $this->secondFactorIdentifier = $secondFactorIdentifier;
- $this->targetInstitution = $targetInstitution;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -102,7 +74,7 @@ public function getAuditLogMetadata()
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
$secondFactorType = new SecondFactorType($data['second_factor_type']);
return new self(
@@ -112,12 +84,14 @@ public static function deserialize(array $data)
new SecondFactorId($data['second_factor_id']),
new SecondFactorId($data['target_second_factor_id']),
$secondFactorType,
- SecondFactorIdentifierFactory::unknownForType($secondFactorType)
+ SecondFactorIdentifierFactory::unknownForType($secondFactorType),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
@@ -127,17 +101,17 @@ public function serialize(): array
'second_factor_id' => (string)$this->secondFactorId,
'target_institution' => (string)$this->targetInstitution,
'target_second_factor_id' => (string)$this->targetSecondFactorId,
- 'second_factor_type' => (string) $this->secondFactorType,
+ 'second_factor_type' => (string)$this->secondFactorType,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withSecondFactorIdentifier($this->secondFactorIdentifier, $this->secondFactorType);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
$this->secondFactorIdentifier = $sensitiveData->getSecondFactorIdentifier();
}
@@ -149,6 +123,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/SecondFactorRevokedEvent.php b/src/Surfnet/Stepup/Identity/Event/SecondFactorRevokedEvent.php
index de976cc94..45bed7e9e 100644
--- a/src/Surfnet/Stepup/Identity/Event/SecondFactorRevokedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/SecondFactorRevokedEvent.php
@@ -31,7 +31,10 @@
abstract class SecondFactorRevokedEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'second_factor_id',
@@ -39,48 +42,29 @@ abstract class SecondFactorRevokedEvent extends IdentityEvent implements Forgett
'second_factor_identifier',
];
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\StepupBundle\Value\SecondFactorType
- */
- public $secondFactorType;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier
- */
- public $secondFactorIdentifier;
-
final public function __construct(
IdentityId $identityId,
Institution $identityInstitution,
- SecondFactorId $secondFactorId,
- SecondFactorType $secondFactorType,
- SecondFactorIdentifier $secondFactorIdentifier
+ public SecondFactorId $secondFactorId,
+ public SecondFactorType $secondFactorType,
+ public SecondFactorIdentifier $secondFactorIdentifier,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->secondFactorId = $secondFactorId;
- $this->secondFactorType = $secondFactorType;
- $this->secondFactorIdentifier = $secondFactorIdentifier;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
- $metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = $this->secondFactorType;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
+ $metadata->secondFactorId = $this->secondFactorId;
+ $metadata->secondFactorType = $this->secondFactorType;
$metadata->secondFactorIdentifier = $this->secondFactorIdentifier;
return $metadata;
}
- final public static function deserialize(array $data)
+ final public static function deserialize(array $data): self
{
$secondFactorType = new SecondFactorType($data['second_factor_type']);
@@ -89,7 +73,7 @@ final public static function deserialize(array $data)
new Institution($data['identity_institution']),
new SecondFactorId($data['second_factor_id']),
$secondFactorType,
- SecondFactorIdentifierFactory::unknownForType($secondFactorType)
+ SecondFactorIdentifierFactory::unknownForType($secondFactorType),
);
}
@@ -99,20 +83,20 @@ final public static function deserialize(array $data)
final public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'second_factor_type' => (string) $this->secondFactorType,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'second_factor_type' => (string)$this->secondFactorType,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withSecondFactorIdentifier($this->secondFactorIdentifier, $this->secondFactorType);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
$this->secondFactorIdentifier = $sensitiveData->getSecondFactorIdentifier();
}
@@ -124,6 +108,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/SecondFactorVettedEvent.php b/src/Surfnet/Stepup/Identity/Event/SecondFactorVettedEvent.php
index 530c35306..c5e0fd903 100644
--- a/src/Surfnet/Stepup/Identity/Event/SecondFactorVettedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/SecondFactorVettedEvent.php
@@ -40,7 +40,10 @@
*/
class SecondFactorVettedEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'name_id',
'identity_institution',
@@ -53,85 +56,41 @@ class SecondFactorVettedEvent extends IdentityEvent implements Forgettable, Righ
'vetting_type',
];
- /**
- * @var \Surfnet\Stepup\Identity\Value\NameId
- */
- public $nameId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\StepupBundle\Value\SecondFactorType
- */
- public $secondFactorType;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier
- */
- public $secondFactorIdentifier;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
- /** @var VettingType */
- public $vettingType;
-
/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
IdentityId $identityId,
- NameId $nameId,
+ public NameId $nameId,
Institution $institution,
- SecondFactorId $secondFactorId,
- SecondFactorType $secondFactorType,
- SecondFactorIdentifier $secondFactorIdentifier,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale,
- VettingType $vettingType
+ public SecondFactorId $secondFactorId,
+ public SecondFactorType $secondFactorType,
+ public SecondFactorIdentifier $secondFactorIdentifier,
+ public CommonName $commonName,
+ public Email $email,
+ /**
+ * @var Locale Eg. "en_GB"
+ */
+ public Locale $preferredLocale,
+ public ?VettingType $vettingType,
) {
parent::__construct($identityId, $institution);
-
- $this->nameId = $nameId;
- $this->secondFactorId = $secondFactorId;
- $this->secondFactorType = $secondFactorType;
- $this->secondFactorIdentifier = $secondFactorIdentifier;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
- $this->vettingType = $vettingType;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
- $metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = $this->secondFactorType;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
+ $metadata->secondFactorId = $this->secondFactorId;
+ $metadata->secondFactorType = $this->secondFactorType;
$metadata->secondFactorIdentifier = $this->secondFactorIdentifier;
$metadata->vettingType = $this->vettingType;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
$secondFactorType = new SecondFactorType($data['second_factor_type']);
return new self(
@@ -144,26 +103,28 @@ public static function deserialize(array $data)
CommonName::unknown(),
Email::unknown(),
new Locale($data['preferred_locale']),
- new UnknownVettingType()
+ new UnknownVettingType(),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'name_id' => (string) $this->nameId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'second_factor_type' => (string) $this->secondFactorType,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'identity_id' => (string)$this->identityId,
+ 'name_id' => (string)$this->nameId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'second_factor_type' => (string)$this->secondFactorType,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -172,10 +133,10 @@ public function getSensitiveData()
->withVettingType($this->vettingType);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->email = $sensitiveData->getEmail();
- $this->commonName = $sensitiveData->getCommonName();
+ $this->email = $sensitiveData->getEmail();
+ $this->commonName = $sensitiveData->getCommonName();
$this->secondFactorIdentifier = $sensitiveData->getSecondFactorIdentifier();
$this->vettingType = $sensitiveData->getVettingType();
}
@@ -187,6 +148,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/SecondFactorVettedWithoutTokenProofOfPossession.php b/src/Surfnet/Stepup/Identity/Event/SecondFactorVettedWithoutTokenProofOfPossession.php
index 4d5be12ed..7ad05ede4 100644
--- a/src/Surfnet/Stepup/Identity/Event/SecondFactorVettedWithoutTokenProofOfPossession.php
+++ b/src/Surfnet/Stepup/Identity/Event/SecondFactorVettedWithoutTokenProofOfPossession.php
@@ -20,6 +20,7 @@
use Surfnet\Stepup\Identity\AuditLog\Metadata;
use Surfnet\Stepup\Identity\Value\CommonName;
+use Surfnet\Stepup\Identity\Value\DocumentNumber;
use Surfnet\Stepup\Identity\Value\Email;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
@@ -38,9 +39,14 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SecondFactorVettedWithoutTokenProofOfPossession extends IdentityEvent implements Forgettable, RightToObtainDataInterface
+class SecondFactorVettedWithoutTokenProofOfPossession extends IdentityEvent implements
+ Forgettable,
+ RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'name_id',
'identity_institution',
@@ -54,89 +60,45 @@ class SecondFactorVettedWithoutTokenProofOfPossession extends IdentityEvent impl
];
/**
- * @var \Surfnet\Stepup\Identity\Value\NameId
- */
- public $nameId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\StepupBundle\Value\SecondFactorType
- */
- public $secondFactorType;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier
- */
- public $secondFactorIdentifier;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\DocumentNumber
+ * @var DocumentNumber
*/
- public $documentNumber;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
- /** @var VettingType */
- public $vettingType;
+ public DocumentNumber $documentNumber;
/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
IdentityId $identityId,
- NameId $nameId,
+ public NameId $nameId,
Institution $institution,
- SecondFactorId $secondFactorId,
- SecondFactorType $secondFactorType,
- SecondFactorIdentifier $secondFactorIdentifier,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale,
- VettingType $vettingType
+ public SecondFactorId $secondFactorId,
+ public SecondFactorType $secondFactorType,
+ public SecondFactorIdentifier $secondFactorIdentifier,
+ public CommonName $commonName,
+ public Email $email,
+ /**
+ * @var Locale Eg. "en_GB"
+ */
+ public Locale $preferredLocale,
+ public ?VettingType $vettingType,
) {
parent::__construct($identityId, $institution);
-
- $this->nameId = $nameId;
- $this->secondFactorId = $secondFactorId;
- $this->secondFactorType = $secondFactorType;
- $this->secondFactorIdentifier = $secondFactorIdentifier;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
- $this->vettingType = $vettingType;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
- $metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = $this->secondFactorType;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
+ $metadata->secondFactorId = $this->secondFactorId;
+ $metadata->secondFactorType = $this->secondFactorType;
$metadata->secondFactorIdentifier = $this->secondFactorIdentifier;
$metadata->vettingType = $this->vettingType;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
$secondFactorType = new SecondFactorType($data['second_factor_type']);
return new self(
@@ -149,26 +111,28 @@ public static function deserialize(array $data)
CommonName::unknown(),
Email::unknown(),
new Locale($data['preferred_locale']),
- new UnknownVettingType()
+ new UnknownVettingType(),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'name_id' => (string) $this->nameId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'second_factor_type' => (string) $this->secondFactorType,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'identity_id' => (string)$this->identityId,
+ 'name_id' => (string)$this->nameId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'second_factor_type' => (string)$this->secondFactorType,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -177,10 +141,10 @@ public function getSensitiveData()
->withVettingType($this->vettingType);
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->email = $sensitiveData->getEmail();
- $this->commonName = $sensitiveData->getCommonName();
+ $this->email = $sensitiveData->getEmail();
+ $this->commonName = $sensitiveData->getCommonName();
$this->secondFactorIdentifier = $sensitiveData->getSecondFactorIdentifier();
$this->vettingType = $sensitiveData->getVettingType();
}
@@ -192,6 +156,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/U2fDevicePossessionProvenAndVerifiedEvent.php b/src/Surfnet/Stepup/Identity/Event/U2fDevicePossessionProvenAndVerifiedEvent.php
index 3242f396b..2026408b6 100644
--- a/src/Surfnet/Stepup/Identity/Event/U2fDevicePossessionProvenAndVerifiedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/U2fDevicePossessionProvenAndVerifiedEvent.php
@@ -25,8 +25,8 @@
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\Locale;
-use Surfnet\Stepup\Identity\Value\U2fKeyHandle;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
+use Surfnet\Stepup\Identity\Value\U2fKeyHandle;
use Surfnet\StepupBundle\Value\SecondFactorType;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
@@ -35,9 +35,15 @@
/**
* @deprecated Built in U2F support is dropped from StepUp, this Event was not removed to support event replay
*/
-class U2fDevicePossessionProvenAndVerifiedEvent extends IdentityEvent implements Forgettable, PossessionProvenAndVerified, RightToObtainDataInterface
+class U2fDevicePossessionProvenAndVerifiedEvent extends IdentityEvent implements
+ Forgettable,
+ PossessionProvenAndVerified,
+ RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'second_factor_id',
@@ -49,41 +55,6 @@ class U2fDevicePossessionProvenAndVerifiedEvent extends IdentityEvent implements
'common_name',
];
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\U2fKeyHandle
- */
- public $keyHandle;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
- /**
- * @var \Surfnet\Stepup\DateTime\DateTime
- */
- public $registrationRequestedAt;
-
- /**
- * @var string
- */
- public $registrationCode;
-
/**
* @param IdentityId $identityId
* @param Institution $identityInstitution
@@ -91,45 +62,37 @@ class U2fDevicePossessionProvenAndVerifiedEvent extends IdentityEvent implements
* @param U2fKeyHandle $keyHandle
* @param CommonName $commonName
* @param Email $email
- * @param Locale $locale
+ * @param Locale $preferredLocale
* @param DateTime $registrationRequestedAt
* @param string $registrationCode
*/
public function __construct(
- IdentityId $identityId,
- Institution $identityInstitution,
- SecondFactorId $secondFactorId,
- U2fKeyHandle $keyHandle,
- CommonName $commonName,
- Email $email,
- Locale $locale,
- DateTime $registrationRequestedAt,
- $registrationCode
+ IdentityId $identityId,
+ Institution $identityInstitution,
+ public SecondFactorId $secondFactorId,
+ public U2fKeyHandle $keyHandle,
+ public CommonName $commonName,
+ public Email $email,
+ public Locale $preferredLocale,
+ public DateTime $registrationRequestedAt,
+ public string $registrationCode,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->secondFactorId = $secondFactorId;
- $this->keyHandle = $keyHandle;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $locale;
- $this->registrationRequestedAt = $registrationRequestedAt;
- $this->registrationCode = $registrationCode;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
- $metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = new SecondFactorType('sms');
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
+ $metadata->secondFactorId = $this->secondFactorId;
+ $metadata->secondFactorType = new SecondFactorType('sms');
$metadata->secondFactorIdentifier = $this->keyHandle;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
// BC compatibility for event replay in test-environment only (2.8.0, fixed in 2.8.1)
if (!isset($data['preferred_locale'])) {
@@ -145,26 +108,28 @@ public static function deserialize(array $data)
Email::unknown(),
new Locale($data['preferred_locale']),
DateTime::fromString($data['registration_requested_at']),
- (string) $data['registration_code']
+ (string)$data['registration_code'],
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'registration_requested_at' => (string) $this->registrationRequestedAt,
- 'registration_code' => $this->registrationCode,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'registration_requested_at' => (string)$this->registrationRequestedAt,
+ 'registration_code' => $this->registrationCode,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -172,11 +137,13 @@ public function getSensitiveData()
->withSecondFactorIdentifier($this->keyHandle, new SecondFactorType('u2f'));
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->keyHandle = $sensitiveData->getSecondFactorIdentifier();
- $this->email = $sensitiveData->getEmail();
- $this->commonName = $sensitiveData->getCommonName();
+ $keyHandle = $sensitiveData->getSecondFactorIdentifier();
+ assert($keyHandle instanceof U2fKeyHandle);
+ $this->keyHandle = $keyHandle;
+ $this->email = $sensitiveData->getEmail();
+ $this->commonName = $sensitiveData->getCommonName();
}
public function obtainUserData(): array
@@ -186,6 +153,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/U2fDevicePossessionProvenEvent.php b/src/Surfnet/Stepup/Identity/Event/U2fDevicePossessionProvenEvent.php
index 8ec89dba4..6d6327061 100644
--- a/src/Surfnet/Stepup/Identity/Event/U2fDevicePossessionProvenEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/U2fDevicePossessionProvenEvent.php
@@ -22,11 +22,13 @@
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
use Surfnet\Stepup\Identity\Value\EmailVerificationWindow;
+use Surfnet\Stepup\Identity\Value\GssfId;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\Locale;
-use Surfnet\Stepup\Identity\Value\U2fKeyHandle;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
+use Surfnet\Stepup\Identity\Value\SecondFactorIdentifier;
+use Surfnet\Stepup\Identity\Value\U2fKeyHandle;
use Surfnet\StepupBundle\Value\SecondFactorType;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
@@ -37,7 +39,10 @@
*/
class U2fDevicePossessionProvenEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'second_factor_id',
@@ -48,51 +53,11 @@ class U2fDevicePossessionProvenEvent extends IdentityEvent implements Forgettabl
'common_name',
];
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\U2fKeyHandle
- */
- public $keyHandle;
-
- /**
- * @var bool
- */
- public $emailVerificationRequired;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\EmailVerificationWindow
- */
- public $emailVerificationWindow;
-
- /**
- * @var string
- */
- public $emailVerificationNonce;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
/**
* @param IdentityId $identityId
* @param Institution $identityInstitution
* @param SecondFactorId $secondFactorId
- * @param U2fKeyHandle $keyHandle
+ * @param SecondFactorIdentifier $keyHandle
* @param bool $emailVerificationRequired
* @param EmailVerificationWindow $emailVerificationWindow
* @param string $emailVerificationNonce
@@ -103,42 +68,33 @@ class U2fDevicePossessionProvenEvent extends IdentityEvent implements Forgettabl
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- IdentityId $identityId,
- Institution $identityInstitution,
- SecondFactorId $secondFactorId,
- U2fKeyHandle $keyHandle,
- $emailVerificationRequired,
- EmailVerificationWindow $emailVerificationWindow,
- $emailVerificationNonce,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale
+ IdentityId $identityId,
+ Institution $identityInstitution,
+ public SecondFactorId $secondFactorId,
+ public SecondFactorIdentifier $keyHandle,
+ public bool $emailVerificationRequired,
+ public EmailVerificationWindow $emailVerificationWindow,
+ public string $emailVerificationNonce,
+ public CommonName $commonName,
+ public Email $email,
+ public Locale $preferredLocale,
) {
parent::__construct($identityId, $identityInstitution);
-
- $this->secondFactorId = $secondFactorId;
- $this->keyHandle = $keyHandle;
- $this->emailVerificationRequired = $emailVerificationRequired;
- $this->emailVerificationWindow = $emailVerificationWindow;
- $this->emailVerificationNonce = $emailVerificationNonce;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
- $metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = new SecondFactorType('sms');
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
+ $metadata->secondFactorId = $this->secondFactorId;
+ $metadata->secondFactorType = new SecondFactorType('sms');
$metadata->secondFactorIdentifier = $this->keyHandle;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
if (!isset($data['email_verification_required'])) {
$data['email_verification_required'] = true;
@@ -154,27 +110,29 @@ public static function deserialize(array $data)
$data['email_verification_nonce'],
CommonName::unknown(),
Email::unknown(),
- new Locale($data['preferred_locale'])
+ new Locale($data['preferred_locale']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'email_verification_required' => (bool) $this->emailVerificationRequired,
- 'email_verification_window' => $this->emailVerificationWindow->serialize(),
- 'email_verification_nonce' => (string) $this->emailVerificationNonce,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'email_verification_required' => $this->emailVerificationRequired,
+ 'email_verification_window' => $this->emailVerificationWindow->serialize(),
+ 'email_verification_nonce' => $this->emailVerificationNonce,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -182,11 +140,12 @@ public function getSensitiveData()
->withSecondFactorIdentifier($this->keyHandle, new SecondFactorType('u2f'));
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->email = $sensitiveData->getEmail();
- $this->commonName = $sensitiveData->getCommonName();
- $this->keyHandle = $sensitiveData->getSecondFactorIdentifier();
+ $this->email = $sensitiveData->getEmail();
+ $this->commonName = $sensitiveData->getCommonName();
+ $keyHandle = $sensitiveData->getSecondFactorIdentifier();
+ $this->keyHandle = $keyHandle;
}
public function obtainUserData(): array
@@ -196,6 +155,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/VettedSecondFactorsAllRevokedEvent.php b/src/Surfnet/Stepup/Identity/Event/VettedSecondFactorsAllRevokedEvent.php
index 4a3d2c88c..0debdb176 100644
--- a/src/Surfnet/Stepup/Identity/Event/VettedSecondFactorsAllRevokedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/VettedSecondFactorsAllRevokedEvent.php
@@ -25,32 +25,35 @@
class VettedSecondFactorsAllRevokedEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
];
final public function __construct(
IdentityId $identityId,
- Institution $identityInstitution
+ Institution $identityInstitution,
) {
parent::__construct($identityId, $identityInstitution);
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
return $metadata;
}
- final public static function deserialize(array $data)
+ final public static function deserialize(array $data): self
{
return new static(
new IdentityId($data['identity_id']),
- new Institution($data['identity_institution'])
+ new Institution($data['identity_institution']),
);
}
@@ -60,8 +63,8 @@ final public static function deserialize(array $data)
final public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
];
}
@@ -70,6 +73,9 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/VettingTypeHintsSavedEvent.php b/src/Surfnet/Stepup/Identity/Event/VettingTypeHintsSavedEvent.php
index 1c03f7a49..842bdc9a4 100644
--- a/src/Surfnet/Stepup/Identity/Event/VettingTypeHintsSavedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/VettingTypeHintsSavedEvent.php
@@ -26,35 +26,26 @@
class VettingTypeHintsSavedEvent extends IdentityEvent implements RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'hints',
- 'institution'
+ 'institution',
];
- /**
- * @var VettingTypeHintCollection
- */
- public $hints;
-
- /**
- * @var Institution
- */
- public $institution;
-
public function __construct(
IdentityId $identityId,
Institution $identityInstitution,
- VettingTypeHintCollection $hints,
- Institution $institution
+ public VettingTypeHintCollection $hints,
+ public Institution $institution,
) {
parent::__construct($identityId, $identityInstitution);
- $this->hints = $hints;
- $this->institution = $institution;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -68,27 +59,31 @@ public function obtainUserData(): array
return $this->serialize();
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
new Institution($data['identity_institution']),
VettingTypeHintCollection::deserialize($data['hints']),
- new Institution($data['institution'])
+ new Institution($data['institution']),
);
}
+
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
'hints' => $this->hints->serialize(),
- 'institution' => (string) $this->institution,
+ 'institution' => (string)$this->institution,
];
}
}
diff --git a/src/Surfnet/Stepup/Identity/Event/WhitelistCreatedEvent.php b/src/Surfnet/Stepup/Identity/Event/WhitelistCreatedEvent.php
index dd56036bd..1dc60b7d4 100644
--- a/src/Surfnet/Stepup/Identity/Event/WhitelistCreatedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/WhitelistCreatedEvent.php
@@ -22,27 +22,23 @@
class WhitelistCreatedEvent implements WhitelistEvent
{
- /**
- * @var InstitutionCollection
- */
- public $whitelistedInstitutions;
-
- public function __construct(InstitutionCollection $institutionCollection)
+ public function __construct(public InstitutionCollection $whitelistedInstitutions)
{
- $this->whitelistedInstitutions = $institutionCollection;
}
/**
* @param array $data
* @return WhitelistCreatedEvent
*/
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(InstitutionCollection::deserialize($data['whitelisted_institutions']));
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
diff --git a/src/Surfnet/Stepup/Identity/Event/WhitelistReplacedEvent.php b/src/Surfnet/Stepup/Identity/Event/WhitelistReplacedEvent.php
index a80389ae8..74bd0bd93 100644
--- a/src/Surfnet/Stepup/Identity/Event/WhitelistReplacedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/WhitelistReplacedEvent.php
@@ -22,21 +22,15 @@
class WhitelistReplacedEvent implements WhitelistEvent
{
- /**
- * @var InstitutionCollection
- */
- public $whitelistedInstitutions;
-
- public function __construct(InstitutionCollection $whitelistedInstitutions)
+ public function __construct(public InstitutionCollection $whitelistedInstitutions)
{
- $this->whitelistedInstitutions = $whitelistedInstitutions;
}
/**
* @param array $data
* @return WhitelistReplacedEvent
*/
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(InstitutionCollection::deserialize($data['whitelisted_institutions']));
}
@@ -44,6 +38,8 @@ public static function deserialize(array $data)
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
diff --git a/src/Surfnet/Stepup/Identity/Event/YubikeyPossessionProvenAndVerifiedEvent.php b/src/Surfnet/Stepup/Identity/Event/YubikeyPossessionProvenAndVerifiedEvent.php
index 1b064bd08..c74513f05 100644
--- a/src/Surfnet/Stepup/Identity/Event/YubikeyPossessionProvenAndVerifiedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/YubikeyPossessionProvenAndVerifiedEvent.php
@@ -32,9 +32,15 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
-class YubikeyPossessionProvenAndVerifiedEvent extends IdentityEvent implements Forgettable, PossessionProvenAndVerified, RightToObtainDataInterface
+class YubikeyPossessionProvenAndVerifiedEvent extends IdentityEvent implements
+ Forgettable,
+ PossessionProvenAndVerified,
+ RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'second_factor_id',
@@ -47,88 +53,46 @@ class YubikeyPossessionProvenAndVerifiedEvent extends IdentityEvent implements F
];
/**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * The Yubikey's public ID.
- *
- * @var \Surfnet\Stepup\Identity\Value\YubikeyPublicId
- */
- public $yubikeyPublicId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
- /**
- * @var \Surfnet\Stepup\DateTime\DateTime
- */
- public $registrationRequestedAt;
-
- /**
- * @var string
- */
- public $registrationCode;
-
- /**
- * @param IdentityId $identityId
- * @param Institution $institution
- * @param SecondFactorId $secondFactorId
- * @param YubikeyPublicId $yubikeyPublicId
- * @param CommonName $commonName
- * @param Email $email
- * @param Locale $locale
- * @param DateTime $registrationRequestedAt
- * @param string $registrationCode
+ * @param IdentityId $identityId
+ * @param Institution $institution
+ * @param SecondFactorId $secondFactorId
+ * @param YubikeyPublicId $yubikeyPublicId
+ * @param CommonName $commonName
+ * @param Email $email
+ * @param Locale $preferredLocale
+ * @param DateTime $registrationRequestedAt
+ * @param string $registrationCode
*/
public function __construct(
- IdentityId $identityId,
- Institution $institution,
- SecondFactorId $secondFactorId,
- YubikeyPublicId $yubikeyPublicId,
- CommonName $commonName,
- Email $email,
- Locale $locale,
- DateTime $registrationRequestedAt,
- $registrationCode
+ IdentityId $identityId,
+ Institution $institution,
+ public SecondFactorId $secondFactorId,
+ /**
+ * The Yubikey's public ID.
+ */
+ public YubikeyPublicId $yubikeyPublicId,
+ public CommonName $commonName,
+ public Email $email,
+ public Locale $preferredLocale,
+ public DateTime $registrationRequestedAt,
+ public string $registrationCode,
) {
parent::__construct($identityId, $institution);
-
- $this->secondFactorId = $secondFactorId;
- $this->yubikeyPublicId = $yubikeyPublicId;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $locale;
- $this->registrationRequestedAt = $registrationRequestedAt;
- $this->registrationCode = $registrationCode;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
- $metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = new SecondFactorType('yubikey');
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
+ $metadata->secondFactorId = $this->secondFactorId;
+ $metadata->secondFactorType = new SecondFactorType('yubikey');
$metadata->secondFactorIdentifier = $this->yubikeyPublicId;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
// BC compatibility for event replay in test-environment only (2.8.0, fixed in 2.8.1)
if (!isset($data['preferred_locale'])) {
@@ -144,26 +108,28 @@ public static function deserialize(array $data)
Email::unknown(),
new Locale($data['preferred_locale']),
DateTime::fromString($data['registration_requested_at']),
- (string) $data['registration_code']
+ (string)$data['registration_code'],
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'registration_requested_at' => (string) $this->registrationRequestedAt,
- 'registration_code' => $this->registrationCode,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'registration_requested_at' => (string)$this->registrationRequestedAt,
+ 'registration_code' => $this->registrationCode,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -171,9 +137,12 @@ public function getSensitiveData()
->withSecondFactorIdentifier($this->yubikeyPublicId, new SecondFactorType('yubikey'));
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->yubikeyPublicId = $sensitiveData->getSecondFactorIdentifier();
+ $yubikeyPublicId = $sensitiveData->getSecondFactorIdentifier();
+ assert($yubikeyPublicId instanceof YubikeyPublicId);
+ $this->yubikeyPublicId = $yubikeyPublicId;
+
$this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
}
@@ -185,6 +154,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/YubikeyPossessionProvenEvent.php b/src/Surfnet/Stepup/Identity/Event/YubikeyPossessionProvenEvent.php
index a640aafb2..31dc8a188 100644
--- a/src/Surfnet/Stepup/Identity/Event/YubikeyPossessionProvenEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/YubikeyPossessionProvenEvent.php
@@ -18,6 +18,7 @@
namespace Surfnet\Stepup\Identity\Event;
+use Surfnet\Stepup\DateTime\DateTime;
use Surfnet\Stepup\Identity\AuditLog\Metadata;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
@@ -34,7 +35,10 @@
class YubikeyPossessionProvenEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'identity_institution',
'second_factor_id',
@@ -46,103 +50,47 @@ class YubikeyPossessionProvenEvent extends IdentityEvent implements Forgettable,
];
/**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * The Yubikey's public ID.
- *
- * @var \Surfnet\Stepup\Identity\Value\YubikeyPublicId
- */
- public $yubikeyPublicId;
-
- /**
- * @var bool
- */
- public $emailVerificationRequired;
-
- /**
- * @var \Surfnet\Stepup\DateTime\DateTime
- */
- public $emailVerificationRequestedAt;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\EmailVerificationWindow
- */
- public $emailVerificationWindow;
-
- /**
- * @var string
- */
- public $emailVerificationNonce;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
+ * @var DateTime
*/
- public $email;
+ public DateTime $emailVerificationRequestedAt;
/**
- * @var \Surfnet\Stepup\Identity\Value\Locale Eg. "en_GB"
- */
- public $preferredLocale;
-
- /**
- * @param IdentityId $identityId
- * @param Institution $institution
- * @param SecondFactorId $secondFactorId
- * @param YubikeyPublicId $yubikeyPublicId
- * @param bool $emailVerificationRequired
- * @param EmailVerificationWindow $emailVerificationWindow
- * @param string $emailVerificationNonce
- * @param CommonName $commonName
- * @param Email $email
- * @param Locale $preferredLocale
- *
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- IdentityId $identityId,
- Institution $institution,
- SecondFactorId $secondFactorId,
- YubikeyPublicId $yubikeyPublicId,
- $emailVerificationRequired,
- EmailVerificationWindow $emailVerificationWindow,
- $emailVerificationNonce,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale
+ IdentityId $identityId,
+ Institution $institution,
+ public SecondFactorId $secondFactorId,
+ /**
+ * The Yubikey's public ID.
+ */
+ public YubikeyPublicId $yubikeyPublicId,
+ public bool $emailVerificationRequired,
+ public EmailVerificationWindow $emailVerificationWindow,
+ public string $emailVerificationNonce,
+ public CommonName $commonName,
+ public Email $email,
+ /**
+ * @var Locale Eg. "en_GB"
+ */
+ public Locale $preferredLocale,
) {
parent::__construct($identityId, $institution);
-
- $this->secondFactorId = $secondFactorId;
- $this->yubikeyPublicId = $yubikeyPublicId;
- $this->emailVerificationRequired = $emailVerificationRequired;
- $this->emailVerificationWindow = $emailVerificationWindow;
- $this->emailVerificationNonce = $emailVerificationNonce;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
- $metadata = new Metadata();
- $metadata->identityId = $this->identityId;
- $metadata->identityInstitution = $this->identityInstitution;
- $metadata->secondFactorId = $this->secondFactorId;
- $metadata->secondFactorType = new SecondFactorType('yubikey');
+ $metadata = new Metadata();
+ $metadata->identityId = $this->identityId;
+ $metadata->identityInstitution = $this->identityInstitution;
+ $metadata->secondFactorId = $this->secondFactorId;
+ $metadata->secondFactorType = new SecondFactorType('yubikey');
$metadata->secondFactorIdentifier = $this->yubikeyPublicId;
return $metadata;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
if (!isset($data['email_verification_required'])) {
$data['email_verification_required'] = true;
@@ -158,27 +106,29 @@ public static function deserialize(array $data)
$data['email_verification_nonce'],
CommonName::unknown(),
Email::unknown(),
- new Locale($data['preferred_locale'])
+ new Locale($data['preferred_locale']),
);
}
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'second_factor_id' => (string) $this->secondFactorId,
- 'email_verification_required' => (bool) $this->emailVerificationRequired,
- 'email_verification_window' => $this->emailVerificationWindow->serialize(),
- 'email_verification_nonce' => (string) $this->emailVerificationNonce,
- 'preferred_locale' => (string) $this->preferredLocale,
+ 'identity_id' => (string)$this->identityId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'second_factor_id' => (string)$this->secondFactorId,
+ 'email_verification_required' => $this->emailVerificationRequired,
+ 'email_verification_window' => $this->emailVerificationWindow->serialize(),
+ 'email_verification_nonce' => $this->emailVerificationNonce,
+ 'preferred_locale' => (string)$this->preferredLocale,
];
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -186,11 +136,13 @@ public function getSensitiveData()
->withSecondFactorIdentifier($this->yubikeyPublicId, new SecondFactorType('yubikey'));
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->email = $sensitiveData->getEmail();
+ $this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
- $this->yubikeyPublicId = $sensitiveData->getSecondFactorIdentifier();
+ $yubikeyPublicId = $sensitiveData->getSecondFactorIdentifier();
+ assert($yubikeyPublicId instanceof YubikeyPublicId);
+ $this->yubikeyPublicId = $yubikeyPublicId;
}
public function obtainUserData(): array
@@ -200,6 +152,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/Event/YubikeySecondFactorBootstrappedEvent.php b/src/Surfnet/Stepup/Identity/Event/YubikeySecondFactorBootstrappedEvent.php
index c98a61771..4f629293f 100644
--- a/src/Surfnet/Stepup/Identity/Event/YubikeySecondFactorBootstrappedEvent.php
+++ b/src/Surfnet/Stepup/Identity/Event/YubikeySecondFactorBootstrappedEvent.php
@@ -32,9 +32,14 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\RightToObtainDataInterface;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
-final class YubikeySecondFactorBootstrappedEvent extends IdentityEvent implements Forgettable, RightToObtainDataInterface
+final class YubikeySecondFactorBootstrappedEvent extends IdentityEvent implements
+ Forgettable,
+ RightToObtainDataInterface
{
- private $allowlist = [
+ /**
+ * @var string[]
+ */
+ private array $allowlist = [
'identity_id',
'name_id',
'identity_institution',
@@ -47,62 +52,25 @@ final class YubikeySecondFactorBootstrappedEvent extends IdentityEvent implement
];
/**
- * @var \Surfnet\Stepup\Identity\Value\NameId
+ * @var Institution
*/
- public $nameId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Institution
- */
- public $institution;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\Locale
- */
- public $preferredLocale;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\SecondFactorId
- */
- public $secondFactorId;
-
- /**
- * @var \Surfnet\Stepup\Identity\Value\YubikeyPublicId
- */
- public $yubikeyPublicId;
+ public Institution $institution;
public function __construct(
IdentityId $identityId,
- NameId $nameId,
+ public NameId $nameId,
Institution $institution,
- CommonName $commonName,
- Email $email,
- Locale $preferredLocale,
- SecondFactorId $secondFactorId,
- YubikeyPublicId $yubikeyPublicId
+ public CommonName $commonName,
+ public Email $email,
+ public Locale $preferredLocale,
+ public SecondFactorId $secondFactorId,
+ public YubikeyPublicId $yubikeyPublicId,
) {
parent::__construct($identityId, $institution);
-
- $this->nameId = $nameId;
$this->institution = $institution;
- $this->commonName = $commonName;
- $this->email = $email;
- $this->preferredLocale = $preferredLocale;
- $this->secondFactorId = $secondFactorId;
- $this->yubikeyPublicId = $yubikeyPublicId;
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
$metadata = new Metadata();
$metadata->identityId = $this->identityId;
@@ -116,19 +84,21 @@ public function getAuditLogMetadata()
/**
* The data ending up in the event_stream, be careful not to include sensitive data here!
+ *
+ * @return array
*/
public function serialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
- 'name_id' => (string) $this->nameId,
- 'identity_institution' => (string) $this->identityInstitution,
- 'preferred_locale' => (string) $this->preferredLocale,
- 'second_factor_id' => (string) $this->secondFactorId,
+ 'identity_id' => (string)$this->identityId,
+ 'name_id' => (string)$this->nameId,
+ 'identity_institution' => (string)$this->identityInstitution,
+ 'preferred_locale' => (string)$this->preferredLocale,
+ 'second_factor_id' => (string)$this->secondFactorId,
];
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self(
new IdentityId($data['identity_id']),
@@ -138,11 +108,11 @@ public static function deserialize(array $data)
Email::unknown(),
new Locale($data['preferred_locale']),
new SecondFactorId($data['second_factor_id']),
- YubikeyPublicId::unknown()
+ YubikeyPublicId::unknown(),
);
}
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return (new SensitiveData)
->withCommonName($this->commonName)
@@ -150,11 +120,13 @@ public function getSensitiveData()
->withSecondFactorIdentifier($this->yubikeyPublicId, new SecondFactorType('yubikey'));
}
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
- $this->email = $sensitiveData->getEmail();
+ $this->email = $sensitiveData->getEmail();
$this->commonName = $sensitiveData->getCommonName();
- $this->yubikeyPublicId = $sensitiveData->getSecondFactorIdentifier();
+ $yubikeyPublicId = $sensitiveData->getSecondFactorIdentifier();
+ assert($yubikeyPublicId instanceof YubikeyPublicId);
+ $this->yubikeyPublicId = $yubikeyPublicId;
}
public function obtainUserData(): array
@@ -164,6 +136,9 @@ public function obtainUserData(): array
return array_merge($serializedPublicUserData, $serializedSensitiveUserData);
}
+ /**
+ * @return string[]
+ */
public function getAllowlist(): array
{
return $this->allowlist;
diff --git a/src/Surfnet/Stepup/Identity/EventSourcing/IdentityRepository.php b/src/Surfnet/Stepup/Identity/EventSourcing/IdentityRepository.php
index 35e8d1d2c..9d2e37c37 100644
--- a/src/Surfnet/Stepup/Identity/EventSourcing/IdentityRepository.php
+++ b/src/Surfnet/Stepup/Identity/EventSourcing/IdentityRepository.php
@@ -34,32 +34,23 @@
class IdentityRepository extends EventSourcingRepository
{
- protected $events;
-
- protected $logger;
-
- private $userDataFilter;
-
/**
* @param EventStreamDecorator[] $eventStreamDecorators
*/
public function __construct(
- EventStoreInterface $eventStore,
+ protected EventStoreInterface $events,
EventBusInterface $eventBus,
AggregateFactory $aggregateFactory,
- UserDataFilterInterface $userDataFilter,
- LoggerInterface $logger,
- array $eventStreamDecorators = []
+ private readonly UserDataFilterInterface $userDataFilter,
+ protected LoggerInterface $logger,
+ array $eventStreamDecorators = [],
) {
- $this->events = $eventStore;
- $this->logger = $logger;
- $this->userDataFilter = $userDataFilter;
parent::__construct(
- $eventStore,
+ $this->events,
$eventBus,
Identity::class,
$aggregateFactory,
- $eventStreamDecorators
+ $eventStreamDecorators,
);
}
diff --git a/src/Surfnet/Stepup/Identity/EventSourcing/WhitelistRepository.php b/src/Surfnet/Stepup/Identity/EventSourcing/WhitelistRepository.php
index dcbae515d..83f24ad2f 100644
--- a/src/Surfnet/Stepup/Identity/EventSourcing/WhitelistRepository.php
+++ b/src/Surfnet/Stepup/Identity/EventSourcing/WhitelistRepository.php
@@ -23,27 +23,28 @@
use Broadway\EventSourcing\EventSourcingRepository;
use Broadway\EventSourcing\EventStreamDecorator;
use Broadway\EventStore\EventStore as EventStoreInterface;
+use Surfnet\Stepup\Identity\Whitelist;
class WhitelistRepository extends EventSourcingRepository
{
/**
- * @param EventStoreInterface $eventStore
- * @param EventBusInterface $eventBus
- * @param AggregateFactory $aggregateFactory
+ * @param EventStoreInterface $eventStore
+ * @param EventBusInterface $eventBus
+ * @param AggregateFactory $aggregateFactory
* @param EventStreamDecorator[] $eventStreamDecorators
*/
public function __construct(
EventStoreInterface $eventStore,
EventBusInterface $eventBus,
AggregateFactory $aggregateFactory,
- array $eventStreamDecorators = []
+ array $eventStreamDecorators = [],
) {
parent::__construct(
$eventStore,
$eventBus,
- \Surfnet\Stepup\Identity\Whitelist::class,
+ Whitelist::class,
$aggregateFactory,
- $eventStreamDecorators
+ $eventStreamDecorators,
);
}
}
diff --git a/src/Surfnet/Stepup/Identity/Identity.php b/src/Surfnet/Stepup/Identity/Identity.php
index 0e8806ff4..f84a0baed 100644
--- a/src/Surfnet/Stepup/Identity/Identity.php
+++ b/src/Surfnet/Stepup/Identity/Identity.php
@@ -108,8 +108,6 @@
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
use Surfnet\StepupBundle\Value\Loa;
use Surfnet\StepupBundle\Value\SecondFactorType;
-use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RecoveryToken;
-use function sprintf;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -123,62 +121,44 @@ class Identity extends EventSourcedAggregateRoot implements IdentityApi
/**
* @var IdentityId
*/
- private $id;
+ private IdentityId $id;
/**
* @var Institution
*/
- private $institution;
+ private Institution $institution;
/**
* @var NameId
*/
- private $nameId;
+ private NameId $nameId;
/**
- * @var \Surfnet\Stepup\Identity\Value\CommonName
+ * @var CommonName
*/
- private $commonName;
+ private CommonName $commonName;
/**
- * @var \Surfnet\Stepup\Identity\Value\Email
+ * @var Email
*/
- private $email;
+ private Email $email;
- /**
- * @var SecondFactorCollection|UnverifiedSecondFactor[]
- */
- private $unverifiedSecondFactors;
+ private ?SecondFactorCollection $unverifiedSecondFactors = null;
- /**
- * @var SecondFactorCollection|VerifiedSecondFactor[]
- */
- private $verifiedSecondFactors;
+ private ?SecondFactorCollection $verifiedSecondFactors = null;
- /**
- * @var SecondFactorCollection|VettedSecondFactor[]
- */
- private $vettedSecondFactors;
+ private ?SecondFactorCollection $vettedSecondFactors = null;
- /**
- * @var RegistrationAuthorityCollection
- */
- private $registrationAuthorities;
+ private ?RegistrationAuthorityCollection $registrationAuthorities = null;
/**
* @var Locale
*/
- private $preferredLocale;
+ private Locale $preferredLocale;
- /**
- * @var boolean
- */
- private $forgotten;
+ private ?bool $forgotten = null;
- /**
- * @var RecoveryTokenCollection
- */
- private $recoveryTokens;
+ private ?RecoveryTokenCollection $recoveryTokens = null;
public static function create(
IdentityId $id,
@@ -186,8 +166,8 @@ public static function create(
NameId $nameId,
CommonName $commonName,
Email $email,
- Locale $preferredLocale
- ) {
+ Locale $preferredLocale,
+ ): self {
$identity = new self();
$identity->apply(new IdentityCreatedEvent($id, $institution, $nameId, $commonName, $email, $preferredLocale));
@@ -198,7 +178,7 @@ final public function __construct()
{
}
- public function rename(CommonName $commonName)
+ public function rename(CommonName $commonName): void
{
$this->assertNotForgotten();
@@ -210,7 +190,7 @@ public function rename(CommonName $commonName)
$this->apply(new IdentityRenamedEvent($this->id, $this->institution, $commonName));
}
- public function changeEmail(Email $email)
+ public function changeEmail(Email $email): void
{
$this->assertNotForgotten();
@@ -222,8 +202,11 @@ public function changeEmail(Email $email)
$this->apply(new IdentityEmailChangedEvent($this->id, $this->institution, $email));
}
- public function bootstrapYubikeySecondFactor(SecondFactorId $secondFactorId, YubikeyPublicId $yubikeyPublicId, $maxNumberOfTokens)
- {
+ public function bootstrapYubikeySecondFactor(
+ SecondFactorId $secondFactorId,
+ YubikeyPublicId $yubikeyPublicId,
+ int $maxNumberOfTokens,
+ ): void {
$this->assertNotForgotten();
$this->assertUserMayAddSecondFactor($maxNumberOfTokens);
@@ -236,18 +219,18 @@ public function bootstrapYubikeySecondFactor(SecondFactorId $secondFactorId, Yub
$this->email,
$this->preferredLocale,
$secondFactorId,
- $yubikeyPublicId
- )
+ $yubikeyPublicId,
+ ),
);
}
public function provePossessionOfYubikey(
- SecondFactorId $secondFactorId,
- YubikeyPublicId $yubikeyPublicId,
- $emailVerificationRequired,
+ SecondFactorId $secondFactorId,
+ YubikeyPublicId $yubikeyPublicId,
+ bool $emailVerificationRequired,
EmailVerificationWindow $emailVerificationWindow,
- $maxNumberOfTokens
- ) {
+ int $maxNumberOfTokens,
+ ): void {
$this->assertNotForgotten();
$this->assertUserMayAddSecondFactor($maxNumberOfTokens);
@@ -265,8 +248,8 @@ public function provePossessionOfYubikey(
$emailVerificationNonce,
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
);
} else {
$this->apply(
@@ -279,19 +262,19 @@ public function provePossessionOfYubikey(
$this->email,
$this->preferredLocale,
DateTime::now(),
- OtpGenerator::generate(8)
- )
+ OtpGenerator::generate(8),
+ ),
);
}
}
public function provePossessionOfPhone(
- SecondFactorId $secondFactorId,
- PhoneNumber $phoneNumber,
- $emailVerificationRequired,
+ SecondFactorId $secondFactorId,
+ PhoneNumber $phoneNumber,
+ bool $emailVerificationRequired,
EmailVerificationWindow $emailVerificationWindow,
- $maxNumberOfTokens
- ) {
+ int $maxNumberOfTokens,
+ ): void {
$this->assertNotForgotten();
$this->assertUserMayAddSecondFactor($maxNumberOfTokens);
@@ -309,8 +292,8 @@ public function provePossessionOfPhone(
$emailVerificationNonce,
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
);
} else {
$this->apply(
@@ -323,14 +306,16 @@ public function provePossessionOfPhone(
$this->email,
$this->preferredLocale,
DateTime::now(),
- OtpGenerator::generate(8)
- )
+ OtpGenerator::generate(8),
+ ),
);
}
}
- public function provePossessionOfPhoneRecoveryToken(RecoveryTokenId $recoveryTokenId, PhoneNumber $phoneNumber): void
- {
+ public function provePossessionOfPhoneRecoveryToken(
+ RecoveryTokenId $recoveryTokenId,
+ PhoneNumber $phoneNumber,
+ ): void {
$this->assertNotForgotten();
$this->assertUserMayAddRecoveryToken(RecoveryTokenType::sms());
$this->apply(
@@ -341,8 +326,8 @@ public function provePossessionOfPhoneRecoveryToken(RecoveryTokenId $recoveryTok
$phoneNumber,
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
);
}
@@ -359,12 +344,12 @@ public function promisePossessionOfSafeStoreSecretRecoveryToken(RecoveryTokenId
$secret,
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
);
}
- public function saveVettingTypeHints(Institution $institution, VettingTypeHintCollection $hints)
+ public function saveVettingTypeHints(Institution $institution, VettingTypeHintCollection $hints): void
{
$this->assertNotForgotten();
$this->apply(
@@ -372,19 +357,19 @@ public function saveVettingTypeHints(Institution $institution, VettingTypeHintCo
$this->id,
$this->institution,
$hints,
- $institution
- )
+ $institution,
+ ),
);
}
public function provePossessionOfGssf(
- SecondFactorId $secondFactorId,
- StepupProvider $provider,
- GssfId $gssfId,
- $emailVerificationRequired,
+ SecondFactorId $secondFactorId,
+ StepupProvider $provider,
+ GssfId $gssfId,
+ bool $emailVerificationRequired,
EmailVerificationWindow $emailVerificationWindow,
- $maxNumberOfTokens
- ) {
+ int $maxNumberOfTokens,
+ ): void {
$this->assertNotForgotten();
$this->assertUserMayAddSecondFactor($maxNumberOfTokens);
@@ -403,8 +388,8 @@ public function provePossessionOfGssf(
$emailVerificationNonce,
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
);
} else {
$this->apply(
@@ -418,8 +403,8 @@ public function provePossessionOfGssf(
$this->email,
$this->preferredLocale,
DateTime::now(),
- OtpGenerator::generate(8)
- )
+ OtpGenerator::generate(8),
+ ),
);
}
}
@@ -428,12 +413,12 @@ public function provePossessionOfGssf(
* @deprecated Built in U2F support is dropped from StepUp, this was not removed to support event replay
*/
public function provePossessionOfU2fDevice(
- SecondFactorId $secondFactorId,
- U2fKeyHandle $keyHandle,
- $emailVerificationRequired,
+ SecondFactorId $secondFactorId,
+ U2fKeyHandle $keyHandle,
+ bool $emailVerificationRequired,
EmailVerificationWindow $emailVerificationWindow,
- $maxNumberOfTokens
- ) {
+ int $maxNumberOfTokens,
+ ): void {
$this->assertNotForgotten();
$this->assertUserMayAddSecondFactor($maxNumberOfTokens);
@@ -451,8 +436,8 @@ public function provePossessionOfU2fDevice(
$emailVerificationNonce,
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
);
} else {
$this->apply(
@@ -465,13 +450,13 @@ public function provePossessionOfU2fDevice(
$this->email,
$this->preferredLocale,
DateTime::now(),
- OtpGenerator::generate(8)
- )
+ OtpGenerator::generate(8),
+ ),
);
}
}
- public function verifyEmail($verificationNonce)
+ public function verifyEmail(string $verificationNonce): void
{
$this->assertNotForgotten();
@@ -485,7 +470,7 @@ public function verifyEmail($verificationNonce)
if (!$secondFactorToVerify) {
throw new DomainException(
- 'Cannot verify second factor, no unverified second factor can be verified using the given nonce'
+ 'Cannot verify second factor, no unverified second factor can be verified using the given nonce',
);
}
@@ -501,26 +486,33 @@ public function verifyEmail($verificationNonce)
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function vetSecondFactor(
- IdentityApi $registrant,
- SecondFactorId $registrantsSecondFactorId,
- SecondFactorType $registrantsSecondFactorType,
- SecondFactorIdentifier $registrantsSecondFactorIdentifier,
- $registrationCode,
- DocumentNumber $documentNumber,
- $identityVerified,
- SecondFactorTypeService $secondFactorTypeService,
+ IdentityApi $registrant,
+ SecondFactorId $registrantsSecondFactorId,
+ SecondFactorType $registrantsSecondFactorType,
+ SecondFactorIdentifier $registrantsSecondFactorIdentifier,
+ string $registrationCode,
+ DocumentNumber $documentNumber,
+ bool $identityVerified,
+ SecondFactorTypeService $secondFactorTypeService,
SecondFactorProvePossessionHelper $secondFactorProvePossessionHelper,
- $provePossessionSkipped
- ) {
+ bool $provePossessionSkipped,
+ ): void {
$this->assertNotForgotten();
+ /** The vetted second factor collection can determine highest loa based on the vetting type,
+ * the other can not (as the verified and unverified second factors do not have a vetting type)
+ * And the vetting type is used to determine if the LoA is diminished (in case of a self
+ * asserted token registration)
+ */
/** @var VettedSecondFactor|null $secondFactorWithHighestLoa */
- $secondFactorWithHighestLoa = $this->vettedSecondFactors->getSecondFactorWithHighestLoa($secondFactorTypeService);
+ $secondFactorWithHighestLoa = $this->vettedSecondFactors->getSecondFactorWithHighestLoa(
+ $secondFactorTypeService,
+ );
$registrantsSecondFactor = $registrant->getVerifiedSecondFactor($registrantsSecondFactorId);
- if ($registrantsSecondFactor === null) {
+ if (!$registrantsSecondFactor instanceof \Surfnet\Stepup\Identity\Entity\VerifiedSecondFactor) {
throw new DomainException(
- sprintf('Registrant second factor with ID %s does not exist', $registrantsSecondFactorId)
+ sprintf('Registrant second factor with ID %s does not exist', $registrantsSecondFactorId),
);
}
@@ -529,14 +521,14 @@ public function vetSecondFactor(
sprintf(
'Vetting failed: authority %s has %d vetted second factors!',
$this->id,
- count($this->vettedSecondFactors)
- )
+ count($this->vettedSecondFactors),
+ ),
);
}
if (!$secondFactorWithHighestLoa->hasEqualOrHigherLoaComparedTo(
$registrantsSecondFactor,
- $secondFactorTypeService
+ $secondFactorTypeService,
)) {
throw new DomainException("Authority does not have the required LoA to vet the registrant's second factor");
}
@@ -545,12 +537,16 @@ public function vetSecondFactor(
throw new DomainException('Will not vet second factor when physical identity has not been verified.');
}
- if ($provePossessionSkipped && !$secondFactorProvePossessionHelper->canSkipProvePossession($registrantsSecondFactorType)) {
- throw new DomainException(sprintf(
- "The possession of registrants second factor with ID '%s' of type '%s' has to be physically proven",
- $registrantsSecondFactorId,
- $registrantsSecondFactorType->getSecondFactorType()
- ));
+ if ($provePossessionSkipped && !$secondFactorProvePossessionHelper->canSkipProvePossession(
+ $registrantsSecondFactorType,
+ )) {
+ throw new DomainException(
+ sprintf(
+ "The possession of registrants second factor with ID '%s' of type '%s' has to be physically proven",
+ $registrantsSecondFactorId,
+ $registrantsSecondFactorType->getSecondFactorType(),
+ ),
+ );
}
$registrant->complyWithVettingOfSecondFactor(
@@ -559,23 +555,23 @@ public function vetSecondFactor(
$registrantsSecondFactorIdentifier,
$registrationCode,
$documentNumber,
- $provePossessionSkipped
+ $provePossessionSkipped,
);
}
public function registerSelfAssertedSecondFactor(
SecondFactorIdentifier $secondFactorIdentifier,
SecondFactorTypeService $secondFactorTypeService,
- RecoveryTokenId $recoveryTokenId
+ RecoveryTokenId $recoveryTokenId,
): void {
$this->assertNotForgotten();
$this->assertSelfAssertedTokenRegistrationAllowed();
try {
$recoveryToken = $this->recoveryTokens->get($recoveryTokenId);
- } catch (DomainException $e) {
+ } catch (DomainException) {
throw new DomainException(
- sprintf('Recovery token used during registration is not possessed by identity %s', (string)$this->id)
+ sprintf('Recovery token used during registration is not possessed by identity %s', (string)$this->id),
);
}
@@ -590,9 +586,9 @@ public function registerSelfAssertedSecondFactor(
throw new DomainException(
sprintf(
'Registering second factor of type %s with ID %s does not exist',
- get_class($secondFactorIdentifier),
- $secondFactorIdentifier->getValue()
- )
+ $secondFactorIdentifier::class,
+ $secondFactorIdentifier->getValue(),
+ ),
);
}
$registeringSecondFactor->vet(true, new SelfAssertedRegistrationVettingType($recoveryToken->getTokenId()));
@@ -623,7 +619,7 @@ public function selfVetSecondFactor(
Loa $authoringSecondFactorLoa,
string $registrationCode,
SecondFactorIdentifier $secondFactorIdentifier,
- SecondFactorTypeService $secondFactorTypeService
+ SecondFactorTypeService $secondFactorTypeService,
): void {
$this->assertNotForgotten();
$registeringSecondFactor = null;
@@ -638,9 +634,9 @@ public function selfVetSecondFactor(
throw new DomainException(
sprintf(
'Registrant second factor of type %s with ID %s does not exist',
- get_class($secondFactorIdentifier),
- $secondFactorIdentifier->getValue()
- )
+ $secondFactorIdentifier::class,
+ $secondFactorIdentifier->getValue(),
+ ),
);
}
@@ -649,7 +645,7 @@ public function selfVetSecondFactor(
}
$selfVettingIsAllowed = $authoringSecondFactorLoa->levelIsHigherOrEqualTo(
- $registeringSecondFactor->getLoaLevel($secondFactorTypeService)
+ $registeringSecondFactor->getLoaLevel($secondFactorTypeService),
);
// Was the authorizing token a self-asserted token (does it have LoA 1.5?)
@@ -657,7 +653,7 @@ public function selfVetSecondFactor(
if (!$selfVettingIsAllowed && !$isSelfVetUsingSAT) {
throw new DomainException(
- "The second factor to be vetted has a higher LoA then the Token used for proving possession"
+ "The second factor to be vetted has a higher LoA then the Token used for proving possession",
);
}
@@ -679,12 +675,12 @@ public function migrateVettedSecondFactor(
IdentityApi $sourceIdentity,
SecondFactorId $secondFactorId,
string $targetSecondFactorId,
- int $maxNumberOfTokens
+ int $maxNumberOfTokens,
): void {
$this->assertNotForgotten();
$this->assertUserMayAddSecondFactor($maxNumberOfTokens);
$secondFactor = $sourceIdentity->getVettedSecondFactorById($secondFactorId);
- if (!$secondFactor) {
+ if (!$secondFactor instanceof VettedSecondFactor) {
throw new DomainException("The second factor on the original identity can not be found");
}
$this->assertTokenNotAlreadyRegistered($secondFactor->getType(), $secondFactor->getIdentifier());
@@ -705,8 +701,8 @@ public function migrateVettedSecondFactor(
$secondFactor->vettingType(),
$this->getCommonName(),
$this->getEmail(),
- $this->getPreferredLocale()
- )
+ $this->getPreferredLocale(),
+ ),
);
$this->apply(
@@ -717,19 +713,19 @@ public function migrateVettedSecondFactor(
$secondFactor->getId(),
new SecondFactorId($targetSecondFactorId),
$secondFactor->getType(),
- $secondFactor->getIdentifier()
- )
+ $secondFactor->getIdentifier(),
+ ),
);
}
public function complyWithVettingOfSecondFactor(
- SecondFactorId $secondFactorId,
- SecondFactorType $secondFactorType,
+ SecondFactorId $secondFactorId,
+ SecondFactorType $secondFactorType,
SecondFactorIdentifier $secondFactorIdentifier,
- $registrationCode,
- DocumentNumber $documentNumber,
- $provePossessionSkipped
- ) {
+ string $registrationCode,
+ DocumentNumber $documentNumber,
+ bool $provePossessionSkipped,
+ ): void {
$this->assertNotForgotten();
$secondFactorToVet = null;
@@ -743,7 +739,7 @@ public function complyWithVettingOfSecondFactor(
if (!$secondFactorToVet) {
throw new DomainException(
'Cannot vet second factor, no verified second factor can be vetted using the given registration code ' .
- 'and second factor identifier'
+ 'and second factor identifier',
);
}
@@ -754,7 +750,7 @@ public function complyWithVettingOfSecondFactor(
$secondFactorToVet->vet($provePossessionSkipped, new OnPremiseVettingType($documentNumber));
}
- public function revokeSecondFactor(SecondFactorId $secondFactorId)
+ public function revokeSecondFactor(SecondFactorId $secondFactorId): void
{
$this->assertNotForgotten();
@@ -788,7 +784,7 @@ public function revokeSecondFactor(SecondFactorId $secondFactorId)
}
}
- public function complyWithSecondFactorRevocation(SecondFactorId $secondFactorId, IdentityId $authorityId)
+ public function complyWithSecondFactorRevocation(SecondFactorId $secondFactorId, IdentityId $authorityId): void
{
$this->assertNotForgotten();
@@ -825,9 +821,10 @@ public function complyWithSecondFactorRevocation(SecondFactorId $secondFactorId,
public function revokeRecoveryToken(RecoveryTokenId $recoveryTokenId): void
{
$this->assertNotForgotten();
- $recoveryToken = $this->recoveryTokens->get($recoveryTokenId);
- if (!$recoveryToken) {
- throw new DomainException('Cannot revoke recovery token: no token with given id exists.');
+ try {
+ $recoveryToken = $this->recoveryTokens->get($recoveryTokenId);
+ } catch (DomainException $e) {
+ throw new DomainException('Cannot revoke recovery token: no token with given id exists.', 0, $e);
}
$recoveryToken->revoke();
}
@@ -835,9 +832,10 @@ public function revokeRecoveryToken(RecoveryTokenId $recoveryTokenId): void
public function complyWithRecoveryTokenRevocation(RecoveryTokenId $recoveryTokenId, IdentityId $authorityId): void
{
$this->assertNotForgotten();
- $recoveryToken = $this->recoveryTokens->get($recoveryTokenId);
- if (!$recoveryToken) {
- throw new DomainException('Cannot revoke recovery token: no token with given id exists.');
+ try {
+ $recoveryToken = $this->recoveryTokens->get($recoveryTokenId);
+ } catch (DomainException $e) {
+ throw new DomainException('Cannot revoke recovery token: no token with given id exists.', 0, $e);
}
$recoveryToken->complyWithRevocation($authorityId);
}
@@ -855,17 +853,19 @@ public function accreditWith(
Institution $institution,
Location $location,
ContactInformation $contactInformation,
- InstitutionConfiguration $institutionConfiguration
- ) {
+ InstitutionConfiguration $institutionConfiguration,
+ ): void {
$this->assertNotForgotten();
- if (!$institutionConfiguration->isInstitutionAllowedToAccreditRoles(new ConfigurationInstitution($this->institution->getInstitution()))) {
+ if (!$institutionConfiguration->isInstitutionAllowedToAccreditRoles(
+ new ConfigurationInstitution($this->institution->getInstitution()),
+ )) {
throw new DomainException('An Identity may only be accredited by configured institutions.');
}
if (!$this->vettedSecondFactors->count()) {
throw new DomainException(
- 'An Identity must have at least one vetted second factor before it can be accredited'
+ 'An Identity must have at least one vetted second factor before it can be accredited',
);
}
@@ -874,37 +874,44 @@ public function accreditWith(
}
if ($role->equals(new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA))) {
- $this->apply(new IdentityAccreditedAsRaForInstitutionEvent(
- $this->id,
- $this->nameId,
- $this->institution,
- $role,
- $location,
- $contactInformation,
- $institution
- ));
+ $this->apply(
+ new IdentityAccreditedAsRaForInstitutionEvent(
+ $this->id,
+ $this->nameId,
+ $this->institution,
+ $role,
+ $location,
+ $contactInformation,
+ $institution,
+ ),
+ );
} elseif ($role->equals(new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA))) {
- $this->apply(new IdentityAccreditedAsRaaForInstitutionEvent(
- $this->id,
- $this->nameId,
- $this->institution,
- $role,
- $location,
- $contactInformation,
- $institution
- ));
+ $this->apply(
+ new IdentityAccreditedAsRaaForInstitutionEvent(
+ $this->id,
+ $this->nameId,
+ $this->institution,
+ $role,
+ $location,
+ $contactInformation,
+ $institution,
+ ),
+ );
} else {
throw new DomainException('An Identity can only be accredited with either the RA or RAA role');
}
}
- public function amendRegistrationAuthorityInformation(Institution $institution, Location $location, ContactInformation $contactInformation)
- {
+ public function amendRegistrationAuthorityInformation(
+ Institution $institution,
+ Location $location,
+ ContactInformation $contactInformation,
+ ): void {
$this->assertNotForgotten();
if (!$this->registrationAuthorities->exists($institution)) {
throw new DomainException(
- 'Cannot amend registration authority information: identity is not a registration authority for institution'
+ 'Cannot amend registration authority information: identity is not a registration authority for institution',
);
}
@@ -915,8 +922,8 @@ public function amendRegistrationAuthorityInformation(Institution $institution,
$this->nameId,
$location,
$contactInformation,
- $institution
- )
+ $institution,
+ ),
);
}
@@ -930,13 +937,15 @@ public function amendRegistrationAuthorityInformation(Institution $institution,
public function appointAs(
Institution $institution,
RegistrationAuthorityRole $role,
- InstitutionConfiguration $institutionConfiguration
- ) {
+ InstitutionConfiguration $institutionConfiguration,
+ ): void {
$this->assertNotForgotten();
- if (!$institutionConfiguration->isInstitutionAllowedToAccreditRoles(new ConfigurationInstitution($this->institution->getInstitution()))) {
+ if (!$institutionConfiguration->isInstitutionAllowedToAccreditRoles(
+ new ConfigurationInstitution($this->institution->getInstitution()),
+ )) {
throw new DomainException(
- 'Cannot appoint as different RegistrationAuthorityRole: identity is not a registration authority for institution'
+ 'Cannot appoint as different RegistrationAuthorityRole: identity is not a registration authority for institution',
);
}
@@ -947,35 +956,41 @@ public function appointAs(
}
if ($role->equals(new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA))) {
- $this->apply(new AppointedAsRaForInstitutionEvent($this->id, $this->institution, $this->nameId, $institution));
+ $this->apply(
+ new AppointedAsRaForInstitutionEvent($this->id, $this->institution, $this->nameId, $institution),
+ );
} elseif ($role->equals(new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA))) {
- $this->apply(new AppointedAsRaaForInstitutionEvent($this->id, $this->institution, $this->nameId, $institution));
+ $this->apply(
+ new AppointedAsRaaForInstitutionEvent($this->id, $this->institution, $this->nameId, $institution),
+ );
} else {
throw new DomainException('An Identity can only be appointed as either RA or RAA');
}
}
- public function retractRegistrationAuthority(Institution $institution)
+ public function retractRegistrationAuthority(Institution $institution): void
{
$this->assertNotForgotten();
if (!$this->registrationAuthorities->exists($institution)) {
throw new DomainException(
- 'Cannot Retract Registration Authority as the Identity is not a registration authority'
+ 'Cannot Retract Registration Authority as the Identity is not a registration authority',
);
}
- $this->apply(new RegistrationAuthorityRetractedForInstitutionEvent(
- $this->id,
- $this->institution,
- $this->nameId,
- $this->commonName,
- $this->email,
- $institution
- ));
+ $this->apply(
+ new RegistrationAuthorityRetractedForInstitutionEvent(
+ $this->id,
+ $this->institution,
+ $this->nameId,
+ $this->commonName,
+ $this->email,
+ $institution,
+ ),
+ );
}
- public function expressPreferredLocale(Locale $preferredLocale)
+ public function expressPreferredLocale(Locale $preferredLocale): void
{
$this->assertNotForgotten();
@@ -986,28 +1001,28 @@ public function expressPreferredLocale(Locale $preferredLocale)
$this->apply(new LocalePreferenceExpressedEvent($this->id, $this->institution, $preferredLocale));
}
- public function forget()
+ public function forget(): void
{
$this->assertNotForgotten();
- if ($this->registrationAuthorities->count()) {
+ if ($this->registrationAuthorities->count() !== 0) {
throw new DomainException('Cannot forget an identity that is currently accredited as an RA(A)');
}
$this->apply(new IdentityForgottenEvent($this->id, $this->institution));
}
- public function allVettedSecondFactorsRemoved()
+ public function allVettedSecondFactorsRemoved(): void
{
$this->apply(
new VettedSecondFactorsAllRevokedEvent(
$this->id,
- $this->institution
- )
+ $this->institution,
+ ),
);
}
- protected function applyIdentityCreatedEvent(IdentityCreatedEvent $event)
+ protected function applyIdentityCreatedEvent(IdentityCreatedEvent $event): void
{
$this->id = $event->identityId;
$this->institution = $event->identityInstitution;
@@ -1024,30 +1039,30 @@ protected function applyIdentityCreatedEvent(IdentityCreatedEvent $event)
$this->recoveryTokens = new RecoveryTokenCollection();
}
- public function applyIdentityRenamedEvent(IdentityRenamedEvent $event)
+ public function applyIdentityRenamedEvent(IdentityRenamedEvent $event): void
{
$this->commonName = $event->commonName;
}
- public function applyIdentityEmailChangedEvent(IdentityEmailChangedEvent $event)
+ public function applyIdentityEmailChangedEvent(IdentityEmailChangedEvent $event): void
{
$this->email = $event->email;
}
- protected function applyYubikeySecondFactorBootstrappedEvent(YubikeySecondFactorBootstrappedEvent $event)
+ protected function applyYubikeySecondFactorBootstrappedEvent(YubikeySecondFactorBootstrappedEvent $event): void
{
$secondFactor = VettedSecondFactor::create(
$event->secondFactorId,
$this,
new SecondFactorType('yubikey'),
$event->yubikeyPublicId,
- new UnknownVettingType()
+ new UnknownVettingType(),
);
$this->vettedSecondFactors->set((string)$secondFactor->getId(), $secondFactor);
}
- protected function applyYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $event)
+ protected function applyYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $event): void
{
$secondFactor = UnverifiedSecondFactor::create(
$event->secondFactorId,
@@ -1055,13 +1070,13 @@ protected function applyYubikeyPossessionProvenEvent(YubikeyPossessionProvenEven
new SecondFactorType('yubikey'),
$event->yubikeyPublicId,
$event->emailVerificationWindow,
- $event->emailVerificationNonce
+ $event->emailVerificationNonce,
);
$this->unverifiedSecondFactors->set((string)$secondFactor->getId(), $secondFactor);
}
- protected function applyYubikeyPossessionProvenAndVerifiedEvent(YubikeyPossessionProvenAndVerifiedEvent $event)
+ protected function applyYubikeyPossessionProvenAndVerifiedEvent(YubikeyPossessionProvenAndVerifiedEvent $event): void
{
$secondFactor = VerifiedSecondFactor::create(
$event->secondFactorId,
@@ -1069,13 +1084,13 @@ protected function applyYubikeyPossessionProvenAndVerifiedEvent(YubikeyPossessio
new SecondFactorType('yubikey'),
$event->yubikeyPublicId,
$event->registrationRequestedAt,
- $event->registrationCode
+ $event->registrationCode,
);
$this->verifiedSecondFactors->set((string)$secondFactor->getId(), $secondFactor);
}
- protected function applyPhonePossessionProvenEvent(PhonePossessionProvenEvent $event)
+ protected function applyPhonePossessionProvenEvent(PhonePossessionProvenEvent $event): void
{
$secondFactor = UnverifiedSecondFactor::create(
$event->secondFactorId,
@@ -1083,13 +1098,13 @@ protected function applyPhonePossessionProvenEvent(PhonePossessionProvenEvent $e
new SecondFactorType('sms'),
$event->phoneNumber,
$event->emailVerificationWindow,
- $event->emailVerificationNonce
+ $event->emailVerificationNonce,
);
$this->unverifiedSecondFactors->set((string)$secondFactor->getId(), $secondFactor);
}
- protected function applyPhonePossessionProvenAndVerifiedEvent(PhonePossessionProvenAndVerifiedEvent $event)
+ protected function applyPhonePossessionProvenAndVerifiedEvent(PhonePossessionProvenAndVerifiedEvent $event): void
{
$secondFactor = VerifiedSecondFactor::create(
$event->secondFactorId,
@@ -1097,13 +1112,13 @@ protected function applyPhonePossessionProvenAndVerifiedEvent(PhonePossessionPro
new SecondFactorType('sms'),
$event->phoneNumber,
$event->registrationRequestedAt,
- $event->registrationCode
+ $event->registrationCode,
);
$this->verifiedSecondFactors->set((string)$secondFactor->getId(), $secondFactor);
}
- protected function applyGssfPossessionProvenEvent(GssfPossessionProvenEvent $event)
+ protected function applyGssfPossessionProvenEvent(GssfPossessionProvenEvent $event): void
{
$secondFactor = UnverifiedSecondFactor::create(
$event->secondFactorId,
@@ -1111,13 +1126,13 @@ protected function applyGssfPossessionProvenEvent(GssfPossessionProvenEvent $eve
new SecondFactorType((string)$event->stepupProvider),
$event->gssfId,
$event->emailVerificationWindow,
- $event->emailVerificationNonce
+ $event->emailVerificationNonce,
);
$this->unverifiedSecondFactors->set((string)$secondFactor->getId(), $secondFactor);
}
- protected function applyGssfPossessionProvenAndVerifiedEvent(GssfPossessionProvenAndVerifiedEvent $event)
+ protected function applyGssfPossessionProvenAndVerifiedEvent(GssfPossessionProvenAndVerifiedEvent $event): void
{
$secondFactor = VerifiedSecondFactor::create(
$event->secondFactorId,
@@ -1125,13 +1140,13 @@ protected function applyGssfPossessionProvenAndVerifiedEvent(GssfPossessionProve
new SecondFactorType((string)$event->stepupProvider),
$event->gssfId,
$event->registrationRequestedAt,
- $event->registrationCode
+ $event->registrationCode,
);
$this->verifiedSecondFactors->set((string)$secondFactor->getId(), $secondFactor);
}
- protected function applyU2fDevicePossessionProvenEvent(U2fDevicePossessionProvenEvent $event)
+ protected function applyU2fDevicePossessionProvenEvent(U2fDevicePossessionProvenEvent $event): void
{
$secondFactor = UnverifiedSecondFactor::create(
$event->secondFactorId,
@@ -1139,13 +1154,13 @@ protected function applyU2fDevicePossessionProvenEvent(U2fDevicePossessionProven
new SecondFactorType('u2f'),
$event->keyHandle,
$event->emailVerificationWindow,
- $event->emailVerificationNonce
+ $event->emailVerificationNonce,
);
$this->unverifiedSecondFactors->set((string)$secondFactor->getId(), $secondFactor);
}
- protected function applyU2fDevicePossessionProvenAndVerifiedEvent(U2fDevicePossessionProvenAndVerifiedEvent $event)
+ protected function applyU2fDevicePossessionProvenAndVerifiedEvent(U2fDevicePossessionProvenAndVerifiedEvent $event): void
{
$secondFactor = VerifiedSecondFactor::create(
$event->secondFactorId,
@@ -1153,27 +1168,28 @@ protected function applyU2fDevicePossessionProvenAndVerifiedEvent(U2fDevicePosse
new SecondFactorType('u2f'),
$event->keyHandle,
$event->registrationRequestedAt,
- $event->registrationCode
+ $event->registrationCode,
);
$this->verifiedSecondFactors->set((string)$secondFactor->getId(), $secondFactor);
}
- protected function applyPhoneRecoveryTokenPossessionProvenEvent(PhoneRecoveryTokenPossessionProvenEvent $event)
+ protected function applyPhoneRecoveryTokenPossessionProvenEvent(PhoneRecoveryTokenPossessionProvenEvent $event): void
{
$recoveryToken = RecoveryTokenEntity::create($event->recoveryTokenId, RecoveryTokenType::sms(), $this);
$this->recoveryTokens->set($recoveryToken);
}
- protected function applySafeStoreSecretRecoveryTokenPossessionPromisedEvent(SafeStoreSecretRecoveryTokenPossessionPromisedEvent $event)
- {
+ protected function applySafeStoreSecretRecoveryTokenPossessionPromisedEvent(
+ SafeStoreSecretRecoveryTokenPossessionPromisedEvent $event,
+ ): void {
$recoveryToken = RecoveryTokenEntity::create($event->recoveryTokenId, RecoveryTokenType::safeStore(), $this);
$this->recoveryTokens->set($recoveryToken);
}
- protected function applyEmailVerifiedEvent(EmailVerifiedEvent $event)
+ protected function applyEmailVerifiedEvent(EmailVerifiedEvent $event): void
{
$secondFactorId = (string)$event->secondFactorId;
@@ -1190,7 +1206,7 @@ protected function applyEmailVerifiedEvent(EmailVerifiedEvent $event)
* vetted second factor on the target identity. The source
* second factor is not yet forgotten.
*/
- public function applySecondFactorMigratedEvent(SecondFactorMigratedEvent $event)
+ public function applySecondFactorMigratedEvent(SecondFactorMigratedEvent $event): void
{
$secondFactorId = (string)$event->newSecondFactorId;
$vetted = VettedSecondFactor::create(
@@ -1198,12 +1214,12 @@ public function applySecondFactorMigratedEvent(SecondFactorMigratedEvent $event)
$this,
$event->secondFactorType,
$event->secondFactorIdentifier,
- $event->vettingType
+ $event->vettingType,
);
$this->vettedSecondFactors->set($secondFactorId, $vetted);
}
- protected function applySecondFactorVettedEvent(SecondFactorVettedEvent $event)
+ protected function applySecondFactorVettedEvent(SecondFactorVettedEvent $event): void
{
$secondFactorId = (string)$event->secondFactorId;
$verified = $this->verifiedSecondFactors->get($secondFactorId);
@@ -1212,8 +1228,9 @@ protected function applySecondFactorVettedEvent(SecondFactorVettedEvent $event)
$this->vettedSecondFactors->set($secondFactorId, $vetted);
}
- protected function applySecondFactorVettedWithoutTokenProofOfPossession(SecondFactorVettedWithoutTokenProofOfPossession $event)
- {
+ protected function applySecondFactorVettedWithoutTokenProofOfPossession(
+ SecondFactorVettedWithoutTokenProofOfPossession $event,
+ ): void {
$secondFactorId = (string)$event->secondFactorId;
/** @var VerifiedSecondFactor $verified */
@@ -1224,91 +1241,103 @@ protected function applySecondFactorVettedWithoutTokenProofOfPossession(SecondFa
$this->vettedSecondFactors->set($secondFactorId, $vetted);
}
- protected function applyUnverifiedSecondFactorRevokedEvent(UnverifiedSecondFactorRevokedEvent $event)
+ protected function applyUnverifiedSecondFactorRevokedEvent(UnverifiedSecondFactorRevokedEvent $event): void
{
$this->unverifiedSecondFactors->remove((string)$event->secondFactorId);
}
protected function applyCompliedWithUnverifiedSecondFactorRevocationEvent(
- CompliedWithUnverifiedSecondFactorRevocationEvent $event
- ) {
+ CompliedWithUnverifiedSecondFactorRevocationEvent $event,
+ ): void {
$this->unverifiedSecondFactors->remove((string)$event->secondFactorId);
}
- protected function applyVerifiedSecondFactorRevokedEvent(VerifiedSecondFactorRevokedEvent $event)
+ protected function applyVerifiedSecondFactorRevokedEvent(VerifiedSecondFactorRevokedEvent $event): void
{
$this->verifiedSecondFactors->remove((string)$event->secondFactorId);
}
protected function applyCompliedWithVerifiedSecondFactorRevocationEvent(
- CompliedWithVerifiedSecondFactorRevocationEvent $event
- ) {
+ CompliedWithVerifiedSecondFactorRevocationEvent $event,
+ ): void {
$this->verifiedSecondFactors->remove((string)$event->secondFactorId);
}
- protected function applyVettedSecondFactorRevokedEvent(VettedSecondFactorRevokedEvent $event)
+ protected function applyVettedSecondFactorRevokedEvent(VettedSecondFactorRevokedEvent $event): void
{
$this->vettedSecondFactors->remove((string)$event->secondFactorId);
}
protected function applyCompliedWithVettedSecondFactorRevocationEvent(
- CompliedWithVettedSecondFactorRevocationEvent $event
- ) {
+ CompliedWithVettedSecondFactorRevocationEvent $event,
+ ): void {
$this->vettedSecondFactors->remove((string)$event->secondFactorId);
}
- protected function applyCompliedWithRecoveryCodeRevocationEvent(CompliedWithRecoveryCodeRevocationEvent $event)
+ protected function applyCompliedWithRecoveryCodeRevocationEvent(CompliedWithRecoveryCodeRevocationEvent $event): void
{
$this->recoveryTokens->remove($event->recoveryTokenId);
}
- protected function applyRecoveryTokenRevokedEvent(RecoveryTokenRevokedEvent $event)
+ protected function applyRecoveryTokenRevokedEvent(RecoveryTokenRevokedEvent $event): void
{
$this->recoveryTokens->remove($event->recoveryTokenId);
}
- protected function applyIdentityAccreditedAsRaForInstitutionEvent(IdentityAccreditedAsRaForInstitutionEvent $event)
+ protected function applyIdentityAccreditedAsRaForInstitutionEvent(IdentityAccreditedAsRaForInstitutionEvent $event): void
{
- $this->registrationAuthorities->set($event->raInstitution, RegistrationAuthority::accreditWith(
- $event->registrationAuthorityRole,
- $event->location,
- $event->contactInformation,
- $event->raInstitution
- ));
+ $this->registrationAuthorities->set(
+ $event->raInstitution,
+ RegistrationAuthority::accreditWith(
+ $event->registrationAuthorityRole,
+ $event->location,
+ $event->contactInformation,
+ $event->raInstitution,
+ ),
+ );
}
- protected function applyIdentityAccreditedAsRaaForInstitutionEvent(IdentityAccreditedAsRaaForInstitutionEvent $event)
+ protected function applyIdentityAccreditedAsRaaForInstitutionEvent(IdentityAccreditedAsRaaForInstitutionEvent $event,): void
{
- $this->registrationAuthorities->set($event->raInstitution, RegistrationAuthority::accreditWith(
- $event->registrationAuthorityRole,
- $event->location,
- $event->contactInformation,
- $event->raInstitution
- ));
+ $this->registrationAuthorities->set(
+ $event->raInstitution,
+ RegistrationAuthority::accreditWith(
+ $event->registrationAuthorityRole,
+ $event->location,
+ $event->contactInformation,
+ $event->raInstitution,
+ ),
+ );
}
protected function applyRegistrationAuthorityInformationAmendedForInstitutionEvent(
- RegistrationAuthorityInformationAmendedForInstitutionEvent $event
- ) {
- $this->registrationAuthorities->get($event->raInstitution)->amendInformation($event->location, $event->contactInformation);
+ RegistrationAuthorityInformationAmendedForInstitutionEvent $event,
+ ): void {
+ $this->registrationAuthorities->get($event->raInstitution)->amendInformation(
+ $event->location,
+ $event->contactInformation,
+ );
}
- protected function applyAppointedAsRaaForInstitutionEvent(AppointedAsRaaForInstitutionEvent $event)
+ protected function applyAppointedAsRaaForInstitutionEvent(AppointedAsRaaForInstitutionEvent $event): void
{
- $this->registrationAuthorities->get($event->raInstitution)->appointAs(new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA));
+ $this->registrationAuthorities->get($event->raInstitution)->appointAs(
+ new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA),
+ );
}
- protected function applyRegistrationAuthorityRetractedForInstitutionEvent(RegistrationAuthorityRetractedForInstitutionEvent $event)
- {
+ protected function applyRegistrationAuthorityRetractedForInstitutionEvent(
+ RegistrationAuthorityRetractedForInstitutionEvent $event,
+ ): void {
$this->registrationAuthorities->remove($event->raInstitution);
}
- protected function applyLocalePreferenceExpressedEvent(LocalePreferenceExpressedEvent $event)
+ protected function applyLocalePreferenceExpressedEvent(LocalePreferenceExpressedEvent $event): void
{
$this->preferredLocale = $event->preferredLocale;
}
- protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
+ protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
$this->commonName = CommonName::unknown();
$this->email = Email::unknown();
@@ -1317,10 +1346,8 @@ protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
/**
* This method is kept to be backwards compatible for changes before FGA
- *
- * @param AppointedAsRaEvent $event
*/
- protected function applyAppointedAsRaEvent(AppointedAsRaEvent $event)
+ protected function applyAppointedAsRaEvent(AppointedAsRaEvent $event): void
{
$this->registrationAuthorities->get($event->identityInstitution)
->appointAs(new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA));
@@ -1328,10 +1355,8 @@ protected function applyAppointedAsRaEvent(AppointedAsRaEvent $event)
/**
* This method is kept to be backwards compatible for changes before FGA
- *
- * @param AppointedAsRaaEvent $event
*/
- protected function applyAppointedAsRaaEvent(AppointedAsRaaEvent $event)
+ protected function applyAppointedAsRaaEvent(AppointedAsRaaEvent $event): void
{
$this->registrationAuthorities->get($event->identityInstitution)
->appointAs(new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA));
@@ -1339,40 +1364,40 @@ protected function applyAppointedAsRaaEvent(AppointedAsRaaEvent $event)
/**
* This method is kept to be backwards compatible for changes before FGA
- *
- * @param AppointedAsRaaEvent $event
*/
- protected function applyIdentityAccreditedAsRaEvent(IdentityAccreditedAsRaEvent $event)
- {
- $this->registrationAuthorities->set($event->identityInstitution, RegistrationAuthority::accreditWith(
- $event->registrationAuthorityRole,
- $event->location,
- $event->contactInformation,
- $event->identityInstitution
- ));
+ protected function applyIdentityAccreditedAsRaEvent(IdentityAccreditedAsRaEvent $event): void
+ {
+ $this->registrationAuthorities->set(
+ $event->identityInstitution,
+ RegistrationAuthority::accreditWith(
+ $event->registrationAuthorityRole,
+ $event->location,
+ $event->contactInformation,
+ $event->identityInstitution,
+ ),
+ );
}
/**
* This method is kept to be backwards compatible for changes before FGA
- *
- * @param IdentityAccreditedAsRaaEvent $event
*/
- protected function applyIdentityAccreditedAsRaaEvent(IdentityAccreditedAsRaaEvent $event)
- {
- $this->registrationAuthorities->set($event->identityInstitution, RegistrationAuthority::accreditWith(
- $event->registrationAuthorityRole,
- $event->location,
- $event->contactInformation,
- $event->identityInstitution
- ));
+ protected function applyIdentityAccreditedAsRaaEvent(IdentityAccreditedAsRaaEvent $event): void
+ {
+ $this->registrationAuthorities->set(
+ $event->identityInstitution,
+ RegistrationAuthority::accreditWith(
+ $event->registrationAuthorityRole,
+ $event->location,
+ $event->contactInformation,
+ $event->identityInstitution,
+ ),
+ );
}
/**
* This method is kept to be backwards compatible for changes before FGA
- *
- * @param AppointedAsRaForInstitutionEvent $event
*/
- protected function applyAppointedAsRaForInstitutionEvent(AppointedAsRaForInstitutionEvent $event)
+ protected function applyAppointedAsRaForInstitutionEvent(AppointedAsRaForInstitutionEvent $event): void
{
$this->registrationAuthorities->get($event->identityInstitution)
->appointAs(new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA));
@@ -1380,21 +1405,20 @@ protected function applyAppointedAsRaForInstitutionEvent(AppointedAsRaForInstitu
/**
* This method is kept to be backwards compatible for changes before FGA
- *
- * @param RegistrationAuthorityInformationAmendedEvent $event
*/
protected function applyRegistrationAuthorityInformationAmendedEvent(
- RegistrationAuthorityInformationAmendedEvent $event
- ) {
- $this->registrationAuthorities->get($event->identityInstitution)->amendInformation($event->location, $event->contactInformation);
+ RegistrationAuthorityInformationAmendedEvent $event,
+ ): void {
+ $this->registrationAuthorities->get($event->identityInstitution)->amendInformation(
+ $event->location,
+ $event->contactInformation,
+ );
}
/**
* This method is kept to be backwards compatible for changes before FGA
- *
- * @param RegistrationAuthorityRetractedEvent $event
*/
- protected function applyRegistrationAuthorityRetractedEvent(RegistrationAuthorityRetractedEvent $event)
+ protected function applyRegistrationAuthorityRetractedEvent(RegistrationAuthorityRetractedEvent $event): void
{
$this->registrationAuthorities->remove($event->identityInstitution);
}
@@ -1411,14 +1435,14 @@ protected function getChildEntities(): array
$this->unverifiedSecondFactors->getValues(),
$this->verifiedSecondFactors->getValues(),
$this->vettedSecondFactors->getValues(),
- $this->registrationAuthorities->getValues()
+ $this->registrationAuthorities->getValues(),
);
}
/**
* @throws DomainException
*/
- private function assertNotForgotten()
+ private function assertNotForgotten(): void
{
if ($this->forgotten) {
throw new DomainException('Operation on this Identity is not allowed: it has been forgotten');
@@ -1428,27 +1452,29 @@ private function assertNotForgotten()
/**
* @throws DomainException
*/
- private function assertUserMayAddSecondFactor($maxNumberOfTokens)
+ private function assertUserMayAddSecondFactor(int $maxNumberOfTokens): void
{
if (count($this->unverifiedSecondFactors) +
count($this->verifiedSecondFactors) +
count($this->vettedSecondFactors) >= $maxNumberOfTokens
) {
throw new DomainException(
- sprintf('User may not have more than %d token(s)', $maxNumberOfTokens)
+ sprintf('User may not have more than %d token(s)', $maxNumberOfTokens),
);
}
}
- private function assertUserMayAddRecoveryToken(RecoveryTokenType $recoveryTokenType)
+ private function assertUserMayAddRecoveryToken(RecoveryTokenType $recoveryTokenType): void
{
// Assert this token type is not yet registered
if ($this->recoveryTokens->hasType($recoveryTokenType)) {
- throw new DomainException(sprintf('Recovery token type %s is already registered', (string) $recoveryTokenType));
+ throw new DomainException(
+ sprintf('Recovery token type %s is already registered', (string)$recoveryTokenType),
+ );
}
}
- public function getId()
+ public function getId(): IdentityId
{
return $this->id;
}
@@ -1456,7 +1482,7 @@ public function getId()
/**
* @return NameId
*/
- public function getNameId()
+ public function getNameId(): NameId
{
return $this->nameId;
}
@@ -1464,22 +1490,22 @@ public function getNameId()
/**
* @return Institution
*/
- public function getInstitution()
+ public function getInstitution(): Institution
{
return $this->institution;
}
- public function getCommonName()
+ public function getCommonName(): CommonName
{
return $this->commonName;
}
- public function getEmail()
+ public function getEmail(): Email
{
return $this->email;
}
- public function getPreferredLocale()
+ public function getPreferredLocale(): Locale
{
return $this->preferredLocale;
}
@@ -1494,7 +1520,7 @@ public function getVettedSecondFactorById(SecondFactorId $secondFactorId): ?Vett
return $this->vettedSecondFactors->get((string)$secondFactorId);
}
- private function assertTokenNotAlreadyRegistered(SecondFactorType $type, SecondFactorIdentifier $identifier)
+ private function assertTokenNotAlreadyRegistered(SecondFactorType $type, SecondFactorIdentifier $identifier): void
{
foreach ($this->unverifiedSecondFactors as $unverified) {
if ($unverified->typeAndIdentifierAreEqual($type, $identifier)) {
@@ -1513,10 +1539,12 @@ private function assertTokenNotAlreadyRegistered(SecondFactorType $type, SecondF
}
}
- private function assertSelfAssertedTokenRegistrationAllowed()
+ private function assertSelfAssertedTokenRegistrationAllowed(): void
{
if ($this->vettedSecondFactors->count() !== 0) {
- throw new DomainException("Self-asserted second factor registration is only allowed when no tokens are vetted yet");
+ throw new DomainException(
+ "Self-asserted second factor registration is only allowed when no tokens are vetted yet",
+ );
}
if ($this->recoveryTokens->count() === 0) {
throw new DomainException("A recovery token is required to perform a self-asserted token registration");
@@ -1526,16 +1554,15 @@ private function assertSelfAssertedTokenRegistrationAllowed()
/**
* Verify that every vetted second factor is self-asserted
*/
- private function assertAllVettedTokensAreSelfAsserted()
+ private function assertAllVettedTokensAreSelfAsserted(): void
{
- /** @var VettedSecondFactor $vettedToken */
+ /** @var VettedSecondFactor $vettedSecondFactor */
foreach ($this->vettedSecondFactors as $vettedSecondFactor) {
if ($vettedSecondFactor->vettingType()->type() !== VettingType::TYPE_SELF_ASSERTED_REGISTRATION) {
throw new DomainException(
- 'Not all tokens are self-asserted, it is not allowed to self-vet using the self-asserted token'
+ 'Not all tokens are self-asserted, it is not allowed to self-vet using the self-asserted token',
);
}
}
- return true;
}
}
diff --git a/src/Surfnet/Stepup/Identity/Value/CommonName.php b/src/Surfnet/Stepup/Identity/Value/CommonName.php
index 590280412..bb0c46a77 100644
--- a/src/Surfnet/Stepup/Identity/Value/CommonName.php
+++ b/src/Surfnet/Stepup/Identity/Value/CommonName.php
@@ -1,5 +1,7 @@
commonName;
}
- public function __toString()
+ public function __toString(): string
{
return $this->commonName;
}
- public function equals(CommonName $other)
+ public function equals(CommonName $other): bool
{
return $this->commonName === $other->commonName;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->commonName;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/ContactInformation.php b/src/Surfnet/Stepup/Identity/Value/ContactInformation.php
index 3435393d9..33906678d 100644
--- a/src/Surfnet/Stepup/Identity/Value/ContactInformation.php
+++ b/src/Surfnet/Stepup/Identity/Value/ContactInformation.php
@@ -1,5 +1,7 @@
contactInformation = trim($contactInformation);
}
- /**
- * @param ContactInformation $otherContactInformation
- * @return bool
- */
- public function equals(ContactInformation $otherContactInformation)
+ public function equals(ContactInformation $otherContactInformation): bool
{
return $this->contactInformation === $otherContactInformation->contactInformation;
}
@@ -52,17 +41,17 @@ public function equals(ContactInformation $otherContactInformation)
/**
* @return string
*/
- public function getContactInformation()
+ public function getContactInformation(): string
{
return $this->contactInformation;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->contactInformation;
}
- public function __toString()
+ public function __toString(): string
{
return $this->contactInformation;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/DocumentNumber.php b/src/Surfnet/Stepup/Identity/Value/DocumentNumber.php
index 90d558143..178e2dd11 100644
--- a/src/Surfnet/Stepup/Identity/Value/DocumentNumber.php
+++ b/src/Surfnet/Stepup/Identity/Value/DocumentNumber.php
@@ -1,5 +1,7 @@
documentNumber;
}
- public function __toString()
+ public function __toString(): string
{
return $this->documentNumber;
}
- public function equals(DocumentNumber $other)
+ public function equals(DocumentNumber $other): bool
{
return $this->documentNumber === $other->documentNumber;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->documentNumber;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/Email.php b/src/Surfnet/Stepup/Identity/Value/Email.php
index 5f9736431..ab9930f29 100644
--- a/src/Surfnet/Stepup/Identity/Value/Email.php
+++ b/src/Surfnet/Stepup/Identity/Value/Email.php
@@ -1,5 +1,7 @@
email = trim($email);
@@ -58,22 +57,22 @@ public function __construct($email)
/**
* @return string
*/
- public function getEmail()
+ public function getEmail(): string
{
return $this->email;
}
- public function __toString()
+ public function __toString(): string
{
return $this->email;
}
- public function equals(Email $other)
+ public function equals(Email $other): bool
{
return $this->email === $other->email;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->email;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/EmailVerificationWindow.php b/src/Surfnet/Stepup/Identity/Value/EmailVerificationWindow.php
index 1192a7ae3..4614b589a 100644
--- a/src/Surfnet/Stepup/Identity/Value/EmailVerificationWindow.php
+++ b/src/Surfnet/Stepup/Identity/Value/EmailVerificationWindow.php
@@ -19,51 +19,34 @@
namespace Surfnet\Stepup\Identity\Value;
use Broadway\Serializer\Serializable as SerializableInterface;
+use Stringable;
use Surfnet\Stepup\DateTime\DateTime;
use Surfnet\Stepup\Exception\InvalidArgumentException;
-final class EmailVerificationWindow implements SerializableInterface
+final readonly class EmailVerificationWindow implements SerializableInterface, Stringable
{
- /**
- * @var DateTime
- */
- private $start;
-
- /**
- * @var DateTime
- */
- private $end;
-
- private function __construct(DateTime $start, DateTime $end)
- {
- $this->start = $start;
- $this->end = $end;
+ private function __construct(
+ private DateTime $start,
+ private DateTime $end,
+ ) {
}
- /**
- * @param TimeFrame $timeFrame
- * @param DateTime $start
- * @return EmailVerificationWindow
- */
- public static function createFromTimeFrameStartingAt(TimeFrame $timeFrame, DateTime $start)
+ public static function createFromTimeFrameStartingAt(TimeFrame $timeFrame, DateTime $start): EmailVerificationWindow
{
return new EmailVerificationWindow($start, $timeFrame->getEndWhenStartingAt($start));
}
- /**
- * @param DateTime $start
- * @param DateTime $end
- * @return EmailVerificationWindow
- */
- public static function createWindowFromTill(DateTime $start, DateTime $end)
+ public static function createWindowFromTill(DateTime $start, DateTime $end): EmailVerificationWindow
{
if (!$end->comesAfter($start)) {
- throw new InvalidArgumentException(sprintf(
- 'An EmailVerificationWindow can only be created with an end time that is after the start time, '
- . 'given start: "%s", given end: "%s"',
- (string) $start,
- (string) $end
- ));
+ throw new InvalidArgumentException(
+ sprintf(
+ 'An EmailVerificationWindow can only be created with an end time that is after the start time, '
+ . 'given start: "%s", given end: "%s"',
+ (string)$start,
+ (string)$end,
+ ),
+ );
}
return new EmailVerificationWindow($start, $end);
@@ -72,7 +55,7 @@ public static function createWindowFromTill(DateTime $start, DateTime $end)
/**
* @return bool
*/
- public function isOpen()
+ public function isOpen(): bool
{
$now = DateTime::now();
@@ -82,34 +65,30 @@ public function isOpen()
/**
* @return DateTime
*/
- public function openUntil()
+ public function openUntil(): DateTime
{
return $this->end;
}
- /**
- * @param EmailVerificationWindow $other
- * @return bool
- */
- public function equals(EmailVerificationWindow $other)
+ public function equals(EmailVerificationWindow $other): bool
{
return $this->start == $other->start && $this->end == $other->end;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new EmailVerificationWindow(
DateTime::fromString($data['start']),
- DateTime::fromString($data['end'])
+ DateTime::fromString($data['end']),
);
}
public function serialize(): array
{
- return ['start' => (string) $this->start, 'end' => (string) $this->end];
+ return ['start' => (string)$this->start, 'end' => (string)$this->end];
}
- public function __toString()
+ public function __toString(): string
{
return $this->start . '-' . $this->end;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/GssfId.php b/src/Surfnet/Stepup/Identity/Value/GssfId.php
index 041cead61..7a403d0c6 100644
--- a/src/Surfnet/Stepup/Identity/Value/GssfId.php
+++ b/src/Surfnet/Stepup/Identity/Value/GssfId.php
@@ -22,41 +22,38 @@
final class GssfId implements SecondFactorIdentifier
{
- /**
- * @var string
- */
- private $gssfId;
+ private readonly string $gssfId;
- public static function unknown()
+ public static function unknown(): static
{
return new self('—');
}
- public function __construct($gssfId)
+ public function __construct(string $gssfId)
{
- if (!is_string($gssfId) || trim($gssfId) === '') {
+ if (trim($gssfId) === '') {
throw InvalidArgumentException::invalidType('non-empty string', 'gssfId', $gssfId);
}
$this->gssfId = trim($gssfId);
}
- public function getValue()
+ public function getValue(): string
{
return $this->gssfId;
}
- public function __toString()
+ public function __toString(): string
{
return $this->gssfId;
}
- public function equals($other): bool
+ public function equals(SecondFactorIdentifier $other): bool
{
return $other instanceof self && $this->gssfId === $other->gssfId;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->gssfId;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/HashedSecret.php b/src/Surfnet/Stepup/Identity/Value/HashedSecret.php
index 80117c07f..722dc54b1 100644
--- a/src/Surfnet/Stepup/Identity/Value/HashedSecret.php
+++ b/src/Surfnet/Stepup/Identity/Value/HashedSecret.php
@@ -23,11 +23,9 @@
*/
class HashedSecret implements Secret
{
- private $secret;
-
- public function __construct(string $secret)
- {
- $this->secret = $secret;
+ public function __construct(
+ private readonly string $secret,
+ ) {
}
public function getSecret(): string
diff --git a/src/Surfnet/Stepup/Identity/Value/IdentityId.php b/src/Surfnet/Stepup/Identity/Value/IdentityId.php
index dc6b0a81a..068c45344 100644
--- a/src/Surfnet/Stepup/Identity/Value/IdentityId.php
+++ b/src/Surfnet/Stepup/Identity/Value/IdentityId.php
@@ -24,39 +24,32 @@
final class IdentityId implements Id, JsonSerializable
{
- /**
- * @var string
- */
- private $value;
+ private readonly string $value;
- public function __construct($value)
+ public function __construct(string $value)
{
- if (!is_string($value)) {
- throw InvalidArgumentException::invalidType('string', 'value', $value);
- }
-
$this->value = $value;
}
/**
* @return string
*/
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->value;
}
- public function equals(Id $other)
+ public function equals(Id $other): bool
{
return $this == $other;
}
- public function __toString()
+ public function __toString(): string
{
return $this->value;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->value;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/Institution.php b/src/Surfnet/Stepup/Identity/Value/Institution.php
index f7550f7a5..d85786d1f 100644
--- a/src/Surfnet/Stepup/Identity/Value/Institution.php
+++ b/src/Surfnet/Stepup/Identity/Value/Institution.php
@@ -1,5 +1,7 @@
institution;
}
- /**
- * @param Institution $otherInstitution
- * @return bool
- */
- public function equals(Institution $otherInstitution)
+ public function equals(Institution $otherInstitution): bool
{
return $this->institution === $otherInstitution->institution;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->institution;
}
- public function __toString()
+ public function __toString(): string
{
return $this->institution;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/Locale.php b/src/Surfnet/Stepup/Identity/Value/Locale.php
index 0af09cfb9..349dc60f2 100644
--- a/src/Surfnet/Stepup/Identity/Value/Locale.php
+++ b/src/Surfnet/Stepup/Identity/Value/Locale.php
@@ -19,32 +19,16 @@
namespace Surfnet\Stepup\Identity\Value;
use JsonSerializable;
+use Stringable;
use Surfnet\Stepup\Exception\InvalidArgumentException;
-final class Locale implements JsonSerializable
+final readonly class Locale implements JsonSerializable, Stringable
{
- /**
- * @var string
- */
- private $locale;
-
- /**
- * @param string $locale
- */
- public function __construct($locale)
+ public function __construct(private string $locale)
{
- if (!is_string($locale)) {
- throw InvalidArgumentException::invalidType('string', 'locale', $locale);
- }
-
- $this->locale = $locale;
}
- /**
- * @param self $other
- * @return bool
- */
- public function equals(Locale $other)
+ public function equals(Locale $other): bool
{
return $this == $other;
}
@@ -52,12 +36,12 @@ public function equals(Locale $other)
/**
* @return string
*/
- public function getLocale()
+ public function getLocale(): string
{
return $this->locale;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->locale;
}
@@ -65,7 +49,7 @@ public function jsonSerialize()
/**
* @return string
*/
- public function __toString()
+ public function __toString(): string
{
return $this->locale;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/Location.php b/src/Surfnet/Stepup/Identity/Value/Location.php
index 048c03804..97540db66 100644
--- a/src/Surfnet/Stepup/Identity/Value/Location.php
+++ b/src/Surfnet/Stepup/Identity/Value/Location.php
@@ -1,5 +1,7 @@
location = trim($location);
}
- /**
- * @param Location $otherLocation
- * @return bool
- */
- public function equals(Location $otherLocation)
+ public function equals(Location $otherLocation): bool
{
return $this->location === $otherLocation->location;
}
@@ -52,17 +41,17 @@ public function equals(Location $otherLocation)
/**
* @return string
*/
- public function getLocation()
+ public function getLocation(): string
{
return $this->location;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->location;
}
- public function __toString()
+ public function __toString(): string
{
return $this->location;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/NameId.php b/src/Surfnet/Stepup/Identity/Value/NameId.php
index 505ef0372..f1bb3a28f 100644
--- a/src/Surfnet/Stepup/Identity/Value/NameId.php
+++ b/src/Surfnet/Stepup/Identity/Value/NameId.php
@@ -19,12 +19,13 @@
namespace Surfnet\Stepup\Identity\Value;
use JsonSerializable;
+use Stringable;
use Surfnet\Stepup\Exception\InvalidArgumentException;
/**
* The natural identifier of an Identity is the SAML Name ID.
*/
-final class NameId implements JsonSerializable
+final class NameId implements JsonSerializable, Stringable
{
/**
* This length reflects the maximum length supported by the data store for the
@@ -34,20 +35,19 @@ final class NameId implements JsonSerializable
*/
private const MAX_LENGTH = 255;
- /**
- * @var string
- */
- private $value;
+ private readonly string $value;
- public function __construct($value)
+ public function __construct(string $value)
{
- if (!is_string($value)) {
- throw InvalidArgumentException::invalidType('string', 'value', $value);
+ if (strlen($value) === 0) {
+ throw new InvalidArgumentException(
+ 'Invalid argument type: nameId is empty',
+ );
}
if (strlen($value) > self::MAX_LENGTH) {
throw new InvalidArgumentException(
- 'Invalid argument type: maximum length for nameId exceeds configured length of ' . self::MAX_LENGTH
+ 'Invalid argument type: maximum length for nameId exceeds configured length of ' . self::MAX_LENGTH,
);
}
@@ -57,22 +57,22 @@ public function __construct($value)
/**
* @return string
*/
- public function getNameId()
+ public function getNameId(): string
{
return $this->value;
}
- public function equals($other)
+ public function equals(NameId $other): bool
{
- return $this == $other;
+ return $this === $other;
}
- public function __toString()
+ public function __toString(): string
{
return $this->value;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->value;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/OnPremiseVettingType.php b/src/Surfnet/Stepup/Identity/Value/OnPremiseVettingType.php
index 8c30dc39a..c971fe4d2 100644
--- a/src/Surfnet/Stepup/Identity/Value/OnPremiseVettingType.php
+++ b/src/Surfnet/Stepup/Identity/Value/OnPremiseVettingType.php
@@ -23,20 +23,13 @@ class OnPremiseVettingType implements VettingType
/**
* @var string
*/
- protected $type;
+ protected string $type = VettingType::TYPE_ON_PREMISE;
- /**
- * @var DocumentNumber
- */
- private $documentNumber;
-
- public function __construct(DocumentNumber $documentNumber)
+ public function __construct(private readonly DocumentNumber $documentNumber)
{
- $this->documentNumber = $documentNumber;
- $this->type = VettingType::TYPE_ON_PREMISE;
}
- public static function deserialize($data)
+ public static function deserialize(array $data): self
{
$documentNumber = new DocumentNumber($data['document_number']);
return new self($documentNumber);
@@ -56,7 +49,7 @@ public function jsonSerialize(): array
{
return [
'type' => $this->type(),
- 'document_number' => (string) $this->getDocumentNumber()
+ 'document_number' => (string)$this->getDocumentNumber(),
];
}
diff --git a/src/Surfnet/Stepup/Identity/Value/PhoneNumber.php b/src/Surfnet/Stepup/Identity/Value/PhoneNumber.php
index 7fb6326f5..2a2ec9142 100644
--- a/src/Surfnet/Stepup/Identity/Value/PhoneNumber.php
+++ b/src/Surfnet/Stepup/Identity/Value/PhoneNumber.php
@@ -22,49 +22,44 @@
final class PhoneNumber implements SecondFactorIdentifier, RecoveryTokenIdentifier
{
- /**
- * @var string
- */
- private $phoneNumber;
+ private readonly string $phoneNumber;
- public static function unknown(): self
+ public static function unknown(): static
{
return new self('+0 (0) 000000000');
}
- public function __construct($phoneNumber)
+ public function __construct(string $phoneNumber)
{
- if (!is_string($phoneNumber)) {
- throw InvalidArgumentException::invalidType('string', 'value', $phoneNumber);
- }
-
if (!preg_match('~^\+[\d\s]+ \(0\) \d+$~', $phoneNumber)) {
- throw new InvalidArgumentException(sprintf(
- "Invalid phone number format, expected +{countryCode} (0) {subscriber}, got '%s...' (truncated)",
- // 12 characters captures the most extended country code up to and incl. the first subscriber digit
- substr($phoneNumber, 0, 12)
- ));
+ throw new InvalidArgumentException(
+ sprintf(
+ "Invalid phone number format, expected +{countryCode} (0) {subscriber}, got '%s...' (truncated)",
+ // 12 characters captures the most extended country code up to and incl. the first subscriber digit
+ substr($phoneNumber, 0, 12),
+ ),
+ );
}
$this->phoneNumber = $phoneNumber;
}
- public function getValue()
+ public function getValue(): string
{
return $this->phoneNumber;
}
- public function equals($other): bool
+ public function equals(RecoveryTokenIdentifier|SecondFactorIdentifier $other): bool
{
return $other instanceof self && $this->phoneNumber === $other->phoneNumber;
}
- public function __toString()
+ public function __toString(): string
{
return $this->phoneNumber;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->phoneNumber;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/RecoveryTokenId.php b/src/Surfnet/Stepup/Identity/Value/RecoveryTokenId.php
index 638825e30..c8c9a94e1 100644
--- a/src/Surfnet/Stepup/Identity/Value/RecoveryTokenId.php
+++ b/src/Surfnet/Stepup/Identity/Value/RecoveryTokenId.php
@@ -23,34 +23,27 @@
final class RecoveryTokenId implements Id
{
- /**
- * @var string
- */
- private $value;
+ private readonly string $value;
- public function __construct($value)
+ public function __construct(string $value)
{
- if (!is_string($value)) {
- throw InvalidArgumentException::invalidType('string', 'value', $value);
- }
-
$this->value = $value;
}
/**
* @return string
*/
- public function getRecoveryTokenId()
+ public function getRecoveryTokenId(): string
{
return $this->value;
}
- public function equals(Id $other)
+ public function equals(Id $other): bool
{
return $this == $other;
}
- public function __toString()
+ public function __toString(): string
{
return $this->value;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/RecoveryTokenIdentifier.php b/src/Surfnet/Stepup/Identity/Value/RecoveryTokenIdentifier.php
index d202bc570..446576219 100644
--- a/src/Surfnet/Stepup/Identity/Value/RecoveryTokenIdentifier.php
+++ b/src/Surfnet/Stepup/Identity/Value/RecoveryTokenIdentifier.php
@@ -22,11 +22,11 @@
interface RecoveryTokenIdentifier extends JsonSerializable
{
- public static function unknown();
+ public static function unknown(): RecoveryTokenIdentifier;
- public function getValue();
+ public function getValue(): string;
- public function equals($other): bool;
+ public function equals(RecoveryTokenIdentifier $other): bool;
- public function __toString();
+ public function __toString(): string;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/RecoveryTokenIdentifierFactory.php b/src/Surfnet/Stepup/Identity/Value/RecoveryTokenIdentifierFactory.php
index 42b311a0c..542b2417b 100644
--- a/src/Surfnet/Stepup/Identity/Value/RecoveryTokenIdentifierFactory.php
+++ b/src/Surfnet/Stepup/Identity/Value/RecoveryTokenIdentifierFactory.php
@@ -30,7 +30,9 @@ public static function forType(RecoveryTokenType $type, string $recoveryTokenIde
if ($type->isSafeStore()) {
return new SafeStore(new HashedSecret($recoveryTokenIdentifier));
}
- throw new InvalidArgumentException(sprintf('Unsupported type given while building recovery method: "%s"', $type));
+ throw new InvalidArgumentException(
+ sprintf('Unsupported type given while building recovery method: "%s"', $type),
+ );
}
public static function unknownForType(RecoveryTokenType $type): RecoveryTokenIdentifier
@@ -42,7 +44,7 @@ public static function unknownForType(RecoveryTokenType $type): RecoveryTokenIde
return SafeStore::unknown();
}
throw new InvalidArgumentException(
- sprintf('Unsupported type given while building unknown recovery method: "%s"', $type)
+ sprintf('Unsupported type given while building unknown recovery method: "%s"', $type),
);
}
}
diff --git a/src/Surfnet/Stepup/Identity/Value/RecoveryTokenType.php b/src/Surfnet/Stepup/Identity/Value/RecoveryTokenType.php
index 4fb51a74d..b3f544fe7 100644
--- a/src/Surfnet/Stepup/Identity/Value/RecoveryTokenType.php
+++ b/src/Surfnet/Stepup/Identity/Value/RecoveryTokenType.php
@@ -18,24 +18,18 @@
namespace Surfnet\Stepup\Identity\Value;
+use Stringable;
use Surfnet\Stepup\Exception\InvalidArgumentException;
-final class RecoveryTokenType
+final class RecoveryTokenType implements Stringable
{
- const TYPE_SMS = 'sms';
- const TYPE_SAFE_STORE = 'safe-store';
+ public const TYPE_SMS = 'sms';
+ public const TYPE_SAFE_STORE = 'safe-store';
- /**
- * @var string
- */
- private $type;
+ private readonly string $type;
- public function __construct($type)
+ public function __construct(string $type)
{
- if (!is_string($type)) {
- throw new InvalidArgumentException(sprintf('The RecoveryTokenType must be of type string, %s given', gettype($type)));
- }
-
if (!in_array($type, [self::TYPE_SMS, self::TYPE_SAFE_STORE])) {
throw new InvalidArgumentException('The RecoveryTokenType must be one of "sms" or "safe-store".');
}
@@ -43,12 +37,12 @@ public function __construct($type)
$this->type = $type;
}
- public static function sms()
+ public static function sms(): RecoveryTokenType
{
return new RecoveryTokenType(self::TYPE_SMS);
}
- public static function safeStore()
+ public static function safeStore(): RecoveryTokenType
{
return new RecoveryTokenType(self::TYPE_SAFE_STORE);
}
@@ -66,12 +60,12 @@ public function isSafeStore(): bool
/**
* @return string
*/
- public function getType()
+ public function getType(): string
{
return $this->type;
}
- public function __toString()
+ public function __toString(): string
{
return $this->type;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/RegistrationAuthorityRole.php b/src/Surfnet/Stepup/Identity/Value/RegistrationAuthorityRole.php
index 74c7d2f84..15e2872ed 100644
--- a/src/Surfnet/Stepup/Identity/Value/RegistrationAuthorityRole.php
+++ b/src/Surfnet/Stepup/Identity/Value/RegistrationAuthorityRole.php
@@ -1,5 +1,7 @@
role = $role;
}
/**
* @SuppressWarnings(PHPMD.ShortMethodName) no use in lengthening a domain term for the sake of shutting up PHPMD
*/
- public static function ra()
+ public static function ra(): self
{
return new self(self::ROLE_RA);
}
- public static function raa()
+ public static function raa(): self
{
return new self(self::ROLE_RAA);
}
- /**
- * @param RegistrationAuthorityRole $role
- * @return bool
- */
- public function equals(RegistrationAuthorityRole $role)
+ public function equals(RegistrationAuthorityRole $role): bool
{
return $this->role === $role->role;
}
@@ -71,7 +60,7 @@ public function equals(RegistrationAuthorityRole $role)
/**
* @return bool
*/
- public function isRa()
+ public function isRa(): bool
{
return $this->role === self::ROLE_RA;
}
@@ -79,22 +68,22 @@ public function isRa()
/**
* @return bool
*/
- public function isRaa()
+ public function isRaa(): bool
{
return $this->role === self::ROLE_RAA;
}
- public function jsonSerialize()
+ public function jsonSerialize(): int
{
return $this->role;
}
- public function __toString()
+ public function __toString(): string
{
- return (string) $this->role;
+ return (string)$this->role;
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): self
{
return new self($data['role']);
}
diff --git a/src/Surfnet/Stepup/Identity/Value/SafeStore.php b/src/Surfnet/Stepup/Identity/Value/SafeStore.php
index f0bb07584..962287eb9 100644
--- a/src/Surfnet/Stepup/Identity/Value/SafeStore.php
+++ b/src/Surfnet/Stepup/Identity/Value/SafeStore.php
@@ -23,12 +23,9 @@
*/
class SafeStore implements RecoveryTokenIdentifier
{
- /** @var Secret */
- private $secret;
-
- public function __construct(Secret $hashedSecret)
- {
- $this->secret = $hashedSecret;
+ public function __construct(
+ private readonly Secret $secret,
+ ) {
}
public static function unknown(): self
@@ -36,17 +33,17 @@ public static function unknown(): self
return new self(new ForgottenSecret());
}
- public static function hidden()
+ public static function hidden(): self
{
return new self(new HiddenSecret());
}
- public function getValue()
+ public function getValue(): string
{
return $this->secret->getSecret();
}
- public function equals($other): bool
+ public function equals(RecoveryTokenIdentifier $other): bool
{
return $other instanceof self && $other->getValue() === $this->getValue();
}
diff --git a/src/Surfnet/Stepup/Identity/Value/SecondFactorId.php b/src/Surfnet/Stepup/Identity/Value/SecondFactorId.php
index 4e6930511..985439c40 100644
--- a/src/Surfnet/Stepup/Identity/Value/SecondFactorId.php
+++ b/src/Surfnet/Stepup/Identity/Value/SecondFactorId.php
@@ -23,34 +23,27 @@
final class SecondFactorId implements Id
{
- /**
- * @var string
- */
- private $value;
+ private readonly string $value;
- public function __construct($value)
+ public function __construct(string $value)
{
- if (!is_string($value)) {
- throw InvalidArgumentException::invalidType('string', 'value', $value);
- }
-
$this->value = $value;
}
/**
* @return string
*/
- public function getSecondFactorId()
+ public function getSecondFactorId(): string
{
return $this->value;
}
- public function equals(Id $other)
+ public function equals(Id $other): bool
{
return $this == $other;
}
- public function __toString()
+ public function __toString(): string
{
return $this->value;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/SecondFactorIdentifier.php b/src/Surfnet/Stepup/Identity/Value/SecondFactorIdentifier.php
index 10f135cc3..8294e46b6 100644
--- a/src/Surfnet/Stepup/Identity/Value/SecondFactorIdentifier.php
+++ b/src/Surfnet/Stepup/Identity/Value/SecondFactorIdentifier.php
@@ -25,20 +25,19 @@ interface SecondFactorIdentifier extends JsonSerializable
/**
* @return static
*/
- public static function unknown();
+ public static function unknown(): static;
/**
* Return a string representation of the value of this value object.
*
* @return string
*/
- public function getValue();
+ public function getValue(): string;
/**
- * @param self $other
* @return bool
*/
- public function equals($other): bool;
+ public function equals(SecondFactorIdentifier $other): bool;
/**
* @return string
diff --git a/src/Surfnet/Stepup/Identity/Value/SelfAssertedRegistrationVettingType.php b/src/Surfnet/Stepup/Identity/Value/SelfAssertedRegistrationVettingType.php
index 0aaad7e56..fae3a8677 100644
--- a/src/Surfnet/Stepup/Identity/Value/SelfAssertedRegistrationVettingType.php
+++ b/src/Surfnet/Stepup/Identity/Value/SelfAssertedRegistrationVettingType.php
@@ -23,17 +23,13 @@ class SelfAssertedRegistrationVettingType implements VettingType
/**
* @var string
*/
- protected $type;
+ protected string $type = VettingType::TYPE_SELF_ASSERTED_REGISTRATION;
- protected $authoringRecoveryToken;
-
- public function __construct(RecoveryTokenId $recoveryTokenId)
+ public function __construct(protected RecoveryTokenId $authoringRecoveryToken)
{
- $this->type = VettingType::TYPE_SELF_ASSERTED_REGISTRATION;
- $this->authoringRecoveryToken = $recoveryTokenId;
}
- public static function deserialize($data)
+ public static function deserialize(array $data): self
{
$recoveryTokenId = new RecoveryTokenId($data['recovery_token_id']);
return new self($recoveryTokenId);
diff --git a/src/Surfnet/Stepup/Identity/Value/SelfVetVettingType.php b/src/Surfnet/Stepup/Identity/Value/SelfVetVettingType.php
index 4057ec15c..12569eda6 100644
--- a/src/Surfnet/Stepup/Identity/Value/SelfVetVettingType.php
+++ b/src/Surfnet/Stepup/Identity/Value/SelfVetVettingType.php
@@ -25,20 +25,13 @@ class SelfVetVettingType implements VettingType
/**
* @var string
*/
- protected $type;
+ protected string $type = VettingType::TYPE_SELF_VET;
- /**
- * @var Loa
- */
- private $authoringLoa;
-
- public function __construct(Loa $loa)
+ public function __construct(private readonly Loa $authoringLoa)
{
- $this->authoringLoa = $loa;
- $this->type = VettingType::TYPE_SELF_VET;
}
- public static function deserialize($data)
+ public static function deserialize(array $data): self
{
$loa = new Loa($data['loa']['level'], $data['loa']['identifier']);
return new self($loa);
@@ -46,7 +39,7 @@ public static function deserialize($data)
public function auditLog(): string
{
- return sprintf(' (self vetted using LoA: %s)', (string) $this->authoringLoa());
+ return sprintf(' (self vetted using LoA: %s)', (string)$this->authoringLoa());
}
public function authoringLoa(): Loa
@@ -60,8 +53,8 @@ public function jsonSerialize(): array
'type' => $this->type(),
'loa' => [
'level' => $this->authoringLoa->getLevel(),
- 'identifier' => (string) $this->authoringLoa,
- ]
+ 'identifier' => (string)$this->authoringLoa,
+ ],
];
}
diff --git a/src/Surfnet/Stepup/Identity/Value/StepupProvider.php b/src/Surfnet/Stepup/Identity/Value/StepupProvider.php
index 12da6613e..f4a1a098f 100644
--- a/src/Surfnet/Stepup/Identity/Value/StepupProvider.php
+++ b/src/Surfnet/Stepup/Identity/Value/StepupProvider.php
@@ -18,18 +18,16 @@
namespace Surfnet\Stepup\Identity\Value;
+use Stringable;
use Surfnet\Stepup\Exception\InvalidArgumentException;
-final class StepupProvider
+final class StepupProvider implements Stringable
{
- /**
- * @var string
- */
- private $provider;
+ private readonly string $provider;
- public function __construct($provider)
+ public function __construct(string $provider)
{
- if (!is_string($provider) || strlen(trim($provider)) === 0) {
+ if (trim($provider) === '') {
throw InvalidArgumentException::invalidType('non-empty string', 'provider', $provider);
}
@@ -39,17 +37,17 @@ public function __construct($provider)
/**
* @return string
*/
- public function getStepupProvider()
+ public function getStepupProvider(): string
{
return $this->provider;
}
- public function equals(StepupProvider $other)
+ public function equals(StepupProvider $other): bool
{
return $this->provider === $other->provider;
}
- public function __toString()
+ public function __toString(): string
{
return $this->provider;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/TimeFrame.php b/src/Surfnet/Stepup/Identity/Value/TimeFrame.php
index 03a49ce89..c5dc70759 100644
--- a/src/Surfnet/Stepup/Identity/Value/TimeFrame.php
+++ b/src/Surfnet/Stepup/Identity/Value/TimeFrame.php
@@ -1,5 +1,6 @@
timeFrame = $timeFrame;
}
/**
- * @param int $seconds
* @return TimeFrame
+ * @throws Exception
+ * @throws Exception
*/
- public static function ofSeconds($seconds)
+ public static function ofSeconds(int $seconds): TimeFrame
{
- if (!is_int($seconds) || $seconds < 1) {
+ if ($seconds < 1) {
throw InvalidArgumentException::invalidType('positive integer', 'seconds', $seconds);
}
return new TimeFrame(new DateInterval('PT' . $seconds . 'S'));
}
- /**
- * @param DateTime $dateTime
- * @return DateTime
- */
- public function getEndWhenStartingAt(DateTime $dateTime)
+ public function getEndWhenStartingAt(DateTime $dateTime): DateTime
{
return $dateTime->add($this->timeFrame);
}
- /**
- * @param TimeFrame $other
- * @return bool
- */
- public function equals(TimeFrame $other)
+ public function equals(TimeFrame $other): bool
{
return $this->timeFrame->s === $other->timeFrame->s;
}
- public function __toString()
+ public function __toString(): string
{
return $this->timeFrame->format('%S');
}
diff --git a/src/Surfnet/Stepup/Identity/Value/U2fKeyHandle.php b/src/Surfnet/Stepup/Identity/Value/U2fKeyHandle.php
index b6c4f05ce..280316dc8 100644
--- a/src/Surfnet/Stepup/Identity/Value/U2fKeyHandle.php
+++ b/src/Surfnet/Stepup/Identity/Value/U2fKeyHandle.php
@@ -25,55 +25,48 @@
*/
final class U2fKeyHandle implements SecondFactorIdentifier
{
- const UNKNOWN = '—';
+ public const UNKNOWN = '—';
- /**
- * @var string
- */
- private $value;
+ private string $value;
/**
* @return static
*/
- public static function unknown()
+ public static function unknown(): static
{
return new self(self::UNKNOWN);
}
- public function __construct($value)
+ public function __construct(string $value)
{
if ($value === self::UNKNOWN) {
$this->value = $value;
return;
}
- if (!is_string($value)) {
- throw InvalidArgumentException::invalidType('string', 'value', $value);
- }
-
- if (empty($value)) {
+ if ($value === '' || $value === '0') {
throw new InvalidArgumentException('Invalid Argument, parameter "value" may not be an empty string');
}
$this->value = $value;
}
- public function getValue()
+ public function getValue(): string
{
return $this->value;
}
- public function __toString()
+ public function __toString(): string
{
return $this->value;
}
- public function equals($other): bool
+ public function equals(SecondFactorIdentifier $other): bool
{
return $other instanceof self && $this->value === $other->value;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->value;
}
diff --git a/src/Surfnet/Stepup/Identity/Value/UnhashedSecret.php b/src/Surfnet/Stepup/Identity/Value/UnhashedSecret.php
index 644aa12ba..da0fa4422 100644
--- a/src/Surfnet/Stepup/Identity/Value/UnhashedSecret.php
+++ b/src/Surfnet/Stepup/Identity/Value/UnhashedSecret.php
@@ -41,21 +41,18 @@ class UnhashedSecret implements HashableSecret
*/
private const ALGORITHM = PASSWORD_BCRYPT;
- private $secret;
-
- public function hashSecret(): Secret
+ public function hashSecret(): HashedSecret
{
$hashedSecret = password_hash(
$this->secret,
self::ALGORITHM,
- ['cost' => self::COST]
+ ['cost' => self::COST],
);
return new HashedSecret($hashedSecret);
}
- public function __construct(string $secret)
+ public function __construct(private readonly string $secret)
{
- $this->secret = $secret;
}
public function getSecret(): string
diff --git a/src/Surfnet/Stepup/Identity/Value/UnknownVettingType.php b/src/Surfnet/Stepup/Identity/Value/UnknownVettingType.php
index 2613caf5d..9b3cdc1cf 100644
--- a/src/Surfnet/Stepup/Identity/Value/UnknownVettingType.php
+++ b/src/Surfnet/Stepup/Identity/Value/UnknownVettingType.php
@@ -23,11 +23,10 @@ class UnknownVettingType implements VettingType
/**
* @var string
*/
- protected $type;
+ protected string $type = VettingType::TYPE_UNKNOWN;
public function __construct()
{
- $this->type = VettingType::TYPE_UNKNOWN;
}
public function auditLog(): string
diff --git a/src/Surfnet/Stepup/Identity/Value/VettingTypeHint.php b/src/Surfnet/Stepup/Identity/Value/VettingTypeHint.php
index c66ed9ff4..f5e672f04 100644
--- a/src/Surfnet/Stepup/Identity/Value/VettingTypeHint.php
+++ b/src/Surfnet/Stepup/Identity/Value/VettingTypeHint.php
@@ -20,26 +20,26 @@
use JsonSerializable;
-class VettingTypeHint implements JsonSerializable
+class VettingTypeHint implements JsonSerializable, \Stringable
{
- /**
- * @var string
- */
- private $locale;
-
- /**
- * The hint text is nullable
- * @var string
- */
- private $hint;
+ public function __construct(
+ private readonly string $locale,
+ /**
+ * The hint text is nullable
+ */
+ private readonly ?string $hint,
+ ) {
+ }
- public function __construct(string $locale, ?string $hint)
+ public function __toString(): string
{
- $this->locale = $locale;
- $this->hint = $hint;
+ if ($this->hint === null) {
+ return '';
+ }
+ return $this->hint;
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
'locale' => $this->locale,
diff --git a/src/Surfnet/Stepup/Identity/Value/YubikeyPublicId.php b/src/Surfnet/Stepup/Identity/Value/YubikeyPublicId.php
index d97278b5f..c3465d051 100644
--- a/src/Surfnet/Stepup/Identity/Value/YubikeyPublicId.php
+++ b/src/Surfnet/Stepup/Identity/Value/YubikeyPublicId.php
@@ -22,37 +22,30 @@
final class YubikeyPublicId implements SecondFactorIdentifier
{
- const UNKNOWN = '—';
+ public const UNKNOWN = '—';
- /**
- * @var string
- */
- private $value;
+ private string $value;
- public static function unknown()
+ public static function unknown(): static
{
return new self(self::UNKNOWN);
}
- public function __construct($value)
+ public function __construct(string $value)
{
if ($value === self::UNKNOWN) {
$this->value = $value;
return;
}
- if (!is_string($value)) {
- throw InvalidArgumentException::invalidType('string', 'value', $value);
- }
-
// Numeric IDs must be left-padded with zeroes until eight characters. Longer IDs, up to twenty characters, may
// not be padded.
- if (!preg_match('~^[0-9]{8,20}$~', $value)) {
+ if (!preg_match('~^\d{8,20}$~', $value)) {
throw new InvalidArgumentException('Given Yubikey public ID is not a string of 8 to 20 digits');
}
if ($value !== sprintf('%08s', ltrim($value, '0'))) {
throw new InvalidArgumentException(
- 'Given Yubikey public ID is longer than 8 digits, yet left-padded with zeroes'
+ 'Given Yubikey public ID is longer than 8 digits, yet left-padded with zeroes',
);
}
@@ -65,22 +58,22 @@ public function __construct($value)
$this->value = $value;
}
- public function getValue()
+ public function getValue(): string
{
return $this->value;
}
- public function __toString()
+ public function __toString(): string
{
return $this->value;
}
- public function equals($other): bool
+ public function equals(SecondFactorIdentifier $other): bool
{
return $other instanceof self && $this->value === $other->value;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->value;
}
diff --git a/src/Surfnet/Stepup/Identity/Whitelist.php b/src/Surfnet/Stepup/Identity/Whitelist.php
index b0df6aa82..08dd4aa27 100644
--- a/src/Surfnet/Stepup/Identity/Whitelist.php
+++ b/src/Surfnet/Stepup/Identity/Whitelist.php
@@ -32,12 +32,9 @@ final class Whitelist extends EventSourcedAggregateRoot implements WhitelistApi
/**
* There can ever be only one whitelist, so using a fixed UUIDv4
*/
- const WHITELIST_AGGREGATE_ID = '125ccee5-d650-437a-a0b0-6bf17c8188fa';
+ public const WHITELIST_AGGREGATE_ID = '125ccee5-d650-437a-a0b0-6bf17c8188fa';
- /**
- * @var InstitutionCollection The collection of institutions currently on the whitelist
- */
- private $whitelist;
+ private ?InstitutionCollection $whitelist = null;
public function __construct()
{
@@ -48,7 +45,7 @@ public function getAggregateRootId(): string
return self::WHITELIST_AGGREGATE_ID;
}
- public static function create(InstitutionCollection $institutionCollection)
+ public static function create(InstitutionCollection $institutionCollection): self
{
$whitelist = new self();
$whitelist->apply(new WhitelistCreatedEvent($institutionCollection));
@@ -56,57 +53,61 @@ public static function create(InstitutionCollection $institutionCollection)
return $whitelist;
}
- public function replaceAll(InstitutionCollection $institutionCollection)
+ public function replaceAll(InstitutionCollection $institutionCollection): void
{
$this->apply(new WhitelistReplacedEvent($institutionCollection));
}
- public function add(InstitutionCollection $institutionCollection)
+ public function add(InstitutionCollection $institutionCollection): void
{
foreach ($institutionCollection as $institution) {
if ($this->whitelist->contains($institution)) {
- throw new DomainException(sprintf(
- 'Cannot add institution "%s" as it is already whitelisted',
- $institution
- ));
+ throw new DomainException(
+ sprintf(
+ 'Cannot add institution "%s" as it is already whitelisted',
+ $institution,
+ ),
+ );
}
}
$this->apply(new InstitutionsAddedToWhitelistEvent($institutionCollection));
}
- public function remove(InstitutionCollection $institutionCollection)
+ public function remove(InstitutionCollection $institutionCollection): void
{
foreach ($institutionCollection as $institution) {
if (!$this->whitelist->contains($institution)) {
- throw new DomainException(sprintf(
- 'Cannot remove institution "%s" as it is not whitelisted',
- $institution
- ));
+ throw new DomainException(
+ sprintf(
+ 'Cannot remove institution "%s" as it is not whitelisted',
+ $institution,
+ ),
+ );
}
}
$this->apply(new InstitutionsRemovedFromWhitelistEvent($institutionCollection));
}
- protected function applyWhitelistCreatedEvent(WhitelistCreatedEvent $event)
+ protected function applyWhitelistCreatedEvent(WhitelistCreatedEvent $event): void
{
$this->whitelist = new InstitutionCollection();
$this->whitelist->addAllFrom($event->whitelistedInstitutions);
}
- protected function applyWhitelistReplacedEvent(WhitelistReplacedEvent $event)
+ protected function applyWhitelistReplacedEvent(WhitelistReplacedEvent $event): void
{
$this->whitelist = new InstitutionCollection();
$this->whitelist->addAllFrom($event->whitelistedInstitutions);
}
- protected function applyInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhitelistEvent $event)
+ protected function applyInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhitelistEvent $event): void
{
$this->whitelist->addAllFrom($event->addedInstitutions);
}
- protected function applyInstitutionsRemovedFromWhitelistEvent(InstitutionsRemovedFromWhitelistEvent $event)
+ protected function applyInstitutionsRemovedFromWhitelistEvent(InstitutionsRemovedFromWhitelistEvent $event): void
{
$this->whitelist->removeAllIn($event->removedInstitutions);
}
diff --git a/src/Surfnet/Stepup/MigrationsFactory/ConfigurationAwareMigrationInterface.php b/src/Surfnet/Stepup/MigrationsFactory/ConfigurationAwareMigrationInterface.php
new file mode 100644
index 000000000..6f56d876a
--- /dev/null
+++ b/src/Surfnet/Stepup/MigrationsFactory/ConfigurationAwareMigrationInterface.php
@@ -0,0 +1,26 @@
+gatewaySchema = $gatewaySchema;
+ $this->middlewareSchema = $middlewareSchema;
+ $this->middlewareUser = $middlewareUser;
+ }
+
+ public function getGatewaySchema(): string
+ {
+ if (empty($this->gatewaySchema)) {
+ throw new RuntimeException("Gateway schema must be set");
+ }
+ return $this->gatewaySchema;
+ }
+
+ public function getMiddlewareSchema(): string
+ {
+ if (empty($this->middlewareSchema)) {
+ throw new RuntimeException("Middleware schema must be set");
+ }
+ return $this->middlewareSchema;
+ }
+
+ public function getMiddlewareUser(): string
+ {
+ if (empty($this->middlewareUser)) {
+ throw new RuntimeException("Middleware user must be set");
+ }
+ return $this->middlewareUser;
+ }
+}
diff --git a/src/Surfnet/Stepup/MigrationsFactory/ConfigurationMigrationFactory.php b/src/Surfnet/Stepup/MigrationsFactory/ConfigurationMigrationFactory.php
new file mode 100644
index 000000000..34dc1322c
--- /dev/null
+++ b/src/Surfnet/Stepup/MigrationsFactory/ConfigurationMigrationFactory.php
@@ -0,0 +1,46 @@
+migrationFactory->createVersion($migrationClassName);
+
+ if ($migration instanceof ConfigurationAwareMigrationInterface) {
+ $migration->setConfiguration($this->gatewaySchema, $this->middlewareSchema, $this->middlewareUser);
+ }
+
+ return $migration;
+ }
+}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Event/EventSerializationAndDeserializationTest.php b/src/Surfnet/Stepup/Tests/Configuration/Event/EventSerializationAndDeserializationTest.php
index ee39b4846..1aadeaef4 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Event/EventSerializationAndDeserializationTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Event/EventSerializationAndDeserializationTest.php
@@ -19,8 +19,9 @@
namespace Surfnet\Stepup\Tests\Configuration\Event;
use Broadway\Serializer\Serializable as SerializableInterface;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Configuration\Configuration;
use Surfnet\Stepup\Configuration\Event\AllowedSecondFactorListUpdatedEvent;
use Surfnet\Stepup\Configuration\Event\ConfigurationUpdatedEvent;
@@ -59,14 +60,17 @@
class EventSerializationAndDeserializationTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
*
* @dataProvider institutionConfigurationEventsProvider
*/
- public function an_event_should_be_the_same_after_serialization_and_deserialization(SerializableInterface $unserializedEvent)
- {
+ public function an_event_should_be_the_same_after_serialization_and_deserialization(
+ SerializableInterface $unserializedEvent,
+ ): void {
$serializedEvent = $unserializedEvent->serialize();
$deserializedEvent = $unserializedEvent::deserialize($serializedEvent);
@@ -74,10 +78,7 @@ public function an_event_should_be_the_same_after_serialization_and_deserializat
$this->assertEquals($unserializedEvent, $deserializedEvent);
}
- /**
- * @return SerializableInterface[]
- */
- public function institutionConfigurationEventsProvider()
+ public function institutionConfigurationEventsProvider(): array
{
$institution = new Institution('A test institution');
$institutionConfigurationId = InstitutionConfigurationId::from($institution);
@@ -87,38 +88,38 @@ public function institutionConfigurationEventsProvider()
// Configuration
'NewConfigurationCreatedEvent' => [
new NewConfigurationCreatedEvent(
- Configuration::CONFIGURATION_ID
- )
+ Configuration::CONFIGURATION_ID,
+ ),
],
'ConfigurationUpdatedEvent' => [
new ConfigurationUpdatedEvent(
Configuration::CONFIGURATION_ID,
- ['configurationKey' => 'configurationValue']
- )
+ ['configurationKey' => 'configurationValue'],
+ ),
],
'EmailTemplatesUpdatedEvent' => [
new EmailTemplatesUpdatedEvent(
Configuration::CONFIGURATION_ID,
- ['template']
- )
+ ['template'],
+ ),
],
'IdentityProvidersUpdatedEvent' => [
new IdentityProvidersUpdatedEvent(
Configuration::CONFIGURATION_ID,
- ['idp']
- )
+ ['idp'],
+ ),
],
'ServiceProvidersUpdatedEvent' => [
new ServiceProvidersUpdatedEvent(
Configuration::CONFIGURATION_ID,
- ['sp']
- )
+ ['sp'],
+ ),
],
'SraaUpdatedEvent' => [
new SraaUpdatedEvent(
Configuration::CONFIGURATION_ID,
- ['sraa']
- )
+ ['sraa'],
+ ),
],
// InstitutionConfiguration
@@ -132,43 +133,43 @@ public function institutionConfigurationEventsProvider()
new NumberOfTokensPerIdentityOption(0),
new SsoOn2faOption(false),
new SelfVetOption(true),
- new SelfAssertedTokensOption(true)
- )
+ new SelfAssertedTokensOption(true),
+ ),
],
'UseRaLocationsOptionChangedEvent' => [
new UseRaLocationsOptionChangedEvent(
$institutionConfigurationId,
$institution,
- new UseRaLocationsOption(true)
- )
+ new UseRaLocationsOption(true),
+ ),
],
'ShowRaaContactInformationOptionChangedEvent' => [
new ShowRaaContactInformationOptionChangedEvent(
$institutionConfigurationId,
$institution,
- new ShowRaaContactInformationOption(true)
- )
+ new ShowRaaContactInformationOption(true),
+ ),
],
'VerifyEmailOptionChangedEvent' => [
new VerifyEmailOptionChangedEvent(
$institutionConfigurationId,
$institution,
- new VerifyEmailOption(true)
- )
+ new VerifyEmailOption(true),
+ ),
],
'SelfVetOptionChangedEvent' => [
new SelfVetOptionChangedEvent(
$institutionConfigurationId,
$institution,
- new SelfVetOption(false)
- )
+ new SelfVetOption(false),
+ ),
],
'SsoOn2faOptionChangedEvent' => [
new SsoOn2faOptionChangedEvent(
$institutionConfigurationId,
$institution,
- new SsoOn2faOption(false)
- )
+ new SsoOn2faOption(false),
+ ),
],
'AllowedSecondFactorListUpdatedEvent:withSecondFactors' => [
new AllowedSecondFactorListUpdatedEvent(
@@ -177,15 +178,15 @@ public function institutionConfigurationEventsProvider()
AllowedSecondFactorList::ofTypes([
new SecondFactorType('yubikey'),
new SecondFactorType('sms'),
- ])
- )
+ ]),
+ ),
],
'AllowedSecondFactorListUpdatedEvent:blank' => [
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- AllowedSecondFactorList::blank()
- )
+ AllowedSecondFactorList::blank(),
+ ),
],
'RaLocationAddedEvent' => [
new RaLocationAddedEvent(
@@ -194,42 +195,42 @@ public function institutionConfigurationEventsProvider()
new RaLocationId($uuid),
new RaLocationName('Test name'),
new Location('Test location'),
- new ContactInformation('Test contact information')
- )
+ new ContactInformation('Test contact information'),
+ ),
],
'RaLocationRenamedEvent' => [
new RaLocationRenamedEvent(
$institutionConfigurationId,
new RaLocationId($uuid),
- new RaLocationName('Test name')
- )
+ new RaLocationName('Test name'),
+ ),
],
'RaLocationRelocatedEvent' => [
new RaLocationRelocatedEvent(
$institutionConfigurationId,
new RaLocationId($uuid),
- new Location('Test location')
- )
+ new Location('Test location'),
+ ),
],
'RaLocationContactInformationChangedEvent' => [
new RaLocationContactInformationChangedEvent(
$institutionConfigurationId,
new RaLocationId($uuid),
- new ContactInformation('Test contact information')
- )
+ new ContactInformation('Test contact information'),
+ ),
],
'RaLocationRemovedEvent' => [
new RaLocationRemovedEvent(
$institutionConfigurationId,
- new RaLocationId($uuid)
- )
+ new RaLocationId($uuid),
+ ),
],
'InstitutionConfigurationRemovedEvent' => [
new InstitutionConfigurationRemovedEvent(
$institutionConfigurationId,
- new Institution('Babelfish Inc')
- )
- ]
+ new Institution('Babelfish Inc'),
+ ),
+ ],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/InstitutionConfigurationTest.php b/src/Surfnet/Stepup/Tests/Configuration/InstitutionConfigurationTest.php
index ec5cbd2a1..b7c81746d 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/InstitutionConfigurationTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/InstitutionConfigurationTest.php
@@ -19,6 +19,7 @@
namespace Surfnet\Stepup\Tests\Configuration;
use Broadway\EventSourcing\Testing\AggregateRootScenarioTestCase;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Surfnet\Stepup\Configuration\Event\AllowedSecondFactorListUpdatedEvent;
use Surfnet\Stepup\Configuration\Event\InstitutionConfigurationRemovedEvent;
use Surfnet\Stepup\Configuration\Event\NewInstitutionConfigurationCreatedEvent;
@@ -30,6 +31,7 @@
use Surfnet\Stepup\Configuration\InstitutionConfiguration;
use Surfnet\Stepup\Configuration\Value\AllowedSecondFactorList;
use Surfnet\Stepup\Configuration\Value\Institution;
+use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption;
@@ -38,21 +40,22 @@
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption;
use Surfnet\Stepup\Configuration\Value\SsoOn2faOption;
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption;
-use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
class InstitutionConfigurationTest extends AggregateRootScenarioTestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group aggregate
*/
- public function use_ra_locations_option_is_set_to_false_by_default_upon_creation_of_an_institution_configuration()
+ public function use_ra_locations_option_is_set_to_false_by_default_upon_creation_of_an_institution_configuration(): void
{
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::from($institution);
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::from($institution);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -63,12 +66,10 @@ public function use_ra_locations_option_is_set_to_false_by_default_upon_creation
$selectRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa());
$this->scenario
- ->when(function () use ($institution, $institutionConfigurationId) {
- return InstitutionConfiguration::create(
- $institutionConfigurationId,
- $institution
- );
- })->then([
+ ->when(fn(): \Surfnet\Stepup\Configuration\InstitutionConfiguration => InstitutionConfiguration::create(
+ $institutionConfigurationId,
+ $institution,
+ ))->then([
new NewInstitutionConfigurationCreatedEvent(
$institutionConfigurationId,
$institution,
@@ -78,27 +79,27 @@ public function use_ra_locations_option_is_set_to_false_by_default_upon_creation
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- AllowedSecondFactorList::blank()
+ AllowedSecondFactorList::blank(),
),
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaOption
+ $useRaOption,
),
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaaOption
+ $useRaaOption,
),
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $selectRaaOption
+ $selectRaaOption,
),
]);
}
@@ -107,12 +108,12 @@ public function use_ra_locations_option_is_set_to_false_by_default_upon_creation
* @test
* @group aggregate
*/
- public function show_raa_contact_information_option_is_set_to_true_by_default_upon_creation_of_an_institution_configuration()
+ public function show_raa_contact_information_option_is_set_to_true_by_default_upon_creation_of_an_institution_configuration(): void
{
- $institution = new Institution('Institution');
+ $institution = new Institution('Institution');
$institutionConfigurationId = InstitutionConfigurationId::from($institution);
- $useRaLocationsOption = new UseRaLocationsOption(false);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $useRaLocationsOption = new UseRaLocationsOption(false);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -123,12 +124,10 @@ public function show_raa_contact_information_option_is_set_to_true_by_default_up
$selectRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa());
$this->scenario
- ->when(function () use ($institution, $institutionConfigurationId, $useRaLocationsOption, $verifyEmailOption) {
- return InstitutionConfiguration::create(
- $institutionConfigurationId,
- $institution
- );
- })->then([
+ ->when(fn(): \Surfnet\Stepup\Configuration\InstitutionConfiguration => InstitutionConfiguration::create(
+ $institutionConfigurationId,
+ $institution,
+ ))->then([
new NewInstitutionConfigurationCreatedEvent(
$institutionConfigurationId,
$institution,
@@ -138,27 +137,27 @@ public function show_raa_contact_information_option_is_set_to_true_by_default_up
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- AllowedSecondFactorList::blank()
+ AllowedSecondFactorList::blank(),
),
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaOption
+ $useRaOption,
),
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaaOption
+ $useRaaOption,
),
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $selectRaaOption
+ $selectRaaOption,
),
]);
}
@@ -167,13 +166,13 @@ public function show_raa_contact_information_option_is_set_to_true_by_default_up
* @test
* @group aggregate
*/
- public function use_ra_locations_option_is_not_changed_if_its_given_value_is_not_different_from_the_current_value()
+ public function use_ra_locations_option_is_not_changed_if_its_given_value_is_not_different_from_the_current_value(): void
{
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::from($institution);
- $originalUseRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::from($institution);
+ $originalUseRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -181,7 +180,7 @@ public function use_ra_locations_option_is_not_changed_if_its_given_value_is_not
$theSameUseRaLocationsOption = $originalUseRaLocationsOption;
$this->scenario
- ->withAggregateId((string) $institutionConfigurationId->getInstitutionConfigurationId())
+ ->withAggregateId((string)$institutionConfigurationId->getInstitutionConfigurationId())
->given([
new NewInstitutionConfigurationCreatedEvent(
$institutionConfigurationId,
@@ -192,12 +191,14 @@ public function use_ra_locations_option_is_not_changed_if_its_given_value_is_not
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
- )
+ $selfAssertedTokensOption,
+ ),
])
- ->when(function (InstitutionConfiguration $institutionConfiguration) use ($theSameUseRaLocationsOption) {
- $institutionConfiguration->configureUseRaLocationsOption($theSameUseRaLocationsOption);
- })
+ ->when(
+ function (InstitutionConfiguration $institutionConfiguration) use ($theSameUseRaLocationsOption): void {
+ $institutionConfiguration->configureUseRaLocationsOption($theSameUseRaLocationsOption);
+ },
+ )
->then([]);
}
@@ -205,13 +206,13 @@ public function use_ra_locations_option_is_not_changed_if_its_given_value_is_not
* @test
* @group aggregate
*/
- public function show_raa_contact_information_option_is_not_changed_if_its_given_value_is_not_different_from_the_current_value()
+ public function show_raa_contact_information_option_is_not_changed_if_its_given_value_is_not_different_from_the_current_value(): void
{
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::from($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::from($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$originalShowRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(0);
$selfVetOption = new SelfVetOption(false);
@@ -219,7 +220,7 @@ public function show_raa_contact_information_option_is_not_changed_if_its_given_
$sameShowRaaContactInformationOption = $originalShowRaaContactInformationOption;
$this->scenario
- ->withAggregateId((string) $institutionConfigurationId->getInstitutionConfigurationId())
+ ->withAggregateId((string)$institutionConfigurationId->getInstitutionConfigurationId())
->given([
new NewInstitutionConfigurationCreatedEvent(
$institutionConfigurationId,
@@ -230,12 +231,17 @@ public function show_raa_contact_information_option_is_not_changed_if_its_given_
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
- )
+ $selfAssertedTokensOption,
+ ),
])
- ->when(function (InstitutionConfiguration $institutionConfiguration) use ($sameShowRaaContactInformationOption) {
- $institutionConfiguration->configureShowRaaContactInformationOption($sameShowRaaContactInformationOption);
- })
+ ->when(
+ function (InstitutionConfiguration $institutionConfiguration) use ($sameShowRaaContactInformationOption,
+ ): void {
+ $institutionConfiguration->configureShowRaaContactInformationOption(
+ $sameShowRaaContactInformationOption,
+ );
+ },
+ )
->then([]);
}
@@ -243,13 +249,13 @@ public function show_raa_contact_information_option_is_not_changed_if_its_given_
* @test
* @group aggregate
*/
- public function use_ra_locations_option_is_changed_if_its_given_value_is_different_from_the_current_value()
+ public function use_ra_locations_option_is_changed_if_its_given_value_is_different_from_the_current_value(): void
{
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::from($institution);
- $originalUseRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::from($institution);
+ $originalUseRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = new SelfVetOption(false);
$selfAssertedTokensOption = new SelfAssertedTokensOption(true);
@@ -257,7 +263,7 @@ public function use_ra_locations_option_is_changed_if_its_given_value_is_differe
$expectedUseRaLocationsOption = new UseRaLocationsOption(false);
$this->scenario
- ->withAggregateId((string) $institutionConfigurationId->getInstitutionConfigurationId())
+ ->withAggregateId((string)$institutionConfigurationId->getInstitutionConfigurationId())
->given([
new NewInstitutionConfigurationCreatedEvent(
$institutionConfigurationId,
@@ -268,17 +274,20 @@ public function use_ra_locations_option_is_changed_if_its_given_value_is_differe
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
- )
+ $selfAssertedTokensOption,
+ ),
])
- ->when(function (InstitutionConfiguration $institutionConfiguration) use ($expectedUseRaLocationsOption) {
- $institutionConfiguration->configureUseRaLocationsOption($expectedUseRaLocationsOption);
- })
+ ->when(
+ function (InstitutionConfiguration $institutionConfiguration) use ($expectedUseRaLocationsOption,
+ ): void {
+ $institutionConfiguration->configureUseRaLocationsOption($expectedUseRaLocationsOption);
+ },
+ )
->then([
new UseRaLocationsOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $expectedUseRaLocationsOption
+ $expectedUseRaLocationsOption,
),
]);
}
@@ -287,13 +296,13 @@ public function use_ra_locations_option_is_changed_if_its_given_value_is_differe
* @test
* @group aggregate
*/
- public function show_raa_contact_information_option_is_changed_if_its_given_value_is_different_from_the_current_value()
+ public function show_raa_contact_information_option_is_changed_if_its_given_value_is_different_from_the_current_value(): void
{
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::from($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::from($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$originalShowRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = new SelfVetOption(false);
$selfAssertedTokensOption = new SelfAssertedTokensOption(true);
@@ -301,7 +310,7 @@ public function show_raa_contact_information_option_is_changed_if_its_given_valu
$expectedShowRaaContactInformationOption = new ShowRaaContactInformationOption(false);
$this->scenario
- ->withAggregateId((string) $institutionConfigurationId->getInstitutionConfigurationId())
+ ->withAggregateId((string)$institutionConfigurationId->getInstitutionConfigurationId())
->given([
new NewInstitutionConfigurationCreatedEvent(
$institutionConfigurationId,
@@ -312,17 +321,23 @@ public function show_raa_contact_information_option_is_changed_if_its_given_valu
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
- )
+ $selfAssertedTokensOption,
+ ),
])
- ->when(function (InstitutionConfiguration $institutionConfiguration) use ($expectedShowRaaContactInformationOption) {
- $institutionConfiguration->configureShowRaaContactInformationOption($expectedShowRaaContactInformationOption);
- })
+ ->when(
+ function (InstitutionConfiguration $institutionConfiguration) use (
+ $expectedShowRaaContactInformationOption,
+ ): void {
+ $institutionConfiguration->configureShowRaaContactInformationOption(
+ $expectedShowRaaContactInformationOption,
+ );
+ },
+ )
->then([
new ShowRaaContactInformationOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $expectedShowRaaContactInformationOption
+ $expectedShowRaaContactInformationOption,
),
]);
}
@@ -331,12 +346,12 @@ public function show_raa_contact_information_option_is_changed_if_its_given_valu
* @test
* @group aggregate
*/
- public function test_the_setting_of_fga_options_on_an_institution_configuration()
+ public function test_the_setting_of_fga_options_on_an_institution_configuration(): void
{
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::from($institution);
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::from($institution);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = new SelfVetOption(false);
$selfAssertedTokensOption = new SelfAssertedTokensOption(false);
@@ -350,18 +365,18 @@ public function test_the_setting_of_fga_options_on_an_institution_configuration(
->when(
function () use (
$institution,
- $institutionConfigurationId
+ $institutionConfigurationId,
) {
$institutionConfiguration = InstitutionConfiguration::create(
$institutionConfigurationId,
- $institution
+ $institution,
);
// First destroy the current config
$institutionConfiguration->destroy();
return $institutionConfiguration;
- }
+ },
)->then(
[
new NewInstitutionConfigurationCreatedEvent(
@@ -373,33 +388,33 @@ function () use (
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- AllowedSecondFactorList::blank()
+ AllowedSecondFactorList::blank(),
),
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaOption
+ $useRaOption,
),
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaaOption
+ $useRaaOption,
),
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $selectRaaOption
+ $selectRaaOption,
),
new InstitutionConfigurationRemovedEvent(
$institutionConfigurationId,
- $institution
+ $institution,
),
- ]
+ ],
);
}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/AllowedSecondFactorListTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/AllowedSecondFactorListTest.php
index ea29ddb3b..2d4873afa 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/AllowedSecondFactorListTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/AllowedSecondFactorListTest.php
@@ -18,6 +18,7 @@
namespace Surfnet\Stepup\Tests\Configuration\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
use Surfnet\Stepup\Configuration\Value\AllowedSecondFactorList;
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
@@ -25,11 +26,13 @@
class AllowedSecondFactorListTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
*/
- public function an_allowed_second_factor_list_deduplicates_its_second_factors_upon_creation()
+ public function an_allowed_second_factor_list_deduplicates_its_second_factors_upon_creation(): void
{
$allowedSecondFactorList = AllowedSecondFactorList::ofTypes([
new SecondFactorType('sms'),
@@ -39,7 +42,7 @@ public function an_allowed_second_factor_list_deduplicates_its_second_factors_up
$this->assertCount(
1,
iterator_to_array($allowedSecondFactorList),
- 'The AllowedSecondFactorList should have deduplicated its second factors, but it did not'
+ 'The AllowedSecondFactorList should have deduplicated its second factors, but it did not',
);
}
@@ -50,7 +53,7 @@ public function an_allowed_second_factor_list_deduplicates_its_second_factors_up
* @dataProvider availableSecondFactorTypeProvider
* @param $availableSecondFactorType
*/
- public function a_blank_allowed_second_factor_list_allows_all_second_factors($availableSecondFactorType)
+ public function a_blank_allowed_second_factor_list_allows_all_second_factors(\Surfnet\StepupBundle\Value\SecondFactorType $availableSecondFactorType): void
{
$allowedSecondFactorList = AllowedSecondFactorList::blank();
@@ -63,16 +66,16 @@ public function a_blank_allowed_second_factor_list_allows_all_second_factors($av
* @test
* @group domain
*/
- public function an_allowed_second_factor_list_contains_a_given_second_factor()
+ public function an_allowed_second_factor_list_contains_a_given_second_factor(): void
{
$allowedSecondFactorList = AllowedSecondFactorList::ofTypes([new SecondFactorType('sms')]);
- $allowedSecondFactor = new SecondFactorType('sms');
+ $allowedSecondFactor = new SecondFactorType('sms');
$containsSecondFactor = $allowedSecondFactorList->contains($allowedSecondFactor);
$this->assertTrue(
$containsSecondFactor,
- 'An allowed second factor list should contain a listed second factor but it does not'
+ 'An allowed second factor list should contain a listed second factor but it does not',
);
}
@@ -80,16 +83,16 @@ public function an_allowed_second_factor_list_contains_a_given_second_factor()
* @test
* @group domain
*/
- public function an_allowed_second_factor_list_does_not_contain_a_given_second_factor()
+ public function an_allowed_second_factor_list_does_not_contain_a_given_second_factor(): void
{
$allowedSecondFactorList = AllowedSecondFactorList::ofTypes([new SecondFactorType('sms')]);
- $allowedSecondFactor = new SecondFactorType('yubikey');
+ $allowedSecondFactor = new SecondFactorType('yubikey');
$containsSecondFactor = $allowedSecondFactorList->contains($allowedSecondFactor);
$this->assertFalse(
$containsSecondFactor,
- 'An allowed second factor list should not contain a listed second factor but it does'
+ 'An allowed second factor list should not contain a listed second factor but it does',
);
}
@@ -97,7 +100,7 @@ public function an_allowed_second_factor_list_does_not_contain_a_given_second_fa
* @test
* @group domain
*/
- public function an_allowed_second_factor_list_contains_the_given_second_factors()
+ public function an_allowed_second_factor_list_contains_the_given_second_factors(): void
{
$secondFactorTypes = [
new SecondFactorType('sms'),
@@ -115,16 +118,16 @@ public function an_allowed_second_factor_list_contains_the_given_second_factors(
* @test
* @group domain
*/
- public function a_second_factor_on_the_allowed_second_factor_list_is_allowed()
+ public function a_second_factor_on_the_allowed_second_factor_list_is_allowed(): void
{
$allowedSecondFactorList = AllowedSecondFactorList::ofTypes([new SecondFactorType('sms')]);
- $allowedSecondFactor = new SecondFactorType('sms');
+ $allowedSecondFactor = new SecondFactorType('sms');
$isSecondFactorAllowed = $allowedSecondFactorList->allows($allowedSecondFactor);
$this->assertTrue(
$isSecondFactorAllowed,
- 'An allowed second factor list should allow a listed second factor but it does not'
+ 'An allowed second factor list should allow a listed second factor but it does not',
);
}
@@ -132,16 +135,16 @@ public function a_second_factor_on_the_allowed_second_factor_list_is_allowed()
* @test
* @group domain
*/
- public function a_second_factor_not_on_the_allowed_second_factor_list_is_not_allowed()
+ public function a_second_factor_not_on_the_allowed_second_factor_list_is_not_allowed(): void
{
$allowedSecondFactorList = AllowedSecondFactorList::ofTypes([new SecondFactorType('sms')]);
- $disallowedSecondFactor = new SecondFactorType('yubikey');
+ $disallowedSecondFactor = new SecondFactorType('yubikey');
$isSecondFactorAllowed = $allowedSecondFactorList->allows($disallowedSecondFactor);
$this->assertFalse(
$isSecondFactorAllowed,
- 'An allowed second factor list should not allow an unlisted second factor but it does not'
+ 'An allowed second factor list should not allow an unlisted second factor but it does not',
);
}
@@ -153,9 +156,11 @@ public function a_second_factor_not_on_the_allowed_second_factor_list_is_not_all
* @param SecondFactorType[] $firstList
* @param SecondFactorType[] $secondList
*/
- public function allowed_second_factor_lists_with_different_elements_are_not_considered_equal(array $firstList, array $secondList)
- {
- $base = AllowedSecondFactorList::ofTypes($firstList);
+ public function allowed_second_factor_lists_with_different_elements_are_not_considered_equal(
+ array $firstList,
+ array $secondList,
+ ): void {
+ $base = AllowedSecondFactorList::ofTypes($firstList);
$other = AllowedSecondFactorList::ofTypes($secondList);
$this->assertFalse($base->equals($other));
@@ -169,24 +174,26 @@ public function allowed_second_factor_lists_with_different_elements_are_not_cons
* @param SecondFactorType[] $firstList
* @param SecondFactorType[] $secondList
*/
- public function allowed_second_factor_lists_with_the_same_elements_are_considered_equal(array $firstList, array $secondList)
- {
- $base = AllowedSecondFactorList::ofTypes($firstList);
+ public function allowed_second_factor_lists_with_the_same_elements_are_considered_equal(
+ array $firstList,
+ array $secondList,
+ ): void {
+ $base = AllowedSecondFactorList::ofTypes($firstList);
$other = AllowedSecondFactorList::ofTypes($secondList);
$this->assertTrue($base->equals($other));
}
- public function differentAllowedSecondFactorListsProvider()
+ public function differentAllowedSecondFactorListsProvider(): array
{
return [
'Different second factor types' => [
[new SecondFactorType('sms'), new SecondFactorType('tiqr')],
- [new SecondFactorType('yubikey'), new SecondFactorType('tiqr')]
+ [new SecondFactorType('yubikey'), new SecondFactorType('tiqr')],
],
'First list contains second list' => [
[new SecondFactorType('sms'), new SecondFactorType('tiqr'), new SecondFactorType('yubikey')],
- [new SecondFactorType('yubikey')]
+ [new SecondFactorType('yubikey')],
],
'First list is empty' => [
[],
@@ -195,11 +202,11 @@ public function differentAllowedSecondFactorListsProvider()
'Second list is empty' => [
[new SecondFactorType('sms'), new SecondFactorType('tiqr')],
[],
- ]
+ ],
];
}
- public function sameAllowedSecondFactorListsProvider()
+ public function sameAllowedSecondFactorListsProvider(): array
{
return [
'Same second factor types' => [
@@ -217,19 +224,20 @@ public function sameAllowedSecondFactorListsProvider()
'Same second factor types, due to deduplication in first list' => [
[new SecondFactorType('sms'), new SecondFactorType('sms'), new SecondFactorType('tiqr')],
[new SecondFactorType('sms'), new SecondFactorType('tiqr')],
- ]
+ ],
];
}
- public function availableSecondFactorTypeProvider()
+ public function availableSecondFactorTypeProvider(): array
{
$service = new SecondFactorTypeService([
'biometric' => ['loa' => 3],
'tiqr' => ['loa' => 3],
]);
- $secondFactorTypes = array_map(function ($availableSecondFactorType) {
- return [new SecondFactorType($availableSecondFactorType)];
- }, $service->getAvailableSecondFactorTypes());
+ $secondFactorTypes = array_map(
+ fn($availableSecondFactorType): array => [new SecondFactorType($availableSecondFactorType)],
+ $service->getAvailableSecondFactorTypes(),
+ );
return array_combine($service->getAvailableSecondFactorTypes(), $secondFactorTypes);
}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/ContactInformationTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/ContactInformationTest.php
index f18e4cab0..c6fac3bf1 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/ContactInformationTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/ContactInformationTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
- new ContactInformation($invalidValue);
- }
+ use MockeryPHPUnitIntegration;
/**
* @test
* @group domain
*/
- public function two_instances_with_the_same_value_are_equal()
+ public function two_instances_with_the_same_value_are_equal(): void
{
$contactInformation = new ContactInformation('a');
- $theSame = new ContactInformation('a');
- $theSameWithSpaces = new ContactInformation(' a ');
- $different = new ContactInformation('A');
+ $theSame = new ContactInformation('a');
+ $theSameWithSpaces = new ContactInformation(' a ');
+ $different = new ContactInformation('A');
$this->assertTrue($contactInformation->equals($theSame));
$this->assertTrue($contactInformation->equals($theSameWithSpaces));
$this->assertFalse($contactInformation->equals($different));
}
-
- /**
- * dataprovider
- */
- public function invalidValueProvider()
- {
- return [
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
- ];
- }
}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionAuthorizationOptionTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionAuthorizationOptionTest.php
index 4c338c262..8496cf977 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionAuthorizationOptionTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionAuthorizationOptionTest.php
@@ -4,7 +4,7 @@
* Copyright 2018 SURFnet B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
- * you may not select this file except in compliance with the License.
+ * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@@ -18,22 +18,26 @@
namespace Surfnet\Stepup\Tests\Configuration\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
use Surfnet\Stepup\Configuration\Value\Institution;
-use Surfnet\Stepup\Configuration\Value\InstitutionRole;
use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
+use Surfnet\Stepup\Configuration\Value\InstitutionRole;
+use Surfnet\Stepup\Exception\InvalidArgumentException;
class InstitutionAuthorizationOptionTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @var Institution
*/
- private $institution;
+ private Institution $institution;
/**
* @var InstitutionRole
*/
- private $institutionRole;
+ private InstitutionRole $institutionRole;
public function setUp(): void
{
@@ -45,7 +49,7 @@ public function setUp(): void
* @test
* @group domain
*/
- public function institution_entries_are_sorted()
+ public function institution_entries_are_sorted(): void
{
$useRaOption = InstitutionAuthorizationOption::fromInstitutionConfig($this->institutionRole, ['z', 'y', 'x']);
$this->assertEquals(['x', 'y', 'z'], $useRaOption->getInstitutions($this->institution));
@@ -55,10 +59,13 @@ public function institution_entries_are_sorted()
* @test
* @group domain
*/
- public function institution_entries_default_is_own_institution()
+ public function institution_entries_default_is_own_institution(): void
{
$useRaOption1 = InstitutionAuthorizationOption::fromInstitutionConfig($this->institutionRole, null);
- $useRaOption2 = InstitutionAuthorizationOption::fromInstitutionConfig($this->institutionRole, [$this->institution->getInstitution()]);
+ $useRaOption2 = InstitutionAuthorizationOption::fromInstitutionConfig(
+ $this->institutionRole,
+ [$this->institution->getInstitution()],
+ );
$this->assertEquals([$this->institution], $useRaOption1->getInstitutions($this->institution));
$this->assertEquals([$this->institution], $useRaOption2->getInstitutions($this->institution));
}
@@ -68,10 +75,16 @@ public function institution_entries_default_is_own_institution()
* @group domain
* @dataProvider institutionSetComparisonProvider
*/
- public function institution_option_instances_can_be_compared($expectation, $configurationA, $configurationB)
- {
+ public function institution_option_instances_can_be_compared(
+ bool $expectation,
+ ?array $configurationA,
+ ?array $configurationB,
+ ): void {
$useRaOption = InstitutionAuthorizationOption::fromInstitutionConfig($this->institutionRole, $configurationA);
- $secondInstitutionOption = InstitutionAuthorizationOption::fromInstitutionConfig($this->institutionRole, $configurationB);
+ $secondInstitutionOption = InstitutionAuthorizationOption::fromInstitutionConfig(
+ $this->institutionRole,
+ $configurationB,
+ );
$this->assertEquals($expectation, $useRaOption->equals($secondInstitutionOption));
}
@@ -79,9 +92,12 @@ public function institution_option_instances_can_be_compared($expectation, $conf
* @test
* @group domain
*/
- public function can_be_retrieved_json_serializable()
+ public function can_be_retrieved_json_serializable(): void
{
- $institutionOption = InstitutionAuthorizationOption::fromInstitutionConfig($this->institutionRole, ['z', 'y', 'x']);
+ $institutionOption = InstitutionAuthorizationOption::fromInstitutionConfig(
+ $this->institutionRole,
+ ['z', 'y', 'x'],
+ );
$this->assertEquals(['x', 'y', 'z'], $institutionOption->jsonSerialize());
}
@@ -89,7 +105,7 @@ public function can_be_retrieved_json_serializable()
* @test
* @group domain
*/
- public function can_be_retrieved_json_serializable_on_empty_set()
+ public function can_be_retrieved_json_serializable_on_empty_set(): void
{
$institutionOption = InstitutionAuthorizationOption::fromInstitutionConfig($this->institutionRole);
$this->assertEquals(null, $institutionOption->jsonSerialize());
@@ -98,27 +114,20 @@ public function can_be_retrieved_json_serializable_on_empty_set()
/**
* @test
* @group domain
- * @dataProvider invalidConstructorArgumentsProvider
*/
- public function invalid_types_are_rejected_during_construction($arguments)
- {
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
-
- InstitutionAuthorizationOption::fromInstitutionConfig($this->institutionRole, $arguments);
- }
- /**
- * @test
- * @group domain
- */
- public function should_be_set_to_default_if_created_with_own_institution_as_institutions()
+ public function should_be_set_to_default_if_created_with_own_institution_as_institutions(): void
{
$institutions = [
$this->institution,
];
- $option = InstitutionAuthorizationOption::fromInstitutions(InstitutionRole::useRa(), $this->institution, $institutions);
+ $option = InstitutionAuthorizationOption::fromInstitutions(
+ InstitutionRole::useRa(),
+ $this->institution,
+ $institutions,
+ );
$this->assertEquals([$this->institution], $option->getInstitutions($this->institution));
- $this->assertEquals(true, $option->isDefault());
+ $this->assertTrue($option->isDefault());
$this->assertEquals([], $option->getInstitutionSet()->toScalarArray());
}
@@ -126,25 +135,31 @@ public function should_be_set_to_default_if_created_with_own_institution_as_inst
* @test
* @group domain
*/
- public function the_default_value_is_given_institution()
+ public function the_default_value_is_given_institution(): void
{
- $this->assertEquals([$this->institution], InstitutionAuthorizationOption::getDefault($this->institutionRole)->getInstitutions($this->institution));
+ $this->assertEquals(
+ [$this->institution],
+ InstitutionAuthorizationOption::getDefault($this->institutionRole)->getInstitutions($this->institution)
+ );
}
/**
* @test
* @group domain
*/
- public function the_empty_value_is_no_value()
+ public function the_empty_value_is_no_value(): void
{
- $this->assertEquals([], InstitutionAuthorizationOption::getEmpty($this->institutionRole)->getInstitutions($this->institution));
+ $this->assertEquals(
+ [],
+ InstitutionAuthorizationOption::getEmpty($this->institutionRole)->getInstitutions($this->institution)
+ );
}
/**
* @test
* @group domain
*/
- public function the_blank_method_should_return_null()
+ public function the_blank_method_should_return_null(): void
{
$this->assertEquals(null, InstitutionAuthorizationOption::blank());
}
@@ -154,8 +169,11 @@ public function the_blank_method_should_return_null()
* @group domain
* @dataProvider institutionHasInstitutionProvider
*/
- public function the_has_institution_method_should_check_for_institutions($expectation, $institutionList, $institution)
- {
+ public function the_has_institution_method_should_check_for_institutions(
+ bool $expectation,
+ array $institutionList,
+ string $institution,
+ ): void {
$institution = new Institution($institution);
$list = [];
foreach ($institutionList as $inst) {
@@ -167,7 +185,7 @@ public function the_has_institution_method_should_check_for_institutions($expect
}
- public function institutionHasInstitutionProvider()
+ public function institutionHasInstitutionProvider(): array
{
return [
'array-with-institution' => [true, ['a', 'b'], 'a'],
@@ -176,7 +194,7 @@ public function institutionHasInstitutionProvider()
];
}
- public function institutionSetComparisonProvider()
+ public function institutionSetComparisonProvider(): array
{
return [
'both-same-set-of-institutions' => [true, ['a', 'b'], ['a', 'b']],
@@ -188,7 +206,7 @@ public function institutionSetComparisonProvider()
];
}
- public function invalidConstructorArgumentsProvider()
+ public function invalidConstructorArgumentsProvider(): array
{
return [
'cant-be-boolean' => [false],
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionConfigurationIdTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionConfigurationIdTest.php
index f81d339b0..181b6d41e 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionConfigurationIdTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionConfigurationIdTest.php
@@ -18,17 +18,22 @@
namespace Surfnet\Stepup\Tests\Configuration\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
+use StdClass;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
+use Surfnet\Stepup\Exception\InvalidArgumentException;
class InstitutionConfigurationIdTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
*/
- public function two_institution_configuration_ids_created_for_the_different_institution_are_not_equal()
+ public function two_institution_configuration_ids_created_for_the_different_institution_are_not_equal(): void
{
$institutionConfigurationId = InstitutionConfigurationId::from(new Institution('An institution'));
$different = InstitutionConfigurationId::from(new Institution('A different institution'));
@@ -41,11 +46,11 @@ public function two_institution_configuration_ids_created_for_the_different_inst
* @group domain
*
* @dataProvider nonStringOrEmptyStringProvider
- * @param $nonStringOrEmptyString
*/
- public function an_institution_configuration_id_cannot_be_created_from_something_other_than_a_string($nonStringOrEmptyString)
- {
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ public function an_institution_configuration_id_cannot_be_created_from_something_other_than_a_string(
+ string $nonStringOrEmptyString,
+ ): void {
+ $this->expectException(InvalidArgumentException::class);
new InstitutionConfigurationId($nonStringOrEmptyString);
}
@@ -54,9 +59,9 @@ public function an_institution_configuration_id_cannot_be_created_from_something
* @test
* @group domain
*/
- public function an_institution_configuration_id_cannot_be_created_from_something_other_than_a_uuid()
+ public function an_institution_configuration_id_cannot_be_created_from_something_other_than_a_uuid(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
$nonUuid = 'this-is-not-a-uuid';
@@ -67,7 +72,7 @@ public function an_institution_configuration_id_cannot_be_created_from_something
* @test
* @group domain
*/
- public function two_institution_configuration_ids_created_for_the_same_institution_are_equal()
+ public function two_institution_configuration_ids_created_for_the_same_institution_are_equal(): void
{
$institutionConfigurationId = InstitutionConfigurationId::from(new Institution('An institution'));
$same = InstitutionConfigurationId::from(new Institution('An institution'));
@@ -79,7 +84,7 @@ public function two_institution_configuration_ids_created_for_the_same_instituti
* @test
* @group domain
*/
- public function institution_configuration_ids_are_created_case_insensitively_from_institutions()
+ public function institution_configuration_ids_are_created_case_insensitively_from_institutions(): void
{
$mixedCaseInstitution = new Institution('An InStItUtIoN');
$lowerCaseInstitution = new Institution('an institution');
@@ -92,7 +97,7 @@ public function institution_configuration_ids_are_created_case_insensitively_fro
$this->assertTrue(
$isSameId,
'An InstitutionConfigurationId based on an institution with mixed casing'
- . 'should match an InstitutionConfigurationId based on the same institution in lower case'
+ . 'should match an InstitutionConfigurationId based on the same institution in lower case',
);
}
@@ -100,12 +105,12 @@ public function institution_configuration_ids_are_created_case_insensitively_fro
* @test
* @group domain
*/
- public function normalized_institution_configuration_ids_and_unnormalized_institution_configuration_ids_are_the_same()
+ public function normalized_institution_configuration_ids_and_unnormalized_institution_configuration_ids_are_the_same(): void
{
$mixedCaseInstitution = new Institution('An InStItUtIoN');
$unnormalizedInstitutionConfigurationId = InstitutionConfigurationId::from($mixedCaseInstitution);
- $normalizedInstitutionConfigurationId = InstitutionConfigurationId::normalizedFrom($mixedCaseInstitution);
+ $normalizedInstitutionConfigurationId = InstitutionConfigurationId::normalizedFrom($mixedCaseInstitution);
$isSameId = $unnormalizedInstitutionConfigurationId->equals($normalizedInstitutionConfigurationId);
@@ -115,15 +120,11 @@ public function normalized_institution_configuration_ids_and_unnormalized_instit
/**
* dataprovider
*/
- public function nonStringOrEmptyStringProvider()
+ public function nonStringOrEmptyStringProvider(): array
{
return [
'empty string' => [''],
'blank string' => [' '],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionRoleTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionRoleTest.php
index a7493ab24..fa7f8bb09 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionRoleTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionRoleTest.php
@@ -1,10 +1,10 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
new InstitutionRole($arguments);
}
@@ -43,7 +43,7 @@ public function invalid_types_are_rejected_during_construction($arguments)
* @group domain
* @dataProvider institutionTypeProvider
*/
- public function institution_roles_can_be_created_by_type($type)
+ public function institution_roles_can_be_created_by_type(string $type): void
{
$role1 = new InstitutionRole($type);
$role2 = new InstitutionRole($type);
@@ -52,7 +52,7 @@ public function institution_roles_can_be_created_by_type($type)
$this->assertTrue($role1->equals($role2));
}
- public function institutionTypeProvider()
+ public function institutionTypeProvider(): array
{
return [
'use_ra' => ['use_ra'],
@@ -61,7 +61,7 @@ public function institutionTypeProvider()
];
}
- public function invalidConstructorArgumentsProvider()
+ public function invalidConstructorArgumentsProvider(): array
{
return [
'cant-be-boolean' => [false],
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionSetTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionSetTest.php
index bab79904a..2a749c131 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionSetTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionSetTest.php
@@ -1,5 +1,7 @@
expectExceptionMessage("Duplicate entries are not allowed in the InstitutionSet");
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
$institutionB = new Institution('b');
$institutionBDupe = new Institution('b');
@@ -59,10 +64,10 @@ public function duplicate_entries_are_not_allowed()
* @test
* @group domain
*/
- public function duplicate_entries_are_not_allowed_case_insensitive()
+ public function duplicate_entries_are_not_allowed_case_insensitive(): void
{
$this->expectExceptionMessage("Duplicate entries are not allowed in the InstitutionSet");
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
$institutionB = new Institution('b');
$institutionBDupe = new Institution('B');
@@ -74,10 +79,12 @@ public function duplicate_entries_are_not_allowed_case_insensitive()
* @test
* @group domain
*/
- public function only_institutions_can_be_present_in_set()
+ public function only_institutions_can_be_present_in_set(): void
{
- $this->expectExceptionMessage("Invalid argument type: \"Surfnet\Stepup\Configuration\Value\Institution\" expected, \"Surfnet\Stepup\Configuration\Value\Location\" given for \"institutions\"");
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectExceptionMessage(
+ "Invalid argument type: \"Surfnet\Stepup\Configuration\Value\Institution\" expected, \"Surfnet\Stepup\Configuration\Value\Location\" given for \"institutions\"",
+ );
+ $this->expectException(InvalidArgumentException::class);
$institution = new Institution('b');
$location = new Location('Foobar');
@@ -89,7 +96,7 @@ public function only_institutions_can_be_present_in_set()
* @test
* @group domain
*/
- public function factory_method_can_build_from_empty_array()
+ public function factory_method_can_build_from_empty_array(): void
{
$input = [];
$set = InstitutionSet::create($input);
@@ -100,18 +107,18 @@ public function factory_method_can_build_from_empty_array()
* @test
* @group domain
*/
- public function factory_method_can_build_from_array_of_string()
+ public function factory_method_can_build_from_array_of_string(): void
{
$input = [
new Institution('a'),
new Institution('b'),
new Institution('c'),
- new Institution('d')
+ new Institution('d'),
];
$set = InstitutionSet::create($input);
$this->assertEquals(
$input,
- $set->toScalarArray()
+ $set->toScalarArray(),
);
}
@@ -122,12 +129,10 @@ public function factory_method_can_build_from_array_of_string()
* @group domain
* @dataProvider dirtyInstitutionListProvider
*
- *
- * @param array $invalid
*/
- public function factory_method_can_build_from_array_of_string_and_rejects_invalid_types(array $invalid)
+ public function factory_method_can_build_from_array_of_string_and_rejects_invalid_types(array $invalid): void
{
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
InstitutionSet::create($invalid);
}
@@ -136,20 +141,20 @@ public function factory_method_can_build_from_array_of_string_and_rejects_invali
* @test
* @group domain
*/
- public function sets_can_be_compared()
+ public function sets_can_be_compared(): void
{
$input = [
new Institution('a'),
new Institution('b'),
new Institution('c'),
- new Institution('d')
+ new Institution('d'),
];
$set = InstitutionSet::create($input);
$secondSet = InstitutionSet::create($input);
$this->assertTrue($set->equals($secondSet));
}
- public function dirtyInstitutionListProvider()
+ public function dirtyInstitutionListProvider(): array
{
return [
'numeric_entry' => [['a', 1, 'b']],
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionTest.php
index 246c405c6..999341ebb 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/InstitutionTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ public function an_institution_cannot_be_created_with_anything_but_a_nonempty_string(
+ string $invalidValue,
+ ): void {
+ $this->expectException(InvalidArgumentException::class);
new Institution($invalidValue);
}
@@ -40,27 +45,23 @@ public function an_institution_cannot_be_created_with_anything_but_a_nonempty_st
* @test
* @group domain
*/
- public function two_institutions_with_the_same_value_are_equal()
+ public function two_institutions_with_the_same_value_are_equal(): void
{
- $institution = new Institution('a');
- $theSame = new Institution('a');
+ $institution = new Institution('a');
+ $theSame = new Institution('a');
$theSameWithSpaces = new Institution(' a ');
- $different = new Institution('A');
+ $different = new Institution('A');
$this->assertTrue($institution->equals($theSame));
$this->assertTrue($institution->equals($theSameWithSpaces));
$this->assertTrue($institution->equals($different));
}
- public function nonStringOrNonEmptyStringProvider()
+ public function nonStringOrNonEmptyStringProvider(): array
{
return [
'empty string' => [''],
'blank string' => [' '],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/LocationTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/LocationTest.php
index 6d813febf..a85043c1d 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/LocationTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/LocationTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
-
- new Location($nonString);
- }
+ use MockeryPHPUnitIntegration;
/**
* @test
* @group domain
*/
- public function two_locations_with_the_same_value_are_equal()
+ public function two_locations_with_the_same_value_are_equal(): void
{
- $location = new Location('a');
- $theSame = new Location('a');
+ $location = new Location('a');
+ $theSame = new Location('a');
$theSameWithSpaces = new Location(' a ');
- $different = new Location('A');
+ $different = new Location('A');
$this->assertTrue($location->equals($theSame));
$this->assertTrue($location->equals($theSameWithSpaces));
$this->assertFalse($location->equals($different));
}
-
- /**
- * dataprovider
- */
- public function nonStringProvider()
- {
- return [
- 'null' => [null],
- 'boolean' => [false],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \stdClass()],
- ];
- }
}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationIdTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationIdTest.php
index 720977b34..4cc9b255b 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationIdTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationIdTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ public function an_ra_location_id_cannot_be_created_with_anything_but_a_nonempty_string(
+ string $nonStringOrEmptyString,
+ ): void {
+ $this->expectException(InvalidArgumentException::class);
new RaLocationId($nonStringOrEmptyString);
}
+
/**
* @test
* @group domain
*/
- public function an_ra_location_id_cannot_be_created_with_anything_but_a_uuid()
+ public function an_ra_location_id_cannot_be_created_with_anything_but_a_uuid(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
$nonUuid = 'this-is-not-a-uuid';
@@ -54,12 +60,12 @@ public function an_ra_location_id_cannot_be_created_with_anything_but_a_uuid()
* @test
* @group domain
*/
- public function two_ra_location_ids_with_the_same_values_are_equal()
+ public function two_ra_location_ids_with_the_same_values_are_equal(): void
{
- $uuid = self::uuid();
+ $uuid = $this->uuid();
$raLocationId = new RaLocationId($uuid);
- $theSame = new RaLocationId($uuid);
+ $theSame = new RaLocationId($uuid);
$this->assertTrue($raLocationId->equals($theSame));
}
@@ -68,27 +74,24 @@ public function two_ra_location_ids_with_the_same_values_are_equal()
* @test
* @group domain
*/
- public function two_ra_location_ids_with_different_values_are_not_equal()
+ public function two_ra_location_ids_with_different_values_are_not_equal(): void
{
- $raLocationId = new RaLocationId(self::uuid());
- $different = new RaLocationId(self::uuid());
+ $raLocationId = new RaLocationId($this->uuid());
+ $different = new RaLocationId($this->uuid());
$this->assertFalse($raLocationId->equals($different));
}
- public function nonStringOrEmptyStringProvider()
+ public function nonStringOrEmptyStringProvider(): array
{
return [
'empty string' => [''],
'blank string' => [' '],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
- private static function uuid() {
- return (string) Uuid::uuid4();
+ private function uuid(): string
+ {
+ return (string)Uuid::uuid4();
}
}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationListTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationListTest.php
index e7c962b21..497d6febe 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationListTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationListTest.php
@@ -18,30 +18,34 @@
namespace Surfnet\Stepup\Tests\Configuration\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
-use Rhumsaa\Uuid\Uuid;
-use Surfnet\Stepup\Configuration\Value\ContactInformation;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Configuration\Entity\RaLocation;
+use Surfnet\Stepup\Configuration\Value\ContactInformation;
use Surfnet\Stepup\Configuration\Value\Location;
use Surfnet\Stepup\Configuration\Value\RaLocationId;
-use Surfnet\Stepup\Configuration\Value\RaLocationName;
use Surfnet\Stepup\Configuration\Value\RaLocationList;
+use Surfnet\Stepup\Configuration\Value\RaLocationName;
+use Surfnet\Stepup\Exception\LogicException;
class RaLocationListTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
*/
- public function an_ra_location_list_does_not_allow_ra_locations_with_the_same_ra_location_id_upon_creation()
+ public function an_ra_location_list_does_not_allow_ra_locations_with_the_same_ra_location_id_upon_creation(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\LogicException::class);
+ $this->expectException(LogicException::class);
$this->expectExceptionMessage('Cannot add');
$raLocations = $this->getRaLocationsArray();
$existingRaLocation = $raLocations[0];
- array_push($raLocations, $existingRaLocation);
+ $raLocations[] = $existingRaLocation;
new RaLocationList($raLocations);
}
@@ -49,9 +53,9 @@ public function an_ra_location_list_does_not_allow_ra_locations_with_the_same_ra
* @test
* @group domain
*/
- public function an_ra_location_list_does_not_allow_adding_ra_locations_with_an_ra_location_id_that_is_already_present()
+ public function an_ra_location_list_does_not_allow_adding_ra_locations_with_an_ra_location_id_that_is_already_present(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\LogicException::class);
+ $this->expectException(LogicException::class);
$this->expectExceptionMessage('Cannot add');
$raLocations = $this->getRaLocationsArray();
@@ -65,7 +69,7 @@ public function an_ra_location_list_does_not_allow_adding_ra_locations_with_an_r
* @test
* @group domain
*/
- public function an_ra_location_list_is_created_from_ra_locations()
+ public function an_ra_location_list_is_created_from_ra_locations(): void
{
$raLocations = $this->getRaLocationsArray();
@@ -79,7 +83,7 @@ public function an_ra_location_list_is_created_from_ra_locations()
* @test
* @group domain
*/
- public function an_ra_location_list_has_an_ra_location_with_a_given_ra_location_id()
+ public function an_ra_location_list_has_an_ra_location_with_a_given_ra_location_id(): void
{
$raLocations = $this->getRaLocationsArray();
$expectedRaLocationIdToBePresent = $raLocations[0]->getId();
@@ -93,10 +97,10 @@ public function an_ra_location_list_has_an_ra_location_with_a_given_ra_location_
* @test
* @group domain
*/
- public function an_ra_location_list_does_not_have_ra_locations_with_a_non_present_ra_location_id()
+ public function an_ra_location_list_does_not_have_ra_locations_with_a_non_present_ra_location_id(): void
{
$raLocations = $this->getRaLocationsArray();
- $expectedRaLocationIdNotToBePresent = new RaLocationId((string) Uuid::uuid4());
+ $expectedRaLocationIdNotToBePresent = new RaLocationId((string)Uuid::uuid4());
$raLocationList = new RaLocationList($raLocations);
@@ -107,7 +111,7 @@ public function an_ra_location_list_does_not_have_ra_locations_with_a_non_presen
* @test
* @group domain
*/
- public function an_ra_location_is_added_to_an_ra_location_list()
+ public function an_ra_location_is_added_to_an_ra_location_list(): void
{
$raLocations = $this->getRaLocationsArray();
@@ -123,7 +127,7 @@ public function an_ra_location_is_added_to_an_ra_location_list()
* @test
* @group domain
*/
- public function an_ra_location_is_removed_from_an_ra_location_list_by_its_ra_location_id()
+ public function an_ra_location_is_removed_from_an_ra_location_list_by_its_ra_location_id(): void
{
$raLocations = $this->getRaLocationsArray();
$raLocationToRemove = $raLocations[0];
@@ -137,20 +141,20 @@ public function an_ra_location_is_removed_from_an_ra_location_list_by_its_ra_loc
$this->assertEquals($expectOnlyTheSecondRaLocation, $raLocationListAsArray);
}
- protected function getRaLocationsArray()
+ protected function getRaLocationsArray(): array
{
return [
RaLocation::create(
- new RaLocationId((string) Uuid::uuid4()),
+ new RaLocationId((string)Uuid::uuid4()),
new RaLocationName('An RA location name'),
new Location('A location'),
- new ContactInformation('Contact Information')
+ new ContactInformation('Contact Information'),
),
RaLocation::create(
- new RaLocationId((string) Uuid::uuid4()),
+ new RaLocationId((string)Uuid::uuid4()),
new RaLocationName('Another RA location name'),
new Location('Another location'),
- new ContactInformation('Some more contact Information')
+ new ContactInformation('Some more contact Information'),
),
];
}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationNameTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationNameTest.php
index 27b608e22..5fdf4714c 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationNameTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/RaLocationNameTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ public function an_ra_location_name_cannot_be_created_with_anything_but_a_nonempty_string(
+ string $nonStringOrEmptyString,
+ ): void {
+ $this->expectException(InvalidArgumentException::class);
new RaLocationName($nonStringOrEmptyString);
}
@@ -41,10 +46,10 @@ public function an_ra_location_name_cannot_be_created_with_anything_but_a_nonemp
* @test
* @group domain
*/
- public function two_ra_location_names_with_the_same_values_are_equal()
+ public function two_ra_location_names_with_the_same_values_are_equal(): void
{
$raLocationName = new RaLocationName('a');
- $theSame = new RaLocationName('a');
+ $theSame = new RaLocationName('a');
$this->assertTrue($raLocationName->equals($theSame));
}
@@ -53,23 +58,19 @@ public function two_ra_location_names_with_the_same_values_are_equal()
* @test
* @group domain
*/
- public function two_ra_location_names_with_different_values_are_not_equal()
+ public function two_ra_location_names_with_different_values_are_not_equal(): void
{
$raLocationName = new RaLocationName('a');
- $different = new RaLocationName('A');
+ $different = new RaLocationName('A');
$this->assertFalse($raLocationName->equals($different));
}
- public function nonStringOrEmptyStringProvider()
+ public function nonStringOrEmptyStringProvider(): array
{
return [
'empty string' => [''],
'blank string' => [' '],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/ShowRaaContactInformationOptionTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/ShowRaaContactInformationOptionTest.php
index 7fedba303..efa48b195 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/ShowRaaContactInformationOptionTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/ShowRaaContactInformationOptionTest.php
@@ -18,37 +18,27 @@
namespace Surfnet\Stepup\Tests\Configuration\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
+use StdClass;
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption;
+use Surfnet\Stepup\Exception\InvalidArgumentException;
class ShowRaaContactInformationOptionTest extends TestCase
{
- /**
- * @test
- * @group domain
- * @group institution-configuration-option
- * @dataProvider nonBooleanProvider
- *
- * @param mixed $nonBooleanProvider
- */
- public function show_raa_contact_information_option_can_only_be_boolean($nonBooleanProvider)
- {
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
-
- new ShowRaaContactInformationOption($nonBooleanProvider);
- }
+ use MockeryPHPUnitIntegration;
/**
* @test
* @group domain
* @group institution-configuration-option
*/
- public function two_show_raa_contact_information_options_with_the_same_values_are_equal()
+ public function two_show_raa_contact_information_options_with_the_same_values_are_equal(): void
{
$option = true;
$showRaaContactInformationOption = new ShowRaaContactInformationOption($option);
- $theSame = new ShowRaaContactInformationOption($option);
+ $theSame = new ShowRaaContactInformationOption($option);
$this->assertTrue($showRaaContactInformationOption->equals($theSame));
}
@@ -58,10 +48,10 @@ public function two_show_raa_contact_information_options_with_the_same_values_ar
* @group domain
* @group institution-configuration-option
*/
- public function two_show_raa_contact_information_options_with_different_values_are_not_equal()
+ public function two_show_raa_contact_information_options_with_different_values_are_not_equal(): void
{
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $different = new ShowRaaContactInformationOption(false);
+ $different = new ShowRaaContactInformationOption(false);
$this->assertFalse($showRaaContactInformationOption->equals($different));
}
@@ -71,22 +61,11 @@ public function two_show_raa_contact_information_options_with_different_values_a
* @group domain
* @group institution-configuration-option
*/
- public function default_value_is_true()
+ public function default_value_is_true(): void
{
$default = ShowRaaContactInformationOption::getDefault();
$true = new ShowRaaContactInformationOption(true);
$this->assertTrue($default->equals($true));
}
-
- public function nonBooleanProvider()
- {
- return [
- 'string' => [''],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
- ];
- }
}
diff --git a/src/Surfnet/Stepup/Tests/Configuration/Value/UseRaLocationsOptionTest.php b/src/Surfnet/Stepup/Tests/Configuration/Value/UseRaLocationsOptionTest.php
index 2261bfbe9..f6f5fa259 100644
--- a/src/Surfnet/Stepup/Tests/Configuration/Value/UseRaLocationsOptionTest.php
+++ b/src/Surfnet/Stepup/Tests/Configuration/Value/UseRaLocationsOptionTest.php
@@ -18,37 +18,27 @@
namespace Surfnet\Stepup\Tests\Configuration\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
+use StdClass;
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption;
+use Surfnet\Stepup\Exception\InvalidArgumentException;
class UseRaLocationsOptionTest extends TestCase
{
- /**
- * @test
- * @group domain
- * @group institution-configuration-option
- * @dataProvider nonBooleanProvider
- *
- * @param mixed $nonBooleanProvider
- */
- public function use_ra_locations_option_can_only_be_boolean($nonBooleanProvider)
- {
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
-
- new UseRaLocationsOption($nonBooleanProvider);
- }
+ use MockeryPHPUnitIntegration;
/**
* @test
* @group domain
* @group institution-configuration-option
*/
- public function two_use_ra_location_options_with_the_same_values_are_equal()
+ public function two_use_ra_location_options_with_the_same_values_are_equal(): void
{
$option = true;
$useRaLocationsOption = new UseRaLocationsOption($option);
- $theSame = new UseRaLocationsOption($option);
+ $theSame = new UseRaLocationsOption($option);
$this->assertTrue($useRaLocationsOption->equals($theSame));
}
@@ -58,10 +48,10 @@ public function two_use_ra_location_options_with_the_same_values_are_equal()
* @group domain
* @group institution-configuration-option
*/
- public function two_use_ra_location_options_with_different_values_are_not_equal()
+ public function two_use_ra_location_options_with_different_values_are_not_equal(): void
{
$useRaLocationsOption = new UseRaLocationsOption(true);
- $different = new UseRaLocationsOption(false);
+ $different = new UseRaLocationsOption(false);
$this->assertFalse($useRaLocationsOption->equals($different));
}
@@ -71,22 +61,11 @@ public function two_use_ra_location_options_with_different_values_are_not_equal(
* @group domain
* @group institution-configuration-option
*/
- public function default_value_is_false()
+ public function default_value_is_false(): void
{
$default = UseRaLocationsOption::getDefault();
- $false = new UseRaLocationsOption(false);
+ $false = new UseRaLocationsOption(false);
$this->assertTrue($default->equals($false));
- }
-
- public function nonBooleanProvider()
- {
- return [
- 'string' => [''],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
- ];
- }
+ }
}
diff --git a/src/Surfnet/Stepup/Tests/DateTime/DateTimeTest.php b/src/Surfnet/Stepup/Tests/DateTime/DateTimeTest.php
index e7d8f2afb..26b96c80c 100644
--- a/src/Surfnet/Stepup/Tests/DateTime/DateTimeTest.php
+++ b/src/Surfnet/Stepup/Tests/DateTime/DateTimeTest.php
@@ -20,11 +20,14 @@
use DateInterval;
use DateTime as CoreDateTime;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\DateTime\DateTime;
class DateTimeTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* Might seem a bit overdone, but we rely on this specific format in quite a bit of places. If the format changes
* this might lead to some unforeseen errors. This ensures that if the format is changed, this test fails and
@@ -34,7 +37,7 @@ class DateTimeTest extends UnitTest
* @test
* @group domain
*/
- public function the_configured_format_is_what_is_needed_for_correct_application_behavior()
+ public function the_configured_format_is_what_is_needed_for_correct_application_behavior(): void
{
$this->assertEquals('Y-m-d\\TH:i:sP', DateTime::FORMAT);
}
@@ -46,21 +49,21 @@ public function the_configured_format_is_what_is_needed_for_correct_application_
* @test
* @group domain
*/
- public function to_string_returns_the_time_in_the_correct_format()
+ public function to_string_returns_the_time_in_the_correct_format(): void
{
$coreDateTimeObject = new CoreDateTime('@1000');
- $ourDateTimeObject = new DateTime(new CoreDateTime('@1000'));
+ $ourDateTimeObject = new DateTime(new CoreDateTime('@1000'));
- $this->assertEquals($coreDateTimeObject->format(DateTime::FORMAT), (string) $ourDateTimeObject);
+ $this->assertEquals($coreDateTimeObject->format(DateTime::FORMAT), (string)$ourDateTimeObject);
}
/**
* @test
* @group domain
*/
- public function add_returns_a_different_object_that_has_the_interval_added()
+ public function add_returns_a_different_object_that_has_the_interval_added(): void
{
- $base = new DateTime(new CoreDateTime('@1000'));
+ $base = new DateTime(new CoreDateTime('@1000'));
$interval = new DateInterval('PT1S');
$result = $base->add($interval);
@@ -73,9 +76,9 @@ public function add_returns_a_different_object_that_has_the_interval_added()
* @test
* @group domain
*/
- public function sub_returns_a_different_object_that_has_the_interval_substracted()
+ public function sub_returns_a_different_object_that_has_the_interval_substracted(): void
{
- $base = new DateTime(new CoreDateTime('@1000'));
+ $base = new DateTime(new CoreDateTime('@1000'));
$interval = new DateInterval('PT1S');
$result = $base->sub($interval);
@@ -88,12 +91,12 @@ public function sub_returns_a_different_object_that_has_the_interval_substracted
* @test
* @group domain
*/
- public function comes_before_works_with_exclusive_comparison()
+ public function comes_before_works_with_exclusive_comparison(): void
{
- $base = new DateTime(new CoreDateTime('@1000'));
+ $base = new DateTime(new CoreDateTime('@1000'));
$before = new DateTime(new CoreDateTime('@999'));
- $same = new DateTime(new CoreDateTime('@1000'));
- $after = new DateTime(new CoreDateTime('@1001'));
+ $same = new DateTime(new CoreDateTime('@1000'));
+ $after = new DateTime(new CoreDateTime('@1001'));
$this->assertTrue($before->comesBefore($base));
$this->assertFalse($same->comesBefore($base));
@@ -104,12 +107,12 @@ public function comes_before_works_with_exclusive_comparison()
* @test
* @group domain
*/
- public function comes_before_or_is_equal_works_with_inclusive_comparison()
+ public function comes_before_or_is_equal_works_with_inclusive_comparison(): void
{
- $base = new DateTime(new CoreDateTime('@1000'));
+ $base = new DateTime(new CoreDateTime('@1000'));
$before = new DateTime(new CoreDateTime('@999'));
- $same = new DateTime(new CoreDateTime('@1000'));
- $after = new DateTime(new CoreDateTime('@1001'));
+ $same = new DateTime(new CoreDateTime('@1000'));
+ $after = new DateTime(new CoreDateTime('@1001'));
$this->assertTrue($before->comesBeforeOrIsEqual($base));
$this->assertTrue($same->comesBeforeOrIsEqual($base));
@@ -120,12 +123,12 @@ public function comes_before_or_is_equal_works_with_inclusive_comparison()
* @test
* @group domain
*/
- public function comes_after_works_with_exclusive_comparison()
+ public function comes_after_works_with_exclusive_comparison(): void
{
- $base = new DateTime(new CoreDateTime('@1000'));
+ $base = new DateTime(new CoreDateTime('@1000'));
$before = new DateTime(new CoreDateTime('@999'));
- $same = new DateTime(new CoreDateTime('@1000'));
- $after = new DateTime(new CoreDateTime('@1001'));
+ $same = new DateTime(new CoreDateTime('@1000'));
+ $after = new DateTime(new CoreDateTime('@1001'));
$this->assertFalse($before->comesAfter($base));
$this->assertFalse($same->comesAfter($base));
@@ -136,12 +139,12 @@ public function comes_after_works_with_exclusive_comparison()
* @test
* @group domain
*/
- public function comes_after_or_is_equal_works_with_inclusive_comparison()
+ public function comes_after_or_is_equal_works_with_inclusive_comparison(): void
{
- $base = new DateTime(new CoreDateTime('@1000'));
+ $base = new DateTime(new CoreDateTime('@1000'));
$before = new DateTime(new CoreDateTime('@999'));
- $same = new DateTime(new CoreDateTime('@1000'));
- $after = new DateTime(new CoreDateTime('@1001'));
+ $same = new DateTime(new CoreDateTime('@1000'));
+ $after = new DateTime(new CoreDateTime('@1001'));
$this->assertFalse($before->comesAfterOrIsEqual($base));
$this->assertTrue($same->comesAfterOrIsEqual($base));
diff --git a/src/Surfnet/Stepup/Tests/Helper/JsonHelperTest.php b/src/Surfnet/Stepup/Tests/Helper/JsonHelperTest.php
index 59917fa82..6d7f1b128 100644
--- a/src/Surfnet/Stepup/Tests/Helper/JsonHelperTest.php
+++ b/src/Surfnet/Stepup/Tests/Helper/JsonHelperTest.php
@@ -18,35 +18,25 @@
namespace Surfnet\Stepup\Tests\Helper;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
+use StdClass;
use Surfnet\Stepup\Exception\InvalidArgumentException;
use Surfnet\Stepup\Exception\JsonException;
use Surfnet\Stepup\Helper\JsonHelper;
class JsonHelperTest extends TestCase
{
- /**
- * @test
- * @group json
- *
- * @dataProvider nonStringProvider
- * @param $nonString
- */
- public function json_helper_can_only_decode_strings($nonString)
- {
- $this->expectException(InvalidArgumentException::class);
-
- JsonHelper::decode($nonString);
- }
+ use MockeryPHPUnitIntegration;
/**
* @test
* @group json
*/
- public function json_helper_decodes_strings_to_arrays()
+ public function json_helper_decodes_strings_to_arrays(): void
{
$expectedDecodedResult = ['hello' => 'world'];
- $json = '{ "hello" : "world" }';
+ $json = '{ "hello" : "world" }';
$actualDecodedResult = JsonHelper::decode($json);
@@ -57,7 +47,7 @@ public function json_helper_decodes_strings_to_arrays()
* @test
* @group json
*/
- public function json_helper_throws_an_exception_when_there_is_a_syntax_error()
+ public function json_helper_throws_an_exception_when_there_is_a_syntax_error(): void
{
$this->expectException(JsonException::class);
$this->expectExceptionMessage('Syntax error');
@@ -67,14 +57,14 @@ public function json_helper_throws_an_exception_when_there_is_a_syntax_error()
JsonHelper::decode($jsonWithMissingDoubleQuotes);
}
- public function nonStringProvider()
+ public function nonStringProvider(): array
{
return [
'boolean' => [true],
- 'array' => [[]],
+ 'array' => [[]],
'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
+ 'float' => [1.2],
+ 'object' => [new StdClass()],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Helper/UserDataFilterTest.php b/src/Surfnet/Stepup/Tests/Helper/UserDataFilterTest.php
index 749b1f591..0241bcc53 100644
--- a/src/Surfnet/Stepup/Tests/Helper/UserDataFilterTest.php
+++ b/src/Surfnet/Stepup/Tests/Helper/UserDataFilterTest.php
@@ -18,6 +18,9 @@
namespace Surfnet\Stepup\Tests\Helper;
+use DateTime as CoreDateTime;
+use Generator;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
use Surfnet\Stepup\DateTime\DateTime;
use Surfnet\Stepup\Helper\UserDataFilter;
@@ -37,17 +40,21 @@
class UserDataFilterTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @dataProvider provideEvents
*/
- public function test_filtering_is_applied_with_expected_result($event, $expectation)
- {
+ public function test_filtering_is_applied_with_expected_result(
+ IdentityCreatedEvent|PhonePossessionProvenAndVerifiedEvent|AppointedAsRaaForInstitutionEvent|PhonePossessionProvenEvent $event,
+ array $expectation,
+ ): void {
$helper = new UserDataFilter();
$data = $helper->filter($event);
$this->assertSame($expectation, array_keys($data));
}
- public function provideEvents()
+ public function provideEvents(): Generator
{
$event = new IdentityCreatedEvent(
new IdentityId("id"),
@@ -55,7 +62,7 @@ public function provideEvents()
new NameId("nameId"),
new CommonName("commonName"),
new Email("test@institution.nl"),
- new Locale("nl_NL")
+ new Locale("nl_NL"),
);
$expectation = [
'id',
@@ -76,7 +83,7 @@ public function provideEvents()
new Email("test@example.com"),
new Locale("nl_NL"),
new DateTime(),
- "Y3MWWNDR"
+ "Y3MWWNDR",
);
$expectation = [
'identity_id',
@@ -95,7 +102,7 @@ public function provideEvents()
new IdentityId("id"),
new Institution("institution"),
new NameId("nameId"),
- new Institution("ra")
+ new Institution("ra"),
);
$expectation = [
'identity_id',
@@ -111,11 +118,11 @@ public function provideEvents()
new SecondFactorId("52"),
new PhoneNumber("+0 (0) 000000000"),
true,
- emailVerificationWindow::createWindowFromTill(new DateTime(), new DateTime()),
+ EmailVerificationWindow::createWindowFromTill(new DateTime(), new DateTime(new CoreDateTime('+5 minute'))),
"30c0fcb136bf324eea652d5b86c1a08c",
new CommonName("commonname"),
new Email("test@example.com"),
- new Locale("nl_NL")
+ new Locale("nl_NL"),
);
$expectation = [
'identity_id',
@@ -129,6 +136,4 @@ public function provideEvents()
];
yield [$event, $expectation];
}
-
-
}
diff --git a/src/Surfnet/Stepup/Tests/Helper/UserDataFormatterTest.php b/src/Surfnet/Stepup/Tests/Helper/UserDataFormatterTest.php
index 8f3a33fd6..369af5275 100644
--- a/src/Surfnet/Stepup/Tests/Helper/UserDataFormatterTest.php
+++ b/src/Surfnet/Stepup/Tests/Helper/UserDataFormatterTest.php
@@ -18,12 +18,15 @@
namespace Surfnet\Stepup\Tests\Helper;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
use Surfnet\Stepup\Helper\UserDataFormatter;
class UserDataFormatterTest extends TestCase
{
- public function test_data_is_formatted()
+ use MockeryPHPUnitIntegration;
+
+ public function test_data_is_formatted(): void
{
$formatter = new UserDataFormatter('Stepup-Middleware');
$expected = [
@@ -33,7 +36,7 @@ public function test_data_is_formatted()
['name' => 'name2', 'value' => 'some-value-2'],
['name' => 'name3', 'value' => 'some-value-3'],
],
- 'name' => 'Stepup-Middleware'
+ 'name' => 'Stepup-Middleware',
];
$inputData = [
@@ -45,7 +48,7 @@ public function test_data_is_formatted()
$this->assertEquals($expected, $formatter->format($inputData, []));
}
- public function test_errors_are_included_in_output()
+ public function test_errors_are_included_in_output(): void
{
$formatter = new UserDataFormatter('Stepup-Middleware');
$expected = [
@@ -55,19 +58,20 @@ public function test_errors_are_included_in_output()
],
'name' => 'Stepup-Middleware',
'message' => [
- 'The application is teetering on the edge of catastrophe!'
- ]
+ 'The application is teetering on the edge of catastrophe!',
+ ],
];
$inputData = [
'foobar-name1' => 'some-value-1',
];
- $this->assertEquals($expected,
+ $this->assertEquals(
+ $expected,
$formatter->format(
$inputData,
- ['The application is teetering on the edge of catastrophe!']
- )
+ ['The application is teetering on the edge of catastrophe!'],
+ ),
);
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Collection/InstitutionCollectionTest.php b/src/Surfnet/Stepup/Tests/Identity/Collection/InstitutionCollectionTest.php
index 958b20ae5..fbd4f5e00 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Collection/InstitutionCollectionTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Collection/InstitutionCollectionTest.php
@@ -18,18 +18,22 @@
namespace Surfnet\Stepup\Tests\Identity\Collection;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
+use Surfnet\Stepup\Exception\RuntimeException;
use Surfnet\Stepup\Identity\Collection\InstitutionCollection;
use Surfnet\Stepup\Identity\Value\Institution;
class InstitutionCollectionTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
* @group whitelist
*/
- public function it_can_be_constructed_with_or_without_institutions()
+ public function it_can_be_constructed_with_or_without_institutions(): void
{
$collection1 = new InstitutionCollection($this->getInstitutions());
$collection2 = new InstitutionCollection();
@@ -43,7 +47,7 @@ public function it_can_be_constructed_with_or_without_institutions()
* @group domain
* @group whitelist
*/
- public function it_correctly_asserts_whether_or_not_it_contains_an_institution()
+ public function it_correctly_asserts_whether_or_not_it_contains_an_institution(): void
{
$institutions = $this->getInstitutions();
@@ -61,7 +65,7 @@ public function it_correctly_asserts_whether_or_not_it_contains_an_institution()
* @group domain
* @group whitelist
*/
- public function it_allows_to_add_an_institution_that_it_does_not_already_contain()
+ public function it_allows_to_add_an_institution_that_it_does_not_already_contain(): void
{
$toAdd = new Institution('to be added');
@@ -76,9 +80,9 @@ public function it_allows_to_add_an_institution_that_it_does_not_already_contain
* @group domain
* @group whitelist
*/
- public function an_institution_already_in_the_collection_cannot_be_added()
+ public function an_institution_already_in_the_collection_cannot_be_added(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\RuntimeException::class);
+ $this->expectException(RuntimeException::class);
$institutions = $this->getInstitutions();
$alreadyExists = $institutions[0];
@@ -93,9 +97,9 @@ public function an_institution_already_in_the_collection_cannot_be_added()
* @group domain
* @group whitelist
*/
- public function an_institution_in_the_collection_can_be_removed()
+ public function an_institution_in_the_collection_can_be_removed(): void
{
- $institutions = $this->getInstitutions();
+ $institutions = $this->getInstitutions();
$inCollection = $institutions[0];
$institutionCollection = new InstitutionCollection($institutions);
@@ -111,9 +115,9 @@ public function an_institution_in_the_collection_can_be_removed()
* @group whitelist
*
*/
- public function an_institution_not_in_the_collection_cannot_be_removed()
+ public function an_institution_not_in_the_collection_cannot_be_removed(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\RuntimeException::class);
+ $this->expectException(RuntimeException::class);
$institutions = $this->getInstitutions();
$notInCollection = new Institution('not in the collection');
@@ -129,7 +133,7 @@ public function an_institution_not_in_the_collection_cannot_be_removed()
* @group domain
* @group whitelist
*/
- public function multiple_institutions_can_be_added_from_another_collection()
+ public function multiple_institutions_can_be_added_from_another_collection(): void
{
$institutions = $this->getInstitutions();
$collectionOneElements = [$institutions[0], $institutions[1]];
@@ -150,7 +154,7 @@ public function multiple_institutions_can_be_added_from_another_collection()
* @group domain
* @group whitelist
*/
- public function multiple_institutions_can_be_removed()
+ public function multiple_institutions_can_be_removed(): void
{
$collectionOneElements = $this->getInstitutions();
$collectionTwoElements = [$collectionOneElements[0], $collectionOneElements[2]];
@@ -168,7 +172,7 @@ public function multiple_institutions_can_be_removed()
/**
* @return array
*/
- private function getInstitutions()
+ private function getInstitutions(): array
{
static $institutions;
diff --git a/src/Surfnet/Stepup/Tests/Identity/Entity/ConfigurableSettingsTest.php b/src/Surfnet/Stepup/Tests/Identity/Entity/ConfigurableSettingsTest.php
index 853bcbffe..1105eb676 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Entity/ConfigurableSettingsTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Entity/ConfigurableSettingsTest.php
@@ -19,6 +19,7 @@
namespace Surfnet\Stepup\Tests\Identity\Entity;
use DateTime as CoreDateTime;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\DateTime\DateTime;
use Surfnet\Stepup\Identity\Entity\ConfigurableSettings;
@@ -27,11 +28,13 @@
class ConfigurableSettingsTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
*/
- public function a_new_email_verification_window_always_starts_now()
+ public function a_new_email_verification_window_always_starts_now(): void
{
$settings = ConfigurableSettings::create(3, []);
@@ -53,13 +56,13 @@ public function a_new_email_verification_window_always_starts_now()
$this->assertTrue($secondWindow->isOpen());
}
- public function localeVerifications()
+ public function localeVerifications(): array
{
return [
- 'No app locales, false' => [false, 'nl_NL', []],
- 'English app locale, Dutch locale, false' => [false, 'nl_NL', ['en_GB']],
- 'English, German app locales, Dutch locale, false' => [false, 'nl_NL', ['en_GB', 'de_DE']],
- 'English, Dutch app locales, Dutch locale, true' => [true, 'nl_NL', ['en_GB', 'nl_NL']],
+ 'No app locales, false' => [false, 'nl_NL', []],
+ 'English app locale, Dutch locale, false' => [false, 'nl_NL', ['en_GB']],
+ 'English, German app locales, Dutch locale, false' => [false, 'nl_NL', ['en_GB', 'de_DE']],
+ 'English, Dutch app locales, Dutch locale, true' => [true, 'nl_NL', ['en_GB', 'nl_NL']],
];
}
@@ -67,12 +70,13 @@ public function localeVerifications()
* @test
* @group domain
* @dataProvider localeVerifications
- * @param boolean $isValid
- * @param string $localeString
* @param string[] $validLocaleStrings
*/
- public function a_locale_can_be_verified_to_be_a_valid_locale($isValid, $localeString, array $validLocaleStrings)
- {
+ public function a_locale_can_be_verified_to_be_a_valid_locale(
+ bool $isValid,
+ string $localeString,
+ array $validLocaleStrings,
+ ): void {
$configuration = ConfigurableSettings::create(3, $validLocaleStrings);
$this->assertEquals($isValid, $configuration->isSupportedLocale(new Locale($localeString)));
diff --git a/src/Surfnet/Stepup/Tests/Identity/Entity/SecondFactorCollectionTest.php b/src/Surfnet/Stepup/Tests/Identity/Entity/SecondFactorCollectionTest.php
index 142f748fb..e74740015 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Entity/SecondFactorCollectionTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Entity/SecondFactorCollectionTest.php
@@ -19,19 +19,25 @@
namespace Surfnet\Stepup\Tests\Identity\Entity;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
-use Surfnet\Stepup\Identity\Entity\SecondFactorCollection;
use Surfnet\Stepup\Identity\Entity\SecondFactor;
+use Surfnet\Stepup\Identity\Entity\SecondFactorCollection;
+use Surfnet\Stepup\Identity\Entity\VettedSecondFactor;
+use Surfnet\Stepup\Identity\Value\DocumentNumber;
+use Surfnet\Stepup\Identity\Value\OnPremiseVettingType;
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
use Surfnet\StepupBundle\Value\SecondFactorType;
class SecondFactorCollectionTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
*/
- public function collection_can_return_second_factor_with_highest_loa()
+ public function collection_can_return_second_factor_with_highest_loa(): void
{
$collection = new SecondFactorCollection([
$this->mockVettedSecondFactor('sms'),
@@ -39,22 +45,20 @@ public function collection_can_return_second_factor_with_highest_loa()
]);
$secondFactor = $collection->getSecondFactorWithHighestLoa(
- new SecondFactorTypeService([])
+ new SecondFactorTypeService([]),
);
$this->assertNotNull($secondFactor, 'Collection should have returned a second factor object');
$this->assertTrue($secondFactor->getType()->isYubikey(), 'Expected yubikey since it has a higher LoA than sms');
}
- /**
- * @param string $type
- * @return SecondFactor
- */
- private function mockVettedSecondFactor($type)
+ private function mockVettedSecondFactor(string $type): SecondFactor
{
- $mock = m::mock('\Surfnet\Stepup\Identity\Entity\SecondFactor');
+ $mock = m::mock(VettedSecondFactor::class);
$mock->shouldReceive('getType')
->andReturn(new SecondFactorType($type));
+ $mock->shouldReceive('vettingType')
+ ->andReturn(new OnPremiseVettingType(new DocumentNumber('123123')));
return $mock;
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Event/EventSerializationAndDeserializationTest.php b/src/Surfnet/Stepup/Tests/Identity/Event/EventSerializationAndDeserializationTest.php
index c1d4cca76..3d2b558f3 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Event/EventSerializationAndDeserializationTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Event/EventSerializationAndDeserializationTest.php
@@ -20,8 +20,9 @@
use Broadway\Serializer\Serializable as SerializableInterface;
use DateTime as CoreDateTime;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\DateTime\DateTime;
use Surfnet\Stepup\Identity\Event\AppointedAsRaaEvent;
use Surfnet\Stepup\Identity\Event\AppointedAsRaaForInstitutionEvent;
@@ -75,27 +76,31 @@
class EventSerializationAndDeserializationTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
* @dataProvider eventProvider
- * @param SerializableInterface $event
*/
- public function an_event_should_be_the_same_after_serialization_and_deserialization(SerializableInterface $event)
+ public function an_event_should_be_the_same_after_serialization_and_deserialization(SerializableInterface $event): void
{
$isForgettableEvent = $event instanceof Forgettable;
$providesSensitiveData = method_exists($event, 'getSensitiveData') || method_exists($event, 'setSensitiveData');
if (!$isForgettableEvent && $providesSensitiveData) {
- $this->fail(sprintf(
- 'You provide sensitive data in %s, but do not implement %s',
- get_class($event),
- 'Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable'
- ));
+ $this->fail(
+ sprintf(
+ 'You provide sensitive data in %s, but do not implement %s',
+ $event::class,
+ Forgettable::class,
+ ),
+ );
}
$serializedEvent = $event->serialize();
if ($isForgettableEvent) {
+ assert($event instanceof Forgettable);
$sensitiveData = $event->getSensitiveData();
}
@@ -111,12 +116,12 @@ public function an_event_should_be_the_same_after_serialization_and_deserializat
* @test
* @group domain
* @dataProvider serializedDataProvider
- * @param string $serializedData
- * @param string $serializedSensitiveData
- * @param SerializableInterface $event
*/
- public function an_serialized_event_should_be_the_same(string $serializedData, string $serializedSensitiveData, SerializableInterface $event)
- {
+ public function an_serialized_event_should_be_the_same(
+ string $serializedData,
+ string $serializedSensitiveData,
+ SerializableInterface $event,
+ ): void {
$isForgettableEvent = $event instanceof Forgettable;
$serializedDataArray = json_decode($serializedData, true);
@@ -134,7 +139,7 @@ public function an_serialized_event_should_be_the_same(string $serializedData, s
* @test
* @group domain
*/
- public function an_email_verification_window_should_be_the_same_after_serialization_and_deserialization()
+ public function an_email_verification_window_should_be_the_same_after_serialization_and_deserialization(): void
{
// use a fixed datetime instance, to prevent microsecond precision issues in PHP 7.1+
$startDateTime = new DateTime(new CoreDateTime('@1000'));
@@ -143,410 +148,420 @@ public function an_email_verification_window_should_be_the_same_after_serializat
$this->assertTrue($window == EmailVerificationWindow::deserialize($window->serialize()));
}
- public function eventProvider()
+ public function eventProvider(): array
{
return [
'CompliedWithUnverifiedSecondFactorRevocationEvent:sms' => [
new CompliedWithUnverifiedSecondFactorRevocationEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('sms'),
new PhoneNumber('+358 (0) 687654321'),
- new IdentityId(static::UUID())
- )
+ new IdentityId($this->UUID()),
+ ),
],
'CompliedWithUnverifiedSecondFactorRevocationEvent:yubikey' => [
new CompliedWithUnverifiedSecondFactorRevocationEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('yubikey'),
new YubikeyPublicId('01906382'),
- new IdentityId(static::UUID())
- )
+ new IdentityId($this->UUID()),
+ ),
],
'CompliedWithUnverifiedSecondFactorRevocationEvent:tiqr' => [
new CompliedWithUnverifiedSecondFactorRevocationEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('tiqr'),
new GssfId('bleep-blorp'),
- new IdentityId(static::UUID())
- )
+ new IdentityId($this->UUID()),
+ ),
],
'CompliedWithVerifiedSecondFactorRevocationEvent:sms' => [
new CompliedWithVerifiedSecondFactorRevocationEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('sms'),
new PhoneNumber('+0 (0) 000000000'),
- new IdentityId(static::UUID())
- )
+ new IdentityId($this->UUID()),
+ ),
],
'CompliedWithVerifiedSecondFactorRevocationEvent:yubikey' => [
new CompliedWithVerifiedSecondFactorRevocationEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('yubikey'),
new YubikeyPublicId('01906382'),
- new IdentityId(static::UUID())
- )
+ new IdentityId($this->UUID()),
+ ),
],
'CompliedWithVerifiedSecondFactorRevocationEvent:tiqr' => [
new CompliedWithVerifiedSecondFactorRevocationEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('tiqr'),
new GssfId('bleep-blorp'),
- new IdentityId(static::UUID())
- )
+ new IdentityId($this->UUID()),
+ ),
],
'CompliedWithVettedSecondFactorRevocationEvent:sms' => [
new CompliedWithVettedSecondFactorRevocationEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('sms'),
new PhoneNumber('+0 (0) 000000000'),
- new IdentityId(static::UUID())
- )
+ new IdentityId($this->UUID()),
+ ),
],
'CompliedWithVettedSecondFactorRevocationEvent:yubikey' => [
new CompliedWithVettedSecondFactorRevocationEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('yubikey'),
new YubikeyPublicId('01906382'),
- new IdentityId(static::UUID())
- )
+ new IdentityId($this->UUID()),
+ ),
],
'CompliedWithVettedSecondFactorRevocationEvent:tiqr' => [
new CompliedWithVettedSecondFactorRevocationEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('tiqr'),
new GssfId('bleep-blorp'),
- new IdentityId(static::UUID())
- )
+ new IdentityId($this->UUID()),
+ ),
],
'EmailVerifiedEvent:sms' => [
new EmailVerifiedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('sms'),
new PhoneNumber('+0 (0) 000000000'),
new DateTime(new CoreDateTime('@1000')),
'123',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
- new Locale('en_GB')
- )
+ new Locale('en_GB'),
+ ),
],
'EmailVerifiedEvent:yubikey' => [
new EmailVerifiedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('yubikey'),
new YubikeyPublicId('01906382'),
new DateTime(new CoreDateTime('@1000')),
'123',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
- new Locale('en_GB')
- )
+ new Locale('en_GB'),
+ ),
],
'EmailVerifiedEvent:tiqr' => [
new EmailVerifiedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('tiqr'),
new GssfId('bleep-blorp'),
new DateTime(new CoreDateTime('@1000')),
'123',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
- new Locale('en_GB')
- )
+ new Locale('en_GB'),
+ ),
],
'IdentityCreatedEvent' => [
new IdentityCreatedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('BabelFish Inc'),
new NameId('42'),
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
- new Locale('en_GB')
- )
+ new Locale('en_GB'),
+ ),
],
'IdentityEmailChangedEvent' => [
new IdentityEmailChangedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new Email('info@example.invalid')
- )
+ new Email('info@example.invalid'),
+ ),
],
'IdentityRenamedEvent' => [
new IdentityRenamedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new CommonName('Henk Westbroek')
- )
+ new CommonName('Henk Westbroek'),
+ ),
],
'PhonePossessionProvenEvent' => [
new PhonePossessionProvenEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new PhoneNumber('+31 (0) 612345678'),
true,
- EmailVerificationWindow::createFromTimeFrameStartingAt(TimeFrame::ofSeconds(3), new DateTime(new CoreDateTime('@1000'))),
+ EmailVerificationWindow::createFromTimeFrameStartingAt(
+ TimeFrame::ofSeconds(3),
+ new DateTime(new CoreDateTime('@1000')),
+ ),
'42',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
- new Locale('en_GB')
- )
+ new Locale('en_GB'),
+ ),
],
'UnverifiedSecondFactorRevokedEvent:sms' => [
new UnverifiedSecondFactorRevokedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('sms'),
- new PhoneNumber('+31 (0) 612345678')
- )
+ new PhoneNumber('+31 (0) 612345678'),
+ ),
],
'UnverifiedSecondFactorRevokedEvent:yubikey' => [
new UnverifiedSecondFactorRevokedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('yubikey'),
- new YubikeyPublicId('01906382')
- )
+ new YubikeyPublicId('01906382'),
+ ),
],
'UnverifiedSecondFactorRevokedEvent:tiqr' => [
new UnverifiedSecondFactorRevokedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('tiqr'),
- new GssfId('bleep-blorp')
- )
+ new GssfId('bleep-blorp'),
+ ),
],
'VerifiedSecondFactorRevokedEvent:sms' => [
new VerifiedSecondFactorRevokedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('sms'),
- PhoneNumber::unknown()
- )
+ PhoneNumber::unknown(),
+ ),
],
'VerifiedSecondFactorRevokedEvent:yubikey' => [
new VerifiedSecondFactorRevokedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('yubikey'),
- new YubikeyPublicId('01906382')
- )
+ new YubikeyPublicId('01906382'),
+ ),
],
'VerifiedSecondFactorRevokedEvent:tiqr' => [
new VerifiedSecondFactorRevokedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('tiqr'),
- new GssfId('bleep-blorp')
- )
+ new GssfId('bleep-blorp'),
+ ),
],
'VettedSecondFactorRevokedEvent:sms' => [
new VettedSecondFactorRevokedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('sms'),
- new PhoneNumber('+1 (0) 5155550100')
- )
+ new PhoneNumber('+1 (0) 5155550100'),
+ ),
],
'VettedSecondFactorRevokedEvent:yubikey' => [
new VettedSecondFactorRevokedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('yubikey'),
- new YubikeyPublicId('01906382')
- )
+ new YubikeyPublicId('01906382'),
+ ),
],
'VettedSecondFactorRevokedEvent:tiqr' => [
new VettedSecondFactorRevokedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new SecondFactorType('tiqr'),
- new GssfId('bleep-blorp')
- )
+ new GssfId('bleep-blorp'),
+ ),
],
'YubikeyPossessionProvenEvent' => [
new YubikeyPossessionProvenEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new YubikeyPublicId('19382933'),
true,
- EmailVerificationWindow::createFromTimeFrameStartingAt(TimeFrame::ofSeconds(3), new DateTime(new CoreDateTime('@1000'))),
+ EmailVerificationWindow::createFromTimeFrameStartingAt(
+ TimeFrame::ofSeconds(3),
+ new DateTime(new CoreDateTime('@1000')),
+ ),
'42',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
- new Locale('en_GB')
- )
+ new Locale('en_GB'),
+ ),
],
'GssfPossessionProvenEvent' => [
new GssfPossessionProvenEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new SecondFactorId(static::UUID()),
+ new SecondFactorId($this->UUID()),
new StepupProvider('tiqr'),
new GssfId('_' . md5('Tiqr')),
true,
- EmailVerificationWindow::createFromTimeFrameStartingAt(TimeFrame::ofSeconds(3), new DateTime(new CoreDateTime('@1000'))),
+ EmailVerificationWindow::createFromTimeFrameStartingAt(
+ TimeFrame::ofSeconds(3),
+ new DateTime(new CoreDateTime('@1000')),
+ ),
'42',
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
- new Locale('en_GB')
- )
+ new Locale('en_GB'),
+ ),
],
'IdentityAccreditedAsRaEvent' => [
new IdentityAccreditedAsRaEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new NameId(md5('someNameId')),
new Institution('Babelfish Inc.'),
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA),
new Location('somewhere behind you'),
- new ContactInformation('Call me maybe')
- )
+ new ContactInformation('Call me maybe'),
+ ),
],
'IdentityAccreditedAsRaaEvent' => [
new IdentityAccreditedAsRaaEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new NameId(md5('someNameId')),
new Institution('Babelfish Inc.'),
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA),
new Location('somewhere behind you'),
- new ContactInformation('Call me maybe')
- )
+ new ContactInformation('Call me maybe'),
+ ),
],
'RegistrationAuthorityInformationAmendedEvent' => [
new RegistrationAuthorityInformationAmendedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Blue Note'),
new NameId(md5('Coleman Hawkins')),
new Location('New York'),
- new ContactInformation("131 West 3rd Street, NY")
- )
+ new ContactInformation("131 West 3rd Street, NY"),
+ ),
],
'AppointedAsRaaEvent' => [
new AppointedAsRaaEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new NameId(md5('someNameId'))
- )
+ new NameId(md5('someNameId')),
+ ),
],
'AppointedAsRaEvent' => [
new AppointedAsRaEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new NameId(md5('someNameId'))
- )
+ new NameId(md5('someNameId')),
+ ),
],
'RegistrationAuthorityRetractedEvent' => [
new RegistrationAuthorityRetractedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
new NameId(md5('someNameId')),
new CommonName('Henk Westbroek'),
- new Email('info@example.invalid')
- )
+ new Email('info@example.invalid'),
+ ),
],
'LocalePreferenceExpressedEvent' => [
new LocalePreferenceExpressedEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
- new Locale('fi_FI')
- )
+ new Locale('fi_FI'),
+ ),
],
'AppointedAsRaaForInstitutionEvent' => [
new AppointedAsRaaForInstitutionEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
new NameId(md5('someNameId')),
- new Institution('Babelfish BV.')
- )
+ new Institution('Babelfish BV.'),
+ ),
],
'AppointedAsRaForInstitutionEvent' => [
new AppointedAsRaForInstitutionEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
new NameId(md5('someNameId')),
- new Institution('Babelfish BV.')
- )
+ new Institution('Babelfish BV.'),
+ ),
],
'IdentityAccreditedAsRaForInstitutionEvent' => [
new IdentityAccreditedAsRaForInstitutionEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new NameId(md5('someNameId')),
new Institution('Babelfish Inc.'),
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA),
new Location('somewhere behind you'),
new ContactInformation('Call me maybe'),
- new Institution('Babelfish BV.')
- )
+ new Institution('Babelfish BV.'),
+ ),
],
'IdentityAccreditedAsRaaForInstitutionEvent' => [
new IdentityAccreditedAsRaaForInstitutionEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new NameId(md5('someNameId')),
new Institution('Babelfish Inc.'),
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA),
new Location('somewhere behind you'),
new ContactInformation('Call me maybe'),
- new Institution('Babelfish BV.')
- )
+ new Institution('Babelfish BV.'),
+ ),
],
'RegistrationAuthorityInformationAmendedForInstitutionEvent' => [
new RegistrationAuthorityInformationAmendedForInstitutionEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Blue Note'),
new NameId(md5('Coleman Hawkins')),
new Location('New York'),
new ContactInformation("131 West 3rd Street, NY"),
- new Institution('Babelfish Inc.')
- )
+ new Institution('Babelfish Inc.'),
+ ),
],
'RegistrationAuthorityRetractedForInstitutionEvent' => [
new RegistrationAuthorityRetractedForInstitutionEvent(
- new IdentityId(static::UUID()),
+ new IdentityId($this->UUID()),
new Institution('Babelfish Inc.'),
new NameId(md5('someNameId')),
new CommonName('Henk Westbroek'),
new Email('info@example.invalid'),
- new Institution('Babelfish Inc.')
- )
+ new Institution('Babelfish Inc.'),
+ ),
],
];
}
- public function serializedDataProvider(){
+ public function serializedDataProvider(): array
+ {
return [
// Tests for changes in BC support for adding the VettingType in the SecondFactorVettedEvents in favour of the 'DocumentNumber'
'SecondFactorVettedEvent:support-new-event-with-vetting-type' => [
@@ -562,7 +577,7 @@ public function serializedDataProvider(){
new CommonName('jane-d1 Institution-D.EXAMPLE.COM'),
new Email('jane+jane-d1@stepup.example.com'),
new Locale('nl_NL'),
- new OnPremiseVettingType(new DocumentNumber('012345678'))
+ new OnPremiseVettingType(new DocumentNumber('012345678')),
),
],
'SecondFactorVettedEvent:support-old-event-with-document-number' => [
@@ -578,7 +593,7 @@ public function serializedDataProvider(){
new CommonName('jane-d1 Institution-D.EXAMPLE.COM'),
new Email('jane+jane-d1@stepup.example.com'),
new Locale('nl_NL'),
- new OnPremiseVettingType(new DocumentNumber('012345678'))
+ new OnPremiseVettingType(new DocumentNumber('012345678')),
),
],
'SecondFactorVettedWithoutTokenProofOfPossession:support-new-event-with-vetting-type' => [
@@ -594,7 +609,7 @@ public function serializedDataProvider(){
new CommonName('jane-d1 Institution-D.EXAMPLE.COM'),
new Email('jane+jane-d1@stepup.example.com'),
new Locale('nl_NL'),
- new OnPremiseVettingType(new DocumentNumber('012345678'))
+ new OnPremiseVettingType(new DocumentNumber('012345678')),
),
],
'SecondFactorVettedWithoutTokenProofOfPossession:support-old-event-with-document-number' => [
@@ -610,14 +625,14 @@ public function serializedDataProvider(){
new CommonName('jane-d1 Institution-D.EXAMPLE.COM'),
new Email('jane+jane-d1@stepup.example.com'),
new Locale('nl_NL'),
- new OnPremiseVettingType(new DocumentNumber('012345678'))
+ new OnPremiseVettingType(new DocumentNumber('012345678')),
),
],
];
}
- private static function UUID()
+ private function UUID(): string
{
- return (string) Uuid::uuid4();
+ return (string)Uuid::uuid4();
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Event/ForgettableEventsTest.php b/src/Surfnet/Stepup/Tests/Identity/Event/ForgettableEventsTest.php
index a186b4950..5df9935ee 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Event/ForgettableEventsTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Event/ForgettableEventsTest.php
@@ -18,82 +18,119 @@
namespace Surfnet\Stepup\Tests\Identity\Event;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
+use ReflectionClass;
+use ReflectionException;
+use Surfnet\Stepup\Identity\Event\CompliedWithRevocationEvent;
+use Surfnet\Stepup\Identity\Event\CompliedWithUnverifiedSecondFactorRevocationEvent;
+use Surfnet\Stepup\Identity\Event\CompliedWithVerifiedSecondFactorRevocationEvent;
+use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
+use Surfnet\Stepup\Identity\Event\EmailVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\GssfPossessionProvenAndVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\GssfPossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\IdentityCreatedEvent;
+use Surfnet\Stepup\Identity\Event\IdentityEmailChangedEvent;
+use Surfnet\Stepup\Identity\Event\IdentityRenamedEvent;
+use Surfnet\Stepup\Identity\Event\PhonePossessionProvenAndVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\PhonePossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\PhoneRecoveryTokenPossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedEvent;
+use Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\SafeStoreSecretRecoveryTokenPossessionPromisedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorMigratedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorMigratedToEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorRevokedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession;
+use Surfnet\Stepup\Identity\Event\U2fDevicePossessionProvenAndVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\U2fDevicePossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\UnverifiedSecondFactorRevokedEvent;
+use Surfnet\Stepup\Identity\Event\VerifiedSecondFactorRevokedEvent;
+use Surfnet\Stepup\Identity\Event\VettedSecondFactorRevokedEvent;
+use Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenAndVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\YubikeySecondFactorBootstrappedEvent;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable;
final class ForgettableEventsTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
*/
- public function certain_events_are_forgettable_events_and_others_are_not()
+ public function certain_events_are_forgettable_events_and_others_are_not(): void
{
$forgettableEventFqcns = [
- 'Surfnet\Stepup\Identity\Event\CompliedWithRevocationEvent',
- 'Surfnet\Stepup\Identity\Event\CompliedWithUnverifiedSecondFactorRevocationEvent',
- 'Surfnet\Stepup\Identity\Event\CompliedWithVerifiedSecondFactorRevocationEvent',
- 'Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent',
- 'Surfnet\Stepup\Identity\Event\EmailVerifiedEvent',
- 'Surfnet\Stepup\Identity\Event\GssfPossessionProvenEvent',
- 'Surfnet\Stepup\Identity\Event\GssfPossessionProvenAndVerifiedEvent',
- 'Surfnet\Stepup\Identity\Event\IdentityCreatedEvent',
- 'Surfnet\Stepup\Identity\Event\IdentityEmailChangedEvent',
- 'Surfnet\Stepup\Identity\Event\IdentityRenamedEvent',
- 'Surfnet\Stepup\Identity\Event\SafeStoreSecretRecoveryTokenPossessionPromisedEvent',
- 'Surfnet\Stepup\Identity\Event\SecondFactorMigratedEvent',
- 'Surfnet\Stepup\Identity\Event\SecondFactorMigratedToEvent',
- 'Surfnet\Stepup\Identity\Event\PhonePossessionProvenEvent',
- 'Surfnet\Stepup\Identity\Event\PhonePossessionProvenAndVerifiedEvent',
- 'Surfnet\Stepup\Identity\Event\PhoneRecoveryTokenPossessionProvenEvent',
- 'Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedEvent',
- 'Surfnet\Stepup\Identity\Event\SecondFactorRevokedEvent',
- 'Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent',
- 'Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession',
- 'Surfnet\Stepup\Identity\Event\U2fDevicePossessionProvenEvent',
- 'Surfnet\Stepup\Identity\Event\U2fDevicePossessionProvenAndVerifiedEvent',
- 'Surfnet\Stepup\Identity\Event\UnverifiedSecondFactorRevokedEvent',
- 'Surfnet\Stepup\Identity\Event\VerifiedSecondFactorRevokedEvent',
- 'Surfnet\Stepup\Identity\Event\VettedSecondFactorRevokedEvent',
- 'Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenEvent',
- 'Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenAndVerifiedEvent',
- 'Surfnet\Stepup\Identity\Event\YubikeySecondFactorBootstrappedEvent',
- 'Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedForInstitutionEvent',
+ CompliedWithRevocationEvent::class,
+ CompliedWithUnverifiedSecondFactorRevocationEvent::class,
+ CompliedWithVerifiedSecondFactorRevocationEvent::class,
+ CompliedWithVettedSecondFactorRevocationEvent::class,
+ EmailVerifiedEvent::class,
+ GssfPossessionProvenEvent::class,
+ GssfPossessionProvenAndVerifiedEvent::class,
+ IdentityCreatedEvent::class,
+ IdentityEmailChangedEvent::class,
+ IdentityRenamedEvent::class,
+ SafeStoreSecretRecoveryTokenPossessionPromisedEvent::class,
+ SecondFactorMigratedEvent::class,
+ SecondFactorMigratedToEvent::class,
+ PhonePossessionProvenEvent::class,
+ PhonePossessionProvenAndVerifiedEvent::class,
+ PhoneRecoveryTokenPossessionProvenEvent::class,
+ RegistrationAuthorityRetractedEvent::class,
+ SecondFactorRevokedEvent::class,
+ SecondFactorVettedEvent::class,
+ SecondFactorVettedWithoutTokenProofOfPossession::class,
+ U2fDevicePossessionProvenEvent::class,
+ U2fDevicePossessionProvenAndVerifiedEvent::class,
+ UnverifiedSecondFactorRevokedEvent::class,
+ VerifiedSecondFactorRevokedEvent::class,
+ VettedSecondFactorRevokedEvent::class,
+ YubikeyPossessionProvenEvent::class,
+ YubikeyPossessionProvenAndVerifiedEvent::class,
+ YubikeySecondFactorBootstrappedEvent::class,
+ RegistrationAuthorityRetractedForInstitutionEvent::class,
];
$otherIdentityEventFqcns = array_diff($this->getConcreteIdentityEventFqcns(), $forgettableEventFqcns);
- $forgettableFqcn = 'Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable';
+ $forgettableFqcn = Forgettable::class;
foreach ($forgettableEventFqcns as $fqcn) {
$this->assertTrue(
is_a($fqcn, $forgettableFqcn, true),
- sprintf('%s is not a Forgettable event, please implement %s', $fqcn, $forgettableFqcn)
+ sprintf('%s is not a Forgettable event, please implement %s', $fqcn, $forgettableFqcn),
);
}
foreach ($otherIdentityEventFqcns as $fqcn) {
$this->assertFalse(
is_a($fqcn, $forgettableFqcn, true),
- sprintf('%s is a Forgettable event, is this correct? Then add it to the list', $fqcn, $forgettableFqcn)
+ sprintf('%s is a Forgettable event, is this correct? Then add it to the list', $fqcn),
);
}
}
/**
* @return string[]
+ * @throws ReflectionException
+ * @throws ReflectionException
*/
- private function getConcreteIdentityEventFqcns()
+ private function getConcreteIdentityEventFqcns(): array
{
return array_filter(
array_map(
- function ($file) {
- $fqcn = sprintf(
+ function ($file): ?string {
+ $fqcn = sprintf(
'Surfnet\Stepup\Identity\Event\%s',
- preg_replace('/\\..+?$/', '', basename($file))
+ preg_replace('/\\..+?$/', '', basename($file)),
);
- $reflection = new \ReflectionClass($fqcn);
+ $reflection = new ReflectionClass($fqcn);
return $reflection->isInstantiable() ? $fqcn : null;
},
- glob(__DIR__ . '/../../../Identity/Event/*Event.php')
- )
+ glob(__DIR__ . '/../../../Identity/Event/*Event.php'),
+ ),
);
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Event/WhitelistEventSerializationAndDeserializationTest.php b/src/Surfnet/Stepup/Tests/Identity/Event/WhitelistEventSerializationAndDeserializationTest.php
index 744ad89ce..ca587a765 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Event/WhitelistEventSerializationAndDeserializationTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Event/WhitelistEventSerializationAndDeserializationTest.php
@@ -19,6 +19,7 @@
namespace Surfnet\Stepup\Tests\Identity\Event;
use Broadway\Serializer\Serializable as SerializableInterface;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Identity\Collection\InstitutionCollection;
use Surfnet\Stepup\Identity\Event\InstitutionsAddedToWhitelistEvent;
@@ -29,33 +30,34 @@
class WhitelistEventSerializationAndDeserializationTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
* @group whitelist
* @dataProvider eventProvider
- * @param SerializableInterface $event
*/
- public function an_event_should_be_the_same_after_serialization_and_deserialization(SerializableInterface $event)
+ public function an_event_should_be_the_same_after_serialization_and_deserialization(SerializableInterface $event,): void
{
- $class = get_class($event);
+ $class = $event::class;
$this->assertTrue($event == call_user_func([$class, 'deserialize'], $event->serialize()));
}
- public function eventProvider()
+ public function eventProvider(): array
{
return [
'WhitelistCreatedEvent' => [
- new WhitelistCreatedEvent($this->getInstitutionCollection())
+ new WhitelistCreatedEvent($this->getInstitutionCollection()),
],
'WhitelistReplacedEvent' => [
- new WhitelistReplacedEvent($this->getInstitutionCollection())
+ new WhitelistReplacedEvent($this->getInstitutionCollection()),
],
'InstitutionsAddedToWhitelistEvent' => [
- new InstitutionsAddedToWhitelistEvent($this->getInstitutionCollection())
+ new InstitutionsAddedToWhitelistEvent($this->getInstitutionCollection()),
],
'InstitutionsRemovedFromWhitelistEvent' => [
- new InstitutionsRemovedFromWhitelistEvent($this->getInstitutionCollection())
+ new InstitutionsRemovedFromWhitelistEvent($this->getInstitutionCollection()),
],
];
}
@@ -63,7 +65,7 @@ public function eventProvider()
/**
* @return InstitutionCollection
*/
- private function getInstitutionCollection()
+ private function getInstitutionCollection(): InstitutionCollection
{
static $institutionCollection;
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/CommonNameTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/CommonNameTest.php
index 5d5e9b89d..7ca82305b 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/CommonNameTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/CommonNameTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
new CommonName($invalidValue);
}
@@ -41,30 +45,23 @@ public function the_common_name_address_must_be_a_non_empty_string($invalidValue
* @test
* @group domain
*/
- public function two_common_names_with_the_same_value_are_equal()
+ public function two_common_names_with_the_same_value_are_equal(): void
{
$commonName = new CommonName('John Doe');
- $theSame = new CommonName('John Doe');
- $different = new CommonName('Jane Doe');
- $unknown = CommonName::unknown();
+ $theSame = new CommonName('John Doe');
+ $different = new CommonName('Jane Doe');
+ $unknown = CommonName::unknown();
$this->assertTrue($commonName->equals($theSame));
$this->assertFalse($commonName->equals($different));
$this->assertFalse($commonName->equals($unknown));
}
- /**
- * provider for {@see the_common_name_address_must_be_a_non_empty_string()}
- */
- public function invalidArgumentProvider()
+ public function invalidArgumentProvider(): array
{
return [
'empty string' => [''],
'blank string' => [' '],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/ContactInformationTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/ContactInformationTest.php
index e832ed502..63b0652af 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/ContactInformationTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/ContactInformationTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
-
- new ContactInformation($invalidValue);
- }
+ use MockeryPHPUnitIntegration;
/**
* @test
* @group domain
*/
- public function two_instances_with_the_same_value_are_equal()
+ public function two_instances_with_the_same_value_are_equal(): void
{
$contactInformation = new ContactInformation('a');
- $theSame = new ContactInformation('a');
- $theSameWithSpaces = new ContactInformation(' a ');
- $different = new ContactInformation('A');
+ $theSame = new ContactInformation('a');
+ $theSameWithSpaces = new ContactInformation(' a ');
+ $different = new ContactInformation('A');
$this->assertTrue($contactInformation->equals($theSame));
$this->assertTrue($contactInformation->equals($theSameWithSpaces));
$this->assertFalse($contactInformation->equals($different));
}
-
- /**
- * dataprovider
- */
- public function invalidValueProvider()
- {
- return [
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
- ];
- }
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/DocumentNumberTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/DocumentNumberTest.php
index 71d79a299..83d4e5d9a 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/DocumentNumberTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/DocumentNumberTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
new DocumentNumber($invalidValue);
}
@@ -40,29 +44,22 @@ public function the_document_number_must_be_a_non_empty_string($invalidValue)
* @test
* @group domain
*/
- public function two_document_numbers_with_the_same_value_are_equal()
+ public function two_document_numbers_with_the_same_value_are_equal(): void
{
$commonName = new DocumentNumber('John Doe');
- $theSame = new DocumentNumber('John Doe');
- $different = new DocumentNumber('Jane Doe');
- $unknown = DocumentNumber::unknown();
+ $theSame = new DocumentNumber('John Doe');
+ $different = new DocumentNumber('Jane Doe');
+ $unknown = DocumentNumber::unknown();
$this->assertTrue($commonName->equals($theSame));
$this->assertFalse($commonName->equals($different));
$this->assertFalse($commonName->equals($unknown));
}
- /**
- * provider for {@see the_document_number_address_must_be_a_non_empty_string()}
- */
- public function invalidArgumentProvider()
+ public function invalidArgumentProvider(): array
{
return [
'empty string' => [''],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/EmailTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/EmailTest.php
index 54ae3f7ea..14be0428d 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/EmailTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/EmailTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
new Email($invalidValue);
}
@@ -40,11 +44,10 @@ public function the_email_address_must_be_a_non_empty_string($invalidValue)
* @test
* @group domain
* @dataProvider invalidEmailProvider
- * @param $invalidValue
*/
- public function the_email_address_given_must_be_rfc_822_compliant($invalidValue)
+ public function the_email_address_given_must_be_rfc_822_compliant(string $invalidValue): void
{
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
new Email($invalidValue);
}
@@ -53,30 +56,23 @@ public function the_email_address_given_must_be_rfc_822_compliant($invalidValue)
* @test
* @group domain
*/
- public function two_emails_with_the_same_value_are_equal()
+ public function two_emails_with_the_same_value_are_equal(): void
{
- $email = new Email('email@example.invalid');
- $theSame = new Email('email@example.invalid');
+ $email = new Email('email@example.invalid');
+ $theSame = new Email('email@example.invalid');
$different = new Email('different@example.invalid');
- $unknown = Email::unknown();
+ $unknown = Email::unknown();
$this->assertTrue($email->equals($theSame));
$this->assertFalse($email->equals($different));
$this->assertFalse($email->equals($unknown));
}
- /**
- * provider for {@see the_email_address_must_be_a_non_empty_string()}
- */
- public function invalidArgumentProvider()
+ public function invalidArgumentProvider(): array
{
return [
'empty string' => [''],
'blank string' => [' '],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
@@ -87,12 +83,12 @@ public function invalidArgumentProvider()
*
* @return array
*/
- public function invalidEmailProvider()
+ public function invalidEmailProvider(): array
{
return [
- 'no @-sign' => ['mailboxexample.invalid'],
- 'no tld' => ['mailbox@example'],
- 'no mailbox' => ['@example.invalid'],
+ 'no @-sign' => ['mailboxexample.invalid'],
+ 'no tld' => ['mailbox@example'],
+ 'no mailbox' => ['@example.invalid'],
'invalid mailbox' => ['(。◕‿◕。)@example.invalid'],
];
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/EmailVerificationWindowTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/EmailVerificationWindowTest.php
index 171e6cf7c..630d0c72f 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/EmailVerificationWindowTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/EmailVerificationWindowTest.php
@@ -20,6 +20,8 @@
use DateInterval;
use DateTime as CoreDateTime;
+use Exception;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
use Surfnet\Stepup\DateTime\DateTime;
use Surfnet\Stepup\Identity\Value\EmailVerificationWindow;
@@ -28,13 +30,15 @@
class EmailVerificationWindowTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
*
* @runInSeparateProcess
*/
- public function window_is_open_for_instructed_timeframe_after_given_time()
+ public function window_is_open_for_instructed_timeframe_after_given_time(): void
{
$startTime = new DateTime(new CoreDateTime('@1'));
$timeFrame = TimeFrame::ofSeconds(3);
@@ -64,18 +68,18 @@ public function window_is_open_for_instructed_timeframe_after_given_time()
*
* @runInSeparateProcess
*/
- public function a_window_is_considered_equal_when_the_start_and_end_are_the_same()
+ public function a_window_is_considered_equal_when_the_start_and_end_are_the_same(): void
{
// since we work with second precision, we might run issues trusting normal time, so we fixate the time
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@10000')));
- $base = $this->newEmailVerificationWindow(3);
- $same = $this->newEmailVerificationWindow(3);
- $startsSameEndsEarlier = $this->newEmailVerificationWindow(2);
- $startsSameEndsLater = $this->newEmailVerificationWindow(4);
- $startsLater = $this->newEmailVerificationWindow(3, 'PT1S');
- $startsLaterEndsAtSameTime = $this->newEmailVerificationWindow(2, 'PT1S');
- $startsEarlier = $this->newEmailVerificationWindow(2, '-PT1S');
+ $base = $this->newEmailVerificationWindow(3);
+ $same = $this->newEmailVerificationWindow(3);
+ $startsSameEndsEarlier = $this->newEmailVerificationWindow(2);
+ $startsSameEndsLater = $this->newEmailVerificationWindow(4);
+ $startsLater = $this->newEmailVerificationWindow(3, 'PT1S');
+ $startsLaterEndsAtSameTime = $this->newEmailVerificationWindow(2, 'PT1S');
+ $startsEarlier = $this->newEmailVerificationWindow(2, '-PT1S');
$startsEarlierEndsAtSameTime = $this->newEmailVerificationWindow(4, '-PT1S');
$this->assertTrue($base->equals($same));
@@ -93,7 +97,7 @@ public function a_window_is_considered_equal_when_the_start_and_end_are_the_same
*
* @runInSeparateProcess
*/
- public function the_window_correctly_calculates_the_end_datetime()
+ public function the_window_correctly_calculates_the_end_datetime(): void
{
// since we work with second precision, we might run issues trusting normal time, so we fixate the time
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@10')));
@@ -105,7 +109,7 @@ public function the_window_correctly_calculates_the_end_datetime()
$window = EmailVerificationWindow::createWindowFromTill(
DateTime::now(),
- DateTime::now()->add(new DateInterval('PT3S'))
+ DateTime::now()->add(new DateInterval('PT3S')),
);
$endTimeTwo = $window->openUntil();
$this->assertEquals(new DateTime(new CoreDateTime('@13')), $endTimeTwo);
@@ -114,15 +118,15 @@ public function the_window_correctly_calculates_the_end_datetime()
/**
* Helper method for easy EmailVerificationWindow creation
*
- * @param int $timeFrameSeconds
* @param string|null $startTimeOffset
- * @return EmailVerificationWindow
+ * @throws Exception
+ * @throws Exception
*/
- private function newEmailVerificationWindow($timeFrameSeconds, $startTimeOffset = null)
+ private function newEmailVerificationWindow(int $timeFrameSeconds, string $startTimeOffset = null): EmailVerificationWindow
{
$start = DateTime::now();
if ($startTimeOffset) {
- if (substr($startTimeOffset, 0, 1) === '-') {
+ if (str_starts_with($startTimeOffset, '-')) {
$offset = substr($startTimeOffset, 1);
$start = $start->sub(new DateInterval($offset));
} else {
@@ -132,7 +136,7 @@ private function newEmailVerificationWindow($timeFrameSeconds, $startTimeOffset
return EmailVerificationWindow::createFromTimeFrameStartingAt(
TimeFrame::ofSeconds($timeFrameSeconds),
- $start
+ $start,
);
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/GssfIdTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/GssfIdTest.php
index 8287d246d..9c8fc1eab 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/GssfIdTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/GssfIdTest.php
@@ -18,21 +18,25 @@
namespace Surfnet\Stepup\Tests\Identity\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
+use StdClass;
+use Surfnet\Stepup\Exception\InvalidArgumentException;
use Surfnet\Stepup\Identity\Value\GssfId;
class GssfIdTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
* @dataProvider invalidValueProvider
- *
- * @param mixed $invalidValue
*/
- public function a_gssf_id_cannot_be_created_with_anything_but_a_nonempty_string($invalidValue)
- {
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ public function a_gssf_id_cannot_be_created_with_anything_but_a_nonempty_string(
+ string $invalidValue,
+ ): void {
+ $this->expectException(InvalidArgumentException::class);
new GssfId($invalidValue);
}
@@ -41,12 +45,12 @@ public function a_gssf_id_cannot_be_created_with_anything_but_a_nonempty_string(
* @test
* @group domain
*/
- public function two_gssf_ids_with_the_same_value_are_equal()
+ public function two_gssf_ids_with_the_same_value_are_equal(): void
{
- $gssf = new GssfId('a');
- $theSame = new GssfId(' a');
- $different = new GssfId('A');
- $unknown = GssfId::unknown();
+ $gssf = new GssfId('a');
+ $theSame = new GssfId(' a');
+ $different = new GssfId('A');
+ $unknown = GssfId::unknown();
$this->assertTrue($gssf->equals($theSame));
$this->assertFalse($gssf->equals($different));
@@ -56,15 +60,11 @@ public function two_gssf_ids_with_the_same_value_are_equal()
/**
* DataProvider for {@see a_gssf_od_cannot_be_created_with_anything_but_a_nonempty_string()}
*/
- public function invalidValueProvider()
+ public function invalidValueProvider(): array
{
return [
'empty string' => [''],
'blank string' => [' '],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/InstitutionTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/InstitutionTest.php
index f058901dd..3e32aeb58 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/InstitutionTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/InstitutionTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
-
+ public function an_institution_cannot_be_created_with_anything_but_a_nonempty_string_type_errors(string $invalidValue): void {
+ $this->expectException(InvalidArgumentException::class);
new Institution($invalidValue);
}
@@ -41,12 +43,12 @@ public function an_institution_cannot_be_created_with_anything_but_a_nonempty_st
* @test
* @group domain
*/
- public function two_institutions_with_the_same_value_are_equal()
+ public function two_institutions_with_the_same_value_are_equal(): void
{
- $institution = new Institution('a');
- $theSame = new Institution('a');
+ $institution = new Institution('a');
+ $theSame = new Institution('a');
$theSameWithSpaces = new Institution(' a ');
- $different = new Institution('A');
+ $different = new Institution('A');
$this->assertTrue($institution->equals($theSame));
$this->assertTrue($institution->equals($theSameWithSpaces));
@@ -56,15 +58,11 @@ public function two_institutions_with_the_same_value_are_equal()
/**
* dataprovider
*/
- public function invalidValueProvider()
+ public function invalidValueProviderInvalidString(): array
{
return [
'empty string' => [''],
'blank string' => [' '],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/LocationTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/LocationTest.php
index a3138c044..931f9eec8 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/LocationTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/LocationTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
-
- new Location($invalidValue);
- }
+ use MockeryPHPUnitIntegration;
/**
* @test
* @group domain
*/
- public function two_locations_with_the_same_value_are_equal()
+ public function two_locations_with_the_same_value_are_equal(): void
{
- $location = new Location('a');
- $theSame = new Location('a');
+ $location = new Location('a');
+ $theSame = new Location('a');
$theSameWithSpaces = new Location(' a ');
- $different = new Location('A');
+ $different = new Location('A');
$this->assertTrue($location->equals($theSame));
$this->assertTrue($location->equals($theSameWithSpaces));
$this->assertFalse($location->equals($different));
}
-
- /**
- * dataprovider
- */
- public function invalidValueProvider()
- {
- return [
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
- ];
- }
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/PhoneNumberTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/PhoneNumberTest.php
index 47ce75305..9b969f12e 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/PhoneNumberTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/PhoneNumberTest.php
@@ -18,21 +18,25 @@
namespace Surfnet\Stepup\Tests\Identity\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
+use StdClass;
+use Surfnet\Stepup\Exception\InvalidArgumentException;
use Surfnet\Stepup\Identity\Value\PhoneNumber;
class PhoneNumberTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
* @dataProvider invalidValueProvider
- *
- * @param mixed $invalidValue
*/
- public function a_phone_number_cannot_be_created_with_anything_but_a_nonempty_string($invalidValue)
- {
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ public function a_phone_number_cannot_be_created_with_anything_but_a_nonempty_string(
+ string $invalidValue,
+ ): void {
+ $this->expectException(InvalidArgumentException::class);
new PhoneNumber($invalidValue);
}
@@ -41,12 +45,12 @@ public function a_phone_number_cannot_be_created_with_anything_but_a_nonempty_st
* @test
* @group domain
*/
- public function two_phone_numbers_with_the_same_value_are_equal()
+ public function two_phone_numbers_with_the_same_value_are_equal(): void
{
- $one = new PhoneNumber('+31 (0) 12345678');
- $theSame = new PhoneNumber('+31 (0) 12345678');
- $different = new PhoneNumber('+31 (0) 87654321');
- $unknown = PhoneNumber::unknown();
+ $one = new PhoneNumber('+31 (0) 12345678');
+ $theSame = new PhoneNumber('+31 (0) 12345678');
+ $different = new PhoneNumber('+31 (0) 87654321');
+ $unknown = PhoneNumber::unknown();
$this->assertTrue($one->equals($theSame));
$this->assertFalse($one->equals($different));
@@ -56,15 +60,11 @@ public function two_phone_numbers_with_the_same_value_are_equal()
/**
* DataProvider for {@see a_phonenumber_cannot_be_created_with_anything_but_a_nonempty_string()}
*/
- public function invalidValueProvider()
+ public function invalidValueProvider(): array
{
return [
'empty string' => [''],
'blank string' => [' '],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/RecoveryTokenIdentifierFactoryTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/RecoveryTokenIdentifierFactoryTest.php
index 58bd671f5..2bc97760a 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/RecoveryTokenIdentifierFactoryTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/RecoveryTokenIdentifierFactoryTest.php
@@ -18,6 +18,7 @@
namespace Surfnet\Stepup\Tests\Identity\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
use Surfnet\Stepup\Identity\Value\HashedSecret;
use Surfnet\Stepup\Identity\Value\PhoneNumber;
@@ -27,27 +28,29 @@
final class RecoveryTokenIdentifierFactoryTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @group domain
*/
- public function test_generates_identifiers_of_all_types()
+ public function test_generates_identifiers_of_all_types(): void
{
$this->assertEquals(
new PhoneNumber('+31 (0) 12345678'),
- RecoveryTokenIdentifierFactory::forType(RecoveryTokenType::sms(), '+31 (0) 12345678')
+ RecoveryTokenIdentifierFactory::forType(RecoveryTokenType::sms(), '+31 (0) 12345678'),
);
$this->assertEquals(
new SafeStore(new HashedSecret('super-secret')),
- RecoveryTokenIdentifierFactory::forType(RecoveryTokenType::safeStore(), 'super-secret')
+ RecoveryTokenIdentifierFactory::forType(RecoveryTokenType::safeStore(), 'super-secret'),
);
$this->assertEquals(
PhoneNumber::unknown(),
- RecoveryTokenIdentifierFactory::unknownForType(RecoveryTokenType::sms())
+ RecoveryTokenIdentifierFactory::unknownForType(RecoveryTokenType::sms()),
);
$this->assertEquals(
SafeStore::unknown(),
- RecoveryTokenIdentifierFactory::unknownForType(RecoveryTokenType::safeStore())
+ RecoveryTokenIdentifierFactory::unknownForType(RecoveryTokenType::safeStore()),
);
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/RegistrationAuthorityRoleTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/RegistrationAuthorityRoleTest.php
index c942ad277..dad2c5e86 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/RegistrationAuthorityRoleTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/RegistrationAuthorityRoleTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
-
- new RegistrationAuthorityRole($invalidValue);
- }
+ use MockeryPHPUnitIntegration;
/**
* @test
* @group domain
*/
- public function two_roles_with_the_same_value_are_equal()
+ public function two_roles_with_the_same_value_are_equal(): void
{
- $role = new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA);
- $theSame = new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA);
- $different = new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_SRAA);
+ $role = new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA);
+ $theSame = new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA);
+ $different = new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_SRAA);
$this->assertTrue($role->equals($theSame));
$this->assertFalse($role->equals($different));
}
-
- /**
- * dataprovider
- */
- public function invalidValueProvider()
- {
- return [
- 'array' => [[]],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
- ];
- }
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/SafeStoreTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/SafeStoreTest.php
index 46154bbbd..a113946b9 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/SafeStoreTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/SafeStoreTest.php
@@ -18,6 +18,7 @@
namespace Surfnet\Stepup\Tests\Identity\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Identity\Value\HashedSecret;
use Surfnet\Stepup\Identity\Value\PhoneNumber;
@@ -28,10 +29,12 @@
class SafeStoreTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @group domain
*/
- public function test_creation_of_safe_store()
+ public function test_creation_of_safe_store(): void
{
$unhashed = new UnhashedSecret('super-secret');
$instance = new SafeStore($unhashed->hashSecret());
@@ -42,7 +45,7 @@ public function test_creation_of_safe_store()
/**
* @group domain
*/
- public function test_equals()
+ public function test_equals(): void
{
$safeStore = new SafeStore(new UnhashedSecret('a'));
$safeStore2 = new SafeStore(new UnhashedSecret('a'));
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/SecondFactorIdentifierFactoryTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/SecondFactorIdentifierFactoryTest.php
index 05b8d4a5a..435ffc78c 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/SecondFactorIdentifierFactoryTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/SecondFactorIdentifierFactoryTest.php
@@ -18,6 +18,7 @@
namespace Surfnet\Stepup\Tests\Identity\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
use Surfnet\Stepup\Identity\Value\GssfId;
use Surfnet\Stepup\Identity\Value\PhoneNumber;
@@ -27,36 +28,38 @@
final class SecondFactorIdentifierFactoryTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
*/
- public function generates_identifiers_of_all_types()
+ public function generates_identifiers_of_all_types(): void
{
$this->assertEquals(
new PhoneNumber('+31 (0) 12345678'),
- SecondFactorIdentifierFactory::forType(new SecondFactorType('sms'), '+31 (0) 12345678')
+ SecondFactorIdentifierFactory::forType(new SecondFactorType('sms'), '+31 (0) 12345678'),
);
$this->assertEquals(
new YubikeyPublicId('08189273'),
- SecondFactorIdentifierFactory::forType(new SecondFactorType('yubikey'), '08189273')
+ SecondFactorIdentifierFactory::forType(new SecondFactorType('yubikey'), '08189273'),
);
$this->assertEquals(
new GssfId('urn:abcd-efgh-ijkl'),
- SecondFactorIdentifierFactory::forType(new SecondFactorType('tiqr'), 'urn:abcd-efgh-ijkl')
+ SecondFactorIdentifierFactory::forType(new SecondFactorType('tiqr'), 'urn:abcd-efgh-ijkl'),
);
$this->assertEquals(
PhoneNumber::unknown(),
- SecondFactorIdentifierFactory::unknownForType(new SecondFactorType('sms'))
+ SecondFactorIdentifierFactory::unknownForType(new SecondFactorType('sms')),
);
$this->assertEquals(
YubikeyPublicId::unknown(),
- SecondFactorIdentifierFactory::unknownForType(new SecondFactorType('yubikey'))
+ SecondFactorIdentifierFactory::unknownForType(new SecondFactorType('yubikey')),
);
$this->assertEquals(
GssfId::unknown(),
- SecondFactorIdentifierFactory::unknownForType(new SecondFactorType('tiqr'))
+ SecondFactorIdentifierFactory::unknownForType(new SecondFactorType('tiqr')),
);
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/StepupProviderTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/StepupProviderTest.php
index 81a199cf5..f89f665fe 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/StepupProviderTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/StepupProviderTest.php
@@ -18,21 +18,25 @@
namespace Surfnet\Stepup\Tests\Identity\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
+use StdClass;
+use Surfnet\Stepup\Exception\InvalidArgumentException;
use Surfnet\Stepup\Identity\Value\StepupProvider;
class StepupProviderTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
* @dataProvider invalidValueProvider
- *
- * @param mixed $invalidValue
*/
- public function a_stepup_provider_cannot_be_created_with_anything_but_a_nonempty_string($invalidValue)
- {
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ public function a_stepup_provider_cannot_be_created_with_anything_but_a_nonempty_string(
+ string $invalidValue,
+ ): void {
+ $this->expectException(InvalidArgumentException::class);
new StepupProvider($invalidValue);
}
@@ -41,11 +45,11 @@ public function a_stepup_provider_cannot_be_created_with_anything_but_a_nonempty
* @test
* @group domain
*/
- public function two_stepup_providers_with_the_same_value_are_equal()
+ public function two_stepup_providers_with_the_same_value_are_equal(): void
{
$institution = new StepupProvider('a');
- $theSame = new StepupProvider('a');
- $different = new StepupProvider('A');
+ $theSame = new StepupProvider('a');
+ $different = new StepupProvider('A');
$this->assertTrue($institution->equals($theSame));
$this->assertFalse($institution->equals($different));
@@ -54,15 +58,11 @@ public function two_stepup_providers_with_the_same_value_are_equal()
/**
* DataProvider for {@see a_stepup_provider_cannot_be_created_with_anything_but_a_nonempty_string()}
*/
- public function invalidValueProvider()
+ public function invalidValueProvider(): array
{
return [
'empty string' => [''],
'blank string' => [' '],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/TimeFrameTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/TimeFrameTest.php
index 98bb4ebbd..bf137a49a 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/TimeFrameTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/TimeFrameTest.php
@@ -1,5 +1,7 @@
expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
TimeFrame::ofSeconds($invalidValue);
}
@@ -39,7 +45,7 @@ public function it_cannot_be_given_an_non_positive_amount_of_seconds($invalidVal
* @test
* @group domain
*/
- public function to_string_output_matches_amount_of_seconds_as_string()
+ public function to_string_output_matches_amount_of_seconds_as_string(): void
{
$seconds = 1000;
@@ -47,24 +53,19 @@ public function to_string_output_matches_amount_of_seconds_as_string()
$this->assertEquals(
'1000',
- (string) $timeFrame,
- 'The amount of seconds as string must match timeFrame::__toString'
+ (string)$timeFrame,
+ 'The amount of seconds as string must match timeFrame::__toString',
);
}
/**
* dataprovider
*/
- public function invalidValueProvider()
+ public function invalidValueProviderInt(): array
{
return [
- 'empty string' => [''],
- 'string' => ['abc'],
- 'array' => [[]],
- 'float' => [2.718],
- 'zero' => [0],
+ 'zero' => [0],
'negative int' => [-1],
- 'object' => [new \StdClass()],
];
}
}
diff --git a/src/Surfnet/Stepup/Tests/Identity/Value/YubikeyPublicIdTest.php b/src/Surfnet/Stepup/Tests/Identity/Value/YubikeyPublicIdTest.php
index 81840b8ee..fa085e594 100644
--- a/src/Surfnet/Stepup/Tests/Identity/Value/YubikeyPublicIdTest.php
+++ b/src/Surfnet/Stepup/Tests/Identity/Value/YubikeyPublicIdTest.php
@@ -18,38 +18,42 @@
namespace Surfnet\Stepup\Tests\Identity\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
+use Surfnet\Stepup\Exception\InvalidArgumentException;
use Surfnet\Stepup\Identity\Value\YubikeyPublicId;
class YubikeyPublicIdTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group domain
*/
- public function two_yubikey_public_ids_with_the_same_value_are_equal()
+ public function two_yubikey_public_ids_with_the_same_value_are_equal(): void
{
- $id = new YubikeyPublicId('00001234');
- $theSame = new YubikeyPublicId('00001234');
- $different = new YubikeyPublicId('987654321');
- $unknown = YubikeyPublicId::unknown();
+ $id = new YubikeyPublicId('00001234');
+ $theSame = new YubikeyPublicId('00001234');
+ $different = new YubikeyPublicId('987654321');
+ $unknown = YubikeyPublicId::unknown();
$this->assertTrue($id->equals($theSame));
$this->assertFalse($id->equals($different));
$this->assertFalse($id->equals($unknown));
}
- public function invalidFormatProvider()
+ public function invalidFormatProvider(): array
{
return [
- '7-character unpadded ID' => ['1906381'],
- '9-character padded ID' => ['0123456789'],
- '19-character padded ID' => ['01234567890123456789'],
- '21-character ID' => ['101234567890123456789'],
- 'empty ID' => [''],
- 'ID with alphabetical characters' => ['abc'],
+ '7-character unpadded ID' => ['1906381'],
+ '9-character padded ID' => ['0123456789'],
+ '19-character padded ID' => ['01234567890123456789'],
+ '21-character ID' => ['101234567890123456789'],
+ 'empty ID' => [''],
+ 'ID with alphabetical characters' => ['abc'],
'ID with alphanumerical characters' => ['abc01908389'],
- 'Larger than 0xffffffffffffffff' => ['18446744073709551616']
+ 'Larger than 0xffffffffffffffff' => ['18446744073709551616'],
];
}
@@ -57,22 +61,20 @@ public function invalidFormatProvider()
* @test
* @group domain
* @dataProvider invalidFormatProvider
- *
- * @param mixed $invalidFormat
*/
- public function it_cannot_be_constructed_with_an_invalid_format($invalidFormat)
+ public function it_cannot_be_constructed_with_an_invalid_format(string $invalidFormat): void
{
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
new YubikeyPublicId($invalidFormat);
}
- public function validFormatProvider()
+ public function validFormatProvider(): array
{
return [
- '8-character ID' => ['01906381'],
- '1-character ID' => ['00000001'],
- '0-character ID' => ['00000000'],
+ '8-character ID' => ['01906381'],
+ '1-character ID' => ['00000001'],
+ '0-character ID' => ['00000000'],
'16-character ID' => ['1234560123456789'],
'20-character ID' => ['12345678901234567890'],
];
@@ -82,10 +84,8 @@ public function validFormatProvider()
* @test
* @group domain
* @dataProvider validFormatProvider
- *
- * @param string $validFormat
*/
- public function its_value_matches_its_input_value($validFormat)
+ public function its_value_matches_its_input_value(string $validFormat): void
{
$id = new YubikeyPublicId($validFormat);
diff --git a/src/Surfnet/Stepup/Token/TokenGenerator.php b/src/Surfnet/Stepup/Token/TokenGenerator.php
index 1c0143ae1..0005110e9 100644
--- a/src/Surfnet/Stepup/Token/TokenGenerator.php
+++ b/src/Surfnet/Stepup/Token/TokenGenerator.php
@@ -25,7 +25,7 @@ class TokenGenerator
*
* @return string
*/
- public static function generateNonce()
+ public static function generateNonce(): string
{
return md5(openssl_random_pseudo_bytes(50));
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Filter/InstitutionAuthorizationRepositoryFilter.php b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Filter/InstitutionAuthorizationRepositoryFilter.php
index 811e49dd3..ff2968c9b 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Filter/InstitutionAuthorizationRepositoryFilter.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Filter/InstitutionAuthorizationRepositoryFilter.php
@@ -23,18 +23,12 @@
class InstitutionAuthorizationRepositoryFilter
{
- /**
- * @param QueryBuilder $queryBuilder
- * @param InstitutionAuthorizationContextInterface $authorizationContext
- * @param string $institutionField
- * @param string $authorizationAlias
- */
public function filter(
- QueryBuilder $queryBuilder,
+ QueryBuilder $queryBuilder,
InstitutionAuthorizationContextInterface $authorizationContext,
- $institutionField,
- $authorizationAlias
- ) {
+ string $institutionField,
+ string $authorizationAlias,
+ ): void {
// If actor is SRAA we don't need filtering
if ($authorizationContext->isActorSraa()) {
return;
@@ -51,19 +45,14 @@ public function filter(
$whereCondition = sprintf(
'%s IN (:%s)',
$institutionField,
- $parameter
+ $parameter,
);
$queryBuilder->andWhere($whereCondition);
$queryBuilder->setParameter($parameter, $values);
}
- /**
- * @param $authorizationAlias
- * @param $name
- * @return string
- */
- private function getParameterName($authorizationAlias, $name)
+ private function getParameterName(string $authorizationAlias, string $name): string
{
return "{$authorizationAlias}_{$name}";
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/AuthorizationContextService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/AuthorizationContextService.php
index 01c1773a6..c1777209d 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/AuthorizationContextService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/AuthorizationContextService.php
@@ -25,6 +25,7 @@
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Value\InstitutionAuthorizationContext;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\ConfiguredInstitutionRepository;
use Surfnet\StepupMiddleware\ApiBundle\Exception\InvalidArgumentException;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuthorizationRepository;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\SraaService;
@@ -37,36 +38,12 @@
*/
class AuthorizationContextService
{
- /**
- * @var SraaService
- */
- private $sraaService;
-
- /**
- * @var IdentityService
- */
- private $identityService;
-
- /**
- * @var ConfiguredInstitutionRepository
- */
- private $institutionRepository;
-
- /**
- * @var AuthorizationRepository
- */
- private $authorizationRepository;
-
public function __construct(
- SraaService $sraaService,
- IdentityService $identityService,
- ConfiguredInstitutionRepository $institutionRepository,
- AuthorizationRepository $authorizationRepository
+ private readonly SraaService $sraaService,
+ private readonly IdentityService $identityService,
+ private readonly ConfiguredInstitutionRepository $institutionRepository,
+ private readonly AuthorizationRepository $authorizationRepository,
) {
- $this->sraaService = $sraaService;
- $this->identityService = $identityService;
- $this->institutionRepository = $institutionRepository;
- $this->authorizationRepository = $authorizationRepository;
}
public function buildSelectRaaInstitutionAuthorizationContext(IdentityId $actorId): InstitutionAuthorizationContext
@@ -86,7 +63,7 @@ public function buildSelectRaaInstitutionAuthorizationContext(IdentityId $actorI
*/
public function buildInstitutionAuthorizationContext(
IdentityId $actorId,
- RegistrationAuthorityRole $role
+ RegistrationAuthorityRole $role,
): InstitutionAuthorizationContext {
$isSraa = $this->isSraa($actorId);
if ($isSraa) {
@@ -102,10 +79,10 @@ public function buildInstitutionAuthorizationContext(
return new InstitutionAuthorizationContext($institutions, $isSraa);
}
- private function isSraa(IdentityId $actorId)
+ private function isSraa(IdentityId $actorId): bool
{
$identity = $this->identityService->find((string)$actorId);
- if (!$identity) {
+ if (!$identity instanceof Identity) {
throw new InvalidArgumentException('The provided id is not associated with any known identity');
}
$sraa = $this->sraaService->findByNameId($identity->nameId);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/AuthorizationService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/AuthorizationService.php
index 697dc8512..d5e5e0bd9 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/AuthorizationService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/AuthorizationService.php
@@ -38,36 +38,12 @@
*/
class AuthorizationService
{
- /**
- * @var IdentityService
- */
- private $identityService;
-
- /**
- * @var InstitutionConfigurationOptionsService
- */
- private $institutionConfigurationService;
-
- /**
- * @var SecondFactorService
- */
- private $secondFactorService;
-
- /**
- * @var RecoveryTokenService
- */
- private $recoveryTokenService;
-
public function __construct(
- IdentityService $identityService,
- InstitutionConfigurationOptionsService $institutionConfigurationService,
- SecondFactorService $secondFactorService,
- RecoveryTokenService $recoveryTokenService
+ private readonly IdentityService $identityService,
+ private readonly InstitutionConfigurationOptionsService $institutionConfigurationService,
+ private readonly SecondFactorService $secondFactorService,
+ private readonly RecoveryTokenService $recoveryTokenService,
) {
- $this->identityService = $identityService;
- $this->institutionConfigurationService = $institutionConfigurationService;
- $this->secondFactorService = $secondFactorService;
- $this->recoveryTokenService = $recoveryTokenService;
}
/**
@@ -82,24 +58,28 @@ public function __construct(
public function assertRegistrationOfSelfAssertedTokensIsAllowed(IdentityId $identityId): AuthorizationDecision
{
$identity = $this->findIdentity($identityId);
- if (!$identity) {
+ if (!$identity instanceof Identity) {
return $this->deny('Identity not found');
}
$institutionConfiguration = $this->findInstitutionConfiguration($identity);
- if (!$institutionConfiguration) {
- return $this->deny('Institution configuration could not be found, unable to ascertain if self-asserted tokens feature is enabled');
+ if (!$institutionConfiguration instanceof InstitutionConfigurationOptions) {
+ return $this->deny(
+ 'Institution configuration could not be found, unable to ascertain if self-asserted tokens feature is enabled',
+ );
}
if (!$institutionConfiguration->selfAssertedTokensOption->isEnabled()) {
- return $this->deny(sprintf('Institution "%s", does not allow self-asserted tokens', (string) $identity->institution));
+ return $this->deny(
+ sprintf('Institution "%s", does not allow self-asserted tokens', (string)$identity->institution),
+ );
}
$hasVettedSecondFactorToken = $this->secondFactorService->hasVettedByIdentity($identityId);
$options = $this->identityService->getSelfAssertedTokenRegistrationOptions(
$identity,
- $hasVettedSecondFactorToken
+ $hasVettedSecondFactorToken,
);
if ($hasVettedSecondFactorToken) {
@@ -108,13 +88,15 @@ public function assertRegistrationOfSelfAssertedTokensIsAllowed(IdentityId $iden
// Only allow self-asserted token (SAT) if the user does not have a token yet, or the first
// registered token was a SAT.
- $hadOtherTokenType = $options->possessedSelfAssertedToken === false && $options->possessedToken === true;
+ $hadOtherTokenType = $options->possessedSelfAssertedToken === false && $options->possessedToken;
if ($hadOtherTokenType) {
- return $this->deny('Identity never possessed a self-asserted token, but did/does possess one of the other types');
+ return $this->deny(
+ 'Identity never possessed a self-asserted token, but did/does possess one of the other types',
+ );
}
// The Identity is not allowed to do a SAT when he had a RT, but lost it. And also currently has no SF
$hasActiveRecoveryToken = $this->recoveryTokenService->identityHasActiveRecoveryToken($identity);
- if ($options->possessedSelfAssertedToken && !$hasActiveRecoveryToken && !$hasVettedSecondFactorToken) {
+ if ($options->possessedSelfAssertedToken && !$hasActiveRecoveryToken) {
return $this->deny('Identity lost both Recovery and Second Factor token, SAT is not allowed');
}
@@ -131,17 +113,21 @@ public function assertRegistrationOfSelfAssertedTokensIsAllowed(IdentityId $iden
public function assertSelfVetUsingSelfAssertedTokenIsAllowed(IdentityId $identityId): AuthorizationDecision
{
$identity = $this->findIdentity($identityId);
- if (!$identity) {
+ if (!$identity instanceof Identity) {
return $this->deny('Identity not found');
}
$institutionConfiguration = $this->findInstitutionConfiguration($identity);
- if (!$institutionConfiguration) {
- return $this->deny('Institution configuration could not be found, unable to ascertain if self-asserted tokens feature is enabled');
+ if (!$institutionConfiguration instanceof InstitutionConfigurationOptions) {
+ return $this->deny(
+ 'Institution configuration could not be found, unable to ascertain if self-asserted tokens feature is enabled',
+ );
}
if (!$institutionConfiguration->selfAssertedTokensOption->isEnabled()) {
- return $this->deny(sprintf('Institution "%s", does not allow self-asserted tokens', (string) $identity->institution));
+ return $this->deny(
+ sprintf('Institution "%s", does not allow self-asserted tokens', (string)$identity->institution),
+ );
}
$query = new VettedSecondFactorQuery();
@@ -167,26 +153,32 @@ public function assertSelfVetUsingSelfAssertedTokenIsAllowed(IdentityId $identit
public function assertRecoveryTokensAreAllowed(IdentityId $identityId): AuthorizationDecision
{
$identity = $this->findIdentity($identityId);
- if (!$identity) {
+ if (!$identity instanceof Identity) {
return $this->deny('Identity not found');
}
$institutionConfiguration = $this->findInstitutionConfiguration($identity);
- if (!$institutionConfiguration) {
- return $this->deny('Institution configuration could not be found, unable to ascertain if self-asserted tokens feature is enabled');
+ if (!$institutionConfiguration instanceof InstitutionConfigurationOptions) {
+ return $this->deny(
+ 'Institution configuration could not be found, unable to ascertain if self-asserted tokens feature is enabled',
+ );
}
if (!$institutionConfiguration->selfAssertedTokensOption->isEnabled()) {
- return $this->deny(sprintf('Institution "%s", does not allow self-asserted tokens', (string) $identity->institution));
+ return $this->deny(
+ sprintf('Institution "%s", does not allow self-asserted tokens', (string)$identity->institution),
+ );
}
// Only allow CRUD actions on recovery tokens when the identity previously registered a SAT
$options = $this->identityService->getSelfAssertedTokenRegistrationOptions(
$identity,
- $this->secondFactorService->hasVettedByIdentity($identityId)
+ $this->secondFactorService->hasVettedByIdentity($identityId),
);
if ($options->possessedSelfAssertedToken === false) {
- return $this->deny('Identity never possessed a self-asserted token, deny access to recovery token CRUD actions');
+ return $this->deny(
+ 'Identity never possessed a self-asserted token, deny access to recovery token CRUD actions',
+ );
}
return $this->allow();
@@ -195,7 +187,7 @@ public function assertRecoveryTokensAreAllowed(IdentityId $identityId): Authoriz
private function findInstitutionConfiguration(Identity $identity): ?InstitutionConfigurationOptions
{
$institution = new Institution((string)$identity->institution);
- return $this->institutionConfigurationService
+ return $this->institutionConfigurationService
->findInstitutionConfigurationOptionsFor($institution);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/CommandAuthorizationService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/CommandAuthorizationService.php
index 10779b05a..86f2f087f 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/CommandAuthorizationService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Service/CommandAuthorizationService.php
@@ -21,6 +21,7 @@
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\RegistrationAuthorityRole;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\WhitelistService;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
@@ -29,7 +30,6 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\SelfServiceExecutable;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\CreateIdentityCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ExpressLocalePreferenceCommand;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\RevokeOwnRecoveryTokenCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\RevokeRegistrantsRecoveryTokenCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\RevokeRegistrantsSecondFactorCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\UpdateIdentityCommand;
@@ -56,58 +56,31 @@
*/
class CommandAuthorizationService
{
- /**
- * @var WhitelistService
- */
- private $whitelistService;
- /**
- * @var IdentityService
- */
- private $identityService;
- /**
- * @var AuthorizationContextService
- */
- private $authorizationContextService;
- /**
- * @var LoggerInterface
- */
- private $logger;
-
public function __construct(
- WhitelistService $whitelistService,
- IdentityService $identityService,
- LoggerInterface $logger,
- AuthorizationContextService $authorizationContextService
+ private readonly WhitelistService $whitelistService,
+ private readonly IdentityService $identityService,
+ private readonly LoggerInterface $logger,
+ private readonly AuthorizationContextService $authorizationContextService,
) {
- $this->logger = $logger;
- $this->authorizationContextService = $authorizationContextService;
- $this->whitelistService = $whitelistService;
- $this->identityService = $identityService;
}
/**
- * @param Institution $institution
* @param IdentityId|null $actorId
* @return bool
*/
- public function isInstitutionWhitelisted(Institution $institution, IdentityId $actorId = null)
+ public function isInstitutionWhitelisted(Institution $institution, IdentityId $actorId = null): bool
{
// If the actor is SRAA all actions should be allowed
if (!is_null($actorId) && $this->isSraa($actorId)) {
return true;
}
-
- if ($this->whitelistService->isWhitelisted($institution->getInstitution())) {
- return true;
- }
-
- return false;
+ return (bool)$this->whitelistService->isWhitelisted($institution->getInstitution());
}
public function maySelfServiceCommandBeExecutedOnBehalfOf(Command $command, IdentityId $actorId = null): bool
{
- $commandName = get_class($command);
- $identityId = $actorId ? $actorId->getIdentityId() : null;
+ $commandName = $command::class;
+ $identityId = $actorId instanceof IdentityId ? $actorId->getIdentityId() : null;
// Assert Self Service command could be executed
if ($command instanceof SelfServiceExecutable) {
@@ -118,7 +91,7 @@ public function maySelfServiceCommandBeExecutedOnBehalfOf(Command $command, Iden
$this->logAllowSelfService(
'SRAA user is always allowed to record SelfService commands',
$commandName,
- $identityId
+ $identityId,
);
return true;
}
@@ -128,7 +101,7 @@ public function maySelfServiceCommandBeExecutedOnBehalfOf(Command $command, Iden
$this->logAllowSelfService(
'Allowing execution of a SelfAsserted command',
$commandName,
- $identityId
+ $identityId,
);
return true;
}
@@ -141,7 +114,7 @@ public function maySelfServiceCommandBeExecutedOnBehalfOf(Command $command, Iden
$this->logAllowSelfService(
'Allowing execution of a CreateIdentityCommand or UpdateIdentityCommand command',
$commandName,
- $identityId
+ $identityId,
);
return true;
}
@@ -151,7 +124,7 @@ public function maySelfServiceCommandBeExecutedOnBehalfOf(Command $command, Iden
$this->logDenySelfService(
'The actor identity id does not match that of the identity id that was recorded in the command',
$commandName,
- $identityId
+ $identityId,
);
return false;
}
@@ -167,10 +140,10 @@ public function maySelfServiceCommandBeExecutedOnBehalfOf(Command $command, Iden
public function mayRaCommandBeExecutedOnBehalfOf(
Command $command,
IdentityId $actorId = null,
- Institution $actorInstitution = null
+ Institution $actorInstitution = null,
): bool {
- $commandName = get_class($command);
- $identityId = $actorId ? $actorId->getIdentityId() : null;
+ $commandName = $command::class;
+ $identityId = $actorId instanceof IdentityId ? $actorId->getIdentityId() : null;
$this->logger->notice('Running the mayRaCommandBeExecutedOnBehalfOf sequence');
// Assert RA(A) specific authorizations
@@ -182,7 +155,7 @@ public function mayRaCommandBeExecutedOnBehalfOf(
$this->logAllowRa(
'RA(A) is always allowed to perform the ExpressLocalePreferenceCommand',
$commandName,
- $identityId
+ $identityId,
);
return true;
}
@@ -192,7 +165,7 @@ public function mayRaCommandBeExecutedOnBehalfOf(
$this->logDenyRA(
'ActorId and/or actorInstitution is missing in mayRaCommandBeExecutedOnBehalfOf',
$commandName,
- $identityId
+ $identityId,
);
return false;
}
@@ -202,7 +175,7 @@ public function mayRaCommandBeExecutedOnBehalfOf(
$this->logAllowRa(
'SRAA is always allowed to execute RA commands',
$commandName,
- $identityId
+ $identityId,
);
return true;
}
@@ -225,15 +198,17 @@ public function mayRaCommandBeExecutedOnBehalfOf(
$command instanceof RevokeRegistrantsSecondFactorCommand ||
$command instanceof RevokeRegistrantsRecoveryTokenCommand
) {
- $this->logger->notice('VetSecondFactorCommand and RevokeRegistrantsSecondFactorCommand require a RA role');
+ $this->logger->notice(
+ 'VetSecondFactorCommand and RevokeRegistrantsSecondFactorCommand require a RA role',
+ );
$roleRequirement = RegistrationAuthorityRole::ra();
// Use the institution of the identity (the user vetting or having his token revoked).
$identity = $this->identityService->find($command->identityId);
- if (!$identity) {
+ if (!$identity instanceof Identity) {
$this->logDenyRA(
'Unable to find the identity of the user that is being vetted, or revoked',
$commandName,
- $identityId
+ $identityId,
);
return false;
}
@@ -241,22 +216,22 @@ public function mayRaCommandBeExecutedOnBehalfOf(
sprintf(
'Changed RA institution (before %s) to identity institution: %s',
$raInstitution,
- $identity->institution->getInstitution()
- )
+ $identity->institution->getInstitution(),
+ ),
);
$raInstitution = $identity->institution->getInstitution();
}
$authorizationContext = $this->authorizationContextService->buildInstitutionAuthorizationContext(
$actorId,
- $roleRequirement
+ $roleRequirement,
);
$this->logger->notice(
sprintf(
'Identity is authorized RA(A) role in institutions: %s',
- implode(',', $authorizationContext->getInstitutions()->serialize())
- )
+ implode(',', $authorizationContext->getInstitutions()->serialize()),
+ ),
);
if (!$authorizationContext->getInstitutions()->contains(new Institution($raInstitution))) {
@@ -264,10 +239,10 @@ public function mayRaCommandBeExecutedOnBehalfOf(
sprintf(
'Identity is not RA(A) for the specified RA institution, "%s". Allowed institutions: "%s"',
$raInstitution,
- implode(',', $authorizationContext->getInstitutions()->serialize())
+ implode(',', $authorizationContext->getInstitutions()->serialize()),
),
$commandName,
- $identityId
+ $identityId,
);
return false;
}
@@ -275,7 +250,7 @@ public function mayRaCommandBeExecutedOnBehalfOf(
$this->logAllowRa(
'Allowed',
$commandName,
- $identityId
+ $identityId,
);
return true;
}
@@ -286,15 +261,13 @@ private function isSraa(IdentityId $actorId = null): bool
return false;
}
- $registrationAuthorityCredentials = $this->identityService->findRegistrationAuthorityCredentialsOf($actorId->getIdentityId());
- if (!$registrationAuthorityCredentials) {
- return false;
- }
-
- if (!$registrationAuthorityCredentials->isSraa()) {
+ $registrationAuthorityCredentials = $this->identityService->findRegistrationAuthorityCredentialsOf(
+ $actorId->getIdentityId(),
+ );
+ if (!$registrationAuthorityCredentials instanceof \Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RegistrationAuthorityCredentials) {
return false;
}
- return true;
+ return $registrationAuthorityCredentials->isSraa();
}
private function logAllowSelfService(string $message, string $commandName, ?string $identityId): void
@@ -308,8 +281,8 @@ private function logAllowSelfService(string $message, string $commandName, ?stri
'Allowing SelfService command %s for identity %s. With message "%s"',
$commandName,
$identityId,
- $message
- )
+ $message,
+ ),
);
}
@@ -323,8 +296,8 @@ private function logDenySelfService(string $message, string $commandName, ?strin
'Denying SelfService command %s for identity %s. With message "%s"',
$commandName,
$identityId,
- $message
- )
+ $message,
+ ),
);
}
@@ -338,8 +311,8 @@ private function logAllowRa(string $message, string $commandName, ?string $ident
'Allowing RA command %s for identity %s. With message "%s"',
$commandName,
$identityId,
- $message
- )
+ $message,
+ ),
);
}
@@ -353,8 +326,8 @@ private function logDenyRA(string $message, string $commandName, ?string $identi
'Denying RA command %s for identity %s. With message "%s"',
$commandName,
$identityId,
- $message
- )
+ $message,
+ ),
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/AuthorizationDecision.php b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/AuthorizationDecision.php
index 3cfca7ea6..8dfaad2cb 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/AuthorizationDecision.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/AuthorizationDecision.php
@@ -20,27 +20,23 @@
use Assert\Assertion;
-final class AuthorizationDecision
+final readonly class AuthorizationDecision
{
- private $code;
-
- private $errorMessages;
-
- public static function allowed()
+ public static function allowed(): self
{
return new self(200);
}
- public static function denied(array $messages = [])
+ public static function denied(array $messages = []): self
{
Assertion::allString($messages, 'The error messages should all be strings');
return new self(403, $messages);
}
- private function __construct(int $code, array $errorMessages = [])
- {
- $this->code = $code;
- $this->errorMessages = $errorMessages;
+ private function __construct(
+ private int $code,
+ private array $errorMessages = [],
+ ) {
}
public function getCode(): int
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionAuthorizationContext.php b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionAuthorizationContext.php
index 598921dc8..24c7b449a 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionAuthorizationContext.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionAuthorizationContext.php
@@ -34,22 +34,10 @@
*/
class InstitutionAuthorizationContext implements InstitutionAuthorizationContextInterface
{
- /**
- * @var InstitutionCollection|null
- */
- private $institutions;
-
- /**
- * @var bool
- */
- private $isSraa;
-
public function __construct(
- InstitutionCollection $institutions = null,
- bool $isSraa = false
+ private readonly ?InstitutionCollection $institutions = null,
+ private readonly bool $isSraa = false,
) {
- $this->institutions = $institutions;
- $this->isSraa = $isSraa;
}
public function getInstitutions(): InstitutionCollection
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionAuthorizationContextInterface.php b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionAuthorizationContextInterface.php
index aaf7870bd..73919157f 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionAuthorizationContextInterface.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionAuthorizationContextInterface.php
@@ -36,10 +36,10 @@ interface InstitutionAuthorizationContextInterface
/**
* @return InstitutionCollection
*/
- public function getInstitutions();
+ public function getInstitutions(): InstitutionCollection;
/**
* @return bool
*/
- public function isActorSraa();
+ public function isActorSraa(): bool;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionRoleSet.php b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionRoleSet.php
index 3ea0bf6a0..023139a2e 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionRoleSet.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionRoleSet.php
@@ -26,7 +26,7 @@ final class InstitutionRoleSet implements InstitutionRoleSetInterface
/**
* @var InstitutionRole[]
*/
- private $institutionRoles;
+ private readonly array $institutionRoles;
public function __construct(array $institutionRoles)
{
@@ -35,14 +35,14 @@ public function __construct(array $institutionRoles)
throw InvalidArgumentException::invalidType(
'InsititutionRole[]',
'institutionRoles',
- $institutionRoles
+ $institutionRoles,
);
}
}
$this->institutionRoles = $institutionRoles;
}
- public function getRoles()
+ public function getRoles(): array
{
return $this->institutionRoles;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionRoleSetInterface.php b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionRoleSetInterface.php
index 67eacf76c..b4898fb17 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionRoleSetInterface.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Authorization/Value/InstitutionRoleSetInterface.php
@@ -18,10 +18,7 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Authorization\Value;
-use Surfnet\Stepup\Configuration\Value\InstitutionRole;
-use Surfnet\StepupMiddleware\ApiBundle\Exception\InvalidArgumentException;
-
interface InstitutionRoleSetInterface
{
- public function getRoles();
+ public function getRoles(): array;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/AllowedSecondFactor.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/AllowedSecondFactor.php
index 5a4623a62..4e94c5d1f 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/AllowedSecondFactor.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/AllowedSecondFactor.php
@@ -21,43 +21,35 @@
use Doctrine\ORM\Mapping as ORM;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\StepupBundle\Value\SecondFactorType;
+use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\AllowedSecondFactorRepository;
-/**
- * @ORM\Entity(
- * repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\AllowedSecondFactorRepository"
- * )
- */
+#[ORM\Entity(repositoryClass: AllowedSecondFactorRepository::class)]
class AllowedSecondFactor
{
/**
- * @ORM\Id
- * @ORM\Column(type="stepup_configuration_institution")
*
* @var Institution
*/
- public $institution;
+ #[ORM\Id]
+ #[ORM\Column(type: 'stepup_configuration_institution')]
+ public Institution $institution;
/**
- * @ORM\Id
- * @ORM\Column(type="stepup_second_factor_type")
*
* @var SecondFactorType
*/
- public $secondFactorType;
+ #[ORM\Id]
+ #[ORM\Column(type: 'stepup_second_factor_type')]
+ public SecondFactorType $secondFactorType;
private function __construct()
{
}
- /**
- * @param Institution $institution
- * @param SecondFactorType $secondFactorType
- * @return AllowedSecondFactor
- */
- public static function createFrom(Institution $institution, SecondFactorType $secondFactorType)
+ public static function createFrom(Institution $institution, SecondFactorType $secondFactorType): self
{
- $allowedSecondFactor = new self;
- $allowedSecondFactor->institution = $institution;
+ $allowedSecondFactor = new self;
+ $allowedSecondFactor->institution = $institution;
$allowedSecondFactor->secondFactorType = $secondFactorType;
return $allowedSecondFactor;
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/ConfiguredInstitution.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/ConfiguredInstitution.php
index e4d3a8260..d1abfdabb 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/ConfiguredInstitution.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/ConfiguredInstitution.php
@@ -20,27 +20,16 @@
use Doctrine\ORM\Mapping as ORM;
use Surfnet\Stepup\Configuration\Value\Institution;
+use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\ConfiguredInstitutionRepository;
-/**
- * @ORM\Entity(
- * repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\ConfiguredInstitutionRepository"
- * )
- */
+#[ORM\Entity(repositoryClass: ConfiguredInstitutionRepository::class)]
class ConfiguredInstitution
{
- /**
- * @ORM\Id
- * @ORM\Column(type="stepup_configuration_institution")
- *
- * @var Institution
- */
- public $institution;
+ #[ORM\Id]
+ #[ORM\Column(type: 'stepup_configuration_institution')]
+ public Institution $institution;
- /**
- * @param Institution $institution
- * @return ConfiguredInstitution
- */
- public static function createFrom(Institution $institution)
+ public static function createFrom(Institution $institution): self
{
$configuredInstitution = new self;
$configuredInstitution->institution = $institution;
@@ -48,7 +37,7 @@ public static function createFrom(Institution $institution)
return $configuredInstitution;
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return ['institution' => $this->institution];
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/InstitutionAuthorization.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/InstitutionAuthorization.php
index 2dd58d560..fc33dbb34 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/InstitutionAuthorization.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/InstitutionAuthorization.php
@@ -21,54 +21,45 @@
use Doctrine\ORM\Mapping as ORM;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
+use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionAuthorizationRepository;
-/**
- * @ORM\Entity(
- * repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionAuthorizationRepository"
- * )
- * @ORM\Table(
- * indexes={
- * @ORM\Index(name="idx_authorization", columns={"institution","institution_relation","institution_role"})
- * }
- * )
- */
+#[ORM\Table]
+#[ORM\Index(name: 'idx_authorization', columns: ['institution', 'institution_relation', 'institution_role'])]
+#[ORM\Entity(repositoryClass: InstitutionAuthorizationRepository::class)]
class InstitutionAuthorization
{
/**
- * @ORM\Id
- * @ORM\Column(type="stepup_configuration_institution")
*
* @var Institution
*/
- public $institution;
+ #[ORM\Id]
+ #[ORM\Column(type: 'stepup_configuration_institution')]
+ public Institution $institution;
/**
- * @ORM\Id
- * @ORM\Column(type="stepup_configuration_institution")
*
* @var Institution
*/
- public $institutionRelation;
+ #[ORM\Id]
+ #[ORM\Column(type: 'stepup_configuration_institution')]
+ public Institution $institutionRelation;
/**
- * @ORM\Id
- * @ORM\Column(type="stepup_institution_role", length=10)
*
* @var InstitutionRole
*/
- public $institutionRole;
+ #[ORM\Id]
+ #[ORM\Column(type: 'stepup_institution_role', length: 10)]
+ public InstitutionRole $institutionRole;
/**
- * @param Institution $institution
- * @param Institution $institutionRelation
- * @param InstitutionRole $institutionRole
* @return InstitutionAuthorization
*/
public static function create(
Institution $institution,
Institution $institutionRelation,
- InstitutionRole $institutionRole
- ) {
+ InstitutionRole $institutionRole,
+ ): self {
$options = new self;
$options->institution = $institution;
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/InstitutionConfigurationOptions.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/InstitutionConfigurationOptions.php
index ccaa9a21b..92684aef5 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/InstitutionConfigurationOptions.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/InstitutionConfigurationOptions.php
@@ -27,70 +27,60 @@
use Surfnet\Stepup\Configuration\Value\SsoOn2faOption;
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption;
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
+use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionConfigurationOptionsRepository;
-/**
- * @ORM\Entity(
- * repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionConfigurationOptionsRepository"
- * )
- */
+#[ORM\Entity(repositoryClass: InstitutionConfigurationOptionsRepository::class)]
class InstitutionConfigurationOptions
{
/**
- * @ORM\Id
- * @ORM\Column(type="stepup_configuration_institution")
*
* @var Institution
*/
- public $institution;
+ #[ORM\Id]
+ #[ORM\Column(type: 'stepup_configuration_institution')]
+ public Institution $institution;
/**
- * @ORM\Column(type="stepup_use_ra_locations_option")
- *
* @var UseRaLocationsOption
*/
- public $useRaLocationsOption;
+ #[ORM\Column(type: 'stepup_use_ra_locations_option')]
+ public UseRaLocationsOption $useRaLocationsOption;
/**
- * @ORM\Column(type="stepup_show_raa_contact_information_option")
- *
* @var ShowRaaContactInformationOption
*/
- public $showRaaContactInformationOption;
+ #[ORM\Column(type: 'stepup_show_raa_contact_information_option')]
+ public ShowRaaContactInformationOption $showRaaContactInformationOption;
/**
- * @ORM\Column(type="stepup_verify_email_option", options={"default" : 1})
- *
* @var VerifyEmailOption
*/
- public $verifyEmailOption;
+ #[ORM\Column(type: 'stepup_verify_email_option', options: ['default' => 1])]
+ public VerifyEmailOption $verifyEmailOption;
/**
- * @ORM\Column(type="stepup_self_vet_option", options={"default" : 0})
- *
* @var SelfVetOption
*/
- public $selfVetOption;
+ #[ORM\Column(type: 'stepup_self_vet_option', options: ['default' => 0])]
+ public SelfVetOption $selfVetOption;
/**
- * @ORM\Column(type="stepup_sso_on_2fa_option", options={"default" : 0})
- *
* @var SsoOn2FaOption
*/
- public $ssoOn2faOption;
+ #[ORM\Column(type: 'stepup_sso_on_2fa_option', options: ['default' => 0])]
+ public SsoOn2faOption $ssoOn2faOption;
/**
- * @ORM\Column(type="stepup_self_asserted_tokens_option", options={"default" : 0})
- *
* @var SelfAssertedTokensOption
*/
- public $selfAssertedTokensOption;
+ #[ORM\Column(type: 'stepup_self_asserted_tokens_option', options: ['default' => 0])]
+ public SelfAssertedTokensOption $selfAssertedTokensOption;
/**
- * @ORM\Column(type="stepup_number_of_tokens_per_identity_option", options={"default" : 0})
- *
* @var NumberOfTokensPerIdentityOption
*/
- public $numberOfTokensPerIdentityOption;
+ #[ORM\Column(type: 'stepup_number_of_tokens_per_identity_option', options: ['default' => 0])]
+ public NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption;
public static function create(
Institution $institution,
@@ -100,14 +90,14 @@ public static function create(
NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption,
SsoOn2faOption $ssoOn2faOption,
SelfVetOption $selfVetOption,
- SelfAssertedTokensOption $selfAssertedTokensOption
- ) {
+ SelfAssertedTokensOption $selfAssertedTokensOption,
+ ): self {
$options = new self;
- $options->institution = $institution;
- $options->useRaLocationsOption = $useRaLocationsOption;
+ $options->institution = $institution;
+ $options->useRaLocationsOption = $useRaLocationsOption;
$options->showRaaContactInformationOption = $showRaaContactInformationOption;
- $options->verifyEmailOption = $verifyEmailOption;
+ $options->verifyEmailOption = $verifyEmailOption;
$options->numberOfTokensPerIdentityOption = $numberOfTokensPerIdentityOption;
$options->ssoOn2faOption = $ssoOn2faOption;
$options->selfVetOption = $selfVetOption;
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/RaLocation.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/RaLocation.php
index 05554fd1c..a8379d948 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/RaLocation.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Entity/RaLocation.php
@@ -18,91 +18,77 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity;
+use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
use Surfnet\Stepup\Configuration\Value\ContactInformation;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\Location;
use Surfnet\Stepup\Configuration\Value\RaLocationName;
+use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\RaLocationRepository;
use Surfnet\StepupMiddleware\ApiBundle\Exception\InvalidArgumentException;
-use Doctrine\ORM\Mapping as ORM;
-/**
- * @ORM\Entity(
- * repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\RaLocationRepository"
- * )
- * @ORM\Table(
- * indexes={
- * @ORM\Index(name="idx_ra_location_institution", columns={"institution"})
- * }
- * )
- */
+#[ORM\Table]
+#[ORM\Index(name: 'idx_ra_location_institution', columns: ['institution'])]
+#[ORM\Entity(repositoryClass: RaLocationRepository::class)]
class RaLocation implements JsonSerializable
{
/**
- * @ORM\Id
- * @ORM\Column(length=36)
*
* @var string
*/
- public $id;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $id;
/**
- * @ORM\Column(type="stepup_configuration_institution")
- *
* @var Institution
*/
- public $institution;
+ #[ORM\Column(type: 'stepup_configuration_institution')]
+ public Institution $institution;
/**
- * @ORM\Column(type="stepup_ra_location_name")
- *
* @var RaLocationName
*/
- public $name;
+ #[ORM\Column(type: 'stepup_ra_location_name')]
+ public RaLocationName $name;
/**
- * @ORM\Column(type="stepup_configuration_location")
- *
* @var Location
*/
- public $location;
+ #[ORM\Column(type: 'stepup_configuration_location')]
+ public Location $location;
/**
- * @ORM\Column(type="stepup_configuration_contact_information")
- *
* @var ContactInformation
*/
- public $contactInformation;
+ #[ORM\Column(type: 'stepup_configuration_contact_information')]
+ public ContactInformation $contactInformation;
public static function create(
- $id,
+ string $id,
Institution $institution,
RaLocationName $name,
Location $location,
- ContactInformation $contactInformation
- ) {
- if (!is_string($id)) {
- throw InvalidArgumentException::invalidType('string', 'id', $id);
- }
-
+ ContactInformation $contactInformation,
+ ): self {
$raLocation = new self;
- $raLocation->id = $id;
- $raLocation->institution = $institution;
- $raLocation->name = $name;
- $raLocation->location = $location;
+ $raLocation->id = $id;
+ $raLocation->institution = $institution;
+ $raLocation->name = $name;
+ $raLocation->location = $location;
$raLocation->contactInformation = $contactInformation;
return $raLocation;
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
- 'id' => $this->id,
- 'institution' => $this->institution,
- 'name' => $this->name,
- 'location' => $this->location,
+ 'id' => $this->id,
+ 'institution' => $this->institution,
+ 'name' => $this->name,
+ 'location' => $this->location,
'contact_information' => $this->contactInformation,
];
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/AllowedSecondFactorListProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/AllowedSecondFactorListProjector.php
index b12eb7982..6e39cfb25 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/AllowedSecondFactorListProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/AllowedSecondFactorListProjector.php
@@ -25,20 +25,12 @@
final class AllowedSecondFactorListProjector extends Projector
{
- /**
- * @var AllowedSecondFactorRepository
- */
- private $allowedSecondFactorRepository;
-
- public function __construct(AllowedSecondFactorRepository $allowedSecondFactorRepository)
- {
- $this->allowedSecondFactorRepository = $allowedSecondFactorRepository;
+ public function __construct(
+ private readonly AllowedSecondFactorRepository $allowedSecondFactorRepository,
+ ) {
}
- /**
- * @param AllowedSecondFactorListUpdatedEvent $event
- */
- public function applyAllowedSecondFactorListUpdatedEvent(AllowedSecondFactorListUpdatedEvent $event)
+ public function applyAllowedSecondFactorListUpdatedEvent(AllowedSecondFactorListUpdatedEvent $event): void
{
// Start with a clean slate
$this->allowedSecondFactorRepository->clearAllowedSecondFactorListFor($event->institution);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/ConfiguredInstitutionProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/ConfiguredInstitutionProjector.php
index 76baf7084..554863814 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/ConfiguredInstitutionProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/ConfiguredInstitutionProjector.php
@@ -26,22 +26,17 @@
final class ConfiguredInstitutionProjector extends Projector
{
- /**
- * @var ConfiguredInstitutionRepository
- */
- private $configuredInstitutionRepository;
-
- public function __construct(ConfiguredInstitutionRepository $configuredInstitutionRepository)
- {
- $this->configuredInstitutionRepository = $configuredInstitutionRepository;
+ public function __construct(
+ private readonly ConfiguredInstitutionRepository $configuredInstitutionRepository,
+ ) {
}
- public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event)
+ public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event): void
{
$this->configuredInstitutionRepository->save(ConfiguredInstitution::createFrom($event->institution));
}
- public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event)
+ public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event): void
{
$this->configuredInstitutionRepository->removeConfigurationFor($event->institution);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/InstitutionAuthorizationProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/InstitutionAuthorizationProjector.php
index 65133cecc..a13db3a70 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/InstitutionAuthorizationProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/InstitutionAuthorizationProjector.php
@@ -32,56 +32,44 @@
*/
final class InstitutionAuthorizationProjector extends Projector
{
- /**
- * @var InstitutionAuthorizationRepository
- */
- private $institutionAuthorizationRepository;
- /**
- * @var InstitutionConfigurationOptionsRepository
- */
- private $institutionConfigurationOptionsRepository;
-
public function __construct(
- InstitutionAuthorizationRepository $institutionAuthorizationRepository,
- InstitutionConfigurationOptionsRepository $institutionConfigurationOptionsRepository
+ private readonly InstitutionAuthorizationRepository $institutionAuthorizationRepository,
) {
- $this->institutionAuthorizationRepository = $institutionAuthorizationRepository;
- $this->institutionConfigurationOptionsRepository = $institutionConfigurationOptionsRepository;
}
- public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event)
+ public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event): void
{
$this->institutionAuthorizationRepository->setDefaultInstitutionOption($event->institution);
}
- public function applyUseRaOptionChangedEvent(UseRaOptionChangedEvent $event)
+ public function applyUseRaOptionChangedEvent(UseRaOptionChangedEvent $event): void
{
$this->institutionAuthorizationRepository->saveInstitutionOption(
$event->institution,
- $event->useRaOption
+ $event->useRaOption,
);
}
- public function applyUseRaaOptionChangedEvent(UseRaaOptionChangedEvent $event)
+ public function applyUseRaaOptionChangedEvent(UseRaaOptionChangedEvent $event): void
{
$this->institutionAuthorizationRepository->saveInstitutionOption(
$event->institution,
- $event->useRaaOption
+ $event->useRaaOption,
);
}
- public function applySelectRaaOptionChangedEvent(SelectRaaOptionChangedEvent $event)
+ public function applySelectRaaOptionChangedEvent(SelectRaaOptionChangedEvent $event): void
{
$this->institutionAuthorizationRepository->saveInstitutionOption(
$event->institution,
- $event->selectRaaOption
+ $event->selectRaaOption,
);
}
- public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event)
+ public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event): void
{
$this->institutionAuthorizationRepository->clearInstitutionOption(
- $event->institution
+ $event->institution,
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/InstitutionConfigurationOptionsProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/InstitutionConfigurationOptionsProjector.php
index 675b247da..9f22e2dc2 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/InstitutionConfigurationOptionsProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/InstitutionConfigurationOptionsProjector.php
@@ -34,25 +34,13 @@
final class InstitutionConfigurationOptionsProjector extends Projector
{
- /**
- * @var InstitutionConfigurationOptionsRepository
- */
- private $institutionConfigurationOptionsRepository;
-
- /**
- * @var AllowedSecondFactorRepository
- */
- private $allowedSecondFactorRepository;
-
public function __construct(
- InstitutionConfigurationOptionsRepository $institutionConfigurationOptionsRepository,
- AllowedSecondFactorRepository $allowedSecondFactorRepository
+ private readonly InstitutionConfigurationOptionsRepository $institutionConfigurationOptionsRepository,
+ private readonly AllowedSecondFactorRepository $allowedSecondFactorRepository,
) {
- $this->institutionConfigurationOptionsRepository = $institutionConfigurationOptionsRepository;
- $this->allowedSecondFactorRepository = $allowedSecondFactorRepository;
}
- public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event)
+ public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event): void
{
$institutionConfigurationOptions = InstitutionConfigurationOptions::create(
$event->institution,
@@ -62,69 +50,83 @@ public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfi
$event->numberOfTokensPerIdentityOption,
$event->ssoOn2faOption,
$event->selfVetOption,
- $event->selfAssertedTokensOption
+ $event->selfAssertedTokensOption,
);
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
}
- public function applyUseRaLocationsOptionChangedEvent(UseRaLocationsOptionChangedEvent $event)
+ public function applyUseRaLocationsOptionChangedEvent(UseRaLocationsOptionChangedEvent $event): void
{
- $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor($event->institution);
+ $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor(
+ $event->institution,
+ );
$institutionConfigurationOptions->useRaLocationsOption = $event->useRaLocationsOption;
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
}
- public function applyShowRaaContactInformationOptionChangedEvent(ShowRaaContactInformationOptionChangedEvent $event)
+ public function applyShowRaaContactInformationOptionChangedEvent(ShowRaaContactInformationOptionChangedEvent $event,): void
{
- $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor($event->institution);
+ $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor(
+ $event->institution,
+ );
$institutionConfigurationOptions->showRaaContactInformationOption = $event->showRaaContactInformationOption;
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
}
- public function applyVerifyEmailOptionChangedEvent(VerifyEmailOptionChangedEvent $event)
+ public function applyVerifyEmailOptionChangedEvent(VerifyEmailOptionChangedEvent $event): void
{
- $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor($event->institution);
+ $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor(
+ $event->institution,
+ );
$institutionConfigurationOptions->verifyEmailOption = $event->verifyEmailOption;
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
}
- public function applyNumberOfTokensPerIdentityOptionChangedEvent(NumberOfTokensPerIdentityOptionChangedEvent $event)
+ public function applyNumberOfTokensPerIdentityOptionChangedEvent(NumberOfTokensPerIdentityOptionChangedEvent $event,): void
{
- $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor($event->institution);
+ $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor(
+ $event->institution,
+ );
$institutionConfigurationOptions->numberOfTokensPerIdentityOption = $event->numberOfTokensPerIdentityOption;
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
}
- public function applySelfVetOptionChangedEvent(SelfVetOptionChangedEvent $event)
+ public function applySelfVetOptionChangedEvent(SelfVetOptionChangedEvent $event): void
{
- $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor($event->institution);
+ $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor(
+ $event->institution,
+ );
$institutionConfigurationOptions->selfVetOption = $event->selfVetOption;
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
}
- public function applySsoOn2faOptionChangedEvent(SsoOn2faOptionChangedEvent $event)
+ public function applySsoOn2faOptionChangedEvent(SsoOn2faOptionChangedEvent $event): void
{
- $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor($event->institution);
+ $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor(
+ $event->institution,
+ );
$institutionConfigurationOptions->ssoOn2faOption = $event->ssoOn2faOption;
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
}
- public function applySelfAssertedTokensOptionChangedEvent(SelfAssertedTokensOptionChangedEvent $event)
+ public function applySelfAssertedTokensOptionChangedEvent(SelfAssertedTokensOptionChangedEvent $event): void
{
- $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor($event->institution);
+ $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor(
+ $event->institution,
+ );
$institutionConfigurationOptions->selfAssertedTokensOption = $event->selfAssertedTokensOption;
$this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
}
- public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event)
+ public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event): void
{
$this->institutionConfigurationOptionsRepository->removeConfigurationOptionsFor($event->institution);
$this->allowedSecondFactorRepository->clearAllowedSecondFactorListFor($event->institution);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/RaLocationProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/RaLocationProjector.php
index fd1c95fd2..183ec7946 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/RaLocationProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Projector/RaLocationProjector.php
@@ -32,30 +32,24 @@
class RaLocationProjector extends Projector
{
- /**
- * @var RaLocationRepository
- */
- private $repository;
-
- public function __construct(RaLocationRepository $repository)
+ public function __construct(private readonly RaLocationRepository $repository)
{
- $this->repository = $repository;
}
- public function applyRaLocationAddedEvent(RaLocationAddedEvent $event)
+ public function applyRaLocationAddedEvent(RaLocationAddedEvent $event): void
{
$raLocation = RaLocation::create(
$event->raLocationId->getRaLocationId(),
$event->institution,
$event->raLocationName,
$event->location,
- $event->contactInformation
+ $event->contactInformation,
);
$this->repository->save($raLocation);
}
- public function applyRaLocationRenamedEvent(RaLocationRenamedEvent $event)
+ public function applyRaLocationRenamedEvent(RaLocationRenamedEvent $event): void
{
$raLocation = $this->fetchRaLocationById($event->raLocationId);
@@ -64,7 +58,7 @@ public function applyRaLocationRenamedEvent(RaLocationRenamedEvent $event)
$this->repository->save($raLocation);
}
- public function applyRaLocationRelocatedEvent(RaLocationRelocatedEvent $event)
+ public function applyRaLocationRelocatedEvent(RaLocationRelocatedEvent $event): void
{
$raLocation = $this->fetchRaLocationById($event->raLocationId);
@@ -73,7 +67,7 @@ public function applyRaLocationRelocatedEvent(RaLocationRelocatedEvent $event)
$this->repository->save($raLocation);
}
- public function applyRaLocationContactInformationChangedEvent(RaLocationContactInformationChangedEvent $event)
+ public function applyRaLocationContactInformationChangedEvent(RaLocationContactInformationChangedEvent $event): void
{
$raLocation = $this->fetchRaLocationById($event->raLocationId);
@@ -82,35 +76,25 @@ public function applyRaLocationContactInformationChangedEvent(RaLocationContactI
$this->repository->save($raLocation);
}
- public function applyRaLocationRemovedEvent(RaLocationRemovedEvent $event)
+ public function applyRaLocationRemovedEvent(RaLocationRemovedEvent $event): void
{
$raLocation = $this->fetchRaLocationById($event->raLocationId);
$this->repository->remove($raLocation);
}
- public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event)
+ public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event): void
{
$this->repository->removeRaLocationsFor($event->institution);
}
- /**
- * @param RaLocationId $raLocationId
- * @return RaLocation
- */
- private function fetchRaLocationById(RaLocationId $raLocationId)
+ private function fetchRaLocationById(RaLocationId $raLocationId): RaLocation
{
$raLocation = $this->repository->findByRaLocationId($raLocationId);
if (is_null($raLocation)) {
throw new RuntimeException(
- 'Tried to update an RA Locations contact information, but location could not be found'
- );
- }
-
- if (!$raLocation instanceof RaLocation) {
- throw new RuntimeException(
- 'Tried to update an RA Locations contact information, but location is of the wrong type'
+ 'Tried to update an RA Locations contact information, but location could not be found',
);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Query/RaLocationQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Query/RaLocationQuery.php
index 7fe232ee3..3550805e7 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Query/RaLocationQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Query/RaLocationQuery.php
@@ -25,15 +25,15 @@ final class RaLocationQuery
/**
* @var string|Institution
*/
- public $institution;
+ public string|Institution $institution;
/**
* @var string
*/
- public $orderBy = 'name';
+ public string $orderBy = 'name';
/**
* @var string
*/
- public $orderDirection = 'asc';
+ public string $orderDirection = 'asc';
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/AllowedSecondFactorRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/AllowedSecondFactorRepository.php
index 37d7d2142..384fedc02 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/AllowedSecondFactorRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/AllowedSecondFactorRepository.php
@@ -19,10 +19,13 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\AllowedSecondFactor;
+/**
+ * @extends ServiceEntityRepository
+ */
final class AllowedSecondFactorRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -30,7 +33,7 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, AllowedSecondFactor::class);
}
- public function save(AllowedSecondFactor $allowedSecondFactor)
+ public function save(AllowedSecondFactor $allowedSecondFactor): void
{
$entityManager = $this->getEntityManager();
$entityManager->persist($allowedSecondFactor);
@@ -38,10 +41,9 @@ public function save(AllowedSecondFactor $allowedSecondFactor)
}
/**
- * @param Institution $institution
* @return AllowedSecondFactor[]
*/
- public function getAllowedSecondFactorsFor(Institution $institution)
+ public function getAllowedSecondFactorsFor(Institution $institution): array
{
return $this->createQueryBuilder('asf')
->select()
@@ -51,7 +53,7 @@ public function getAllowedSecondFactorsFor(Institution $institution)
->execute();
}
- public function clearAllowedSecondFactorListFor(Institution $institution)
+ public function clearAllowedSecondFactorListFor(Institution $institution): void
{
$this->createQueryBuilder('asf')
->delete()
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/ConfiguredInstitutionRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/ConfiguredInstitutionRepository.php
index b66851bb3..4acf92683 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/ConfiguredInstitutionRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/ConfiguredInstitutionRepository.php
@@ -19,10 +19,13 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\ConfiguredInstitution;
+/**
+ * @extends ServiceEntityRepository
+ */
class ConfiguredInstitutionRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -30,10 +33,7 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, ConfiguredInstitution::class);
}
- /**
- * @param ConfiguredInstitution $configuredInstitution
- */
- public function save(ConfiguredInstitution $configuredInstitution)
+ public function save(ConfiguredInstitution $configuredInstitution): void
{
$entityManager = $this->getEntityManager();
$entityManager->persist($configuredInstitution);
@@ -41,10 +41,9 @@ public function save(ConfiguredInstitution $configuredInstitution)
}
/**
- * @param Institution $institution
* @return bool
*/
- public function hasConfigurationFor(Institution $institution)
+ public function hasConfigurationFor(Institution $institution): bool
{
$result = $this->createQueryBuilder('ci')
->select('ci.institution')
@@ -56,10 +55,7 @@ public function hasConfigurationFor(Institution $institution)
return $result !== null;
}
- /**
- * @param Institution $institution
- */
- public function removeConfigurationFor(Institution $institution)
+ public function removeConfigurationFor(Institution $institution): void
{
$this->createQueryBuilder('ci')
->delete()
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/InstitutionAuthorizationRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/InstitutionAuthorizationRepository.php
index b22d903ac..2300cb090 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/InstitutionAuthorizationRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/InstitutionAuthorizationRepository.php
@@ -19,13 +19,17 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
-use Doctrine\ORM\EntityManager;
+use Doctrine\ORM\EntityManagerInterface;
+use Doctrine\ORM\OptimisticLockException;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionAuthorization;
+/**
+ * @extends ServiceEntityRepository
+ */
class InstitutionAuthorizationRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -34,11 +38,9 @@ public function __construct(ManagerRegistry $registry)
}
/**
- * @param Institution $institution
- * @param InstitutionRole $role
* @return InstitutionAuthorization[]
*/
- public function findAuthorizationOptionsForInstitutionByRole(Institution $institution, InstitutionRole $role)
+ public function findAuthorizationOptionsForInstitutionByRole(Institution $institution, InstitutionRole $role): array
{
return $this->createQueryBuilder('ia')
->where('ia.institution = :institution')
@@ -50,10 +52,9 @@ public function findAuthorizationOptionsForInstitutionByRole(Institution $instit
}
/**
- * @param Institution $institution
* @return InstitutionAuthorization[]
*/
- public function findAuthorizationOptionsForInstitution(Institution $institution)
+ public function findAuthorizationOptionsForInstitution(Institution $institution): array
{
return $this->createQueryBuilder('ia')
->where('ia.institution = :institution')
@@ -63,10 +64,9 @@ public function findAuthorizationOptionsForInstitution(Institution $institution)
}
/**
- * @param Institution $institution
* @return InstitutionAuthorization[]
*/
- public function findSelectRaasForInstitution(Institution $institution)
+ public function findSelectRaasForInstitution(Institution $institution): array
{
return $this->createQueryBuilder('ia')
->where('ia.institutionRelation = :institution')
@@ -78,37 +78,32 @@ public function findSelectRaasForInstitution(Institution $institution)
}
/**
- * @param Institution $institution
- * @param InstitutionAuthorizationOption $institutionOption
- * @throws \Doctrine\ORM\OptimisticLockException
+ * @throws OptimisticLockException
*/
- public function saveInstitutionOption(Institution $institution, InstitutionAuthorizationOption $institutionOption)
- {
+ public function saveInstitutionOption(
+ Institution $institution,
+ InstitutionAuthorizationOption $institutionOption,
+ ): void {
$institutionAuthorizations = [];
foreach ($institutionOption->getInstitutions($institution) as $relatedInstitution) {
$institutionAuthorizations[] = InstitutionAuthorization::create(
$institution,
$relatedInstitution,
- $institutionOption->getInstitutionRole()
+ $institutionOption->getInstitutionRole(),
);
}
$this->save($institution, $institutionOption->getInstitutionRole(), $institutionAuthorizations);
}
- /**
- * @param Institution $institution
- * @param InstitutionAuthorizationOption $institutionOption
- * @throws \Doctrine\ORM\OptimisticLockException
- */
- public function clearInstitutionOption(Institution $institution)
+ public function clearInstitutionOption(Institution $institution): void
{
$entityManager = $this->getEntityManager();
$entityManager->createQuery(
- 'DELETE '.InstitutionAuthorization::class.' ia
- WHERE ia.institution = :institution'
+ 'DELETE ' . InstitutionAuthorization::class . ' ia
+ WHERE ia.institution = :institution',
)
->setParameter('institution', $institution->getInstitution())
->execute();
@@ -118,32 +113,28 @@ public function clearInstitutionOption(Institution $institution)
/**
- * @param Institution $institution
- * @throws \Doctrine\ORM\OptimisticLockException
+ * @throws OptimisticLockException
*/
- public function setDefaultInstitutionOption(Institution $institution)
+ public function setDefaultInstitutionOption(Institution $institution): void
{
$this->saveInstitutionOption(
$institution,
- InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa())
+ InstitutionAuthorizationOption::getDefault(InstitutionRole::useRa()),
);
$this->saveInstitutionOption(
$institution,
- InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa())
+ InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa()),
);
$this->saveInstitutionOption(
$institution,
- InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa())
+ InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa()),
);
}
/**
- * @param Institution $institution
- * @param InstitutionRole $role
* @param InstitutionAuthorization[] $institutionAuthorizations
- * @throws \Doctrine\ORM\OptimisticLockException
*/
- private function save(Institution $institution, InstitutionRole $role, array $institutionAuthorizations)
+ private function save(Institution $institution, InstitutionRole $role, array $institutionAuthorizations): void
{
$entityManager = $this->getEntityManager();
@@ -153,29 +144,30 @@ private function save(Institution $institution, InstitutionRole $role, array $in
$entityManager->flush();
}
- /**
- * @param EntityManager $entityManager
- * @param Institution $institution
- * @param InstitutionRole $role
- */
- private function clearOldAuthorizations(EntityManager $entityManager, Institution $institution, InstitutionRole $role)
- {
+ private function clearOldAuthorizations(
+ EntityManagerInterface $entityManager,
+ Institution $institution,
+ InstitutionRole $role,
+ ): void {
$entityManager->createQuery(
- 'DELETE '.InstitutionAuthorization::class.' ia
- WHERE ia.institutionRole = :role AND ia.institution = :institution'
+ 'DELETE ' . InstitutionAuthorization::class . ' ia
+ WHERE ia.institutionRole = :role AND ia.institution = :institution',
)
->setParameter('role', $role)
->setParameter('institution', $institution->getInstitution())
->execute();
+
+ $this->getEntityManager()->clear();
}
/**
- * @param EntityManager $entityManager
- * @param InstitutionRole $role
* @param InstitutionAuthorization[] $institutionAuthorizations
*/
- private function addNewAuthorizations(EntityManager $entityManager, InstitutionRole $role, array $institutionAuthorizations)
- {
+ private function addNewAuthorizations(
+ EntityManagerInterface $entityManager,
+ InstitutionRole $role,
+ array $institutionAuthorizations,
+ ): void {
foreach ($institutionAuthorizations as $institutionAuthorization) {
if ($institutionAuthorization->institutionRole === $role) {
$entityManager->persist($institutionAuthorization);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/InstitutionConfigurationOptionsRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/InstitutionConfigurationOptionsRepository.php
index ad882684a..bb8f422ad 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/InstitutionConfigurationOptionsRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/InstitutionConfigurationOptionsRepository.php
@@ -19,11 +19,14 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\NonUniqueResultException;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionConfigurationOptions;
+/**
+ * @extends ServiceEntityRepository
+ */
class InstitutionConfigurationOptionsRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -32,11 +35,9 @@ public function __construct(ManagerRegistry $registry)
}
/**
- * @param Institution $institution
- * @return InstitutionConfigurationOptions
* @throws NonUniqueResultException
*/
- public function findConfigurationOptionsFor(Institution $institution)
+ public function findConfigurationOptionsFor(Institution $institution): ?InstitutionConfigurationOptions
{
return $this->createQueryBuilder('ico')
->where('ico.institution = :institution')
@@ -45,20 +46,14 @@ public function findConfigurationOptionsFor(Institution $institution)
->getOneOrNullResult();
}
- /**
- * @param InstitutionConfigurationOptions $institutionConfigurationOptions
- */
- public function save(InstitutionConfigurationOptions $institutionConfigurationOptions)
+ public function save(InstitutionConfigurationOptions $institutionConfigurationOptions): void
{
$entityManager = $this->getEntityManager();
$entityManager->persist($institutionConfigurationOptions);
$entityManager->flush();
}
- /**
- * @param Institution $institution
- */
- public function removeConfigurationOptionsFor(Institution $institution)
+ public function removeConfigurationOptionsFor(Institution $institution): void
{
$this->createQueryBuilder('ico')
->delete()
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/RaLocationRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/RaLocationRepository.php
index edbc76e92..8b8d77f75 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/RaLocationRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Repository/RaLocationRepository.php
@@ -19,13 +19,16 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\RaLocationId;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\RaLocation;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Query\RaLocationQuery;
use Surfnet\StepupMiddleware\ApiBundle\Exception\RuntimeException;
+/**
+ * @extends ServiceEntityRepository
+ */
class RaLocationRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -34,21 +37,20 @@ public function __construct(ManagerRegistry $registry)
}
/**
- * @param RaLocationQuery $query
* @return null|RaLocation[]
*/
- public function search(RaLocationQuery $query)
+ public function search(RaLocationQuery $query): ?array
{
if (!in_array($query->orderBy, ['name', 'location', 'contact_information'])) {
throw new RuntimeException(sprintf('Unknown order by column "%s"', $query->orderBy));
}
- $orderBy = 'rl.'.$query->orderBy;
+ $orderBy = 'rl.' . $query->orderBy;
$orderDirection = $query->orderDirection === 'asc' ? 'ASC' : 'DESC';
return $this->getEntityManager()->createQueryBuilder()
->select('rl')
- ->from('Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\RaLocation', 'rl')
+ ->from(RaLocation::class, 'rl')
->where('rl.institution = :institution')
->setParameter('institution', $query->institution->getInstitution())
->orderBy($orderBy, $orderDirection)
@@ -56,11 +58,7 @@ public function search(RaLocationQuery $query)
->getResult();
}
- /**
- * @param RaLocationId $raLocationId
- * @return RaLocation[]
- */
- public function findByRaLocationId(RaLocationId $raLocationId)
+ public function findByRaLocationId(RaLocationId $raLocationId): ?RaLocation
{
return $this->createQueryBuilder('rl')
->where('rl.id = :id')
@@ -69,20 +67,14 @@ public function findByRaLocationId(RaLocationId $raLocationId)
->getOneOrNullResult();
}
- /**
- * @param RaLocation $raLocation
- */
- public function save(RaLocation $raLocation)
+ public function save(RaLocation $raLocation): void
{
$entityManager = $this->getEntityManager();
$entityManager->persist($raLocation);
$entityManager->flush();
}
- /**
- * @param RaLocation $raLocation
- */
- public function remove(RaLocation $raLocation)
+ public function remove(RaLocation $raLocation): void
{
$entityManager = $this->getEntityManager();
$entityManager->remove($raLocation);
@@ -90,10 +82,9 @@ public function remove(RaLocation $raLocation)
}
/**
- * @param Institution $institution
* @return RaLocation[]
*/
- public function findByInstitution(Institution $institution)
+ public function findByInstitution(Institution $institution): array
{
return $this->createQueryBuilder('rl')
->where('rl.institution = :institution')
@@ -102,10 +93,7 @@ public function findByInstitution(Institution $institution)
->getResult();
}
- /**
- * @param Institution $institution
- */
- public function removeRaLocationsFor(Institution $institution)
+ public function removeRaLocationsFor(Institution $institution): void
{
$this->createQueryBuilder('rl')
->delete()
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/AllowedSecondFactorListService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/AllowedSecondFactorListService.php
index 38a7b6b04..91b6c92ea 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/AllowedSecondFactorListService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/AllowedSecondFactorListService.php
@@ -22,33 +22,20 @@
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\AllowedSecondFactor;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\AllowedSecondFactorRepository;
-use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\ConfiguredInstitutionRepository;
class AllowedSecondFactorListService
{
- /**
- * @var AllowedSecondFactorRepository
- */
- private $allowedSecondFactorRepository;
-
- /**
- * @var ConfiguredInstitutionRepository
- */
- private $configuredInstitutionRepository;
-
public function __construct(
- AllowedSecondFactorRepository $allowedSecondFactoryRepository,
- ConfiguredInstitutionRepository $configuredInstitutionRepository
+ private readonly AllowedSecondFactorRepository $allowedSecondFactorRepository,
) {
- $this->allowedSecondFactorRepository = $allowedSecondFactoryRepository;
- $this->configuredInstitutionRepository = $configuredInstitutionRepository;
}
- public function getAllowedSecondFactorListFor(Institution $institution)
+ public function getAllowedSecondFactorListFor(Institution $institution): AllowedSecondFactorList
{
- $allowedSecondFactors = array_map(function (AllowedSecondFactor $allowedSecondFactor) {
- return $allowedSecondFactor->secondFactorType;
- }, $this->allowedSecondFactorRepository->getAllowedSecondFactorsFor($institution));
+ $allowedSecondFactors = array_map(
+ fn(AllowedSecondFactor $allowedSecondFactor): \Surfnet\StepupBundle\Value\SecondFactorType => $allowedSecondFactor->secondFactorType,
+ $this->allowedSecondFactorRepository->getAllowedSecondFactorsFor($institution),
+ );
return AllowedSecondFactorList::ofTypes($allowedSecondFactors);
}
@@ -56,7 +43,7 @@ public function getAllowedSecondFactorListFor(Institution $institution)
/**
* @return AllowedSecondFactorMap
*/
- public function getAllowedSecondFactorMap()
+ public function getAllowedSecondFactorMap(): AllowedSecondFactorMap
{
return AllowedSecondFactorMap::from($this->allowedSecondFactorRepository->findAll());
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/AllowedSecondFactorMap.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/AllowedSecondFactorMap.php
index 6b0eefd04..8aeac28bc 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/AllowedSecondFactorMap.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/AllowedSecondFactorMap.php
@@ -27,7 +27,7 @@ final class AllowedSecondFactorMap
/**
* @var AllowedSecondFactor[]
*/
- private $mappedAllowedSecondFactors = [];
+ private array $mappedAllowedSecondFactors = [];
private function __construct()
{
@@ -37,7 +37,7 @@ private function __construct()
* @param AllowedSecondFactor[] $allowedSecondFactors
* @return AllowedSecondFactorMap
*/
- public static function from($allowedSecondFactors)
+ public static function from(array $allowedSecondFactors): self
{
$allowedSecondFactorMap = new self();
foreach ($allowedSecondFactors as $allowedSecondFactor) {
@@ -47,11 +47,7 @@ public static function from($allowedSecondFactors)
return $allowedSecondFactorMap;
}
- /**
- * @param Institution $institution
- * @return AllowedSecondFactorList
- */
- public function getAllowedSecondFactorListFor(Institution $institution)
+ public function getAllowedSecondFactorListFor(Institution $institution): AllowedSecondFactorList
{
$institution = strtolower($institution->getInstitution());
if (!array_key_exists($institution, $this->mappedAllowedSecondFactors)) {
@@ -62,10 +58,9 @@ public function getAllowedSecondFactorListFor(Institution $institution)
}
/**
- * @param AllowedSecondFactor $allowedSecondFactor
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
*/
- private function add(AllowedSecondFactor $allowedSecondFactor)
+ private function add(AllowedSecondFactor $allowedSecondFactor): void
{
$institution = strtolower($allowedSecondFactor->institution->getInstitution());
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/ConfiguredInstitutionService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/ConfiguredInstitutionService.php
index c55f1cc74..0b04c2521 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/ConfiguredInstitutionService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/ConfiguredInstitutionService.php
@@ -25,20 +25,15 @@
class ConfiguredInstitutionService
{
- /**
- * @var ConfiguredInstitutionRepository
- */
- private $repository;
-
- public function __construct(ConfiguredInstitutionRepository $repository)
- {
- $this->repository = $repository;
+ public function __construct(
+ private readonly ConfiguredInstitutionRepository $repository,
+ ) {
}
/**
* @return ConfiguredInstitution[]
*/
- public function getAll()
+ public function getAll(): array
{
return $this->repository->findAll();
}
@@ -47,7 +42,7 @@ public function getAll()
/**
* @return InstitutionListing[]
*/
- public function getAllAsInstitution()
+ public function getAllAsInstitution(): array
{
$configuredInstitutions = $this->repository->findAll();
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionAuthorizationOptionMap.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionAuthorizationOptionMap.php
index e92d20bd2..b6244bf09 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionAuthorizationOptionMap.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionAuthorizationOptionMap.php
@@ -27,11 +27,9 @@ final class InstitutionAuthorizationOptionMap
/**
* @var InstitutionAuthorizationOption[]
*/
- private $institutionOptions;
+ private array $institutionOptions = [];
/**
- * InstitutionAuthorizationOptionMap constructor.
- * @param Institution $institution
* @param InstitutionAuthorization[] $institutionAuthorizations
*/
private function __construct(Institution $institution, array $institutionAuthorizations)
@@ -51,30 +49,24 @@ private function __construct(Institution $institution, array $institutionAuthori
}
$institutions[$role->getType()][] = $authorization->institutionRelation;
}
-
- $this->institutionOptions = [];
foreach ($roles as $role) {
- $institutionAuthorizationOption = InstitutionAuthorizationOption::fromInstitutions($role, $institution, $institutions[$role->getType()]);
+ $institutionAuthorizationOption = InstitutionAuthorizationOption::fromInstitutions(
+ $role,
+ $institution,
+ $institutions[$role->getType()],
+ );
$this->institutionOptions[$role->getType()] = $institutionAuthorizationOption;
}
}
- /**
- * @param Institution $institution
- * @param InstitutionAuthorization[]|null
- * @return InstitutionAuthorizationOptionMap
- */
- public static function fromInstitutionAuthorizations(Institution $institution, array $institutionAuthorizations)
- {
+ public static function fromInstitutionAuthorizations(
+ Institution $institution,
+ array $institutionAuthorizations,
+ ): self {
return new self($institution, $institutionAuthorizations);
}
- /**
- * InstitutionAuthorizationOption
- * @param InstitutionRole $role
- * @return InstitutionAuthorizationOption
- */
- public function getAuthorizationOptionsByRole(InstitutionRole $role)
+ public function getAuthorizationOptionsByRole(InstitutionRole $role): InstitutionAuthorizationOption
{
if (!isset($this->institutionOptions[$role->getType()])) {
return InstitutionAuthorizationOption::getEmpty($role);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionAuthorizationService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionAuthorizationService.php
index 9aa3d5fbc..3a1b973c9 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionAuthorizationService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionAuthorizationService.php
@@ -25,27 +25,17 @@
class InstitutionAuthorizationService
{
- /**
- * @var InstitutionAuthorizationRepository
- */
- private $repository;
-
- /**
- * @param InstitutionAuthorizationRepository $repository
- */
- public function __construct(
- InstitutionAuthorizationRepository $repository
- ) {
- $this->repository = $repository;
+ public function __construct(private readonly InstitutionAuthorizationRepository $repository)
+ {
}
/**
- * @param Institution $institution
- * @param InstitutionRole $role
* @return InstitutionAuthorizationOption
*/
- public function findAuthorizationsByRoleFor(Institution $institution, InstitutionRole $role)
- {
+ public function findAuthorizationsByRoleFor(
+ Institution $institution,
+ InstitutionRole $role,
+ ): InstitutionAuthorizationOption {
$authorizations = $this->repository->findAuthorizationOptionsForInstitutionByRole($institution, $role);
$institutions = [];
@@ -57,10 +47,9 @@ public function findAuthorizationsByRoleFor(Institution $institution, Institutio
}
/**
- * @param Institution $institution
* @return InstitutionAuthorizationOptionMap
*/
- public function findAuthorizationsFor(Institution $institution)
+ public function findAuthorizationsFor(Institution $institution): InstitutionAuthorizationOptionMap
{
$authorizations = $this->repository->findAuthorizationOptionsForInstitution($institution);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionConfigurationOptionsService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionConfigurationOptionsService.php
index 6dca4da00..71a7ab6d9 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionConfigurationOptionsService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/InstitutionConfigurationOptionsService.php
@@ -24,41 +24,21 @@
class InstitutionConfigurationOptionsService
{
- /**
- * @var InstitutionConfigurationOptionsRepository
- */
- private $repository;
-
- /**
- * @var int
- */
- private $numberOfTokensPerIdentity;
-
- /**
- * @param InstitutionConfigurationOptionsRepository $repository
- * @param int $numberOfTokensPerIdentity
- */
public function __construct(
- InstitutionConfigurationOptionsRepository $repository,
- $numberOfTokensPerIdentity
+ private readonly InstitutionConfigurationOptionsRepository $repository,
+ private int $numberOfTokensPerIdentity,
) {
- $this->repository = $repository;
- $this->numberOfTokensPerIdentity = $numberOfTokensPerIdentity;
}
/**
* @return InstitutionConfigurationOptions[]
*/
- public function findAllInstitutionConfigurationOptions()
+ public function findAllInstitutionConfigurationOptions(): array
{
return $this->repository->findAll();
}
- /**
- * @param Institution $institution
- * @return InstitutionConfigurationOptions|null
- */
- public function findInstitutionConfigurationOptionsFor(Institution $institution)
+ public function findInstitutionConfigurationOptionsFor(Institution $institution): ?InstitutionConfigurationOptions
{
return $this->repository->findConfigurationOptionsFor($institution);
}
@@ -68,15 +48,14 @@ public function findInstitutionConfigurationOptionsFor(Institution $institution)
*
* When the DISABLED value is set on the institution (when no specific configuration was pushed) the application
* default is returned.
- *
- * @param Institution $institution
- * @return int
*/
- public function getMaxNumberOfTokensFor(Institution $institution)
+ public function getMaxNumberOfTokensFor(Institution $institution): int
{
$configuration = $this->findInstitutionConfigurationOptionsFor($institution);
- if ($configuration !== null && $configuration->numberOfTokensPerIdentityOption->isEnabled()) {
+ if ($configuration instanceof InstitutionConfigurationOptions &&
+ $configuration->numberOfTokensPerIdentityOption->isEnabled()
+ ) {
return $configuration->numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity();
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/RaLocationService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/RaLocationService.php
index 8c9fb8c80..1705d4b88 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/RaLocationService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Configuration/Service/RaLocationService.php
@@ -26,40 +26,28 @@
class RaLocationService
{
- /**
- * @var RaLocationRepository
- */
- private $repository;
-
- public function __construct(RaLocationRepository $repository)
+ public function __construct(private readonly RaLocationRepository $repository)
{
- $this->repository = $repository;
}
/**
- * @param RaLocationQuery $query
* @return null|RaLocation[]
*/
- public function search(RaLocationQuery $query)
+ public function search(RaLocationQuery $query): ?array
{
return $this->repository->search($query);
}
- /**
- * @param RaLocationId $raLocationId
- * @return RaLocation[]
- */
- public function findByRaLocationId(RaLocationId $raLocationId)
+ public function findByRaLocationId(RaLocationId $raLocationId): ?RaLocation
{
return $this->repository->findByRaLocationId($raLocationId);
}
/**
- * @param Institution $institution
- * @return RaLocation[]
+ * @return RaLocation[]|null
*/
- public function listRaLocationsFor(Institution $institution)
+ public function listRaLocationsFor(Institution $institution): ?array
{
return $this->repository->findByInstitution($institution);
}
@@ -67,7 +55,7 @@ public function listRaLocationsFor(Institution $institution)
/**
* @return RaLocation[]
*/
- public function getAllRaLocations()
+ public function getAllRaLocations(): array
{
return $this->repository->findAll();
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/AbstractController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/AbstractController.php
new file mode 100644
index 000000000..05a29358a
--- /dev/null
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/AbstractController.php
@@ -0,0 +1,41 @@
+isGranted($role, $subject)) {
+ return;
+ }
+ }
+
+ throw $this->createAccessDeniedException($message);
+ }
+ parent::denyAccessUnlessGranted($attribute, $subject, $message);
+ }
+}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/AuditLogController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/AuditLogController.php
index 64b58e18c..05c3875eb 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/AuditLogController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/AuditLogController.php
@@ -24,36 +24,31 @@
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\SecondFactorAuditLogQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\AuditLogService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
-final class AuditLogController extends Controller
+final class AuditLogController extends AbstractController
{
- /**
- * @var AuditLogService
- */
- private $auditLogService;
-
- public function __construct(AuditLogService $service)
- {
- $this->auditLogService = $service;
+ public function __construct(
+ private readonly AuditLogService $auditLogService,
+ ) {
}
- public function secondFactorAuditLogAction(Request $request, Institution $institution)
+ public function secondFactorAuditLog(Request $request, Institution $institution): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
$identityId = $request->get('identityId');
if (empty($identityId)) {
throw new BadApiRequestException(['This API-call MUST include the identityId as get parameter']);
}
- $query = new SecondFactorAuditLogQuery();
+ $query = new SecondFactorAuditLogQuery();
$query->identityInstitution = $institution;
- $query->identityId = new IdentityId($identityId);
- $query->orderBy = $request->get('orderBy', $query->orderBy);
- $query->orderDirection = $request->get('orderDirection', $query->orderDirection);
- $query->pageNumber = $request->get('p', 1);
+ $query->identityId = new IdentityId($identityId);
+ $query->orderBy = $request->get('orderBy', $query->orderBy);
+ $query->orderDirection = $request->get('orderDirection', $query->orderDirection);
+ $query->pageNumber = $request->get('p', 1);
$paginator = $this->auditLogService->searchSecondFactorAuditLog($query);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/AuthorizationController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/AuthorizationController.php
index 14b13ce49..dd824d7c6 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/AuthorizationController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/AuthorizationController.php
@@ -21,38 +21,34 @@
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Service\AuthorizationService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonAuthorizationResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
class AuthorizationController extends AbstractController
{
- /**
- * @var AuthorizationService
- */
- private $authorizationService;
-
- /**
- * @param AuthorizationService $authorizationService
- */
- public function __construct(AuthorizationService $authorizationService)
- {
- $this->authorizationService = $authorizationService;
+ public function __construct(
+ private readonly AuthorizationService $authorizationService,
+ ) {
}
- public function mayRegisterSelfAssertedTokensAction(string $identityId)
+ public function mayRegisterSelfAssertedTokens(string $identityId): JsonAuthorizationResponse
{
- $decision = $this->authorizationService->assertRegistrationOfSelfAssertedTokensIsAllowed(new IdentityId($identityId));
+ $decision = $this->authorizationService->assertRegistrationOfSelfAssertedTokensIsAllowed(
+ new IdentityId($identityId),
+ );
return JsonAuthorizationResponse::from($decision);
}
- public function mayRegisterRecoveryTokensAction(string $identityId)
+ public function mayRegisterRecoveryTokens(string $identityId): JsonAuthorizationResponse
{
$decision = $this->authorizationService->assertRecoveryTokensAreAllowed(new IdentityId($identityId));
return JsonAuthorizationResponse::from($decision);
}
- public function maySelfVetSelfAssertedTokenAction(string $identityId)
+ public function maySelfVetSelfAssertedToken(string $identityId): JsonAuthorizationResponse
{
- $decision = $this->authorizationService->assertSelfVetUsingSelfAssertedTokenIsAllowed(new IdentityId($identityId));
+ $decision = $this->authorizationService->assertSelfVetUsingSelfAssertedTokenIsAllowed(
+ new IdentityId($identityId),
+ );
return JsonAuthorizationResponse::from($decision);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/CommandController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/CommandController.php
index 2f1cb0e16..1ccc0706a 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/CommandController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/CommandController.php
@@ -22,76 +22,39 @@
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Service\CommandAuthorizationService;
-use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\WhitelistService;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Metadata;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\SelfServiceExecutable;
use Surfnet\StepupMiddleware\CommandHandlingBundle\EventSourcing\MetadataEnricher;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\ForbiddenException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\CreateIdentityCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\UpdateIdentityCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\TransactionAwarePipeline;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
-use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
+use function sprintf;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CommandController extends Controller
+class CommandController extends AbstractController
{
- /**
- * @var WhitelistService
- */
- private $whitelistService;
-
- /**
- * @var TransactionAwarePipeline
- */
- private $pipeline;
-
- /**
- * @var MetadataEnricher
- */
- private $metadataEnricher;
-
- /**
- * @var AuthorizationChecker
- */
- private $authorizationChecker;
-
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- /**
- * @var CommandAuthorizationService
- */
- private $commandAuthorizationService;
-
-
public function __construct(
- TransactionAwarePipeline $pipeline,
- WhitelistService $whitelistService,
- MetadataEnricher $enricher,
- AuthorizationCheckerInterface $authorizationChecker,
- LoggerInterface $logger,
- CommandAuthorizationService $commandAuthorizationService
+ private readonly TransactionAwarePipeline $pipeline,
+ private readonly MetadataEnricher $metadataEnricher,
+ private readonly AuthorizationCheckerInterface $authorizationChecker,
+ private readonly LoggerInterface $logger,
+ private readonly CommandAuthorizationService $commandAuthorizationService,
) {
- $this->pipeline = $pipeline;
- $this->whitelistService = $whitelistService;
- $this->authorizationChecker = $authorizationChecker;
- $this->metadataEnricher = $enricher;
- $this->logger = $logger;
- $this->commandAuthorizationService = $commandAuthorizationService;
}
- public function handleAction(Command $command, Metadata $metadata, Request $request)
+ public function handle(AbstractCommand $command, Metadata $metadata, Request $request): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS']);
$this->logger->notice(sprintf('Received request to process Command "%s"', $command));
$this->metadataEnricher->setMetadata($metadata);
@@ -109,7 +72,7 @@ public function handleAction(Command $command, Metadata $metadata, Request $requ
} catch (ForbiddenException $e) {
throw new AccessDeniedHttpException(
sprintf('Processing of command "%s" is forbidden for this client', $command),
- $e
+ $e,
);
}
@@ -121,12 +84,7 @@ public function handleAction(Command $command, Metadata $metadata, Request $requ
return $response;
}
- /**
- * @param Command $command
- * @param Metadata $metadata
- * @return Institution
- */
- private function resolveInstitution(Command $command, Metadata $metadata)
+ private function resolveInstitution(Command $command, Metadata $metadata): Institution
{
if ($metadata->actorInstitution) {
return new Institution($metadata->actorInstitution);
@@ -142,49 +100,53 @@ private function resolveInstitution(Command $command, Metadata $metadata)
// conservative, if we cannot determine an institution, deny processing.
throw new AccessDeniedHttpException(
- 'Cannot reliably determine the institution of the actor, denying processing of command'
+ 'Cannot reliably determine the institution of the actor, denying processing of command',
);
}
- /**
- * @param Command $command
- * @param Metadata $metadata
- */
- private function handleAuthorization(Command $command, Metadata $metadata)
+ private function handleAuthorization(Command $command, Metadata $metadata): void
{
// Get the actorId and actorInstitution from the metadata
// Be aware that these values could be null when executing commands where we shouldn't log in for
// - CreateIdentityCommand
// - UpdateIdentityCommand
- $actorId = !is_null($metadata->actorId) ? new IdentityId($metadata->actorId) : null;
- $actorInstitution = !is_null($metadata->actorInstitution) ? new Institution($metadata->actorInstitution) : null;
+ $actorId = is_null($metadata->actorId) ? null : new IdentityId($metadata->actorId);
+ $actorInstitution = is_null($metadata->actorInstitution) ? null : new Institution($metadata->actorInstitution);
// The institution of an actor should be whitelisted or the actor should be SRAA
// Be aware that the actor metadata is not always present, see self::resolveInstitution
$this->logger->notice('Ensuring that the actor institution is on the whitelist, or the actor is SRAA');
$institution = $this->resolveInstitution($command, $metadata);
if (!$this->commandAuthorizationService->isInstitutionWhitelisted($institution, $actorId)) {
- throw new AccessDeniedHttpException(sprintf(
- 'Institution "%s" is not on the whitelist and actor "%s" is not an SRAA, processing of command denied',
- $institution,
- $metadata->actorId
- ));
+ throw new AccessDeniedHttpException(
+ sprintf(
+ 'Institution "%s" is not on the whitelist and actor "%s" is not an SRAA, processing of command denied',
+ $institution,
+ $metadata->actorId,
+ ),
+ );
}
- $this->logger->notice('Ensuring that the actor is allowed to execute a command based on the fine grained authorization configuration');
+ $this->logger->notice(
+ 'Ensuring that the actor is allowed to execute a command based on the fine grained authorization configuration',
+ );
// Validate that if a command is an SelfServiceExecutable we may execute the command
// This should be an SRAA or the actor itself
// Be aware that for the CreateIdentityCommand and UpdateIdentityCommand the actorId is unknown because we aren't logged in yet
if (!$this->commandAuthorizationService->maySelfserviceCommandBeExecutedOnBehalfOf(
$command,
- $actorId
+ $actorId,
)) {
- throw new AccessDeniedHttpException(sprintf(
- 'The actor "%s" is not allowed to act on behalf of identity "%s" processing of SelfService command denied',
- new IdentityId($metadata->actorId),
- $command->getIdentityId()
- ));
+ $message = 'Processing of SelfService command denied, see log entries for details';
+ if ($command instanceof SelfServiceExecutable) {
+ $message = sprintf(
+ 'The actor "%s" is not allowed to act on behalf of identity "%s" processing of SelfService command denied',
+ new IdentityId($metadata->actorId),
+ $command->getIdentityId(),
+ );
+ }
+ throw new AccessDeniedHttpException($message);
}
// Validate that if a command is an RAExecutable we may execute the command
@@ -192,13 +154,15 @@ private function handleAuthorization(Command $command, Metadata $metadata)
if (!$this->commandAuthorizationService->mayRaCommandBeExecutedOnBehalfOf(
$command,
$actorId,
- $actorInstitution
+ $actorInstitution,
)) {
- throw new AccessDeniedHttpException(sprintf(
- 'The actor "%s" is not allowed to act on behalf of institution "%s" processing of RA command denied',
- new IdentityId($metadata->actorId),
- $institution
- ));
+ throw new AccessDeniedHttpException(
+ sprintf(
+ 'The actor "%s" is not allowed to act on behalf of institution "%s" processing of RA command denied',
+ new IdentityId($metadata->actorId),
+ $institution,
+ ),
+ );
}
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/ConfiguredInstitutionController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/ConfiguredInstitutionController.php
index 8438da1e2..ad5cd715a 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/ConfiguredInstitutionController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/ConfiguredInstitutionController.php
@@ -19,24 +19,19 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Controller;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\ConfiguredInstitutionService;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
-class ConfiguredInstitutionController extends Controller
+class ConfiguredInstitutionController extends AbstractController
{
- /**
- * @var ConfiguredInstitutionService
- */
- private $configuredInstitutionService;
-
- public function __construct(ConfiguredInstitutionService $allListings)
- {
- $this->configuredInstitutionService = $allListings;
+ public function __construct(
+ private readonly ConfiguredInstitutionService $configuredInstitutionService,
+ ) {
}
- public function collectionAction()
+ public function collection(): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
$allListings = $this->configuredInstitutionService->getAllAsInstitution();
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/DeprovisionController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/DeprovisionController.php
index 8ef735f0c..08db563fe 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/DeprovisionController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/DeprovisionController.php
@@ -22,38 +22,31 @@
use Surfnet\Stepup\Exception\DomainException;
use Surfnet\Stepup\Helper\UserDataFormatterInterface;
use Surfnet\StepupMiddleware\ApiBundle\Service\DeprovisionServiceInterface;
-use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
class DeprovisionController extends AbstractController
{
- private $deprovisionService;
-
- private $formatHelper;
-
public function __construct(
- DeprovisionServiceInterface $deprovisionService,
- UserDataFormatterInterface $formatHelper
+ private readonly DeprovisionServiceInterface $deprovisionService,
+ private readonly UserDataFormatterInterface $formatHelper,
) {
- $this->deprovisionService = $deprovisionService;
- $this->formatHelper = $formatHelper;
}
- public function deprovisionAction(string $collabPersonId): JsonResponse
+ public function deprovision(string $collabPersonId): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_DEPROVISION']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_DEPROVISION']);
$errors = [];
try {
$userData = $this->deprovisionService->readUserData($collabPersonId);
- if (!empty($userData)) {
+ if ($userData !== []) {
$this->deprovisionService->deprovision($collabPersonId);
}
- } catch (DomainException $e) {
+ } catch (DomainException) {
// On domain exceptions, like when the identity is forgotten, we return OK, with empty data
// just so the deprovision run does not end prematurely. At this point, no other domain exceptions
// are thrown.
$userData = [];
- $errors = [];
} catch (Exception $e) {
$userData = [];
$errors = [$e->getMessage()];
@@ -61,9 +54,9 @@ public function deprovisionAction(string $collabPersonId): JsonResponse
return new JsonResponse($this->formatHelper->format($userData, $errors));
}
- public function dryRunAction(string $collabPersonId): JsonResponse
+ public function dryRun(string $collabPersonId): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_DEPROVISION']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_DEPROVISION']);
$errors = [];
try {
$userData = $this->deprovisionService->readUserData($collabPersonId);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/IdentityController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/IdentityController.php
index 97364c8f7..d490208e5 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/IdentityController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/IdentityController.php
@@ -18,56 +18,39 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Controller;
-use Surfnet\Stepup\Configuration\Value\InstitutionRole;
use Surfnet\Stepup\Identity\Value\Institution;
-use Surfnet\StepupMiddleware\ApiBundle\Authorization\Value\InstitutionRoleSet;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\IdentityQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonNotFoundResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-class IdentityController extends Controller
+class IdentityController extends AbstractController
{
- /**
- * @var IdentityService
- */
- private $identityService;
-
- /**
- * @var InstitutionRoleSet
- */
- private $roleRequirements;
-
public function __construct(
- IdentityService $identityService
+ private readonly IdentityService $identityService,
) {
- $this->identityService = $identityService;
-
- $this->roleRequirements = new InstitutionRoleSet(
- [new InstitutionRole(InstitutionRole::ROLE_USE_RA), new InstitutionRole(InstitutionRole::ROLE_USE_RAA)]
- );
}
- public function getAction($id)
+ public function get(string $id): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
$identity = $this->identityService->find($id);
- if ($identity === null) {
+ if (!$identity instanceof Identity) {
throw new NotFoundHttpException(sprintf("Identity '%s' does not exist", $id));
}
return new JsonResponse($identity);
}
- public function collectionAction(Request $request, Institution $institution)
+ public function collection(Request $request, Institution $institution): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
$query = new IdentityQuery();
$query->institution = $institution;
@@ -81,19 +64,15 @@ public function collectionAction(Request $request, Institution $institution)
return JsonCollectionResponse::fromPaginator($paginator);
}
- /**
- * @param string $identityId
- * @return \Symfony\Component\HttpFoundation\Response
- */
- public function getRegistrationAuthorityCredentialsAction($identityId)
+ public function getRegistrationAuthorityCredentials(string $identityId): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
$identityService = $this->identityService;
$credentials = $identityService->findRegistrationAuthorityCredentialsOf($identityId);
- if (!$credentials) {
+ if (!$credentials instanceof \Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RegistrationAuthorityCredentials) {
return new JsonNotFoundResponse();
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/InstitutionConfigurationOptionsController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/InstitutionConfigurationOptionsController.php
index 9475003f1..c4976bff0 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/InstitutionConfigurationOptionsController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/InstitutionConfigurationOptionsController.php
@@ -23,40 +23,22 @@
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\AllowedSecondFactorListService;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionAuthorizationService;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionConfigurationOptionsService;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-final class InstitutionConfigurationOptionsController extends Controller
+final class InstitutionConfigurationOptionsController extends AbstractController
{
- /**
- * @var InstitutionConfigurationOptionsService
- */
- private $institutionConfigurationOptionsService;
-
- /**
- * @return InstitutionAuthorizationService
- */
- private $institutionAuthorizationService;
-
- /**
- * @var AllowedSecondFactorListService
- */
- private $allowedSecondFactorListService;
-
public function __construct(
- InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
- InstitutionAuthorizationService $institutionAuthorizationService,
- AllowedSecondFactorListService $allowedSecondFactorListService
+ private readonly InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
+ private readonly InstitutionAuthorizationService $institutionAuthorizationService,
+ private readonly AllowedSecondFactorListService $allowedSecondFactorListService,
) {
- $this->institutionConfigurationOptionsService = $institutionConfigurationOptionsService;
- $this->institutionAuthorizationService = $institutionAuthorizationService;
- $this->allowedSecondFactorListService = $allowedSecondFactorListService;
}
- public function getForInstitutionAction($institutionName)
+ public function getForInstitution(string $institutionName): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_SS', 'ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_SS', 'ROLE_RA', 'ROLE_READ']);
$institution = new Institution($institutionName);
@@ -68,9 +50,9 @@ public function getForInstitutionAction($institutionName)
->allowedSecondFactorListService
->getAllowedSecondFactorListFor($institution);
- if ($institutionConfigurationOptions === null) {
+ if (!$institutionConfigurationOptions instanceof \Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionConfigurationOptions) {
throw new NotFoundHttpException(
- sprintf('No institution configuration options found for institution "%s"', $institution)
+ sprintf('No institution configuration options found for institution "%s"', $institution),
);
}
@@ -83,18 +65,24 @@ public function getForInstitutionAction($institutionName)
->findAuthorizationsFor($institution);
return new JsonResponse([
- 'institution' => $institutionConfigurationOptions->institution,
- 'use_ra_locations' => $institutionConfigurationOptions->useRaLocationsOption,
+ 'institution' => $institutionConfigurationOptions->institution,
+ 'use_ra_locations' => $institutionConfigurationOptions->useRaLocationsOption,
'show_raa_contact_information' => $institutionConfigurationOptions->showRaaContactInformationOption,
- 'verify_email' => $institutionConfigurationOptions->verifyEmailOption,
+ 'verify_email' => $institutionConfigurationOptions->verifyEmailOption,
'sso_on_2fa' => $institutionConfigurationOptions->ssoOn2faOption,
'self_vet' => $institutionConfigurationOptions->selfVetOption,
'allow_self_asserted_tokens' => $institutionConfigurationOptions->selfAssertedTokensOption,
'number_of_tokens_per_identity' => $numberOfTokensPerIdentity,
- 'allowed_second_factors' => $allowedSecondFactorList,
- 'use_ra' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(InstitutionRole::useRa())->jsonSerialize(),
- 'use_raa' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(InstitutionRole::useRaa())->jsonSerialize(),
- 'select_raa' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(InstitutionRole::selectRaa())->jsonSerialize(),
+ 'allowed_second_factors' => $allowedSecondFactorList,
+ 'use_ra' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(
+ InstitutionRole::useRa(),
+ )->jsonSerialize(),
+ 'use_raa' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(
+ InstitutionRole::useRaa(),
+ )->jsonSerialize(),
+ 'select_raa' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(
+ InstitutionRole::selectRaa(),
+ )->jsonSerialize(),
]);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/ProfileController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/ProfileController.php
index b1a9c420d..9ec1a7629 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/ProfileController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/ProfileController.php
@@ -19,38 +19,37 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Controller;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\ProfileService;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\Profile;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-class ProfileController extends Controller
+class ProfileController extends AbstractController
{
- /**
- * @var ProfileService
- */
- private $profileService;
-
public function __construct(
- ProfileService $profileService
+ private readonly ProfileService $profileService,
) {
- $this->profileService = $profileService;
}
- public function getAction(Request $request, $identityId)
+ public function get(Request $request, string $identityId): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
// Is the actor allowed to view the profile page?
$actorId = $request->get('actorId');
if ($identityId !== $actorId) {
- throw new AccessDeniedHttpException("Identity and actor id should match. It is not yet allowed to view the profile of somebody else.");
+ throw new AccessDeniedHttpException(
+ "Identity and actor id should match. It is not yet allowed to view the profile of somebody else.",
+ );
}
$profile = $this->profileService->createProfile($identityId);
- if (!$profile) {
- throw new NotFoundHttpException("The profile cannot be created, the identity id did not match an identity.");
+ if (!$profile instanceof Profile) {
+ throw new NotFoundHttpException(
+ "The profile cannot be created, the identity id did not match an identity.",
+ );
}
return new JsonResponse($profile);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaCandidateController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaCandidateController.php
index 9cb7cf23e..4d34013e6 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaCandidateController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaCandidateController.php
@@ -18,59 +18,45 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Controller;
-use Surfnet\Stepup\Configuration\Value\InstitutionRole;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\RegistrationAuthorityRole;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Service\AuthorizationContextService;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RaCandidateQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaCandidateService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use function sprintf;
-class RaCandidateController extends Controller
+class RaCandidateController extends AbstractController
{
- /**
- * @var RaCandidateService
- */
- private $raCandidateService;
-
- /**
- * @var AuthorizationContextService
- */
- private $authorizationService;
-
public function __construct(
- RaCandidateService $raCandidateService,
- AuthorizationContextService $authorizationService
+ private readonly RaCandidateService $raCandidateService,
+ private readonly AuthorizationContextService $authorizationService,
) {
- $this->raCandidateService = $raCandidateService;
- $this->authorizationService = $authorizationService;
}
/**
- * @param Request $request
* @return JsonCollectionResponse
*/
- public function searchAction(Request $request)
+ public function search(Request $request): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
$actorId = new IdentityId($request->get('actorId'));
- $query = new RaCandidateQuery();
- $query->institution = $request->get('institution');
- $query->commonName = $request->get('commonName');
- $query->email = $request->get('email');
+ $query = new RaCandidateQuery();
+ $query->institution = $request->get('institution');
+ $query->commonName = $request->get('commonName');
+ $query->email = $request->get('email');
$query->secondFactorTypes = $request->get('secondFactorTypes');
- $query->raInstitution = $request->get('raInstitution');
- $query->pageNumber = (int) $request->get('p', 1);
+ $query->raInstitution = $request->get('raInstitution');
+ $query->pageNumber = (int)$request->get('p', 1);
$query->authorizationContext = $this->authorizationService->buildSelectRaaInstitutionAuthorizationContext(
- $actorId
+ $actorId,
);
$paginator = $this->raCandidateService->search($query);
@@ -81,12 +67,11 @@ public function searchAction(Request $request)
}
/**
- * @param Request $request
* @return JsonResponse
*/
- public function getAction(Request $request)
+ public function get(Request $request): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
$actorId = new IdentityId($request->get('actorId'));
@@ -94,7 +79,7 @@ public function getAction(Request $request)
$authorizationContext = $this->authorizationService->buildInstitutionAuthorizationContext(
$actorId,
- RegistrationAuthorityRole::ra()
+ RegistrationAuthorityRole::ra(),
);
$raCandidate = $this->raCandidateService->findOneByIdentityId($identityId);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaController.php
index a1a07fab6..08afa1f4a 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaController.php
@@ -21,23 +21,18 @@
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaListingService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
-class RaController extends Controller
+class RaController extends AbstractController
{
- /**
- * @var RaListingService
- */
- private $raListingService;
-
- public function __construct(RaListingService $raListingService)
- {
- $this->raListingService = $raListingService;
+ public function __construct(
+ private readonly RaListingService $raListingService,
+ ) {
}
- public function listAction(Institution $institution)
+ public function list(Institution $institution): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_SS', 'ROLE_READ']);
$registrationAuthorityCredentials = $this->raListingService->listRegistrationAuthoritiesFor($institution);
$count = count($registrationAuthorityCredentials);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaListingController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaListingController.php
index 4ec8e2e68..8e7760081 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaListingController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaListingController.php
@@ -25,50 +25,38 @@
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RaListingQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaListingService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-class RaListingController extends Controller
+class RaListingController extends AbstractController
{
- /**
- * @var RaListingService
- */
- private $raListingService;
-
- /**
- * @var AuthorizationContextService
- */
- private $authorizationService;
-
public function __construct(
- RaListingService $raListingService,
- AuthorizationContextService $authorizationService
+ private readonly RaListingService $raListingService,
+ private readonly AuthorizationContextService $authorizationService,
) {
- $this->raListingService = $raListingService;
- $this->authorizationService = $authorizationService;
}
- public function getAction(Request $request, $identityId)
+ public function get(Request $request, string $identityId): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
$actorId = new IdentityId($request->get('actorId'));
$institution = new Institution($request->get('institution'));
$authorizationContext = $this->authorizationService->buildInstitutionAuthorizationContext(
$actorId,
- RegistrationAuthorityRole::raa()
+ RegistrationAuthorityRole::raa(),
);
$raListing = $this->raListingService->findByIdentityIdAndRaInstitutionWithContext(
new IdentityId($identityId),
$institution,
- $authorizationContext
+ $authorizationContext,
);
- if ($raListing === null) {
+ if (!$raListing instanceof \Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing) {
throw new NotFoundHttpException(sprintf("RaListing '%s' does not exist", $identityId));
}
@@ -76,12 +64,11 @@ public function getAction(Request $request, $identityId)
}
/**
- * @param Request $request
* @return JsonCollectionResponse
*/
- public function searchAction(Request $request)
+ public function search(Request $request): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
$actorId = new IdentityId($request->get('actorId'));
@@ -116,7 +103,7 @@ public function searchAction(Request $request)
$query->orderDirection = $request->get('orderDirection');
$query->authorizationContext = $this->authorizationService->buildInstitutionAuthorizationContext(
$actorId,
- RegistrationAuthorityRole::raa()
+ RegistrationAuthorityRole::raa(),
);
$searchResults = $this->raListingService->search($query);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaLocationController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaLocationController.php
index 9a7155a6f..b27ee7750 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaLocationController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaLocationController.php
@@ -23,43 +23,38 @@
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Query\RaLocationQuery;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\RaLocationService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
-final class RaLocationController extends Controller
+final class RaLocationController extends AbstractController
{
- /**
- * @return RaLocationService
- */
- private $raLocationService;
-
- public function __construct(RaLocationService $raLocationService)
- {
- $this->raLocationService = $raLocationService;
+ public function __construct(
+ private readonly RaLocationService $raLocationService,
+ ) {
}
- public function searchAction(Request $request, Institution $institution)
+ public function search(Request $request, Institution $institution): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
- $query = new RaLocationQuery();
- $query->institution = $institution;
- $query->orderBy = $request->get('orderBy', $query->orderBy);
+ $query = new RaLocationQuery();
+ $query->institution = $institution;
+ $query->orderBy = $request->get('orderBy', $query->orderBy);
$query->orderDirection = $request->get('orderDirection', $query->orderDirection);
$raLocations = $this->raLocationService->search($query);
- $count = count($raLocations);
+ $count = count($raLocations);
return new JsonCollectionResponse($count, 1, $count, $raLocations);
}
- public function getAction(Request $request)
+ public function get(Request $request): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
$raLocationId = new RaLocationId($request->get('raLocationId'));
- $raLocation = $this->raLocationService->findByRaLocationId($raLocationId);
+ $raLocation = $this->raLocationService->findByRaLocationId($raLocationId);
return new JsonResponse($raLocation);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaSecondFactorController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaSecondFactorController.php
index 89dd7bcc1..c8e84d4f5 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaSecondFactorController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RaSecondFactorController.php
@@ -24,33 +24,21 @@
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RaSecondFactorQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaSecondFactorService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
-final class RaSecondFactorController extends Controller
+final class RaSecondFactorController extends AbstractController
{
- /**
- * @var RaSecondFactorService
- */
- private $raSecondFactorService;
-
- /**
- * @var AuthorizationContextService
- */
- private $authorizationService;
-
public function __construct(
- RaSecondFactorService $raSecondFactorService,
- AuthorizationContextService $authorizationService
+ private readonly RaSecondFactorService $raSecondFactorService,
+ private readonly AuthorizationContextService $authorizationService,
) {
- $this->raSecondFactorService = $raSecondFactorService;
- $this->authorizationService = $authorizationService;
}
- public function collectionAction(Request $request)
+ public function collection(Request $request): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
$query = $this->buildRaSecondFactorQuery($request);
@@ -61,9 +49,9 @@ public function collectionAction(Request $request)
return JsonCollectionResponse::fromPaginator($paginator, $filters);
}
- public function exportAction(Request $request)
+ public function export(Request $request): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
$query = $this->buildRaSecondFactorQuery($request);
@@ -73,10 +61,9 @@ public function exportAction(Request $request)
}
/**
- * @param Request $request
* @return RaSecondFactorQuery
*/
- private function buildRaSecondFactorQuery(Request $request)
+ private function buildRaSecondFactorQuery(Request $request): RaSecondFactorQuery
{
$actorId = new IdentityId($request->get('actorId'));
@@ -92,7 +79,7 @@ private function buildRaSecondFactorQuery(Request $request)
$query->orderDirection = $request->get('orderDirection');
$query->authorizationContext = $this->authorizationService->buildInstitutionAuthorizationContext(
$actorId,
- RegistrationAuthorityRole::ra()
+ RegistrationAuthorityRole::ra(),
);
return $query;
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RecoveryTokenController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RecoveryTokenController.php
index 1205b2828..ace32e80f 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RecoveryTokenController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/RecoveryTokenController.php
@@ -27,7 +27,7 @@
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RecoveryTokenQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RecoveryTokenService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -36,36 +36,18 @@
* Exposes the Recovery Tokens projection through the
* Middleware Identity (read) API
*/
-class RecoveryTokenController extends Controller
+class RecoveryTokenController extends AbstractController
{
- /**
- * @var RecoveryTokenService
- */
- private $service;
-
- /**
- * @var AuthorizationContextService
- */
- private $authorizationService;
-
- /**
- * @var LoggerInterface
- */
- private $logger;
-
public function __construct(
- RecoveryTokenService $recoveryTokenServiceService,
- AuthorizationContextService $authorizationService,
- LoggerInterface $logger
+ private readonly RecoveryTokenService $service,
+ private readonly AuthorizationContextService $authorizationService,
+ private readonly LoggerInterface $logger,
) {
- $this->service = $recoveryTokenServiceService;
- $this->authorizationService = $authorizationService;
- $this->logger = $logger;
}
- public function getAction($id)
+ public function get(string $id): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
$this->logger->info(sprintf('Received request to get recovery token: %s', $id));
try {
@@ -76,18 +58,20 @@ public function getAction($id)
return new JsonResponse($recoveryToken);
}
- public function collectionAction(Request $request)
+ public function collection(Request $request): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
- $this->logger->info(sprintf('Received search request for recovery tokens with params: %s', $request->getQueryString()));
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->logger->info(
+ sprintf('Received search request for recovery tokens with params: %s', $request->getQueryString()),
+ );
$query = new RecoveryTokenQuery();
- $query->identityId = $request->get('identityId');
+ $query->identityId = $request->get('identityId') ? new IdentityId($request->get('identityId')) : null;
$query->type = $request->get('type');
$query->status = $request->get('status');
$query->institution = $request->get('institution');
$query->email = $request->get('email');
$query->name = $request->get('name');
- $query->pageNumber = (int) $request->get('p', 1);
+ $query->pageNumber = (int)$request->get('p', 1);
$query->orderBy = $request->get('orderBy');
$query->orderDirection = $request->get('orderDirection');
@@ -99,7 +83,7 @@ public function collectionAction(Request $request)
$actorId = new IdentityId($actorId);
$query->authorizationContext = $this->authorizationService->buildInstitutionAuthorizationContext(
$actorId,
- RegistrationAuthorityRole::ra()
+ RegistrationAuthorityRole::ra(),
);
}
$paginator = $this->service->search($query);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/SraaController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/SraaController.php
index 63bf793f3..a410fde6c 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/SraaController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/SraaController.php
@@ -21,42 +21,35 @@
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\SraaService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonNotFoundResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
-class SraaController extends Controller
+class SraaController extends AbstractController
{
- /**
- * @var SraaService
- */
- private $sraaService;
-
- public function __construct(SraaService $sraaService)
+ public function __construct(private readonly SraaService $sraaService)
{
- $this->sraaService = $sraaService;
}
/**
* @param string $nameId injected by symfony from the request
- * @return JsonNotFoundResponse|JsonResponse
*/
- public function getAction($nameId)
+ public function get(string $nameId): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
$sraa = $this->sraaService->findByNameId(new NameId($nameId));
- if (!$sraa) {
+ if (!$sraa instanceof \Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Sraa) {
return new JsonNotFoundResponse();
}
return new JsonResponse($sraa);
}
- public function listAction() : JsonResponse
+ public function list(): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
return new JsonResponse($this->sraaService->findAll());
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/UnverifiedSecondFactorController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/UnverifiedSecondFactorController.php
index 61a0c6e6a..2cec19a2d 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/UnverifiedSecondFactorController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/UnverifiedSecondFactorController.php
@@ -18,48 +18,45 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Controller;
+use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\UnverifiedSecondFactor;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\UnverifiedSecondFactorQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\SecondFactorService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-class UnverifiedSecondFactorController extends Controller
+class UnverifiedSecondFactorController extends AbstractController
{
- /**
- * @var SecondFactorService
- */
- private $secondFactorService;
-
- public function __construct(SecondFactorService $secondFactorService)
- {
- $this->secondFactorService = $secondFactorService;
+ public function __construct(
+ private readonly SecondFactorService $secondFactorService,
+ ) {
}
- public function getAction($id)
+ public function get(string $id): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
$secondFactor = $this->secondFactorService->findUnverified(new SecondFactorId($id));
- if ($secondFactor === null) {
+ if (!$secondFactor instanceof UnverifiedSecondFactor) {
throw new NotFoundHttpException(sprintf("Unverified second factor '%s' does not exist", $id));
}
return new JsonResponse($secondFactor);
}
- public function collectionAction(Request $request)
+ public function collection(Request $request): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
- $query = new UnverifiedSecondFactorQuery();
- $query->identityId = $request->get('identityId');
+ $query = new UnverifiedSecondFactorQuery();
+ $query->identityId = new IdentityId($request->get('identityId'));
$query->verificationNonce = $request->get('verificationNonce');
- $query->pageNumber = (int) $request->get('p', 1);
+ $query->pageNumber = (int)$request->get('p', 1);
$paginator = $this->secondFactorService->searchUnverifiedSecondFactors($query);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VerifiedSecondFactorController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VerifiedSecondFactorController.php
index 9818307ad..6fe3b9b2e 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VerifiedSecondFactorController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VerifiedSecondFactorController.php
@@ -18,18 +18,18 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Controller;
-use Surfnet\Stepup\Configuration\Value\InstitutionRole;
use Surfnet\Stepup\Helper\SecondFactorProvePossessionHelper;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\RegistrationAuthorityRole;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
use Surfnet\StepupBundle\Value\SecondFactorType;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Service\AuthorizationContextService;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\VerifiedSecondFactor;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\VerifiedSecondFactorOfIdentityQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\VerifiedSecondFactorQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\SecondFactorService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -37,50 +37,31 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class VerifiedSecondFactorController extends Controller
+class VerifiedSecondFactorController extends AbstractController
{
- /**
- * @var SecondFactorService
- */
- private $secondFactorService;
-
- /**
- * @var AuthorizationContextService
- */
- private $institutionAuthorizationService;
-
- /**
- * @var SecondFactorProvePossessionHelper
- */
- private $secondFactorProvePossessionHelper;
-
-
public function __construct(
- SecondFactorService $secondFactorService,
- AuthorizationContextService $authorizationService,
- SecondFactorProvePossessionHelper $secondFactorProvePossessionHelper
+ private readonly SecondFactorService $secondFactorService,
+ private readonly AuthorizationContextService $institutionAuthorizationService,
+ private readonly SecondFactorProvePossessionHelper $secondFactorProvePossessionHelper,
) {
- $this->secondFactorService = $secondFactorService;
- $this->institutionAuthorizationService = $authorizationService;
- $this->secondFactorProvePossessionHelper = $secondFactorProvePossessionHelper;
}
- public function getAction($id)
+ public function get(string $id): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
$secondFactor = $this->secondFactorService->findVerified(new SecondFactorId($id));
- if ($secondFactor === null) {
+ if (!$secondFactor instanceof VerifiedSecondFactor) {
throw new NotFoundHttpException(sprintf("Verified second factor '%s' does not exist", $id));
}
return new JsonResponse($secondFactor);
}
- public function collectionAction(Request $request)
+ public function collection(Request $request): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
$actorId = new IdentityId($request->get('actorId'));
@@ -95,10 +76,10 @@ public function collectionAction(Request $request)
}
$query->registrationCode = $request->get('registrationCode');
- $query->pageNumber = (int) $request->get('p', 1);
+ $query->pageNumber = (int)$request->get('p', 1);
$query->authorizationContext = $this->institutionAuthorizationService->buildInstitutionAuthorizationContext(
$actorId,
- RegistrationAuthorityRole::ra()
+ RegistrationAuthorityRole::ra(),
);
$paginator = $this->secondFactorService->searchVerifiedSecondFactors($query);
@@ -106,26 +87,26 @@ public function collectionAction(Request $request)
return JsonCollectionResponse::fromPaginator($paginator);
}
- public function collectionOfIdentityAction(Request $request)
+ public function collectionOfIdentity(Request $request): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_SS', 'ROLE_READ']);
$query = new VerifiedSecondFactorOfIdentityQuery();
$query->identityId = new IdentityId($request->get('identityId'));
- $query->pageNumber = (int) $request->get('p', 1);
+ $query->pageNumber = (int)$request->get('p', 1);
$paginator = $this->secondFactorService->searchVerifiedSecondFactorsOfIdentity($query);
return JsonCollectionResponse::fromPaginator($paginator);
}
- public function getCanSkipProvePossessionAction($id)
+ public function getCanSkipProvePossession(string $id): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_READ']);
$secondFactor = $this->secondFactorService->findVerified(new SecondFactorId($id));
- if ($secondFactor === null) {
+ if (!$secondFactor instanceof VerifiedSecondFactor) {
throw new NotFoundHttpException(sprintf("Verified second factor '%s' does not exist", $id));
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VettedSecondFactorController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VettedSecondFactorController.php
index 20beef918..ff13fcdf1 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VettedSecondFactorController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VettedSecondFactorController.php
@@ -18,47 +18,44 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Controller;
+use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\VettedSecondFactor;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\VettedSecondFactorQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\SecondFactorService;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-class VettedSecondFactorController extends Controller
+class VettedSecondFactorController extends AbstractController
{
- /**
- * @var SecondFactorService
- */
- private $secondFactorService;
-
- public function __construct(SecondFactorService $secondFactorService)
- {
- $this->secondFactorService = $secondFactorService;
+ public function __construct(
+ private readonly SecondFactorService $secondFactorService,
+ ) {
}
- public function getAction($id)
+ public function get(string $id): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
$secondFactor = $this->secondFactorService->findVetted(new SecondFactorId($id));
- if ($secondFactor === null) {
+ if (!$secondFactor instanceof VettedSecondFactor) {
throw new NotFoundHttpException(sprintf("Vetted second factor '%s' does not exist", $id));
}
return new JsonResponse($secondFactor);
}
- public function collectionAction(Request $request)
+ public function collection(Request $request): JsonCollectionResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
- $query = new VettedSecondFactorQuery();
- $query->identityId = $request->get('identityId');
- $query->pageNumber = (int) $request->get('p', 1);
+ $query = new VettedSecondFactorQuery();
+ $query->identityId = new IdentityId($request->get('identityId'));
+ $query->pageNumber = (int)$request->get('p', 1);
$paginator = $this->secondFactorService->searchVettedSecondFactors($query);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VettingTypeHintController.php b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VettingTypeHintController.php
index 5c6e1578c..7a316c5cf 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VettingTypeHintController.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Controller/VettingTypeHintController.php
@@ -19,87 +19,34 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Controller;
use Psr\Log\LoggerInterface;
-use Surfnet\Stepup\Configuration\Value\InstitutionRole;
-use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
-use Surfnet\Stepup\Identity\Value\RecoveryTokenId;
-use Surfnet\StepupMiddleware\ApiBundle\Authorization\Service\AuthorizationContextService;
use Surfnet\StepupMiddleware\ApiBundle\Exception\NotFoundException;
-use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RecoveryTokenQuery;
-use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RecoveryTokenService;
-use Surfnet\StepupMiddleware\ApiBundle\Response\JsonCollectionResponse;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\VettingTypeHintService;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ApiBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-use function in_array;
-use function sprintf;
-class VettingTypeHintController extends Controller
+class VettingTypeHintController extends AbstractController
{
- /**
- * @var VettingTypeHintService
- */
- private $service;
-
- /**
- * @var LoggerInterface
- */
- private $logger;
-
public function __construct(
- VettingTypeHintService $vettingTypeHintService,
- LoggerInterface $logger
+ private readonly VettingTypeHintService $service,
+ private readonly LoggerInterface $logger,
) {
- $this->service = $vettingTypeHintService;
- $this->logger = $logger;
}
- public function getAction($institution)
+ public function get(string $institution): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
+ $this->denyAccessUnlessGrantedOneOff(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
$this->logger->info(sprintf('Received request to get a vetting type hint for institution: %s', $institution));
try {
$recoveryToken = $this->service->findBy(new Institution($institution));
} catch (NotFoundException $e) {
- throw new NotFoundHttpException(sprintf("Vetting type hint for institution '%s' was not found", $institution), $e);
- }
- return new JsonResponse($recoveryToken);
- }
-
- public function collectionAction(Request $request)
- {
- $this->denyAccessUnlessGranted(['ROLE_RA', 'ROLE_SS', 'ROLE_READ']);
- $this->logger->info(sprintf('Received search request for recovery tokens with params: %s', $request->getQueryString()));
- $query = new RecoveryTokenQuery();
- $query->identityId = $request->get('identityId');
- $query->type = $request->get('type');
- $query->status = $request->get('status');
- $query->institution = $request->get('institution');
- $query->email = $request->get('email');
- $query->name = $request->get('name');
- $query->pageNumber = (int) $request->get('p', 1);
- $query->orderBy = $request->get('orderBy');
- $query->orderDirection = $request->get('orderDirection');
-
- $roles = $this->getUser()->getRoles();
- // Only apply the authorization context on non self service requests
- if (!in_array('ROLE_SS', $roles)) {
- $actorId = $request->get('actorId', $request->get('identityId'));
- $this->logger->info(sprintf('Executing query on behalf of %s', $actorId));
- $actorId = new IdentityId($actorId);
- $query->authorizationContext = $this->authorizationService->buildInstitutionAuthorizationContext(
- $actorId,
- new InstitutionRole(InstitutionRole::ROLE_USE_RA)
+ throw new NotFoundHttpException(
+ sprintf("Vetting type hint for institution '%s' was not found", $institution),
+ $e,
);
}
- $paginator = $this->service->search($query);
- $this->logger->info(sprintf('Found %d results', $paginator->count()));
-
- $filters = $this->service->getFilterOptions($query);
-
- return JsonCollectionResponse::fromPaginator($paginator, $filters);
+ return new JsonResponse($recoveryToken);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/DependencyInjection/Configuration.php b/src/Surfnet/StepupMiddleware/ApiBundle/DependencyInjection/Configuration.php
index 75644d526..77012057c 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/DependencyInjection/Configuration.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/DependencyInjection/Configuration.php
@@ -23,23 +23,21 @@
class Configuration implements ConfigurationInterface
{
- public function getConfigTreeBuilder()
+ public function getConfigTreeBuilder(): TreeBuilder
{
- $treeBuilder = new TreeBuilder();
+ $treeBuilder = new TreeBuilder('surfnet_stepup_middleware_api');
+ $rootNode = $treeBuilder->getRootNode();
- $treeBuilder
- ->root('surfnet_stepup_middleware_api')
- ->children()
- ->scalarNode('http_basic_realm')
- ->defaultValue('Secure Gateway API')
- ->validate()
- ->ifTrue(function ($realm) {
- return !is_string($realm) || empty($realm);
- })
- ->thenInvalid("Invalid HTTP Basic realm '%s'. Must be string and non-empty.")
- ->end()
- ->end()
- ->end();
+ $rootNode
+ ->children()
+ ->scalarNode('http_basic_realm')
+ ->defaultValue('Secure Gateway API')
+ ->validate()
+ ->ifTrue(fn($realm): bool => !is_string($realm) || ($realm === '' || $realm === '0'))
+ ->thenInvalid("Invalid HTTP Basic realm '%s'. Must be string and non-empty.")
+ ->end()
+ ->end()
+ ->end();
return $treeBuilder;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/DependencyInjection/SurfnetStepupMiddlewareApiExtension.php b/src/Surfnet/StepupMiddleware/ApiBundle/DependencyInjection/SurfnetStepupMiddlewareApiExtension.php
index 845bd3e09..7c1fc678b 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/DependencyInjection/SurfnetStepupMiddlewareApiExtension.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/DependencyInjection/SurfnetStepupMiddlewareApiExtension.php
@@ -26,7 +26,7 @@
class SurfnetStepupMiddlewareApiExtension extends Extension
{
- public function load(array $config, ContainerBuilder $container)
+ public function load(array $config, ContainerBuilder $container): void
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), $config);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/AuthorityRoleType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/AuthorityRoleType.php
index cb04ac9d8..db0b778e6 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/AuthorityRoleType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/AuthorityRoleType.php
@@ -29,30 +29,30 @@
*/
class AuthorityRoleType extends Type
{
- const NAME = 'authority_role';
+ public const NAME = 'authority_role';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- if (!isset($fieldDeclaration['length'])) {
- $fieldDeclaration['length'] = 20;
+ if (!isset($column['length'])) {
+ $column['length'] = 20;
}
- return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getVarcharTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{
if (is_null($value)) {
- return $value;
+ return null;
}
- return (string) $value;
+ return (string)$value;
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?AuthorityRole
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
@@ -61,7 +61,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -70,7 +70,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $authorityRole;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/CommonNameType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/CommonNameType.php
index 9e462c501..5d6f0a290 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/CommonNameType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/CommonNameType.php
@@ -23,41 +23,42 @@
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Exception\InvalidArgumentException;
use Surfnet\Stepup\Identity\Value\CommonName;
+use TypeError;
/**
* Custom Type for the CommonName Value Object
*/
class CommonNameType extends Type
{
- const NAME = 'stepup_common_name';
+ public const NAME = 'stepup_common_name';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getVarcharTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{
if (is_null($value)) {
- return $value;
+ return null;
}
- return (string) $value;
+ return (string)$value;
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?CommonName
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
$commonName = new CommonName($value);
- } catch (InvalidArgumentException $e) {
+ } catch (InvalidArgumentException|TypeError $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -66,7 +67,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $commonName;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationContactInformationType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationContactInformationType.php
index 2ba32b6ae..ef3167b99 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationContactInformationType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationContactInformationType.php
@@ -1,5 +1,7 @@
getClobTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getClobTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
return null;
@@ -46,28 +49,28 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
throw new ConversionException(
sprintf(
"Encountered illegal contact information of type %s '%s', expected a ContactInformation instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
return $value->getContactInformation();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?ContactInformation
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
$contactInformation = new ContactInformation($value);
- } catch (InvalidArgumentException $e) {
+ } catch (InvalidArgumentException|TypeError $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -76,7 +79,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $contactInformation;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationInstitutionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationInstitutionType.php
index abf0aff55..af3c2f0a7 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationInstitutionType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationInstitutionType.php
@@ -29,36 +29,36 @@
*/
class ConfigurationInstitutionType extends Type
{
- const NAME = 'stepup_configuration_institution';
+ public const NAME = 'stepup_configuration_institution';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getVarcharTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
- return $value;
+ return null;
}
if (!$value instanceof Institution) {
throw new ConversionException(
sprintf(
"Encountered illegal institution of type %s '%s', expected an Institution instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
return $value->getInstitution();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?Institution
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
@@ -67,7 +67,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -76,7 +76,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $institution;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationLocationType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationLocationType.php
index d52f5deb1..55f0324f1 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationLocationType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ConfigurationLocationType.php
@@ -1,5 +1,7 @@
getClobTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getClobTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
- return $value;
+ return null;
}
if (!$value instanceof Location) {
throw new ConversionException(
sprintf(
"Encountered illegal location of type %s '%s', expected a Location instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
return $value->getLocation();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?Location
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
$location = new Location($value);
- } catch (InvalidArgumentException $e) {
+ } catch (InvalidArgumentException|TypeError $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -76,7 +79,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $location;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ContactInformationType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ContactInformationType.php
index 93842158a..d9b399dab 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ContactInformationType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ContactInformationType.php
@@ -1,5 +1,7 @@
getClobTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getClobTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
- return $value;
+ return null;
}
- return (string) $value;
+ return (string)$value;
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?ContactInformation
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
$contactInformation = new ContactInformation($value);
- } catch (InvalidArgumentException $e) {
+ } catch (InvalidArgumentException|TypeError $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -66,7 +69,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $contactInformation;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/DateTimeType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/DateTimeType.php
index 8c5678a2e..0457837a5 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/DateTimeType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/DateTimeType.php
@@ -30,25 +30,19 @@
*/
class DateTimeType extends Type
{
- const NAME = 'stepup_datetime';
+ public const NAME = 'stepup_datetime';
/**
- * @param array $fieldDeclaration
+ * @param array $column
* @param AbstractPlatform $platform
* @return string
- * @throws \Doctrine\DBAL\DBALException
*/
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getDateTimeTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getDateTimeTypeDeclarationSQL($column);
}
- /**
- * @param mixed $value
- * @param AbstractPlatform $platform
- * @return null|string
- */
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string
{
if ($value === null) {
return null;
@@ -61,31 +55,32 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
}
/**
- * @param mixed $value
- * @param AbstractPlatform $platform
- * @return null|DateTime
* @throws ConversionException
*/
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?DateTime
{
if (is_null($value)) {
- return $value;
+ return null;
}
- $dateTime = CoreDateTime::createFromFormat($platform->getDateTimeFormatString(), $value, new DateTimeZone('UTC'));
+ $dateTime = CoreDateTime::createFromFormat(
+ $platform->getDateTimeFormatString(),
+ $value,
+ new DateTimeZone('UTC'),
+ );
if (!$dateTime) {
throw ConversionException::conversionFailedFormat(
$value,
$this->getName(),
- $platform->getDateTimeFormatString()
+ $platform->getDateTimeFormatString(),
);
}
return new DateTime($dateTime);
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/DocumentNumberType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/DocumentNumberType.php
index 52c534514..2393a0335 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/DocumentNumberType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/DocumentNumberType.php
@@ -1,5 +1,7 @@
getVarcharTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getVarcharTypeDeclarationSQL($column);
}
/**
- * @param mixed $value
- * @param AbstractPlatform $platform
- * @return null|string
* @throws ConversionException
*/
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{
if (is_null($value)) {
return null;
@@ -57,9 +51,9 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
throw new ConversionException(
sprintf(
"Encountered illegal document number of type %s '%s', expected a DocumentNumber instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
@@ -67,12 +61,9 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
}
/**
- * @param mixed $value
- * @param AbstractPlatform $platform
- * @return null|DocumentNumber
- * @throws ConversionException
+ * @throws InvalidArgumentException
*/
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?DocumentNumber
{
if (is_null($value)) {
return null;
@@ -81,7 +72,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return new DocumentNumber($value);
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/EmailType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/EmailType.php
index 32cd2381f..90e3b1ac7 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/EmailType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/EmailType.php
@@ -29,26 +29,26 @@
*/
class EmailType extends Type
{
- const NAME = 'stepup_email';
+ public const NAME = 'stepup_email';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getVarcharTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{
if (is_null($value)) {
- return $value;
+ return null;
}
- return (string) $value;
+ return (string)$value;
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?Email
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
@@ -57,7 +57,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -66,7 +66,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $email;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionRoleType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionRoleType.php
index 7c98c0db1..2630e86be 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionRoleType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionRoleType.php
@@ -21,7 +21,6 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
-use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
use Surfnet\Stepup\Exception\InvalidArgumentException;
@@ -30,36 +29,36 @@
*/
class InstitutionRoleType extends Type
{
- const NAME = 'stepup_institution_role';
+ public const NAME = 'stepup_institution_role';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getVarcharTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
- return $value;
+ return null;
}
if (!$value instanceof InstitutionRole) {
throw new ConversionException(
sprintf(
"Encountered illegal location of type %s '%s', expected a InstitutionRole instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
return $value->getType();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?InstitutionRole
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
@@ -68,7 +67,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -77,7 +76,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $institutionRole;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionType.php
index 5f7f410f5..d4570b01c 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/InstitutionType.php
@@ -21,34 +21,34 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
-use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Exception\InvalidArgumentException;
+use Surfnet\Stepup\Identity\Value\Institution;
/**
* Custom Type for the Institution Value Object
*/
class InstitutionType extends Type
{
- const NAME = 'institution';
+ public const NAME = 'institution';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getVarcharTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{
if (is_null($value)) {
- return $value;
+ return null;
}
- return (string) $value;
+ return (string)$value;
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?Institution
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
@@ -57,7 +57,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -66,7 +66,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $institution;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocaleType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocaleType.php
index dd62270a6..a46588ecf 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocaleType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocaleType.php
@@ -1,5 +1,7 @@
getVarcharTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getVarcharTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{
if (is_null($value)) {
- return $value;
+ return null;
}
- return (string) $value;
+ return (string)$value;
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?Locale
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
$locale = new Locale($value);
- } catch (InvalidArgumentException $e) {
+ } catch (InvalidArgumentException|TypeError $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -66,7 +69,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $locale;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocationType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocationType.php
index 254cbcb68..1a4bfe8a7 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocationType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/LocationType.php
@@ -1,5 +1,7 @@
getClobTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getClobTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{
if (is_null($value)) {
- return $value;
+ return null;
}
- return (string) $value;
+ return (string)$value;
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?Location
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
$location = new Location($value);
- } catch (InvalidArgumentException $e) {
+ } catch (InvalidArgumentException|TypeError $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -66,7 +69,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $location;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php
index c5ff9903d..83c31c081 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NameIdType.php
@@ -29,26 +29,26 @@
*/
class NameIdType extends Type
{
- const NAME = 'stepup_name_id';
+ public const NAME = 'stepup_name_id';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getVarcharTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{
if (is_null($value)) {
- return $value;
+ return null;
}
- return (string) $value;
+ return (string)$value;
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?NameId
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
@@ -57,7 +57,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -66,7 +66,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $nameId;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NumberOfTokensPerIdentityType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NumberOfTokensPerIdentityType.php
index 49fd1198b..1bbfb6b74 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NumberOfTokensPerIdentityType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/NumberOfTokensPerIdentityType.php
@@ -20,6 +20,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
+use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption;
use Surfnet\Stepup\Exception\InvalidArgumentException;
@@ -27,19 +28,19 @@
/**
* Custom Type for the NumberOfTokensPerIdentityOption Value Object
*/
-class NumberOfTokensPerIdentityType extends Type
+class NumberOfTokensPerIdentityType extends IntegerType
{
- const NAME = 'stepup_number_of_tokens_per_identity_option';
+ public const NAME = 'stepup_number_of_tokens_per_identity_option';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getIntegerTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getIntegerTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
- return $value;
+ return null;
}
if (!$value instanceof NumberOfTokensPerIdentityOption) {
@@ -47,28 +48,28 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
sprintf(
"Encountered illegal number of tokens per identity %s '%s', expected a
NumberOfTokensPerIdentityOption instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
return $value->getNumberOfTokensPerIdentity();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?NumberOfTokensPerIdentityOption
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
- $numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption((int) $value);
+ $numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption((int)$value);
} catch (InvalidArgumentException $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -77,7 +78,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $numberOfTokensPerIdentityOption;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RaLocationNameType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RaLocationNameType.php
index d06dd6dc4..bdc0efdcc 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RaLocationNameType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RaLocationNameType.php
@@ -29,36 +29,36 @@
*/
class RaLocationNameType extends Type
{
- const NAME = 'stepup_ra_location_name';
+ public const NAME = 'stepup_ra_location_name';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
return $platform->getVarcharTypeDeclarationSQL([]);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
{
if (is_null($value)) {
- return $value;
+ return null;
}
if (!$value instanceof RaLocationName) {
throw new ConversionException(
sprintf(
"Encountered illegal RA location name of type %s '%s', expected a RaLocationName instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
return $value->getRaLocationName();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?RaLocationName
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
@@ -67,7 +67,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -76,7 +76,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $raLocationName;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RecoveryTokenStatusType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RecoveryTokenStatusType.php
index 3a6222c24..a98d54d55 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RecoveryTokenStatusType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/RecoveryTokenStatusType.php
@@ -28,26 +28,25 @@
*/
class RecoveryTokenStatusType extends Type
{
- const NAME = 'stepup_recovery_token_status';
+ public const NAME = 'stepup_recovery_token_status';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getIntegerTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getIntegerTypeDeclarationSQL($column);
}
/**
- * @param mixed $value
* @throws ConversionException
*/
- public function convertToDatabaseValue($value, AbstractPlatform $platform): int
+ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): int
{
if (!$value instanceof RecoveryTokenStatus) {
throw new ConversionException(
sprintf(
"Encountered illegal recovery token status of type %s '%s', expected a RecoveryTokenStatus instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
@@ -59,15 +58,18 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): int
return 20;
}
- throw new ConversionException(sprintf("Encountered inconvertible second factor status '%s'", (string) $value));
+ throw new ConversionException(sprintf("Encountered inconvertible second factor status '%s'", (string)$value));
}
/**
- * @param mixed $value
* @throws ConversionException
*/
- public function convertToPHPValue($value, AbstractPlatform $platform): RecoveryTokenStatus
+ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): RecoveryTokenStatus
{
+ if (is_scalar($value)) {
+ $value = (string)$value;
+ }
+
if ($value === '0') {
return RecoveryTokenStatus::active();
} elseif ($value === '10') {
@@ -79,13 +81,13 @@ public function convertToPHPValue($value, AbstractPlatform $platform): RecoveryT
throw new ConversionException(
sprintf(
"Encountered illegal recovery token status of type %s '%s', expected it to be one of [0,10,20]",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SecondFactorStatusType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SecondFactorStatusType.php
index 0901599c4..e85378df4 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SecondFactorStatusType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SecondFactorStatusType.php
@@ -29,33 +29,30 @@
*/
class SecondFactorStatusType extends Type
{
- const NAME = 'stepup_second_factor_status';
+ public const NAME = 'stepup_second_factor_status';
/**
- * @param array $fieldDeclaration
+ * @param array $column
* @param AbstractPlatform $platform
* @return string
*/
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getIntegerTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getIntegerTypeDeclarationSQL($column);
}
/**
- * @param mixed $value
- * @param AbstractPlatform $platform
- * @return int
* @throws ConversionException
*/
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): int
{
if (!$value instanceof SecondFactorStatus) {
throw new ConversionException(
sprintf(
"Encountered illegal second factor status of type %s '%s', expected a SecondFactorStatus instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
@@ -71,17 +68,17 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
return 40;
}
- throw new ConversionException(sprintf("Encountered inconvertible second factor status '%s'", (string) $value));
+ throw new ConversionException(sprintf("Encountered inconvertible second factor status '%s'", (string)$value));
}
/**
- * @param mixed $value
- * @param AbstractPlatform $platform
- * @return SecondFactorStatus
* @throws ConversionException
*/
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): SecondFactorStatus
{
+ if (is_scalar($value)) {
+ $value = (string)$value;
+ }
if ($value === '0') {
return SecondFactorStatus::unverified();
} elseif ($value === '10') {
@@ -97,13 +94,13 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
throw new ConversionException(
sprintf(
"Encountered illegal second factor status of type %s '%s', expected it to be one of [0,10,20,30,40]",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SecondFactorTypeType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SecondFactorTypeType.php
index 9c4661c76..f6507e266 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SecondFactorTypeType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SecondFactorTypeType.php
@@ -29,26 +29,26 @@
*/
class SecondFactorTypeType extends Type
{
- const NAME = 'stepup_second_factor_type';
+ public const NAME = 'stepup_second_factor_type';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getVarcharTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
{
if (is_null($value)) {
- return $value;
+ return null;
}
- return (string) $value;
+ return (string)$value;
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?SecondFactorType
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
@@ -57,7 +57,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -66,7 +66,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $secondFactorType;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfAssertedTokensOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfAssertedTokensOptionType.php
index 5aa124f5b..3d24cfd23 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfAssertedTokensOptionType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfAssertedTokensOptionType.php
@@ -20,26 +20,28 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
+use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
+use phpseclib3\Math\PrimeField\Integer;
use Surfnet\Stepup\Configuration\Value\SelfAssertedTokensOption;
use TypeError;
/**
* Custom Type for the SelfAssertedTokens options Value Object
*/
-class SelfAssertedTokensOptionType extends Type
+class SelfAssertedTokensOptionType extends IntegerType
{
- const NAME = 'stepup_self_asserted_tokens_option';
+ public const NAME = 'stepup_self_asserted_tokens_option';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getIntegerTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getIntegerTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?int
{
if (is_null($value)) {
- return $value;
+ return null;
}
if (!$value instanceof SelfAssertedTokensOption) {
@@ -47,28 +49,28 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
sprintf(
"Encountered illegal self vet option %s '%s', expected a
SelfAssertedTokensOption instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
- return (int) $value->isEnabled();
+ return (int)$value->isEnabled();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?SelfAssertedTokensOption
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
- $selfAssertedTokensOption = new SelfAssertedTokensOption((bool) $value);
+ $selfAssertedTokensOption = new SelfAssertedTokensOption((bool)$value);
} catch (TypeError $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -77,7 +79,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $selfAssertedTokensOption;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfVetOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfVetOptionType.php
index b4bf7c7cd..1202b099a 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfVetOptionType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SelfVetOptionType.php
@@ -20,6 +20,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
+use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\SelfVetOption;
use TypeError;
@@ -27,19 +28,19 @@
/**
* Custom Type for the SelfVetOption Value Object
*/
-class SelfVetOptionType extends Type
+class SelfVetOptionType extends IntegerType
{
- const NAME = 'stepup_self_vet_option';
+ public const NAME = 'stepup_self_vet_option';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getIntegerTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getIntegerTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?int
{
if (is_null($value)) {
- return $value;
+ return null;
}
if (!$value instanceof SelfVetOption) {
@@ -47,28 +48,28 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
sprintf(
"Encountered illegal self vet option %s '%s', expected a
SelfVetOption instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
- return (int) $value->isEnabled();
+ return (int)$value->isEnabled();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?SelfVetOption
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
- $selfVetOption = new SelfVetOption((bool) $value);
+ $selfVetOption = new SelfVetOption((bool)$value);
} catch (TypeError $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -77,7 +78,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $selfVetOption;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php
index aaa7e7519..263320b61 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/ShowRaaContactInformationOptionType.php
@@ -29,47 +29,47 @@
*/
class ShowRaaContactInformationOptionType extends Type
{
- const NAME = 'stepup_show_raa_contact_information_option';
+ public const NAME = 'stepup_show_raa_contact_information_option';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getBooleanTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getBooleanTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?int
{
if (is_null($value)) {
- return $value;
+ return null;
}
if (!$value instanceof ShowRaaContactInformationOption) {
throw new ConversionException(
sprintf(
"Encountered illegal location of type %s '%s', expected a ShowRaaContactInformationOption instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
- return (int) $value->isEnabled();
+ return (int)$value->isEnabled();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?ShowRaaContactInformationOption
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
$showRaaContactInformationOption = new ShowRaaContactInformationOption(
- $platform->convertFromBoolean($value)
+ $platform->convertFromBoolean($value),
);
} catch (InvalidArgumentException $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -78,7 +78,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $showRaaContactInformationOption;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SsoOn2faOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SsoOn2faOptionType.php
index af4be71ac..904cee34d 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SsoOn2faOptionType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/SsoOn2faOptionType.php
@@ -20,6 +20,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
+use Doctrine\DBAL\Types\IntegerType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\SsoOn2faOption;
use TypeError;
@@ -27,19 +28,19 @@
/**
* Custom Type for the SsoOn2faOption Value Object
*/
-class SsoOn2faOptionType extends Type
+class SsoOn2faOptionType extends IntegerType
{
- const NAME = 'stepup_sso_on_2fa_option';
+ public const NAME = 'stepup_sso_on_2fa_option';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getIntegerTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getIntegerTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?int
{
if (is_null($value)) {
- return $value;
+ return null;
}
if (!$value instanceof SsoOn2faOption) {
@@ -47,28 +48,28 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
sprintf(
"Encountered illegal sso on 2fo vet option %s '%s', expected a
SsoOn2faOption instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
- return (int) $value->isEnabled();
+ return (int)$value->isEnabled();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?SsoOn2faOption
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
- $ssoOn2faOption = new SsoOn2faOption((bool) $value);
+ $ssoOn2faOption = new SsoOn2faOption((bool)$value);
} catch (TypeError $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -77,7 +78,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $ssoOn2faOption;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php
index 597e7a48b..b4473bde8 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/UseRaLocationsOptionType.php
@@ -29,36 +29,36 @@
*/
class UseRaLocationsOptionType extends Type
{
- const NAME = 'stepup_use_ra_locations_option';
+ public const NAME = 'stepup_use_ra_locations_option';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getBooleanTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getBooleanTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?int
{
if (is_null($value)) {
- return $value;
+ return null;
}
if (!$value instanceof UseRaLocationsOption) {
throw new ConversionException(
sprintf(
"Encountered illegal location of type %s '%s', expected a UseRaLocationsOption instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
- return (int) $value->isEnabled();
+ return (int)$value->isEnabled();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?UseRaLocationsOption
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
@@ -67,7 +67,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -76,7 +76,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $useRaLocationsOption;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VerifyEmailOptionType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VerifyEmailOptionType.php
index d56f1c105..5ade89796 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VerifyEmailOptionType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VerifyEmailOptionType.php
@@ -19,6 +19,7 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Types\BooleanType;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
@@ -27,38 +28,38 @@
/**
* Custom Type for the VerifyEmailOption Value Object
*/
-class VerifyEmailOptionType extends Type
+class VerifyEmailOptionType extends BooleanType
{
- const NAME = 'stepup_verify_email_option';
+ public const NAME = 'stepup_verify_email_option';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getBooleanTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getBooleanTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
+ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?int
{
if (is_null($value)) {
- return $value;
+ return null;
}
if (!$value instanceof VerifyEmailOption) {
throw new ConversionException(
sprintf(
"Encountered illegal location of type %s '%s', expected a VerifyEmailOption instance",
- is_object($value) ? get_class($value) : gettype($value),
- is_scalar($value) ? (string) $value : ''
- )
+ get_debug_type($value),
+ is_scalar($value) ? (string)$value : '',
+ ),
);
}
- return (int) $value->isEnabled();
+ return (int)$value->isEnabled();
}
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?VerifyEmailOption
{
if (is_null($value)) {
- return $value;
+ return null;
}
try {
@@ -67,7 +68,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -76,7 +77,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $verifyEmailOption;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VettingTypeHintsType.php b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VettingTypeHintsType.php
index 7a32fef6d..f58c7006b 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VettingTypeHintsType.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Doctrine/Type/VettingTypeHintsType.php
@@ -20,6 +20,7 @@
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
+use Doctrine\DBAL\Types\JsonType;
use Doctrine\DBAL\Types\Type;
use Surfnet\Stepup\Exception\InvalidArgumentException;
use Surfnet\Stepup\Identity\Collection\VettingTypeHintCollection;
@@ -27,34 +28,29 @@
/**
* Custom Type for the vetting type hints Value Object
*/
-class VettingTypeHintsType extends Type
+class VettingTypeHintsType extends JsonType
{
- const NAME = 'stepup_vetting_type_hints';
+ public const NAME = 'stepup_vetting_type_hints';
- public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
+ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
- return $platform->getJsonTypeDeclarationSQL($fieldDeclaration);
+ return $platform->getJsonTypeDeclarationSQL($column);
}
- public function convertToDatabaseValue($value, AbstractPlatform $platform)
- {
- return $value;
- }
-
- public function convertToPHPValue($value, AbstractPlatform $platform)
+ public function convertToPHPValue($value, AbstractPlatform $platform): ?VettingTypeHintCollection
{
if (is_null($value)) {
return null;
}
try {
- $data = json_decode($value, true);
+ $data = json_decode((string)$value, true);
$vettingTypeHints = VettingTypeHintCollection::deserialize($data);
} catch (InvalidArgumentException $e) {
// get nice standard message, so we can throw it keeping the exception chain
$doctrineExceptionMessage = ConversionException::conversionFailed(
$value,
- $this->getName()
+ $this->getName(),
)->getMessage();
throw new ConversionException($doctrineExceptionMessage, 0, $e);
@@ -63,7 +59,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
return $vettingTypeHints;
}
- public function getName()
+ public function getName(): string
{
return self::NAME;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/EventListener/ExceptionListener.php b/src/Surfnet/StepupMiddleware/ApiBundle/EventListener/ExceptionListener.php
index 15cd2d273..bcbdba467 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/EventListener/ExceptionListener.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/EventListener/ExceptionListener.php
@@ -34,30 +34,25 @@
*/
class ExceptionListener
{
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- public function __construct(LoggerInterface $logger)
- {
- $this->logger = $logger;
+ public function __construct(
+ private readonly LoggerInterface $logger,
+ ) {
}
- public function onKernelException(ExceptionEvent $event)
+ public function onKernelException(ExceptionEvent $event): void
{
$throwable = $event->getThrowable();
$this->logException($throwable);
- if ($throwable instanceof HttpExceptionInterface && $throwable instanceof Throwable) {
+ if ($throwable instanceof HttpExceptionInterface) {
$statusCode = $throwable->getStatusCode();
$headers = $throwable->getHeaders();
} else {
$statusCode = $throwable instanceof BadApiRequestException
- || $throwable instanceof BadCommandRequestException
- || $throwable instanceof DomainException
- || $throwable instanceof AggregateNotFoundException
+ || $throwable instanceof BadCommandRequestException
+ || $throwable instanceof DomainException
+ || $throwable instanceof AggregateNotFoundException
? 400
: 500;
@@ -67,7 +62,7 @@ public function onKernelException(ExceptionEvent $event)
$event->setResponse($this->createJsonErrorResponse($throwable, $statusCode, $headers));
}
- private function logException(Throwable $throwable)
+ private function logException(Throwable $throwable): void
{
# As per \Symfony\Component\HttpKernel\EventListener\ExceptionListener#logException().
$isCritical = !$throwable instanceof HttpExceptionInterface || $throwable->getStatusCode() >= 500;
@@ -79,13 +74,7 @@ private function logException(Throwable $throwable)
}
}
- /**
- * @param Throwable $exception
- * @param int $statusCode
- * @param array $headers OPTIONAL
- * @return JsonResponse
- */
- private function createJsonErrorResponse(Throwable $throwable, $statusCode, $headers = [])
+ private function createJsonErrorResponse(Throwable $throwable, int $statusCode, array $headers = []): JsonResponse
{
if ($throwable instanceof BadApiRequestException
|| $throwable instanceof BadCommandRequestException
@@ -93,7 +82,7 @@ private function createJsonErrorResponse(Throwable $throwable, $statusCode, $hea
) {
$errors = $throwable->getErrors();
} else {
- $errors = [sprintf('%s: %s', get_class($throwable), $throwable->getMessage())];
+ $errors = [sprintf('%s: %s', $throwable::class, $throwable->getMessage())];
}
return new JsonResponse(['errors' => $errors], $statusCode, $headers);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Exception/BadApiRequestException.php b/src/Surfnet/StepupMiddleware/ApiBundle/Exception/BadApiRequestException.php
index bd8517ac3..ad0e059dc 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Exception/BadApiRequestException.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Exception/BadApiRequestException.php
@@ -18,37 +18,26 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Exception;
+use Throwable;
+
/**
* Thrown when a client provided invalid command input to the application.
*/
class BadApiRequestException extends RuntimeException
{
- /**
- * @var string[]
- */
- private $errors;
-
- /**
- * @param string[] $errors
- * @param string $message
- * @param int $code
- * @param \Exception|null $previous
- */
public function __construct(
- array $errors,
- $message = 'Invalid Request',
- $code = 0,
- \Exception $previous = null
+ private readonly array $errors,
+ string $message = 'Invalid Request',
+ int $code = 0,
+ ?Throwable $previous = null,
) {
parent::__construct($message, $code, $previous);
-
- $this->errors = $errors;
}
/**
* @return string[]
*/
- public function getErrors()
+ public function getErrors(): array
{
return $this->errors;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Exception/BadCommandRequestException.php b/src/Surfnet/StepupMiddleware/ApiBundle/Exception/BadCommandRequestException.php
index a58549ed3..01450bffb 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Exception/BadCommandRequestException.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Exception/BadCommandRequestException.php
@@ -20,35 +20,25 @@
use Symfony\Component\Validator\ConstraintViolationInterface;
use Symfony\Component\Validator\ConstraintViolationListInterface;
+use Throwable;
/**
* Thrown when a client provided invalid command input to the application.
*/
class BadCommandRequestException extends RuntimeException
{
- /**
- * @var string[]
- */
- private $errors;
-
- /**
- * @param string $message
- * @param ConstraintViolationListInterface $violations
- * @return self
- */
- public static function withViolations($message, ConstraintViolationListInterface $violations)
+ public static function withViolations(string $message, ConstraintViolationListInterface $violations): self
{
$violationStrings = self::convertViolationsToStrings($violations);
- $message = sprintf('%s (%s)', $message, join('; ', $violationStrings));
+ $message = sprintf('%s (%s)', $message, implode('; ', $violationStrings));
return new self($violationStrings, $message);
}
/**
- * @param ConstraintViolationListInterface $violations
* @return string[]
*/
- private static function convertViolationsToStrings(ConstraintViolationListInterface $violations)
+ private static function convertViolationsToStrings(ConstraintViolationListInterface $violations): array
{
$violationStrings = [];
@@ -60,27 +50,19 @@ private static function convertViolationsToStrings(ConstraintViolationListInterf
return $violationStrings;
}
- /**
- * @param string[] $errors
- * @param string $message
- * @param int $code
- * @param \Exception|null $previous
- */
public function __construct(
- array $errors,
- $message = 'JSON could not be reconstituted into valid object.',
- $code = 0,
- \Exception $previous = null
+ private readonly array $errors,
+ string $message = 'JSON could not be reconstituted into valid object.',
+ int $code = 0,
+ ?Throwable $previous = null,
) {
parent::__construct($message, $code, $previous);
-
- $this->errors = $errors;
}
/**
* @return string[]
*/
- public function getErrors()
+ public function getErrors(): array
{
return $this->errors;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Exception/InvalidArgumentException.php b/src/Surfnet/StepupMiddleware/ApiBundle/Exception/InvalidArgumentException.php
index 1bd89c277..d76474f23 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Exception/InvalidArgumentException.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Exception/InvalidArgumentException.php
@@ -22,20 +22,13 @@
class InvalidArgumentException extends CoreInvalidArgumentException implements Exception
{
- /**
- * @param string $expected description of expected type
- * @param string $parameterName
- * @param mixed $parameter the parameter that is not of the expected type.
- *
- * @return self
- */
- public static function invalidType($expected, $parameterName, $parameter)
+ public static function invalidType(string $expected, string $parameterName, mixed $parameter): self
{
$message = sprintf(
'Invalid argument type: "%s" expected, "%s" given for "%s"',
$expected,
- is_object($parameter) ? get_class($parameter) : gettype($parameter),
- $parameterName
+ get_debug_type($parameter),
+ $parameterName,
);
return new self($message);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/AuditLogEntry.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/AuditLogEntry.php
index 76835bf8b..cbd110731 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/AuditLogEntry.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/AuditLogEntry.php
@@ -20,23 +20,57 @@
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
+use Surfnet\Stepup\DateTime\DateTime;
+use Surfnet\Stepup\Identity\Event\AppointedAsRaaEvent;
+use Surfnet\Stepup\Identity\Event\AppointedAsRaaForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\AppointedAsRaEvent;
+use Surfnet\Stepup\Identity\Event\AppointedAsRaForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\CompliedWithRecoveryCodeRevocationEvent;
+use Surfnet\Stepup\Identity\Event\CompliedWithUnverifiedSecondFactorRevocationEvent;
+use Surfnet\Stepup\Identity\Event\CompliedWithVerifiedSecondFactorRevocationEvent;
+use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
+use Surfnet\Stepup\Identity\Event\EmailVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\GssfPossessionProvenAndVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\GssfPossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaEvent;
+use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaEvent;
+use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\IdentityCreatedEvent;
+use Surfnet\Stepup\Identity\Event\IdentityEmailChangedEvent;
+use Surfnet\Stepup\Identity\Event\IdentityRenamedEvent;
+use Surfnet\Stepup\Identity\Event\PhonePossessionProvenAndVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\PhonePossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\PhoneRecoveryTokenPossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\RecoveryTokenRevokedEvent;
+use Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedEvent;
+use Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\SafeStoreSecretRecoveryTokenPossessionPromisedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorMigratedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorMigratedToEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession;
+use Surfnet\Stepup\Identity\Event\UnverifiedSecondFactorRevokedEvent;
+use Surfnet\Stepup\Identity\Event\VerifiedSecondFactorRevokedEvent;
+use Surfnet\Stepup\Identity\Event\VettedSecondFactorRevokedEvent;
+use Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenAndVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\YubikeySecondFactorBootstrappedEvent;
+use Surfnet\Stepup\Identity\Value\CommonName;
+use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Exception\LogicException;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuditLogRepository;
/**
* @SuppressWarnings(PHPMD.UnusedPrivateField)
- *
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuditLogRepository")
- * @ORM\Table(
- * name="audit_log",
- * indexes={
- * @ORM\Index(name="idx_auditlog_actorid", columns={"actor_id"}),
- * @ORM\Index(name="idx_auditlog_identityid", columns={"identity_id"}),
- * @ORM\Index(name="idx_auditlog_identityinstitution", columns={"identity_institution"}),
- * @ORM\Index(name="idx_auditlog_secondfactorid", columns={"second_factor_id"}),
- * @ORM\Index(name="idx_auditlog_ra_institution", columns={"ra_institution"}),
- * }
- * )
*/
+#[ORM\Table(name: 'audit_log')]
+#[ORM\Index(name: 'idx_auditlog_actorid', columns: ['actor_id'])]
+#[ORM\Index(name: 'idx_auditlog_identityid', columns: ['identity_id'])]
+#[ORM\Index(name: 'idx_auditlog_identityinstitution', columns: ['identity_institution'])]
+#[ORM\Index(name: 'idx_auditlog_secondfactorid', columns: ['second_factor_id'])]
+#[ORM\Index(name: 'idx_auditlog_ra_institution', columns: ['ra_institution'])]
+#[ORM\Entity(repositoryClass: AuditLogRepository::class)]
class AuditLogEntry implements JsonSerializable
{
/**
@@ -44,153 +78,98 @@ class AuditLogEntry implements JsonSerializable
*
* @var string[]
*/
- private $eventActionMap = [
- 'Surfnet\Stepup\Identity\Event\CompliedWithUnverifiedSecondFactorRevocationEvent' => 'revoked_by_ra',
- 'Surfnet\Stepup\Identity\Event\CompliedWithVerifiedSecondFactorRevocationEvent' => 'revoked_by_ra',
- 'Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent' => 'revoked_by_ra',
- 'Surfnet\Stepup\Identity\Event\EmailVerifiedEvent' => 'email_verified',
- 'Surfnet\Stepup\Identity\Event\GssfPossessionProvenEvent' => 'possession_proven',
- 'Surfnet\Stepup\Identity\Event\GssfPossessionProvenAndVerifiedEvent' => 'possession_proven',
- 'Surfnet\Stepup\Identity\Event\IdentityCreatedEvent' => 'created',
- 'Surfnet\Stepup\Identity\Event\IdentityEmailChangedEvent' => 'email_changed',
- 'Surfnet\Stepup\Identity\Event\IdentityRenamedEvent' => 'renamed',
- 'Surfnet\Stepup\Identity\Event\PhonePossessionProvenEvent' => 'possession_proven',
- 'Surfnet\Stepup\Identity\Event\PhonePossessionProvenAndVerifiedEvent' => 'possession_proven',
- 'Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent' => 'vetted',
- 'Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession' => 'vetted_possession_unknown',
- 'Surfnet\Stepup\Identity\Event\SecondFactorMigratedToEvent' => 'migrated_to',
- 'Surfnet\Stepup\Identity\Event\SecondFactorMigratedEvent' => 'migrated_from',
- 'Surfnet\Stepup\Identity\Event\UnverifiedSecondFactorRevokedEvent' => 'revoked',
- 'Surfnet\Stepup\Identity\Event\VerifiedSecondFactorRevokedEvent' => 'revoked',
- 'Surfnet\Stepup\Identity\Event\VettedSecondFactorRevokedEvent' => 'revoked',
- 'Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenEvent' => 'possession_proven',
- 'Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenAndVerifiedEvent' => 'possession_proven',
- 'Surfnet\Stepup\Identity\Event\YubikeySecondFactorBootstrappedEvent' => 'bootstrapped',
- 'Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaEvent' => 'accredited_as_raa',
- 'Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaEvent' => 'accredited_as_ra',
- 'Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaForInstitutionEvent' => 'accredited_as_ra',
- 'Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaForInstitutionEvent' => 'accredited_as_raa',
- 'Surfnet\Stepup\Identity\Event\AppointedAsRaaEvent' => 'appointed_as_raa',
- 'Surfnet\Stepup\Identity\Event\AppointedAsRaEvent' => 'appointed_as_ra',
- 'Surfnet\Stepup\Identity\Event\AppointedAsRaaForInstitutionEvent' => 'appointed_as_raa',
- 'Surfnet\Stepup\Identity\Event\AppointedAsRaForInstitutionEvent' => 'appointed_as_ra',
- 'Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedEvent' => 'retracted_as_ra',
- 'Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedForInstitutionEvent' => 'retracted_as_ra',
- 'Surfnet\Stepup\Identity\Event\SafeStoreSecretRecoveryTokenPossessionPromisedEvent' => 'recovery_token_possession_promised',
- 'Surfnet\Stepup\Identity\Event\RecoveryTokenRevokedEvent' => 'recovery_token_revoked',
- 'Surfnet\Stepup\Identity\Event\PhoneRecoveryTokenPossessionProvenEvent' => 'recovery_token_possession_proven',
- 'Surfnet\Stepup\Identity\Event\CompliedWithRecoveryCodeRevocationEvent' => 'recovery_token_revoked',
+ private array $eventActionMap = [
+ CompliedWithUnverifiedSecondFactorRevocationEvent::class => 'revoked_by_ra',
+ CompliedWithVerifiedSecondFactorRevocationEvent::class => 'revoked_by_ra',
+ CompliedWithVettedSecondFactorRevocationEvent::class => 'revoked_by_ra',
+ EmailVerifiedEvent::class => 'email_verified',
+ GssfPossessionProvenEvent::class => 'possession_proven',
+ GssfPossessionProvenAndVerifiedEvent::class => 'possession_proven',
+ IdentityCreatedEvent::class => 'created',
+ IdentityEmailChangedEvent::class => 'email_changed',
+ IdentityRenamedEvent::class => 'renamed',
+ PhonePossessionProvenEvent::class => 'possession_proven',
+ PhonePossessionProvenAndVerifiedEvent::class => 'possession_proven',
+ SecondFactorVettedEvent::class => 'vetted',
+ SecondFactorVettedWithoutTokenProofOfPossession::class => 'vetted_possession_unknown',
+ SecondFactorMigratedToEvent::class => 'migrated_to',
+ SecondFactorMigratedEvent::class => 'migrated_from',
+ UnverifiedSecondFactorRevokedEvent::class => 'revoked',
+ VerifiedSecondFactorRevokedEvent::class => 'revoked',
+ VettedSecondFactorRevokedEvent::class => 'revoked',
+ YubikeyPossessionProvenEvent::class => 'possession_proven',
+ YubikeyPossessionProvenAndVerifiedEvent::class => 'possession_proven',
+ YubikeySecondFactorBootstrappedEvent::class => 'bootstrapped',
+ IdentityAccreditedAsRaaEvent::class => 'accredited_as_raa',
+ IdentityAccreditedAsRaEvent::class => 'accredited_as_ra',
+ IdentityAccreditedAsRaForInstitutionEvent::class => 'accredited_as_ra',
+ IdentityAccreditedAsRaaForInstitutionEvent::class => 'accredited_as_raa',
+ AppointedAsRaaEvent::class => 'appointed_as_raa',
+ AppointedAsRaEvent::class => 'appointed_as_ra',
+ AppointedAsRaaForInstitutionEvent::class => 'appointed_as_raa',
+ AppointedAsRaForInstitutionEvent::class => 'appointed_as_ra',
+ RegistrationAuthorityRetractedEvent::class => 'retracted_as_ra',
+ RegistrationAuthorityRetractedForInstitutionEvent::class => 'retracted_as_ra',
+ SafeStoreSecretRecoveryTokenPossessionPromisedEvent::class => 'recovery_token_possession_promised',
+ RecoveryTokenRevokedEvent::class => 'recovery_token_revoked',
+ PhoneRecoveryTokenPossessionProvenEvent::class => 'recovery_token_possession_proven',
+ CompliedWithRecoveryCodeRevocationEvent::class => 'recovery_token_revoked',
];
- /**
- * @ORM\Id
- * @ORM\Column(length=36)
- *
- * @var string
- */
- public $id;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $id;
- /**
- * @ORM\Column(length=36, nullable=true)
- *
- * @var string|null
- */
- public $actorId;
+ #[ORM\Column(length: 36, nullable: true)]
+ public ?string $actorId = null;
- /**
- * @ORM\Column(type="stepup_common_name", nullable=true)
- *
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $actorCommonName;
+ #[ORM\Column(type: 'stepup_common_name', nullable: true)]
+ public ?CommonName $actorCommonName = null;
- /**
- * @ORM\Column(type="institution", nullable=true)
- *
- * @var \Surfnet\Stepup\Identity\Value\Institution|null
- */
- public $actorInstitution;
+ #[ORM\Column(type: 'institution', nullable: true)]
+ public ?Institution $actorInstitution = null;
/**
* Only in certain situations will this field be filled, It represents the RA institution the
* event log entry is targeted at. For example. John Doe is accredited to become RA by Joe from
* institution-a. The actual institution John is appointed RA for is stored in this field.
- *
- * @ORM\Column(length=255, nullable=true)
- *
- * @var string|null
*/
- public $raInstitution;
+ #[ORM\Column(length: 255, nullable: true)]
+ public ?string $raInstitution = null;
- /**
- * @ORM\Column(length=36)
- *
- * @var string
- */
- public $identityId;
+ #[ORM\Column(length: 36)]
+ public string $identityId;
- /**
- * @ORM\Column(type="institution")
- *
- * @var \Surfnet\Stepup\Identity\Value\Institution
- */
- public $identityInstitution;
+ #[ORM\Column(type: 'institution')]
+ public Institution $identityInstitution;
- /**
- * @ORM\Column(length=36, nullable=true)
- *
- * @var string|null
- */
- public $secondFactorId;
+ #[ORM\Column(length: 36, nullable: true)]
+ public ?string $secondFactorId = null;
- /**
- * @ORM\Column(length=255, nullable=true)
- *
- * @var string
- */
- public $secondFactorIdentifier;
+ #[ORM\Column(length: 255, nullable: true)]
+ public ?string $secondFactorIdentifier = null;
- /**
- * @ORM\Column(length=36, nullable=true)
- *
- * @var string|null
- */
- public $secondFactorType;
+ #[ORM\Column(length: 36, nullable: true)]
+ public ?string $secondFactorType = null;
- /**
- * @ORM\Column(length=255, nullable=true)
- *
- * @var string
- */
- public $recoveryTokenIdentifier;
+ #[ORM\Column(length: 255, nullable: true)]
+ public ?string $recoveryTokenIdentifier;
- /**
- * @ORM\Column(length=36, nullable=true)
- *
- * @var string|null
- */
- public $recoveryTokenType;
+ #[ORM\Column(length: 36, nullable: true)]
+ public ?string $recoveryTokenType = null;
- /**
- * @ORM\Column(length=255)
- *
- * @var string
- */
- public $event;
+ #[ORM\Column(length: 255)]
+ public string $event;
- /**
- * @ORM\Column(type="stepup_datetime")
- *
- * @var \Surfnet\Stepup\DateTime\DateTime
- */
- public $recordedOn;
+ #[ORM\Column(type: 'stepup_datetime')]
+ public DateTime $recordedOn;
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
'actor_id' => $this->actorId,
- 'actor_institution' => $this->actorInstitution ? (string)$this->actorInstitution : null,
- 'actor_common_name' => $this->actorCommonName,
+ 'actor_institution' => $this->actorInstitution instanceof Institution ? (string)$this->actorInstitution : null,
+ 'actor_common_name' => (string)$this->actorCommonName,
'identity_id' => $this->identityId,
'identity_institution' => (string)$this->identityInstitution,
'ra_institution' => (string)$this->raInstitution,
@@ -200,7 +179,7 @@ public function jsonSerialize()
'recovery_token_type' => $this->recoveryTokenType,
'recovery_token_identifier' => $this->recoveryTokenIdentifier,
'action' => $this->mapEventToAction($this->event),
- 'recorded_on' => (string) $this->recordedOn,
+ 'recorded_on' => (string)$this->recordedOn,
];
}
@@ -210,7 +189,7 @@ public function jsonSerialize()
* @param string $event Event FQCN
* @return string Action name
*/
- private function mapEventToAction($event)
+ private function mapEventToAction(string $event): string
{
if (!isset($this->eventActionMap[$event])) {
throw new LogicException(sprintf("Action name for event '%s' not registered", $event));
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/Identity.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/Identity.php
index a3e4c3398..cf89dd2ce 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/Identity.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/Identity.php
@@ -25,61 +25,34 @@
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\Locale;
use Surfnet\Stepup\Identity\Value\NameId;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository;
-/**
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository")
- * @ORM\Table(
- * indexes={
- * @ORM\Index(name="idx_identity_institution", columns={"institution"}),
- * @ORM\Index(name="idxft_identity_email", columns={"email"}, flags={"FULLTEXT"}),
- * @ORM\Index(name="idxft_identity_commonname", columns={"common_name"}, flags={"FULLTEXT"})
- * }
- * )
- */
+#[ORM\Table]
+#[ORM\Index(name: 'idx_identity_institution', columns: ['institution'])]
+#[ORM\Index(name: 'idxft_identity_email', columns: ['email'], flags: ['FULLTEXT'])]
+#[ORM\Index(name: 'idxft_identity_commonname', columns: ['common_name'], flags: ['FULLTEXT'])]
+#[ORM\Entity(repositoryClass: IdentityRepository::class)]
class Identity implements JsonSerializable
{
- /**
- * @ORM\Id
- * @ORM\Column(length=36)
- *
- * @var string
- */
- public $id;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $id;
- /**
- * @ORM\Column(type="stepup_name_id")
- *
- * @var \Surfnet\Stepup\Identity\Value\NameId
- */
- public $nameId;
+ #[ORM\Column(type: 'stepup_name_id')]
+ public NameId $nameId;
- /**
- * @ORM\Column(type="stepup_common_name")
- *
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $commonName;
+ #[ORM\Column(type: 'stepup_common_name')]
+ public CommonName $commonName;
- /**
- * @ORM\Column(type="institution")
- *
- * @var \Surfnet\Stepup\Identity\Value\Institution
- */
- public $institution;
+ #[ORM\Column(type: 'institution')]
+ public Institution $institution;
- /**
- * @ORM\Column(type="stepup_email")
- *
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
+ #[ORM\Column(type: 'stepup_email')]
+ public Email $email;
- /**
- * @ORM\Column(type="stepup_locale")
- *
- * @var \Surfnet\Stepup\Identity\Value\Locale
- */
- public $preferredLocale;
+ #[ORM\Column(type: 'stepup_locale')]
+ public Locale $preferredLocale;
+ public ?bool $possessedSelfAssertedToken = null;
public static function create(
string $id,
@@ -87,8 +60,8 @@ public static function create(
NameId $nameId,
Email $email,
CommonName $commonName,
- Locale $preferredLocale
- ) {
+ Locale $preferredLocale,
+ ): self {
$identity = new self();
$identity->id = $id;
@@ -100,7 +73,7 @@ public static function create(
return $identity;
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
'id' => $this->id,
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/IdentitySelfAssertedTokenOptions.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/IdentitySelfAssertedTokenOptions.php
index a493f1a4b..683b775a1 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/IdentitySelfAssertedTokenOptions.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/IdentitySelfAssertedTokenOptions.php
@@ -21,49 +21,46 @@
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
use Surfnet\Stepup\Identity\Value\IdentityId;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentitySelfAssertedTokenOptionsRepository;
-/**
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentitySelfAssertedTokenOptionsRepository")
- */
+#[ORM\Entity(repositoryClass: IdentitySelfAssertedTokenOptionsRepository::class)]
class IdentitySelfAssertedTokenOptions implements JsonSerializable
{
/**
- * @ORM\Id
- * @ORM\Column(length=36)
*
* @var IdentityId
*/
- public $identityId;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $identityId;
/**
- * @ORM\Column(type="boolean")
- *
- * In order to determine if the user is allowed to register
- * a self-asserted token. One of the conditions is that there should
- * be no previous token registration in his name. Regardless of type.
+ * In order to determine if the user is allowed to register
+ * a self-asserted token. One of the conditions is that there should
+ * be no previous token registration in his name. Regardless of type.
*
* @var bool
*/
- public $possessedToken = false;
+ #[ORM\Column(type: 'boolean')]
+ public bool $possessedToken = false;
/**
- * @ORM\Column(type="boolean")
- *
- * Indicator if Identity is allowed to work with Recovery Tokens
+ * Indicator if Identity is allowed to work with Recovery Tokens
*
- * Satisfies business rule:
- * Limit a user to only add/modify/see recovery methods in the overview
- * screen when they have previously had an active self-asserted token
+ * Satisfies business rule:
+ * Limit a user to only add/modify/see recovery methods in the overview
+ * screen when they have previously had an active self-asserted token
*
* @var bool
*/
- public $possessedSelfAssertedToken;
+ #[ORM\Column(type: 'boolean')]
+ public bool $possessedSelfAssertedToken;
public static function create(
IdentityId $identityId,
bool $possessedToken,
- bool $possessedSelfAssertedToken
- ) {
+ bool $possessedSelfAssertedToken,
+ ): self {
$identitySelfAssertedTokenOptions = new self();
$identitySelfAssertedTokenOptions->identityId = $identityId;
@@ -72,10 +69,10 @@ public static function create(
return $identitySelfAssertedTokenOptions;
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
- 'identity_id' => (string) $this->identityId,
+ 'identity_id' => (string)$this->identityId,
'possessed_self_asserted_token' => $this->possessedSelfAssertedToken,
'possessed_token' => $this->possessedToken,
];
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/InstitutionListing.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/InstitutionListing.php
index 5ed531daf..6355ef219 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/InstitutionListing.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/InstitutionListing.php
@@ -21,21 +21,20 @@
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
use Surfnet\Stepup\Identity\Value\Institution;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\InstitutionListingRepository;
-/**
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\InstitutionListingRepository")
- */
+#[ORM\Entity(repositoryClass: InstitutionListingRepository::class)]
class InstitutionListing implements JsonSerializable
{
/**
- * @ORM\Id
- * @ORM\Column(type="institution")
*
- * @var \Surfnet\Stepup\Identity\Value\Institution
+ * @var Institution
*/
- public $institution;
+ #[ORM\Id]
+ #[ORM\Column(type: 'institution')]
+ public Institution $institution;
- public static function createFrom(Institution $institution)
+ public static function createFrom(Institution $institution): self
{
$instance = new self();
$instance->institution = $institution;
@@ -43,7 +42,7 @@ public static function createFrom(Institution $institution)
return $instance;
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return ['name' => $this->institution];
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaCandidate.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaCandidate.php
index 30cda420a..3c4f9fb54 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaCandidate.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaCandidate.php
@@ -25,57 +25,53 @@
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\NameId;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaCandidateRepository;
/**
* Be aware that this entity is used for the RA Candidate presentation only. This entity shouldn't be used to store any RA candidates.
- *
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaCandidateRepository", readOnly=true)
*/
+#[ORM\Entity(repositoryClass: RaCandidateRepository::class, readOnly: true)]
class RaCandidate implements JsonSerializable
{
/**
- * @ORM\Id
- * @ORM\Column(length=36)
*
* @var string
*/
- public $identityId;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $identityId;
/**
- * @ORM\Id
- * @ORM\Column(type="institution")
*
* @var Institution
*/
- public $raInstitution;
+ #[ORM\Id]
+ #[ORM\Column(type: 'institution')]
+ public Institution $raInstitution;
/**
- * @ORM\Column(type="institution")
- *
- * @var \Surfnet\Stepup\Identity\Value\Institution
+ * @var Institution
*/
- public $institution;
+ #[ORM\Column(type: 'institution')]
+ public Institution $institution;
/**
- * @ORM\Column(type="stepup_name_id")
- *
- * @var \Surfnet\Stepup\Identity\Value\NameId
+ * @var NameId
*/
- public $nameId;
+ #[ORM\Column(type: 'stepup_name_id')]
+ public NameId $nameId;
/**
- * @ORM\Column(type="stepup_common_name")
- *
- * @var \Surfnet\Stepup\Identity\Value\CommonName
+ * @var CommonName
*/
- public $commonName;
+ #[ORM\Column(type: 'stepup_common_name')]
+ public CommonName $commonName;
/**
- * @ORM\Column(type="stepup_email")
- *
- * @var \Surfnet\Stepup\Identity\Value\Email
+ * @var Email
*/
- public $email;
+ #[ORM\Column(type: 'stepup_email')]
+ public Email $email;
private function __construct()
{
@@ -87,27 +83,27 @@ public static function nominate(
NameId $nameId,
CommonName $commonName,
Email $email,
- Institution $raInstitution
- ) {
- $candidate = new self();
- $candidate->identityId = (string) $identityId;
- $candidate->institution = $institution;
- $candidate->nameId = $nameId;
- $candidate->commonName = $commonName;
- $candidate->email = $email;
+ Institution $raInstitution,
+ ): self {
+ $candidate = new self();
+ $candidate->identityId = (string)$identityId;
+ $candidate->institution = $institution;
+ $candidate->nameId = $nameId;
+ $candidate->commonName = $commonName;
+ $candidate->email = $email;
$candidate->raInstitution = $raInstitution;
return $candidate;
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
- 'identity_id' => $this->identityId,
- 'institution' => $this->institution,
- 'common_name' => $this->commonName,
- 'email' => $this->email,
- 'name_id' => $this->nameId,
+ 'identity_id' => $this->identityId,
+ 'institution' => $this->institution,
+ 'common_name' => $this->commonName,
+ 'email' => $this->email,
+ 'name_id' => $this->nameId,
'ra_institution' => $this->raInstitution,
];
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaListing.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaListing.php
index 53ec53602..3848c981c 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaListing.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaListing.php
@@ -26,126 +26,107 @@
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\Location;
use Surfnet\StepupMiddleware\ApiBundle\Exception\InvalidArgumentException;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaListingRepository;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\AuthorityRole;
-/**
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaListingRepository")
- *
- * @ORM\Table(
- * indexes={
- * @ORM\Index(name="idx_ra_listing_institution", columns={"institution"}),
- * @ORM\Index(name="idx_ra_listing_ra_institution", columns={"ra_institution"}),
- * },
- * uniqueConstraints={
- * @ORM\UniqueConstraint(name="idx_ra_listing_unique_identity_institution", columns={"identity_id", "ra_institution"})
- * }
- * )
- */
+#[ORM\Table]
+#[ORM\Index(name: 'idx_ra_listing_institution', columns: ['institution'])]
+#[ORM\Index(name: 'idx_ra_listing_ra_institution', columns: ['ra_institution'])]
+#[ORM\UniqueConstraint(name: 'idx_ra_listing_unique_identity_institution', columns: ['identity_id', 'ra_institution'])]
+#[ORM\Entity(repositoryClass: RaListingRepository::class)]
class RaListing implements JsonSerializable
{
/**
- * @ORM\Id
- * @ORM\Column(type="integer")
- * @ORM\GeneratedValue
*
* @var integer
*/
- public $id;
+ #[ORM\Id]
+ #[ORM\Column(type: 'integer')]
+ #[ORM\GeneratedValue]
+ public int $id;
/**
- * @ORM\Column(length=36)
- *
* @var string
*/
- public $identityId;
+ #[ORM\Column(length: 36)]
+ public string $identityId;
/**
- * @ORM\Column(type="institution")
- *
* @var Institution
*/
- public $raInstitution;
+ #[ORM\Column(type: 'institution')]
+ public Institution $raInstitution;
/**
- * @ORM\Column(type="institution")
- *
* @var Institution
*/
- public $institution;
+ #[ORM\Column(type: 'institution')]
+ public Institution $institution;
/**
- * @ORM\Column(type="stepup_common_name")
- *
* @var CommonName
*/
- public $commonName;
+ #[ORM\Column(type: 'stepup_common_name')]
+ public CommonName $commonName;
/**
- * @ORM\Column(type="stepup_email")
- *
* @var Email
*/
- public $email;
+ #[ORM\Column(type: 'stepup_email')]
+ public Email $email;
/**
- * @ORM\Column(type="authority_role")
- *
* @var AuthorityRole
*/
- public $role;
+ #[ORM\Column(type: 'authority_role')]
+ public AuthorityRole $role;
/**
- * @ORM\Column(type="stepup_location", nullable=true)
- *
* @var Location
*/
- public $location;
+ #[ORM\Column(type: 'stepup_location', nullable: true)]
+ public Location $location;
/**
- * @ORM\Column(type="stepup_contact_information", nullable=true)
- *
* @var ContactInformation
*/
- public $contactInformation;
+ #[ORM\Column(type: 'stepup_contact_information', nullable: true)]
+ public ContactInformation $contactInformation;
public static function create(
- $identityId,
+ string $identityId,
Institution $institution,
CommonName $commonName,
Email $email,
AuthorityRole $role,
Location $location,
ContactInformation $contactInformation,
- Institution $raInstitution
- ) {
- if (!is_string($identityId)) {
- throw InvalidArgumentException::invalidType('string', 'id', $identityId);
- }
-
- $entry = new self();
- $entry->identityId = $identityId;
- $entry->institution = $institution;
- $entry->commonName = $commonName;
- $entry->email = $email;
- $entry->role = $role;
- $entry->location = $location;
+ Institution $raInstitution,
+ ): self {
+ $entry = new self();
+ $entry->identityId = $identityId;
+ $entry->institution = $institution;
+ $entry->commonName = $commonName;
+ $entry->email = $email;
+ $entry->role = $role;
+ $entry->location = $location;
$entry->contactInformation = $contactInformation;
- $entry->raInstitution = $raInstitution;
+ $entry->raInstitution = $raInstitution;
return $entry;
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
- 'identity_id' => $this->identityId,
- 'institution' => (string) $this->institution,
- 'ra_institution' => (string) $this->raInstitution,
- 'common_name' => (string) $this->commonName,
- 'email' => (string) $this->email,
- 'role' => (string) $this->role,
- 'location' => (string) $this->location,
- 'contact_information' => (string) $this->contactInformation,
+ 'identity_id' => $this->identityId,
+ 'institution' => (string)$this->institution,
+ 'ra_institution' => (string)$this->raInstitution,
+ 'common_name' => (string)$this->commonName,
+ 'email' => (string)$this->email,
+ 'role' => (string)$this->role,
+ 'location' => (string)$this->location,
+ 'contact_information' => (string)$this->contactInformation,
];
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaSecondFactor.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaSecondFactor.php
index 052f94a6b..e3142f912 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaSecondFactor.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RaSecondFactor.php
@@ -24,136 +24,68 @@
use Surfnet\Stepup\Identity\Value\DocumentNumber;
use Surfnet\Stepup\Identity\Value\Email;
use Surfnet\Stepup\Identity\Value\Institution;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaSecondFactorRepository;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\SecondFactorStatus;
/**
* A second factor as displayed in the registration authority application. One exists for every second factor,
* regardless of state. As such, it sports a status property, indicating whether its vetted, revoked etc.
- *
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaSecondFactorRepository")
- * @ORM\Table(
- * indexes={
- * @ORM\Index(name="idx_ra_second_factor_second_factor_id", columns={"second_factor_id"}),
- * @ORM\Index(name="idx_ra_second_factor_identity_id", columns={"identity_id"}),
- * @ORM\Index(name="idx_ra_second_factor_institution", columns={"institution"}),
- * @ORM\Index(name="idx_ra_second_factor_name", columns={"name"}, flags={"FULLTEXT"}),
- * @ORM\Index(name="idx_ra_second_factor_email", columns={"email"}, flags={"FULLTEXT"}),
- * }
- * )
*/
+#[ORM\Table]
+#[ORM\Index(name: 'idx_ra_second_factor_second_factor_id', columns: ['second_factor_id'])]
+#[ORM\Index(name: 'idx_ra_second_factor_identity_id', columns: ['identity_id'])]
+#[ORM\Index(name: 'idx_ra_second_factor_institution', columns: ['institution'])]
+#[ORM\Index(name: 'idx_ra_second_factor_name', columns: ['name'], flags: ['FULLTEXT'])]
+#[ORM\Index(name: 'idx_ra_second_factor_email', columns: ['email'], flags: ['FULLTEXT'])]
+#[ORM\Entity(repositoryClass: RaSecondFactorRepository::class)]
class RaSecondFactor implements JsonSerializable
{
/**
- * @ORM\Id
- * @ORM\Column(length=36)
- *
- * @var string The second factor's ID (UUID).
- */
- public $id;
-
- /**
- * @ORM\Column(length=16)
- *
- * @var string
- */
- public $type;
-
- /**
- * @ORM\Column(length=255)
- *
- * @var string The ID of the specific instance of second factor type (ie. phone number, Yubikey public ID).
- */
- public $secondFactorId;
-
- /**
- * @ORM\Column(length=36)
- *
- * @var string
- */
- public $identityId;
-
- /**
- * @ORM\Column(type="institution")
- *
- * @var \Surfnet\Stepup\Identity\Value\Institution
- */
- public $institution;
-
- /**
- * The name of the registrant.
- *
- * @ORM\Column(type="stepup_common_name")
- *
- * @var \Surfnet\Stepup\Identity\Value\CommonName
- */
- public $name;
-
- /**
- * The e-mail of the registrant.
- *
- * @ORM\Column(type="stepup_email")
- *
- * @var \Surfnet\Stepup\Identity\Value\Email
- */
- public $email;
-
- /**
- * @ORM\Column(type="stepup_document_number", nullable=true)
- *
- * @var DocumentNumber
- */
- public $documentNumber;
-
- /**
- * @ORM\Column(type="stepup_second_factor_status")
- *
* @var SecondFactorStatus
*/
- public $status;
+ #[ORM\Column(type: 'stepup_second_factor_status')]
+ public SecondFactorStatus $status;
- /**
- * @param string $id
- * @param string $type
- * @param string $secondFactorId
- * @param string $identityId
- * @param Institution $institution
- * @param CommonName $name
- * @param Email $email
- * @param DocumentNumber|null $documentNumber
- */
public function __construct(
- $id,
- $type,
- $secondFactorId,
- $identityId,
- Institution $institution,
- CommonName $name,
- Email $email,
- DocumentNumber $documentNumber = null
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $id,
+ #[ORM\Column(length: 16)]
+ public string $type,
+ #[ORM\Column(length: 255)]
+ public string $secondFactorId,
+ #[ORM\Column(length: 36)]
+ public string $identityId,
+ #[ORM\Column(type: 'institution')]
+ public Institution $institution,
+ /**
+ * The name of the registrant.
+ */
+ #[ORM\Column(type: 'stepup_common_name')]
+ public CommonName $name,
+ /**
+ * The e-mail of the registrant.
+ */
+ #[ORM\Column(type: 'stepup_email')]
+ public Email $email,
+ #[ORM\Column(type: 'stepup_document_number', nullable: true)]
+ public ?DocumentNumber $documentNumber = null,
) {
- $this->id = $id;
- $this->type = $type;
- $this->secondFactorId = $secondFactorId;
- $this->identityId = $identityId;
- $this->institution = $institution;
- $this->name = $name;
- $this->email = $email;
- $this->documentNumber = $documentNumber;
$this->status = SecondFactorStatus::unverified();
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
- 'id' => $this->id,
- 'type' => $this->type,
+ 'id' => $this->id,
+ 'type' => $this->type,
'second_factor_id' => $this->secondFactorId,
- 'status' => (string) $this->status,
- 'identity_id' => $this->identityId,
- 'name' => $this->name,
- 'document_number' => $this->documentNumber,
- 'email' => $this->email,
- 'institution' => $this->institution,
+ 'status' => (string)$this->status,
+ 'identity_id' => $this->identityId,
+ 'name' => $this->name,
+ 'document_number' => $this->documentNumber,
+ 'email' => $this->email,
+ 'institution' => $this->institution,
];
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RecoveryToken.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RecoveryToken.php
index 64647a425..04ca1f144 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RecoveryToken.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/RecoveryToken.php
@@ -19,90 +19,72 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Entity;
use Doctrine\ORM\Mapping as ORM;
+use JsonSerializable;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
use Surfnet\Stepup\Identity\Value\Institution;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RecoveryTokenRepository;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RecoveryTokenStatus;
-/**
- * @ORM\Entity(
- * repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RecoveryTokenRepository"
- * )
- * @ORM\Table(
- * indexes={
- * @ORM\Index(name="idx_recovery_method_type", columns={"type"}),
- * }
- * )
- */
-class RecoveryToken implements \JsonSerializable
+#[ORM\Table]
+#[ORM\Index(name: 'idx_recovery_method_type', columns: ['type'])]
+#[ORM\Entity(repositoryClass: RecoveryTokenRepository::class)]
+class RecoveryToken implements JsonSerializable
{
- /**
- * @ORM\Id
- * @ORM\Column(length=36)
- *
- * @var string
- */
- public $id;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $id;
/**
- * @ORM\Column(length=36)
- *
* @var string
*/
- public $identityId;
+ #[ORM\Column(length: 36)]
+ public string $identityId;
/**
- * @ORM\Column(length=16)
- *
* @var string
*/
- public $type;
+ #[ORM\Column(length: 16)]
+ public string $type;
/**
- * @ORM\Column(type="stepup_recovery_token_status")
- *
* @var RecoveryTokenStatus
*/
- public $status;
+ #[ORM\Column(type: 'stepup_recovery_token_status')]
+ public RecoveryTokenStatus $status;
/**
- * @ORM\Column(type="institution")
- *
* @var Institution
*/
- public $institution;
+ #[ORM\Column(type: 'institution')]
+ public Institution $institution;
/**
* The name of the registrant.
- *
- * @ORM\Column(type="stepup_common_name")
- *
* @var CommonName
*/
- public $name;
+ #[ORM\Column(type: 'stepup_common_name')]
+ public CommonName $name;
/**
* The e-mail of the registrant.
- *
- * @ORM\Column(type="stepup_email")
- *
* @var Email
*/
- public $email;
+ #[ORM\Column(type: 'stepup_email')]
+ public Email $email;
/**
- * @ORM\Column(length=255)
- *
* @var string
*/
- public $recoveryMethodIdentifier;
+ #[ORM\Column(length: 255)]
+ public string $recoveryMethodIdentifier;
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
- 'id' => $this->id,
+ 'id' => $this->id,
'type' => $this->type,
- 'status' => (string) $this->status,
+ 'status' => (string)$this->status,
'recovery_method_identifier' => $this->recoveryMethodIdentifier,
'identity_id' => $this->identityId,
'name' => $this->name,
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/SecondFactorRevocation.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/SecondFactorRevocation.php
index f1b44fa5e..404c091f9 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/SecondFactorRevocation.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/SecondFactorRevocation.php
@@ -19,53 +19,43 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Entity;
use Doctrine\ORM\Mapping as ORM;
+use Surfnet\Stepup\DateTime\DateTime;
+use Surfnet\Stepup\Identity\Value\Institution;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SecondFactorRevocationRepository;
-/**
- * @ORM\Entity(
- * repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SecondFactorRevocationRepository"
- * )
- * @ORM\Table(
- * name="second_factor_revocation",
- * indexes={
- * @ORM\Index(name="idx_secondfactorrevocation_recordedon", columns={"recorded_on"})
- * }
- * )
- */
+#[ORM\Table(name: 'second_factor_revocation')]
+#[ORM\Index(name: 'idx_secondfactorrevocation_recordedon', columns: ['recorded_on'])]
+#[ORM\Entity(repositoryClass: SecondFactorRevocationRepository::class)]
class SecondFactorRevocation
{
/**
- * @ORM\Id
- * @ORM\Column(length=36)
- *
* @var string
*/
- public $id;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $id;
/**
- * @ORM\Column(type="institution")
- *
- * @var \Surfnet\Stepup\Identity\Value\Institution
+ * @var Institution
*/
- public $institution;
+ #[ORM\Column(type: 'institution')]
+ public Institution $institution;
/**
- * @ORM\Column(length=36, nullable=true)
- *
* @var string|null
*/
- public $secondFactorType;
+ #[ORM\Column(length: 36, nullable: true)]
+ public ?string $secondFactorType = null;
/**
- * @ORM\Column
- *
* @var string
*/
- public $revokedBy;
+ #[ORM\Column]
+ public string $revokedBy;
/**
- * @ORM\Column(type="stepup_datetime")
- *
- * @var \Surfnet\Stepup\DateTime\DateTime
+ * @var DateTime
*/
- public $recordedOn;
+ #[ORM\Column(type: 'stepup_datetime')]
+ public DateTime $recordedOn;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/Sraa.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/Sraa.php
index faafcdc43..3feafacee 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/Sraa.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/Sraa.php
@@ -20,22 +20,15 @@
use Doctrine\ORM\Mapping as ORM;
use Surfnet\Stepup\Identity\Value\NameId;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SraaRepository;
-/**
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SraaRepository")
- */
+#[ORM\Entity(repositoryClass: SraaRepository::class)]
class Sraa
{
- /**
- * @var \Surfnet\Stepup\Identity\Value\NameId
- *
- * @ORM\Id
- * @ORM\Column(type="stepup_name_id", length=200)
- */
- public $nameId;
-
- public function __construct(NameId $nameId)
- {
- $this->nameId = $nameId;
+ public function __construct(
+ #[ORM\Id]
+ #[ORM\Column(type: 'stepup_name_id', length: 200)]
+ public NameId $nameId,
+ ) {
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/UnverifiedSecondFactor.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/UnverifiedSecondFactor.php
index aeecc28c2..fa45af37f 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/UnverifiedSecondFactor.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/UnverifiedSecondFactor.php
@@ -19,59 +19,51 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Entity;
use Doctrine\ORM\Mapping as ORM;
-use Surfnet\Stepup\DateTime\DateTime;
+use JsonSerializable;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\UnverifiedSecondFactorRepository;
-/**
- * @ORM\Entity(
- * repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\UnverifiedSecondFactorRepository"
- * )
- */
-class UnverifiedSecondFactor implements \JsonSerializable
+#[ORM\Entity(repositoryClass: UnverifiedSecondFactorRepository::class)]
+class UnverifiedSecondFactor implements JsonSerializable
{
/**
- * @ORM\Id
- * @ORM\Column(length=36)
*
* @var string
*/
- public $id;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $id;
/**
- * @ORM\Column(length=36)
- *
* @var string
*/
- public $identityId;
+ #[ORM\Column(length: 36)]
+ public string $identityId;
/**
- * @ORM\Column(length=16)
- *
* @var string
*/
- public $type;
+ #[ORM\Column(length: 16)]
+ public string $type;
/**
* The second factor identifier, ie. telephone number, Yubikey public ID, Tiqr ID
- *
- * @ORM\Column(length=255)
- *
* @var string
*/
- public $secondFactorIdentifier;
+ #[ORM\Column(length: 255)]
+ public string $secondFactorIdentifier;
/**
- * @ORM\Column(length=32)
- *
* @var string
*/
- public $verificationNonce;
+ #[ORM\Column(length: 32)]
+ public string $verificationNonce;
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
- 'id' => $this->id,
- 'type' => $this->type,
- 'second_factor_identifier' => $this->secondFactorIdentifier
+ 'id' => $this->id,
+ 'type' => $this->type,
+ 'second_factor_identifier' => $this->secondFactorIdentifier,
];
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VerifiedSecondFactor.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VerifiedSecondFactor.php
index 771ad37af..b8ac78aab 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VerifiedSecondFactor.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VerifiedSecondFactor.php
@@ -19,80 +19,47 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Entity;
use Doctrine\ORM\Mapping as ORM;
+use JsonSerializable;
+use Surfnet\Stepup\DateTime\DateTime;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VerifiedSecondFactorRepository;
-/**
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VerifiedSecondFactorRepository")
- * @ORM\Table(
- * indexes={
- * @ORM\Index(name="idx_institution", columns={"institution"})
- * }
- * )
- */
-class VerifiedSecondFactor implements \JsonSerializable
+#[ORM\Table]
+#[ORM\Index(name: 'idx_institution', columns: ['institution'])]
+#[ORM\Entity(repositoryClass: VerifiedSecondFactorRepository::class)]
+class VerifiedSecondFactor implements JsonSerializable
{
- /**
- * @ORM\Id
- * @ORM\Column(length=36)
- *
- * @var string
- */
- public $id;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $id;
- /**
- * @ORM\Column(length=36)
- *
- * @var string
- */
- public $identityId;
+ #[ORM\Column(length: 36)]
+ public string $identityId;
- /**
- * @ORM\Column
- *
- * @var string
- */
- public $institution;
+ #[ORM\Column]
+ public string $institution;
- /**
- * @ORM\Column
- *
- * @var string
- */
- public $commonName;
+ #[ORM\Column]
+ public string $commonName;
- /**
- * @ORM\Column(length=16)
- *
- * @var string
- */
- public $type;
+ #[ORM\Column(length: 16)]
+ public string $type;
/**
* The second factor identifier, ie. telephone number, Yubikey public ID, Tiqr ID
- *
- * @ORM\Column(length=255)
- *
- * @var string
*/
- public $secondFactorIdentifier;
+ #[ORM\Column(length: 255)]
+ public string $secondFactorIdentifier;
- /**
- * @ORM\Column(length=8)
- *
- * @var string
- */
- public $registrationCode;
+ #[ORM\Column(length: 8)]
+ public string $registrationCode;
- /**
- * @ORM\Column(type="stepup_datetime")
- *
- * @var \DateTime
- */
- public $registrationRequestedAt;
+ #[ORM\Column(type: 'stepup_datetime')]
+ public DateTime $registrationRequestedAt;
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
- 'id' => $this->id,
+ 'id' => $this->id,
'type' => $this->type,
'second_factor_identifier' => $this->secondFactorIdentifier,
'registration_code' => $this->registrationCode,
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VettedSecondFactor.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VettedSecondFactor.php
index c5586dad3..2ddb0cf64 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VettedSecondFactor.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VettedSecondFactor.php
@@ -19,80 +19,49 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Entity;
use Doctrine\ORM\Mapping as ORM;
+use JsonSerializable;
use Surfnet\Stepup\Identity\Value\VettingType;
-use function is_null;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettedSecondFactorRepository;
-/**
- * @ORM\Entity(
- * repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettedSecondFactorRepository"
- * )
- * @ORM\Table(
- * indexes={
- * @ORM\Index(name="idx_vetted_second_factor_type", columns={"type"}),
- * @ORM\Index(name="idx_vetted_second_factor_vetting_type", columns={"vetting_type"}),
- * }
- * )
- */
-class VettedSecondFactor implements \JsonSerializable
+#[ORM\Table]
+#[ORM\Index(name: 'idx_vetted_second_factor_type', columns: ['type'])]
+#[ORM\Index(name: 'idx_vetted_second_factor_vetting_type', columns: ['vetting_type'])]
+#[ORM\Entity(repositoryClass: VettedSecondFactorRepository::class)]
+class VettedSecondFactor implements JsonSerializable
{
- /**
- * @ORM\Id
- * @ORM\Column(length=36)
- *
- * @var string
- */
- public $id;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $id;
- /**
- * @ORM\Column(length=36)
- *
- * @var string
- */
- public $identityId;
+ #[ORM\Column(length: 36)]
+ public string $identityId;
- /**
- * @ORM\Column(length=16)
- *
- * @var string
- */
- public $type;
+ #[ORM\Column(length: 16)]
+ public string $type;
- /**
- * The second factor identifier, ie. telephone number, Yubikey public ID, Tiqr ID
- *
- * @ORM\Column(length=255)
- *
- * @var string
- */
- public $secondFactorIdentifier;
+ #[ORM\Column(length: 255)]
+ public string $secondFactorIdentifier;
- /**
- * @ORM\Column(length=255, nullable=true)
- * @var string
- */
- public $vettingType;
+ #[ORM\Column(length: 255, nullable: true)]
+ public ?string $vettingType = null;
- /**
- * @param VettedSecondFactor $vettedSecondFactor
- * @return bool
- */
public function isEqual(VettedSecondFactor $vettedSecondFactor): bool
{
- return $vettedSecondFactor->type == $this->type && $vettedSecondFactor->secondFactorIdentifier == $this->secondFactorIdentifier;
+ return $vettedSecondFactor->type === $this->type && $vettedSecondFactor->secondFactorIdentifier === $this->secondFactorIdentifier;
}
public function vettingType(): string
{
- if (is_null($this->vettingType)) {
+ if (!$this->vettingType) {
return VettingType::TYPE_ON_PREMISE;
}
return $this->vettingType;
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
- 'id' => $this->id,
+ 'id' => $this->id,
'type' => $this->type,
'second_factor_identifier' => $this->secondFactorIdentifier,
'vetting_type' => $this->vettingType,
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VettingTypeHint.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VettingTypeHint.php
index 1c7764a26..eda25072f 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VettingTypeHint.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/VettingTypeHint.php
@@ -19,35 +19,21 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Entity;
use Doctrine\ORM\Mapping as ORM;
+use JsonSerializable;
use Surfnet\Stepup\Identity\Collection\VettingTypeHintCollection;
-use Surfnet\Stepup\Identity\Value\CommonName;
-use Surfnet\Stepup\Identity\Value\Email;
-use Surfnet\Stepup\Identity\Value\Institution;
-use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RecoveryTokenStatus;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettingTypeHintRepository;
-/**
- * @ORM\Entity(
- * repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettingTypeHintRepository"
- * )
- */
-class VettingTypeHint implements \JsonSerializable
+#[ORM\Entity(repositoryClass: VettingTypeHintRepository::class)]
+class VettingTypeHint implements JsonSerializable
{
- /**
- * @ORM\Id
- * @ORM\Column(length=36)
- *
- * @var string
- */
- public $institution;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $institution;
- /**
- * @ORM\Column(type="stepup_vetting_type_hints")
- *
- * @var VettingTypeHintCollection
- */
- public $hints;
+ #[ORM\Column(type: 'stepup_vetting_type_hints')]
+ public VettingTypeHintCollection $hints;
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
'institution' => $this->institution,
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/WhitelistEntry.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/WhitelistEntry.php
index b6c79aa02..437054d5f 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/WhitelistEntry.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Entity/WhitelistEntry.php
@@ -21,29 +21,24 @@
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
use Surfnet\Stepup\Identity\Value\Institution;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\WhitelistEntryRepository;
-/**
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\WhitelistEntryRepository")
- */
+#[ORM\Entity(repositoryClass: WhitelistEntryRepository::class)]
class WhitelistEntry implements JsonSerializable
{
- /**
- * @ORM\Id
- * @ORM\Column(type="institution")
- *
- * @var Institution
- */
- public $institution;
+ #[ORM\Id]
+ #[ORM\Column(type: 'institution')]
+ public Institution $institution;
- public static function createFrom(Institution $institution)
+ public static function createFrom(Institution $institution): self
{
- $instance = new self();
+ $instance = new self();
$instance->institution = $institution;
return $instance;
}
- public function jsonSerialize()
+ public function jsonSerialize(): string
{
return $this->institution;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/AuditLogProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/AuditLogProjector.php
index 1a3eaf64a..e22f7c590 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/AuditLogProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/AuditLogProjector.php
@@ -21,7 +21,7 @@
use Broadway\Domain\DomainMessage;
use Broadway\EventHandling\EventListener;
use DateTime as CoreDateTime;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\DateTime\DateTime;
use Surfnet\Stepup\Identity\AuditLog\Metadata;
use Surfnet\Stepup\Identity\Event\AuditableEvent;
@@ -29,42 +29,25 @@
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Identity\Event\RecoveryTokenRevokedEvent;
use Surfnet\Stepup\Identity\Value\CommonName;
-use Surfnet\Stepup\Identity\Value\RecoveryTokenIdentifier;
+use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\RecoveryTokenIdentifierFactory;
use Surfnet\Stepup\Identity\Value\RecoveryTokenType;
-use Surfnet\Stepup\Identity\Value\SecondFactorIdentifier;
-use Surfnet\Stepup\Identity\Value\SecondFactorIdentifierFactory;
-use Surfnet\StepupBundle\Value\SecondFactorType;
+use Surfnet\Stepup\Identity\Value\VettingType;
use Surfnet\StepupMiddleware\ApiBundle\Exception\RuntimeException;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\AuditLogEntry;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuditLogRepository;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository;
-use function get_class;
-use function is_null;
-use function property_exists;
-use function sprintf;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AuditLogProjector implements EventListener
{
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuditLogRepository
- */
- private $auditLogRepository;
-
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository
- */
- private $identityRepository;
-
public function __construct(
- AuditLogRepository $auditLogRepository,
- IdentityRepository $identityRepository
+ private readonly AuditLogRepository $auditLogRepository,
+ private readonly IdentityRepository $identityRepository,
) {
- $this->auditLogRepository = $auditLogRepository;
- $this->identityRepository = $identityRepository;
}
/**
@@ -87,75 +70,75 @@ public function handle(DomainMessage $domainMessage): void
}
/**
- * @param AuditableEvent $event
- * @param DomainMessage $domainMessage
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
- private function applyAuditableEvent(AuditableEvent $event, DomainMessage $domainMessage)
+ private function applyAuditableEvent(AuditableEvent $event, DomainMessage $domainMessage): void
{
$auditLogMetadata = $event->getAuditLogMetadata();
$metadata = $domainMessage->getMetadata()->serialize();
$entry = new AuditLogEntry();
- $entry->id = (string) Uuid::uuid4();
+ $entry->id = (string)Uuid::uuid4();
if (isset($metadata['actorId'])) {
$actor = $this->identityRepository->find($metadata['actorId']);
- if (!$actor) {
- throw new RuntimeException(sprintf(
- 'Cannot create AuditLogEntry, given Actor Identity "%s" does not exist',
- $metadata['actorId']
- ));
+ if (!$actor instanceof Identity) {
+ throw new RuntimeException(
+ sprintf(
+ 'Cannot create AuditLogEntry, given Actor Identity "%s" does not exist',
+ $metadata['actorId'],
+ ),
+ );
}
- $entry->actorId = $metadata['actorId'];
+ $entry->actorId = $metadata['actorId'];
$entry->actorCommonName = $actor->commonName;
}
$this->augmentActorCommonName($entry, $auditLogMetadata);
if (isset($metadata['actorInstitution'])) {
- $entry->actorInstitution = $metadata['actorInstitution'];
+ $entry->actorInstitution = new Institution($metadata['actorInstitution']);
}
- $entry->identityId = (string) $auditLogMetadata->identityId;
+ $entry->identityId = (string)$auditLogMetadata->identityId;
$entry->identityInstitution = $auditLogMetadata->identityInstitution;
- $entry->event = get_class($event);
- $entry->recordedOn = new DateTime(new CoreDateTime($domainMessage->getRecordedOn()->toString()));
+ $entry->event = $event::class;
+ $entry->recordedOn = new DateTime(new CoreDateTime($domainMessage->getRecordedOn()->toString()));
- if ($auditLogMetadata->secondFactorId) {
- $entry->secondFactorId = (string) $auditLogMetadata->secondFactorId;
+ if ($auditLogMetadata->secondFactorId instanceof \Surfnet\Stepup\Identity\Value\SecondFactorId) {
+ $entry->secondFactorId = (string)$auditLogMetadata->secondFactorId;
}
- if ($auditLogMetadata->secondFactorType) {
- $entry->secondFactorType = (string) $auditLogMetadata->secondFactorType;
+ if ($auditLogMetadata->secondFactorType instanceof \Surfnet\StepupBundle\Value\SecondFactorType) {
+ $entry->secondFactorType = (string)$auditLogMetadata->secondFactorType;
}
if (!$event instanceof RecoveryTokenRevokedEvent
&& !$event instanceof CompliedWithRecoveryCodeRevocationEvent
&& $auditLogMetadata->recoveryTokenId
) {
- $entry->recoveryTokenIdentifier = (string) $auditLogMetadata->recoveryTokenId;
+ $entry->recoveryTokenIdentifier = (string)$auditLogMetadata->recoveryTokenId;
}
- if ($auditLogMetadata->recoveryTokenType) {
- $entry->recoveryTokenType = (string) $auditLogMetadata->recoveryTokenType;
+ if ($auditLogMetadata->recoveryTokenType instanceof \Surfnet\Stepup\Identity\Value\RecoveryTokenType) {
+ $entry->recoveryTokenType = (string)$auditLogMetadata->recoveryTokenType;
}
- if ($auditLogMetadata->secondFactorIdentifier) {
- $entry->secondFactorIdentifier = (string) $auditLogMetadata->secondFactorIdentifier;
+ if ($auditLogMetadata->secondFactorIdentifier instanceof \Surfnet\Stepup\Identity\Value\SecondFactorIdentifier) {
+ $entry->secondFactorIdentifier = (string)$auditLogMetadata->secondFactorIdentifier;
}
- if ($auditLogMetadata->raInstitution) {
- $entry->raInstitution = (string) $auditLogMetadata->raInstitution;
+ if ($auditLogMetadata->raInstitution instanceof \Surfnet\Stepup\Identity\Value\Institution) {
+ $entry->raInstitution = (string)$auditLogMetadata->raInstitution;
}
$this->auditLogRepository->save($entry);
}
- private function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
+ private function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
$entries = $this->auditLogRepository->findByIdentityId($event->identityId);
foreach ($entries as $auditLogEntry) {
@@ -163,7 +146,7 @@ private function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
if ($auditLogEntry->recoveryTokenIdentifier) {
$auditLogEntry->recoveryTokenIdentifier = RecoveryTokenIdentifierFactory::unknownForType(
- new RecoveryTokenType($auditLogEntry->recoveryTokenType)
+ new RecoveryTokenType($auditLogEntry->recoveryTokenType),
);
}
}
@@ -179,8 +162,10 @@ private function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
private function augmentActorCommonName(AuditLogEntry $entry, Metadata $auditLogMetadata): void
{
- if (property_exists($auditLogMetadata, 'vettingType') && !is_null($auditLogMetadata->vettingType)) {
- $entry->actorCommonName .= $auditLogMetadata->vettingType->auditLog();
+ if (property_exists($auditLogMetadata, 'vettingType') && $auditLogMetadata->vettingType instanceof VettingType) {
+ $entry->actorCommonName = new CommonName(
+ $entry->actorCommonName->getCommonName() . $auditLogMetadata->vettingType->auditLog()
+ );
}
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/IdentityProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/IdentityProjector.php
index 291147b78..a6574ab84 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/IdentityProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/IdentityProjector.php
@@ -21,7 +21,6 @@
use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityCreatedEvent;
use Surfnet\Stepup\Identity\Event\IdentityEmailChangedEvent;
-use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Identity\Event\IdentityRenamedEvent;
use Surfnet\Stepup\Identity\Event\LocalePreferenceExpressedEvent;
use Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent;
@@ -32,68 +31,65 @@
class IdentityProjector extends Projector
{
- /**
- * @var IdentityRepository
- */
- private $identityRepository;
-
- public function __construct(IdentityRepository $identityRepository)
- {
- $this->identityRepository = $identityRepository;
+ public function __construct(
+ private readonly IdentityRepository $identityRepository,
+ ) {
}
- public function applyIdentityCreatedEvent(IdentityCreatedEvent $event)
+ public function applyIdentityCreatedEvent(IdentityCreatedEvent $event): void
{
- $this->identityRepository->save(Identity::create(
- (string) $event->identityId,
- $event->identityInstitution,
- $event->nameId,
- $event->email,
- $event->commonName,
- $event->preferredLocale,
- false
- ));
+ $this->identityRepository->save(
+ Identity::create(
+ (string)$event->identityId,
+ $event->identityInstitution,
+ $event->nameId,
+ $event->email,
+ $event->commonName,
+ $event->preferredLocale,
+ ),
+ );
}
- public function applyIdentityRenamedEvent(IdentityRenamedEvent $event)
+ public function applyIdentityRenamedEvent(IdentityRenamedEvent $event): void
{
- $identity = $this->identityRepository->find((string) $event->identityId);
+ $identity = $this->identityRepository->find((string)$event->identityId);
$identity->commonName = $event->commonName;
$this->identityRepository->save($identity);
}
- public function applyIdentityEmailChangedEvent(IdentityEmailChangedEvent $event)
+ public function applyIdentityEmailChangedEvent(IdentityEmailChangedEvent $event): void
{
- $identity = $this->identityRepository->find((string) $event->identityId);
+ $identity = $this->identityRepository->find((string)$event->identityId);
$identity->email = $event->email;
$this->identityRepository->save($identity);
}
- public function applyLocalePreferenceExpressedEvent(LocalePreferenceExpressedEvent $event)
+ public function applyLocalePreferenceExpressedEvent(LocalePreferenceExpressedEvent $event): void
{
- $identity = $this->identityRepository->find((string) $event->identityId);
+ $identity = $this->identityRepository->find((string)$event->identityId);
$identity->preferredLocale = $event->preferredLocale;
$this->identityRepository->save($identity);
}
- public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event)
+ public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event): void
{
- $this->determinePossessionOfSelfAssertedToken($event->vettingType, (string) $event->identityId);
+ $this->determinePossessionOfSelfAssertedToken($event->vettingType, (string)$event->identityId);
}
- public function applySecondFactorVettedWithoutTokenProofOfPossession(SecondFactorVettedWithoutTokenProofOfPossession $event)
- {
- $this->determinePossessionOfSelfAssertedToken($event->vettingType, (string) $event->identityId);
+ public function applySecondFactorVettedWithoutTokenProofOfPossession(
+ SecondFactorVettedWithoutTokenProofOfPossession $event,
+ ): void {
+ $this->determinePossessionOfSelfAssertedToken($event->vettingType, (string)$event->identityId);
}
private function determinePossessionOfSelfAssertedToken(VettingType $vettingType, string $identityId): void
{
if ($vettingType->type() === VettingType::TYPE_SELF_ASSERTED_REGISTRATION) {
$identity = $this->identityRepository->find($identityId);
- if ($identity) {
+ if ($identity instanceof Identity) {
$identity->possessedSelfAssertedToken = true;
$this->identityRepository->save($identity);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/IdentitySelfAssertedTokenOptionsProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/IdentitySelfAssertedTokenOptionsProjector.php
index d5636d4b8..695ec0b37 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/IdentitySelfAssertedTokenOptionsProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/IdentitySelfAssertedTokenOptionsProjector.php
@@ -29,37 +29,33 @@
class IdentitySelfAssertedTokenOptionsProjector extends Projector
{
- /**
- * @var IdentitySelfAssertedTokenOptionsRepository
- */
- private $repository;
-
- public function __construct(IdentitySelfAssertedTokenOptionsRepository $identitySelfAssertedTokenOptionsRepository)
- {
- $this->repository = $identitySelfAssertedTokenOptionsRepository;
+ public function __construct(
+ private readonly IdentitySelfAssertedTokenOptionsRepository $repository,
+ ) {
}
/**
* Identity is created, we also create a set of
* IdentitySelfAssertedTokenOptions.
*/
- public function applyIdentityCreatedEvent(IdentityCreatedEvent $event)
+ public function applyIdentityCreatedEvent(IdentityCreatedEvent $event): void
{
$identitySelfAssertedTokenOptions = IdentitySelfAssertedTokenOptions::create(
$event->identityId,
false,
- false
+ false,
);
$this->repository->save($identitySelfAssertedTokenOptions);
}
- public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event)
+ public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event): void
{
$this->determinePossessionOfToken($event->vettingType, $event->identityId);
}
- public function applySecondFactorVettedWithoutTokenProofOfPossession(SecondFactorVettedWithoutTokenProofOfPossession $event)
- {
+ public function applySecondFactorVettedWithoutTokenProofOfPossession(
+ SecondFactorVettedWithoutTokenProofOfPossession $event,
+ ): void {
$this->determinePossessionOfToken($event->vettingType, $event->identityId);
}
@@ -69,11 +65,11 @@ private function determinePossessionOfToken(VettingType $vettingType, IdentityId
$identitySelfAssertedTokenOptions = $this->repository->find($identityId);
// Scenario 1: A new token is registered, we have no sat options yet,
// create them. These are identities from the pre SAT era.
- if (!$identitySelfAssertedTokenOptions) {
+ if (!$identitySelfAssertedTokenOptions instanceof IdentitySelfAssertedTokenOptions) {
$identitySelfAssertedTokenOptions = IdentitySelfAssertedTokenOptions::create(
$identityId,
true,
- $isSelfAssertedToken
+ $isSelfAssertedToken,
);
$this->repository->save($identitySelfAssertedTokenOptions);
return;
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/InstitutionListingProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/InstitutionListingProjector.php
index 5764b4761..797a7036c 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/InstitutionListingProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/InstitutionListingProjector.php
@@ -28,14 +28,11 @@
*/
class InstitutionListingProjector extends Projector
{
- private $institutionListingRepository;
-
- public function __construct(InstitutionListingRepository $institutionListingRepository)
+ public function __construct(private readonly InstitutionListingRepository $institutionListingRepository)
{
- $this->institutionListingRepository = $institutionListingRepository;
}
- public function applyIdentityCreatedEvent(IdentityCreatedEvent $event)
+ public function applyIdentityCreatedEvent(IdentityCreatedEvent $event): void
{
$this->institutionListingRepository->addIfNotExists($event->identityInstitution);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RaListingProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RaListingProjector.php
index 7c2ad6c6a..0fe328319 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RaListingProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RaListingProjector.php
@@ -20,8 +20,8 @@
use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\AppointedAsRaaEvent;
-use Surfnet\Stepup\Identity\Event\AppointedAsRaEvent;
use Surfnet\Stepup\Identity\Event\AppointedAsRaaForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\AppointedAsRaEvent;
use Surfnet\Stepup\Identity\Event\AppointedAsRaForInstitutionEvent;
use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaEvent;
use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaForInstitutionEvent;
@@ -44,76 +44,60 @@
*/
class RaListingProjector extends Projector
{
- /**
- * @var RaListingRepository
- */
- private $raListingRepository;
-
- /**
- * @var IdentityRepository
- */
- private $identityRepository;
-
- public function __construct(RaListingRepository $raListingRepository, IdentityRepository $identityRepository)
- {
- $this->raListingRepository = $raListingRepository;
- $this->identityRepository = $identityRepository;
+ public function __construct(
+ private readonly RaListingRepository $raListingRepository,
+ private readonly IdentityRepository $identityRepository,
+ ) {
}
- /**
- * @param IdentityAccreditedAsRaForInstitutionEvent $event
- * @return void
- */
- public function applyIdentityAccreditedAsRaForInstitutionEvent(IdentityAccreditedAsRaForInstitutionEvent $event)
+ public function applyIdentityAccreditedAsRaForInstitutionEvent(IdentityAccreditedAsRaForInstitutionEvent $event,): void
{
- $identity = $this->identityRepository->find((string) $event->identityId);
+ $identity = $this->identityRepository->find((string)$event->identityId);
$raListing = RaListing::create(
- (string) $event->identityId,
+ (string)$event->identityId,
$event->identityInstitution,
$identity->commonName,
$identity->email,
AuthorityRole::fromRegistrationAuthorityRole($event->registrationAuthorityRole),
$event->location,
$event->contactInformation,
- $event->raInstitution
+ $event->raInstitution,
);
$this->raListingRepository->save($raListing);
}
- /**
- * @param IdentityAccreditedAsRaaForInstitutionEvent $event
- * @return void
- */
- public function applyIdentityAccreditedAsRaaForInstitutionEvent(IdentityAccreditedAsRaaForInstitutionEvent $event)
+ public function applyIdentityAccreditedAsRaaForInstitutionEvent(IdentityAccreditedAsRaaForInstitutionEvent $event,): void
{
- $identity = $this->identityRepository->find((string) $event->identityId);
+ $identity = $this->identityRepository->find((string)$event->identityId);
$raListing = RaListing::create(
- (string) $event->identityId,
+ (string)$event->identityId,
$event->identityInstitution,
$identity->commonName,
$identity->email,
AuthorityRole::fromRegistrationAuthorityRole($event->registrationAuthorityRole),
$event->location,
$event->contactInformation,
- $event->raInstitution
+ $event->raInstitution,
);
$this->raListingRepository->save($raListing);
}
public function applyRegistrationAuthorityInformationAmendedForInstitutionEvent(
- RegistrationAuthorityInformationAmendedForInstitutionEvent $event
- ) {
- /** @var RaListing $raListing */
- $raListing = $this->raListingRepository->findByIdentityIdAndRaInstitution($event->identityId, $event->raInstitution);
+ RegistrationAuthorityInformationAmendedForInstitutionEvent $event,
+ ): void {
+ $raListing = $this->raListingRepository->findByIdentityIdAndRaInstitution(
+ $event->identityId,
+ $event->raInstitution,
+ );
- if (!$raListing) {
+ if (!$raListing instanceof \Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing) {
throw new RuntimeException(
"Tried to amend an RaListing's registration authority location and contact information, " .
- "but the listing could not be found"
+ "but the listing could not be found",
);
}
@@ -123,33 +107,38 @@ public function applyRegistrationAuthorityInformationAmendedForInstitutionEvent(
$this->raListingRepository->save($raListing);
}
- public function applyAppointedAsRaForInstitutionEvent(AppointedAsRaForInstitutionEvent $event)
+ public function applyAppointedAsRaForInstitutionEvent(AppointedAsRaForInstitutionEvent $event): void
{
- /** @var RaListing $raListing */
- $raListing = $this->raListingRepository->findByIdentityIdAndRaInstitution($event->identityId, $event->raInstitution);
+ $raListing = $this->raListingRepository->findByIdentityIdAndRaInstitution(
+ $event->identityId,
+ $event->raInstitution,
+ );
$raListing->role = AuthorityRole::ra();
$this->raListingRepository->save($raListing);
}
- public function applyAppointedAsRaaForInstitutionEvent(AppointedAsRaaForInstitutionEvent $event)
+ public function applyAppointedAsRaaForInstitutionEvent(AppointedAsRaaForInstitutionEvent $event): void
{
- /** @var RaListing $raListing */
- $raListing = $this->raListingRepository->findByIdentityIdAndRaInstitution($event->identityId, $event->raInstitution);
+ $raListing = $this->raListingRepository->findByIdentityIdAndRaInstitution(
+ $event->identityId,
+ $event->raInstitution,
+ );
$raListing->role = AuthorityRole::raa();
$this->raListingRepository->save($raListing);
}
- public function applyRegistrationAuthorityRetractedForInstitutionEvent(RegistrationAuthorityRetractedForInstitutionEvent $event)
- {
+ public function applyRegistrationAuthorityRetractedForInstitutionEvent(
+ RegistrationAuthorityRetractedForInstitutionEvent $event,
+ ): void {
$this->raListingRepository->removeByIdentityIdAndRaInstitution($event->identityId, $event->raInstitution);
}
- protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
+ protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
$this->raListingRepository->removeByIdentityId($event->identityId, $event->identityInstitution);
}
@@ -157,22 +146,20 @@ protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
/**
* This method is kept to be backwards compatible for changes before FGA
*
- * @param IdentityAccreditedAsRaEvent $event
* @return void
*/
- public function applyIdentityAccreditedAsRaEvent(IdentityAccreditedAsRaEvent $event)
+ public function applyIdentityAccreditedAsRaEvent(IdentityAccreditedAsRaEvent $event): void
{
- $identity = $this->identityRepository->find((string) $event->identityId);
-
+ $identity = $this->identityRepository->find((string)$event->identityId);
$raListing = RaListing::create(
- (string) $event->identityId,
+ (string)$event->identityId,
$event->identityInstitution,
$identity->commonName,
$identity->email,
AuthorityRole::fromRegistrationAuthorityRole($event->registrationAuthorityRole),
$event->location,
$event->contactInformation,
- $event->identityInstitution
+ $event->identityInstitution,
);
$this->raListingRepository->save($raListing);
@@ -181,22 +168,20 @@ public function applyIdentityAccreditedAsRaEvent(IdentityAccreditedAsRaEvent $ev
/**
* This method is kept to be backwards compatible for changes before FGA
*
- * @param IdentityAccreditedAsRaaEvent $event
* @return void
*/
- public function applyIdentityAccreditedAsRaaEvent(IdentityAccreditedAsRaaEvent $event)
+ public function applyIdentityAccreditedAsRaaEvent(IdentityAccreditedAsRaaEvent $event): void
{
- $identity = $this->identityRepository->find((string) $event->identityId);
-
+ $identity = $this->identityRepository->find((string)$event->identityId);
$raListing = RaListing::create(
- (string) $event->identityId,
+ (string)$event->identityId,
$event->identityInstitution,
$identity->commonName,
$identity->email,
AuthorityRole::fromRegistrationAuthorityRole($event->registrationAuthorityRole),
$event->location,
$event->contactInformation,
- $event->identityInstitution
+ $event->identityInstitution,
);
$this->raListingRepository->save($raListing);
@@ -204,19 +189,19 @@ public function applyIdentityAccreditedAsRaaEvent(IdentityAccreditedAsRaaEvent $
/**
* This method is kept to be backwards compatible for changes before FGA
- *
- * @param RegistrationAuthorityInformationAmendedEvent $event
*/
public function applyRegistrationAuthorityInformationAmendedEvent(
- RegistrationAuthorityInformationAmendedEvent $event
- ) {
- /** @var RaListing $raListing */
- $raListing = $this->raListingRepository->findByIdentityIdAndRaInstitution($event->identityId, $event->identityInstitution);
+ RegistrationAuthorityInformationAmendedEvent $event,
+ ): void {
+ $raListing = $this->raListingRepository->findByIdentityIdAndRaInstitution(
+ $event->identityId,
+ $event->identityInstitution,
+ );
- if (!$raListing) {
+ if (!$raListing instanceof \Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing) {
throw new RuntimeException(
"Tried to amend an RaListing's registration authority location and contact information, " .
- "but the listing could not be found"
+ "but the listing could not be found",
);
}
@@ -228,40 +213,40 @@ public function applyRegistrationAuthorityInformationAmendedEvent(
/**
* This method is kept to be backwards compatible for changes before FGA
- *
- * @param AppointedAsRaEvent $event
*/
- public function applyAppointedAsRaEvent(AppointedAsRaEvent $event)
+ public function applyAppointedAsRaEvent(AppointedAsRaEvent $event): void
{
- /** @var RaListing $raListing */
- $raListing = $this->raListingRepository->findByIdentityIdAndInstitution($event->identityId, $event->identityInstitution);
-
- $raListing->role = AuthorityRole::ra();
+ $raListing = $this->raListingRepository->findByIdentityIdAndInstitution(
+ $event->identityId,
+ $event->identityInstitution,
+ );
- $this->raListingRepository->save($raListing);
+ foreach ($raListing as $listing) {
+ $listing->role = AuthorityRole::ra();
+ $this->raListingRepository->save($listing);
+ }
}
/**
* This method is kept to be backwards compatible for changes before FGA
- *
- * @param AppointedAsRaaEvent $event
*/
- public function applyAppointedAsRaaEvent(AppointedAsRaaEvent $event)
+ public function applyAppointedAsRaaEvent(AppointedAsRaaEvent $event): void
{
- /** @var RaListing $raListing */
- $raListing = $this->raListingRepository->findByIdentityIdAndInstitution($event->identityId, $event->identityInstitution);
-
- $raListing->role = AuthorityRole::raa();
+ $raListing = $this->raListingRepository->findByIdentityIdAndInstitution(
+ $event->identityId,
+ $event->identityInstitution,
+ );
- $this->raListingRepository->save($raListing);
+ foreach ($raListing as $listing) {
+ $listing->role = AuthorityRole::raa();
+ $this->raListingRepository->save($listing);
+ }
}
/**
* This method is kept to be backwards compatible for changes before FGA
- *
- * @param RegistrationAuthorityRetractedEvent $event
*/
- public function applyRegistrationAuthorityRetractedEvent(RegistrationAuthorityRetractedEvent $event)
+ public function applyRegistrationAuthorityRetractedEvent(RegistrationAuthorityRetractedEvent $event): void
{
$this->raListingRepository->removeByIdentityIdAndInstitution($event->identityId, $event->identityInstitution);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RaSecondFactorProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RaSecondFactorProjector.php
index 27ad4eb34..a9921fd6f 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RaSecondFactorProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RaSecondFactorProjector.php
@@ -58,29 +58,17 @@
*/
class RaSecondFactorProjector extends Projector
{
- /**
- * @var RaSecondFactorRepository
- */
- private $raSecondFactorRepository;
-
- /**
- * @var IdentityRepository
- */
- private $identityRepository;
-
public function __construct(
- RaSecondFactorRepository $raSecondFactorRepository,
- IdentityRepository $identityRepository
+ private readonly RaSecondFactorRepository $raSecondFactorRepository,
+ private readonly IdentityRepository $identityRepository,
) {
- $this->raSecondFactorRepository = $raSecondFactorRepository;
- $this->identityRepository = $identityRepository;
}
- public function applyIdentityRenamedEvent(IdentityRenamedEvent $event)
+ public function applyIdentityRenamedEvent(IdentityRenamedEvent $event): void
{
- $secondFactors = $this->raSecondFactorRepository->findByIdentityId((string) $event->identityId);
+ $secondFactors = $this->raSecondFactorRepository->findByIdentityId((string)$event->identityId);
- if (count($secondFactors) === 0) {
+ if ($secondFactors === []) {
return;
}
@@ -93,11 +81,11 @@ public function applyIdentityRenamedEvent(IdentityRenamedEvent $event)
$this->raSecondFactorRepository->saveAll($secondFactors);
}
- public function applyIdentityEmailChangedEvent(IdentityEmailChangedEvent $event)
+ public function applyIdentityEmailChangedEvent(IdentityEmailChangedEvent $event): void
{
- $secondFactors = $this->raSecondFactorRepository->findByIdentityId((string) $event->identityId);
+ $secondFactors = $this->raSecondFactorRepository->findByIdentityId((string)$event->identityId);
- if (count($secondFactors) === 0) {
+ if ($secondFactors === []) {
return;
}
@@ -110,167 +98,161 @@ public function applyIdentityEmailChangedEvent(IdentityEmailChangedEvent $event)
$this->raSecondFactorRepository->saveAll($secondFactors);
}
- public function applyYubikeySecondFactorBootstrappedEvent(YubikeySecondFactorBootstrappedEvent $event)
+ public function applyYubikeySecondFactorBootstrappedEvent(YubikeySecondFactorBootstrappedEvent $event): void
{
- $identity = $this->identityRepository->find((string) $event->identityId);
+ $identity = $this->identityRepository->find((string)$event->identityId);
$secondFactor = new RaSecondFactor(
- (string) $event->secondFactorId,
+ (string)$event->secondFactorId,
'yubikey',
- (string) $event->yubikeyPublicId,
+ (string)$event->yubikeyPublicId,
$identity->id,
$identity->institution,
$event->commonName,
- $event->email
+ $event->email,
);
$secondFactor->status = SecondFactorStatus::vetted();
$this->raSecondFactorRepository->save($secondFactor);
}
- public function applyYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $event)
+ public function applyYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $event): void
{
$this->saveRaSecondFactor(
- (string) $event->identityId,
- (string) $event->secondFactorId,
+ (string)$event->identityId,
+ (string)$event->secondFactorId,
'yubikey',
- (string) $event->yubikeyPublicId,
+ (string)$event->yubikeyPublicId,
$event->commonName,
- $event->email
+ $event->email,
);
}
- public function applyYubikeyPossessionProvenAndVerifiedEvent(YubikeyPossessionProvenAndVerifiedEvent $event)
+ public function applyYubikeyPossessionProvenAndVerifiedEvent(YubikeyPossessionProvenAndVerifiedEvent $event): void
{
$this->saveRaSecondFactor(
- (string) $event->identityId,
- (string) $event->secondFactorId,
+ (string)$event->identityId,
+ (string)$event->secondFactorId,
'yubikey',
- (string) $event->yubikeyPublicId,
+ (string)$event->yubikeyPublicId,
$event->commonName,
- $event->email
+ $event->email,
);
}
- public function applyPhonePossessionProvenEvent(PhonePossessionProvenEvent $event)
+ public function applyPhonePossessionProvenEvent(PhonePossessionProvenEvent $event): void
{
$this->saveRaSecondFactor(
- (string) $event->identityId,
- (string) $event->secondFactorId,
+ (string)$event->identityId,
+ (string)$event->secondFactorId,
'sms',
- (string) $event->phoneNumber,
+ (string)$event->phoneNumber,
$event->commonName,
- $event->email
+ $event->email,
);
}
- public function applyPhonePossessionProvenAndVerifiedEvent(PhonePossessionProvenAndVerifiedEvent $event)
+ public function applyPhonePossessionProvenAndVerifiedEvent(PhonePossessionProvenAndVerifiedEvent $event): void
{
$this->saveRaSecondFactor(
- (string) $event->identityId,
- (string) $event->secondFactorId,
+ (string)$event->identityId,
+ (string)$event->secondFactorId,
'sms',
- (string) $event->phoneNumber,
+ (string)$event->phoneNumber,
$event->commonName,
- $event->email
+ $event->email,
);
}
- public function applyGssfPossessionProvenEvent(GssfPossessionProvenEvent $event)
+ public function applyGssfPossessionProvenEvent(GssfPossessionProvenEvent $event): void
{
$this->saveRaSecondFactor(
- (string) $event->identityId,
- (string) $event->secondFactorId,
- (string) $event->stepupProvider,
- (string) $event->gssfId,
+ (string)$event->identityId,
+ (string)$event->secondFactorId,
+ (string)$event->stepupProvider,
+ (string)$event->gssfId,
$event->commonName,
- $event->email
+ $event->email,
);
}
- public function applyGssfPossessionProvenAndVerifiedEvent(GssfPossessionProvenAndVerifiedEvent $event)
+ public function applyGssfPossessionProvenAndVerifiedEvent(GssfPossessionProvenAndVerifiedEvent $event): void
{
$this->saveRaSecondFactor(
- (string) $event->identityId,
- (string) $event->secondFactorId,
- (string) $event->stepupProvider,
- (string) $event->gssfId,
+ (string)$event->identityId,
+ (string)$event->secondFactorId,
+ (string)$event->stepupProvider,
+ (string)$event->gssfId,
$event->commonName,
- $event->email
+ $event->email,
);
}
/**
* @deprecated Built in U2F support is dropped from StepUp, this was not removed to support event replay
*/
- public function applyU2fDevicePossessionProvenEvent(U2fDevicePossessionProvenEvent $event)
+ public function applyU2fDevicePossessionProvenEvent(U2fDevicePossessionProvenEvent $event): void
{
$this->saveRaSecondFactor(
- (string) $event->identityId,
- (string) $event->secondFactorId,
+ (string)$event->identityId,
+ (string)$event->secondFactorId,
'u2f',
$event->keyHandle->getValue(),
$event->commonName,
- $event->email
+ $event->email,
);
}
/**
* @deprecated Built in U2F support is dropped from StepUp, this was not removed to support event replay
*/
- public function applyU2fDevicePossessionProvenAndVerifiedEvent(U2fDevicePossessionProvenAndVerifiedEvent $event)
+ public function applyU2fDevicePossessionProvenAndVerifiedEvent(U2fDevicePossessionProvenAndVerifiedEvent $event,): void
{
$this->saveRaSecondFactor(
- (string) $event->identityId,
- (string) $event->secondFactorId,
+ (string)$event->identityId,
+ (string)$event->secondFactorId,
'u2f',
$event->keyHandle->getValue(),
$event->commonName,
- $event->email
+ $event->email,
);
}
/**
- * @param string $identityId
- * @param string $secondFactorId
- * @param string $secondFactorType
- * @param string $secondFactorIdentifier
- * @param CommonName $commonName
- * @param Email $email
* @param SecondFactorStatus|null $status
* @param DocumentNumber|null $documentNumber
*/
private function saveRaSecondFactor(
- $identityId,
- $secondFactorId,
- $secondFactorType,
- $secondFactorIdentifier,
- CommonName $commonName,
- Email $email,
+ string $identityId,
+ string $secondFactorId,
+ string $secondFactorType,
+ string $secondFactorIdentifier,
+ CommonName $commonName,
+ Email $email,
SecondFactorStatus $status = null,
- DocumentNumber $documentNumber = null
- ) {
+ DocumentNumber $documentNumber = null,
+ ): void {
$identity = $this->identityRepository->find($identityId);
$secondFactor = new RaSecondFactor(
- (string) $secondFactorId,
+ $secondFactorId,
$secondFactorType,
$secondFactorIdentifier,
$identity->id,
$identity->institution,
$commonName,
$email,
- $documentNumber
+ $documentNumber,
);
- if ($status !== null) {
+ if ($status instanceof SecondFactorStatus) {
$secondFactor->status = $status;
}
$this->raSecondFactorRepository->save($secondFactor);
}
- public function applyEmailVerifiedEvent(EmailVerifiedEvent $event)
+ public function applyEmailVerifiedEvent(EmailVerifiedEvent $event): void
{
$this->updateStatus($event->secondFactorId, SecondFactorStatus::verified());
}
@@ -279,34 +261,35 @@ public function applyEmailVerifiedEvent(EmailVerifiedEvent $event)
* The RA second factor projection is updated with a new Second factor based on the 'source' second factor
* from the original identity.
*/
- public function applySecondFactorMigratedEvent(SecondFactorMigratedEvent $event)
+ public function applySecondFactorMigratedEvent(SecondFactorMigratedEvent $event): void
{
- $oldSecondFactor = $this->raSecondFactorRepository->find((string) $event->secondFactorId);
+ $oldSecondFactor = $this->raSecondFactorRepository->find((string)$event->secondFactorId);
$this->saveRaSecondFactor(
- (string) $event->identityId,
- (string) $event->newSecondFactorId,
- (string) $event->secondFactorType,
- (string) $event->secondFactorIdentifier,
+ (string)$event->identityId,
+ (string)$event->newSecondFactorId,
+ (string)$event->secondFactorType,
+ (string)$event->secondFactorIdentifier,
$event->commonName,
$event->email,
$oldSecondFactor->status,
- $oldSecondFactor->documentNumber
+ $oldSecondFactor->documentNumber,
);
}
- public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event)
+ public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event): void
{
- $secondFactor = $this->raSecondFactorRepository->find((string) $event->secondFactorId);
+ $secondFactor = $this->raSecondFactorRepository->find((string)$event->secondFactorId);
$secondFactor->documentNumber = $event->vettingType->getDocumentNumber();
$secondFactor->status = SecondFactorStatus::vetted();
$this->raSecondFactorRepository->save($secondFactor);
}
- public function applySecondFactorVettedWithoutTokenProofOfPossession(SecondFactorVettedWithoutTokenProofOfPossession $event)
- {
- $secondFactor = $this->raSecondFactorRepository->find((string) $event->secondFactorId);
+ public function applySecondFactorVettedWithoutTokenProofOfPossession(
+ SecondFactorVettedWithoutTokenProofOfPossession $event,
+ ): void {
+ $secondFactor = $this->raSecondFactorRepository->find((string)$event->secondFactorId);
$documentNumber = null;
if ($event->vettingType instanceof OnPremiseVettingType) {
@@ -318,51 +301,47 @@ public function applySecondFactorVettedWithoutTokenProofOfPossession(SecondFacto
$this->raSecondFactorRepository->save($secondFactor);
}
- protected function applyUnverifiedSecondFactorRevokedEvent(UnverifiedSecondFactorRevokedEvent $event)
+ protected function applyUnverifiedSecondFactorRevokedEvent(UnverifiedSecondFactorRevokedEvent $event): void
{
$this->updateStatus($event->secondFactorId, SecondFactorStatus::revoked());
}
protected function applyCompliedWithUnverifiedSecondFactorRevocationEvent(
- CompliedWithUnverifiedSecondFactorRevocationEvent $event
- ) {
+ CompliedWithUnverifiedSecondFactorRevocationEvent $event,
+ ): void {
$this->updateStatus($event->secondFactorId, SecondFactorStatus::revoked());
}
- protected function applyVerifiedSecondFactorRevokedEvent(VerifiedSecondFactorRevokedEvent $event)
+ protected function applyVerifiedSecondFactorRevokedEvent(VerifiedSecondFactorRevokedEvent $event): void
{
$this->updateStatus($event->secondFactorId, SecondFactorStatus::revoked());
}
protected function applyCompliedWithVerifiedSecondFactorRevocationEvent(
- CompliedWithVerifiedSecondFactorRevocationEvent $event
- ) {
+ CompliedWithVerifiedSecondFactorRevocationEvent $event,
+ ): void {
$this->updateStatus($event->secondFactorId, SecondFactorStatus::revoked());
}
- protected function applyVettedSecondFactorRevokedEvent(VettedSecondFactorRevokedEvent $event)
+ protected function applyVettedSecondFactorRevokedEvent(VettedSecondFactorRevokedEvent $event): void
{
$this->updateStatus($event->secondFactorId, SecondFactorStatus::revoked());
}
protected function applyCompliedWithVettedSecondFactorRevocationEvent(
- CompliedWithVettedSecondFactorRevocationEvent $event
- ) {
+ CompliedWithVettedSecondFactorRevocationEvent $event,
+ ): void {
$this->updateStatus($event->secondFactorId, SecondFactorStatus::revoked());
}
- protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
+ protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
$this->raSecondFactorRepository->updateStatusByIdentityIdToForgotten($event->identityId);
}
- /**
- * @param SecondFactorId $secondFactorId
- * @param SecondFactorStatus $status
- */
- private function updateStatus(SecondFactorId $secondFactorId, SecondFactorStatus $status)
+ private function updateStatus(SecondFactorId $secondFactorId, SecondFactorStatus $status): void
{
- $secondFactor = $this->raSecondFactorRepository->find((string) $secondFactorId);
+ $secondFactor = $this->raSecondFactorRepository->find((string)$secondFactorId);
$secondFactor->status = $status;
$this->raSecondFactorRepository->save($secondFactor);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RecoveryTokenProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RecoveryTokenProjector.php
index 1f83b6eff..901eca786 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RecoveryTokenProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/RecoveryTokenProjector.php
@@ -34,25 +34,18 @@
*/
class RecoveryTokenProjector extends Projector
{
- /**
- * @var RecoveryTokenRepository
- */
- private $recoveryTokenRepository;
-
- public function __construct(
- RecoveryTokenRepository $recoveryMethodRepository
- ) {
- $this->recoveryTokenRepository = $recoveryMethodRepository;
+ public function __construct(private readonly RecoveryTokenRepository $recoveryTokenRepository)
+ {
}
- public function applyPhoneRecoveryTokenPossessionProvenEvent(PhoneRecoveryTokenPossessionProvenEvent $event)
+ public function applyPhoneRecoveryTokenPossessionProvenEvent(PhoneRecoveryTokenPossessionProvenEvent $event): void
{
$recoveryToken = new RecoveryToken();
$recoveryToken->id = $event->recoveryTokenId->getRecoveryTokenId();
$recoveryToken->identityId = $event->identityId->getIdentityId();
$recoveryToken->type = RecoveryTokenType::TYPE_SMS;
$recoveryToken->status = RecoveryTokenStatus::active();
- $recoveryToken->recoveryMethodIdentifier = (string) $event->phoneNumber;
+ $recoveryToken->recoveryMethodIdentifier = (string)$event->phoneNumber;
$recoveryToken->institution = $event->identityInstitution;
$recoveryToken->email = $event->email;
$recoveryToken->name = $event->commonName;
@@ -60,14 +53,15 @@ public function applyPhoneRecoveryTokenPossessionProvenEvent(PhoneRecoveryTokenP
$this->recoveryTokenRepository->save($recoveryToken);
}
- public function applySafeStoreSecretRecoveryTokenPossessionPromisedEvent(SafeStoreSecretRecoveryTokenPossessionPromisedEvent $event)
- {
+ public function applySafeStoreSecretRecoveryTokenPossessionPromisedEvent(
+ SafeStoreSecretRecoveryTokenPossessionPromisedEvent $event,
+ ): void {
$recoveryToken = new RecoveryToken();
$recoveryToken->id = $event->recoveryTokenId->getRecoveryTokenId();
$recoveryToken->identityId = $event->identityId->getIdentityId();
$recoveryToken->type = RecoveryTokenType::TYPE_SAFE_STORE;
$recoveryToken->status = RecoveryTokenStatus::active();
- $recoveryToken->recoveryMethodIdentifier = (string) $event->secret;
+ $recoveryToken->recoveryMethodIdentifier = (string)$event->secret;
$recoveryToken->institution = $event->identityInstitution;
$recoveryToken->email = $event->email;
$recoveryToken->name = $event->commonName;
@@ -93,7 +87,7 @@ public function applyRecoveryTokenRevokedEvent(RecoveryTokenRevokedEvent $event)
* When Identity is forgotten, the recovery token projections for this identity
* are removed from the recovery_tokens table.
*/
- protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
+ protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
$this->recoveryTokenRepository->removeByIdentity($event->identityId);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SecondFactorProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SecondFactorProjector.php
index f0186a5ca..093ed64be 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SecondFactorProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SecondFactorProjector.php
@@ -53,32 +53,14 @@
*/
class SecondFactorProjector extends Projector
{
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\UnverifiedSecondFactorRepository
- */
- private $unverifiedRepository;
-
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VerifiedSecondFactorRepository
- */
- private $verifiedRepository;
-
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettedSecondFactorRepository
- */
- private $vettedRepository;
-
public function __construct(
- UnverifiedSecondFactorRepository $unverifiedRepository,
- VerifiedSecondFactorRepository $verifiedRepository,
- VettedSecondFactorRepository $vettedRepository
+ private readonly UnverifiedSecondFactorRepository $unverifiedRepository,
+ private readonly VerifiedSecondFactorRepository $verifiedRepository,
+ private readonly VettedSecondFactorRepository $vettedRepository,
) {
- $this->unverifiedRepository = $unverifiedRepository;
- $this->verifiedRepository = $verifiedRepository;
- $this->vettedRepository = $vettedRepository;
}
- public function applyYubikeySecondFactorBootstrappedEvent(YubikeySecondFactorBootstrappedEvent $event)
+ public function applyYubikeySecondFactorBootstrappedEvent(YubikeySecondFactorBootstrappedEvent $event): void
{
$secondFactor = new VettedSecondFactor();
$secondFactor->id = $event->secondFactorId->getSecondFactorId();
@@ -89,7 +71,7 @@ public function applyYubikeySecondFactorBootstrappedEvent(YubikeySecondFactorBoo
$this->vettedRepository->save($secondFactor);
}
- public function applyYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $event)
+ public function applyYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $event): void
{
$secondFactor = new UnverifiedSecondFactor();
$secondFactor->id = $event->secondFactorId->getSecondFactorId();
@@ -101,7 +83,7 @@ public function applyYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $
$this->unverifiedRepository->save($secondFactor);
}
- public function applyYubikeyPossessionProvenAndVerifiedEvent(YubikeyPossessionProvenAndVerifiedEvent $event)
+ public function applyYubikeyPossessionProvenAndVerifiedEvent(YubikeyPossessionProvenAndVerifiedEvent $event): void
{
$secondFactor = new VerifiedSecondFactor();
$secondFactor->id = $event->secondFactorId->getSecondFactorId();
@@ -116,7 +98,7 @@ public function applyYubikeyPossessionProvenAndVerifiedEvent(YubikeyPossessionPr
$this->verifiedRepository->save($secondFactor);
}
- public function applyPhonePossessionProvenEvent(PhonePossessionProvenEvent $event)
+ public function applyPhonePossessionProvenEvent(PhonePossessionProvenEvent $event): void
{
$secondFactor = new UnverifiedSecondFactor();
$secondFactor->id = $event->secondFactorId->getSecondFactorId();
@@ -128,7 +110,7 @@ public function applyPhonePossessionProvenEvent(PhonePossessionProvenEvent $even
$this->unverifiedRepository->save($secondFactor);
}
- public function applyPhonePossessionProvenAndVerifiedEvent(PhonePossessionProvenAndVerifiedEvent $event)
+ public function applyPhonePossessionProvenAndVerifiedEvent(PhonePossessionProvenAndVerifiedEvent $event): void
{
$secondFactor = new VerifiedSecondFactor();
$secondFactor->id = $event->secondFactorId->getSecondFactorId();
@@ -143,7 +125,7 @@ public function applyPhonePossessionProvenAndVerifiedEvent(PhonePossessionProven
$this->verifiedRepository->save($secondFactor);
}
- public function applyGssfPossessionProvenEvent(GssfPossessionProvenEvent $event)
+ public function applyGssfPossessionProvenEvent(GssfPossessionProvenEvent $event): void
{
$secondFactor = new UnverifiedSecondFactor();
$secondFactor->id = $event->secondFactorId->getSecondFactorId();
@@ -155,7 +137,7 @@ public function applyGssfPossessionProvenEvent(GssfPossessionProvenEvent $event)
$this->unverifiedRepository->save($secondFactor);
}
- public function applyGssfPossessionProvenAndVerifiedEvent(GssfPossessionProvenAndVerifiedEvent $event)
+ public function applyGssfPossessionProvenAndVerifiedEvent(GssfPossessionProvenAndVerifiedEvent $event): void
{
$secondFactor = new VerifiedSecondFactor();
$secondFactor->id = $event->secondFactorId->getSecondFactorId();
@@ -170,8 +152,12 @@ public function applyGssfPossessionProvenAndVerifiedEvent(GssfPossessionProvenAn
$this->verifiedRepository->save($secondFactor);
}
- public function applyEmailVerifiedEvent(EmailVerifiedEvent $event)
+ public function applyEmailVerifiedEvent(EmailVerifiedEvent $event): void
{
+ if ($event->secondFactorType->isU2f()) {
+ // u2f is deprecated so those events shouldn't be handled anymore
+ return;
+ }
$unverified = $this->unverifiedRepository->find($event->secondFactorId->getSecondFactorId());
$verified = new VerifiedSecondFactor();
@@ -188,7 +174,7 @@ public function applyEmailVerifiedEvent(EmailVerifiedEvent $event)
$this->unverifiedRepository->remove($unverified);
}
- public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event)
+ public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event): void
{
$verified = $this->verifiedRepository->find($event->secondFactorId->getSecondFactorId());
@@ -200,7 +186,7 @@ public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event)
// In case the vetting type is unknown (for example when no event replay was performed)
// fall back to the unknown vetting type.
$vettingType = $event->vettingType;
- if (!$vettingType) {
+ if (!$vettingType instanceof \Surfnet\Stepup\Identity\Value\VettingType) {
$vettingType = new UnknownVettingType();
}
$vetted->vettingType = $vettingType->type();
@@ -214,7 +200,7 @@ public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event)
* The original 'source' second factor is not yet removed. This is handled when the
* old identity is cleaned up.
*/
- public function applySecondFactorMigratedEvent(SecondFactorMigratedEvent $event)
+ public function applySecondFactorMigratedEvent(SecondFactorMigratedEvent $event): void
{
$vetted = new VettedSecondFactor();
$vetted->id = $event->newSecondFactorId->getSecondFactorId();
@@ -226,8 +212,9 @@ public function applySecondFactorMigratedEvent(SecondFactorMigratedEvent $event)
$this->vettedRepository->save($vetted);
}
- public function applySecondFactorVettedWithoutTokenProofOfPossession(SecondFactorVettedWithoutTokenProofOfPossession $event)
- {
+ public function applySecondFactorVettedWithoutTokenProofOfPossession(
+ SecondFactorVettedWithoutTokenProofOfPossession $event,
+ ): void {
$verified = $this->verifiedRepository->find($event->secondFactorId->getSecondFactorId());
$vetted = new VettedSecondFactor();
@@ -238,7 +225,7 @@ public function applySecondFactorVettedWithoutTokenProofOfPossession(SecondFacto
$vettingType = $event->vettingType;
// In case the vetting type is unknown (for example when no event replay was performed)
// fall back to the unknown vetting type.
- if (!$vettingType) {
+ if (!$vettingType instanceof \Surfnet\Stepup\Identity\Value\VettingType) {
$vettingType = new UnknownVettingType();
}
$vetted->vettingType = $vettingType->type();
@@ -247,40 +234,50 @@ public function applySecondFactorVettedWithoutTokenProofOfPossession(SecondFacto
$this->verifiedRepository->remove($verified);
}
- protected function applyUnverifiedSecondFactorRevokedEvent(UnverifiedSecondFactorRevokedEvent $event)
+ protected function applyUnverifiedSecondFactorRevokedEvent(UnverifiedSecondFactorRevokedEvent $event): void
{
- $this->unverifiedRepository->remove($this->unverifiedRepository->find($event->secondFactorId->getSecondFactorId()));
+ $this->unverifiedRepository->remove(
+ $this->unverifiedRepository->find($event->secondFactorId->getSecondFactorId()),
+ );
}
protected function applyCompliedWithUnverifiedSecondFactorRevocationEvent(
- CompliedWithUnverifiedSecondFactorRevocationEvent $event
- ) {
- $this->unverifiedRepository->remove($this->unverifiedRepository->find($event->secondFactorId->getSecondFactorId()));
+ CompliedWithUnverifiedSecondFactorRevocationEvent $event,
+ ): void {
+ $this->unverifiedRepository->remove(
+ $this->unverifiedRepository->find($event->secondFactorId->getSecondFactorId()),
+ );
}
- protected function applyVerifiedSecondFactorRevokedEvent(VerifiedSecondFactorRevokedEvent $event)
+ protected function applyVerifiedSecondFactorRevokedEvent(VerifiedSecondFactorRevokedEvent $event): void
{
- $this->verifiedRepository->remove($this->verifiedRepository->find($event->secondFactorId->getSecondFactorId()));
+ if ($event->secondFactorType->isU2f()) {
+ // u2f is deprecated so those events shouldn't be handled anymore
+ return;
+ }
+ $verifiedSecondFactor = $this->verifiedRepository->find($event->secondFactorId->getSecondFactorId());
+
+ $this->verifiedRepository->remove($verifiedSecondFactor);
}
protected function applyCompliedWithVerifiedSecondFactorRevocationEvent(
- CompliedWithVerifiedSecondFactorRevocationEvent $event
- ) {
+ CompliedWithVerifiedSecondFactorRevocationEvent $event,
+ ): void {
$this->verifiedRepository->remove($this->verifiedRepository->find($event->secondFactorId->getSecondFactorId()));
}
- protected function applyVettedSecondFactorRevokedEvent(VettedSecondFactorRevokedEvent $event)
+ protected function applyVettedSecondFactorRevokedEvent(VettedSecondFactorRevokedEvent $event): void
{
$this->vettedRepository->remove($this->vettedRepository->find($event->secondFactorId->getSecondFactorId()));
}
protected function applyCompliedWithVettedSecondFactorRevocationEvent(
- CompliedWithVettedSecondFactorRevocationEvent $event
- ) {
+ CompliedWithVettedSecondFactorRevocationEvent $event,
+ ): void {
$this->vettedRepository->remove($this->vettedRepository->find($event->secondFactorId->getSecondFactorId()));
}
- protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
+ protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
$this->unverifiedRepository->removeByIdentityId($event->identityId);
$this->verifiedRepository->removeByIdentityId($event->identityId);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SecondFactorRevocationProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SecondFactorRevocationProjector.php
index c21adeaa3..e5e3047d2 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SecondFactorRevocationProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SecondFactorRevocationProjector.php
@@ -21,7 +21,7 @@
use Broadway\Domain\DomainMessage;
use Broadway\ReadModel\Projector;
use DateTime as CoreDateTime;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\DateTime\DateTime;
use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
use Surfnet\Stepup\Identity\Event\VettedSecondFactorRevokedEvent;
@@ -30,22 +30,16 @@
class SecondFactorRevocationProjector extends Projector
{
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SecondFactorRevocationRepository
- */
- private $repository;
-
- public function __construct(SecondFactorRevocationRepository $repository)
+ public function __construct(private readonly SecondFactorRevocationRepository $repository)
{
- $this->repository = $repository;
}
protected function applyVettedSecondFactorRevokedEvent(
VettedSecondFactorRevokedEvent $event,
- DomainMessage $domainMessage
- ) {
+ DomainMessage $domainMessage,
+ ): void {
$revocation = new SecondFactorRevocation();
- $revocation->id = (string) Uuid::uuid4();
+ $revocation->id = (string)Uuid::uuid4();
$revocation->institution = $event->identityInstitution;
$revocation->secondFactorType = $event->secondFactorType->getSecondFactorType();
$revocation->revokedBy = 'self';
@@ -56,10 +50,10 @@ protected function applyVettedSecondFactorRevokedEvent(
protected function applyCompliedWithVettedSecondFactorRevocationEvent(
CompliedWithVettedSecondFactorRevocationEvent $event,
- DomainMessage $domainMessage
- ) {
+ DomainMessage $domainMessage,
+ ): void {
$revocation = new SecondFactorRevocation();
- $revocation->id = (string) Uuid::uuid4();
+ $revocation->id = (string)Uuid::uuid4();
$revocation->institution = $event->identityInstitution;
$revocation->secondFactorType = $event->secondFactorType->getSecondFactorType();
$revocation->revokedBy = 'ra';
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SraaProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SraaProjector.php
index 59c1ed8b8..e4e40341c 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SraaProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/SraaProjector.php
@@ -26,20 +26,11 @@
class SraaProjector extends Projector
{
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SraaRepository
- */
- private $sraaRepository;
-
- public function __construct(SraaRepository $raaRepository)
+ public function __construct(private readonly SraaRepository $sraaRepository)
{
- $this->sraaRepository = $raaRepository;
}
- /**
- * @param SraaUpdatedEvent $event
- */
- public function applySraaUpdatedEvent(SraaUpdatedEvent $event)
+ public function applySraaUpdatedEvent(SraaUpdatedEvent $event): void
{
$this->sraaRepository->removeAll();
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/VettingTypeHintProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/VettingTypeHintProjector.php
index 14f05bdad..1c184f337 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/VettingTypeHintProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/VettingTypeHintProjector.php
@@ -19,7 +19,6 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;
use Broadway\ReadModel\Projector;
-use Surfnet\Stepup\Configuration\EventSourcing\InstitutionConfigurationRepository;
use Surfnet\Stepup\Identity\Event\VettingTypeHintsSavedEvent;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\VettingTypeHint;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettingTypeHintRepository;
@@ -32,17 +31,11 @@
*/
class VettingTypeHintProjector extends Projector
{
- /**
- * @var VettingTypeHintRepository
- */
- private $vettingTypeHintRepository;
-
- public function __construct(VettingTypeHintRepository $vettingTypeHintRepository)
+ public function __construct(private readonly VettingTypeHintRepository $vettingTypeHintRepository)
{
- $this->vettingTypeHintRepository = $vettingTypeHintRepository;
}
- public function applyVettingTypeHintsSavedEvent(VettingTypeHintsSavedEvent $event)
+ public function applyVettingTypeHintsSavedEvent(VettingTypeHintsSavedEvent $event): void
{
$entity = $this->vettingTypeHintRepository->find($event->institution);
if (!$entity) {
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/WhitelistProjector.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/WhitelistProjector.php
index 959ece9b7..e08240a44 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/WhitelistProjector.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/WhitelistProjector.php
@@ -28,23 +28,11 @@
class WhitelistProjector extends Projector
{
- /**
- * @var WhitelistEntryRepository
- */
- private $whitelistEntryRepository;
-
- /**
- * @param WhitelistEntryRepository $whitelistRepository
- */
- public function __construct(WhitelistEntryRepository $whitelistRepository)
+ public function __construct(private readonly WhitelistEntryRepository $whitelistEntryRepository)
{
- $this->whitelistEntryRepository = $whitelistRepository;
}
- /**
- * @param WhitelistCreatedEvent $event
- */
- protected function applyWhitelistCreatedEvent(WhitelistCreatedEvent $event)
+ protected function applyWhitelistCreatedEvent(WhitelistCreatedEvent $event): void
{
$whitelistEntries = [];
foreach ($event->whitelistedInstitutions as $institution) {
@@ -54,10 +42,7 @@ protected function applyWhitelistCreatedEvent(WhitelistCreatedEvent $event)
$this->whitelistEntryRepository->saveEntries($whitelistEntries);
}
- /**
- * @param WhitelistReplacedEvent $event
- */
- protected function applyWhitelistReplacedEvent(WhitelistReplacedEvent $event)
+ protected function applyWhitelistReplacedEvent(WhitelistReplacedEvent $event): void
{
$this->whitelistEntryRepository->removeAll();
@@ -69,10 +54,7 @@ protected function applyWhitelistReplacedEvent(WhitelistReplacedEvent $event)
$this->whitelistEntryRepository->saveEntries($whitelistEntries);
}
- /**
- * @param InstitutionsAddedToWhitelistEvent $event
- */
- protected function applyInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhitelistEvent $event)
+ protected function applyInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhitelistEvent $event): void
{
$whitelistEntries = [];
foreach ($event->addedInstitutions as $institution) {
@@ -82,10 +64,7 @@ protected function applyInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhi
$this->whitelistEntryRepository->saveEntries($whitelistEntries);
}
- /**
- * @param InstitutionsRemovedFromWhitelistEvent $event
- */
- protected function applyInstitutionsRemovedFromWhitelistEvent(InstitutionsRemovedFromWhitelistEvent $event)
+ protected function applyInstitutionsRemovedFromWhitelistEvent(InstitutionsRemovedFromWhitelistEvent $event): void
{
$institutions = [];
foreach ($event->removedInstitutions as $institution) {
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/AbstractQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/AbstractQuery.php
index 0c23d2da7..f64e21e2e 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/AbstractQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/AbstractQuery.php
@@ -23,10 +23,10 @@ abstract class AbstractQuery
/**
* @var int
*/
- public $pageNumber;
+ public int $pageNumber;
/**
* @var int
*/
- public $itemsPerPage = 25;
+ public int $itemsPerPage = 25;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/IdentityQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/IdentityQuery.php
index 2ca424a40..aba44360e 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/IdentityQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/IdentityQuery.php
@@ -18,25 +18,27 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Query;
+use Surfnet\Stepup\Identity\Value\Institution;
+
class IdentityQuery extends AbstractQuery
{
/**
* @var string
*/
- public $nameId;
+ public ?string $nameId = null;
/**
* @var string
*/
- public $commonName;
+ public ?string $commonName = null;
/**
- * @var string|\Surfnet\Stepup\Identity\Value\Institution
+ * @var string|Institution
*/
- public $institution;
+ public string|Institution $institution;
/**
* @var string
*/
- public $email;
+ public ?string $email = null;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaCandidateQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaCandidateQuery.php
index 4c80dc64e..851593132 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaCandidateQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaCandidateQuery.php
@@ -18,37 +18,23 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Query;
+use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Value\InstitutionAuthorizationContextInterface;
class RaCandidateQuery extends AbstractQuery
{
- /**
- * @var string|\Surfnet\Stepup\Identity\Value\Institution
- */
- public $institution;
+ public string|Institution|null $institution = null;
- /**
- * @var string
- */
- public $commonName;
+ public ?string $commonName = null;
- /**
- * @var string
- */
- public $email;
+ public ?string $email = null;
/**
* @var string[]
*/
- public $secondFactorTypes;
+ public array $secondFactorTypes = [];
- /**
- * @var string|\Surfnet\Stepup\Identity\Value\Institution
- */
- public $raInstitution;
+ public string|Institution|null $raInstitution = null;
- /**
- * @var InstitutionAuthorizationContextInterface
- */
- public $authorizationContext;
+ public InstitutionAuthorizationContextInterface $authorizationContext;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaListingQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaListingQuery.php
index 4b92455cd..abfa6eece 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaListingQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaListingQuery.php
@@ -19,52 +19,26 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Query;
use Surfnet\Stepup\Identity\Value\IdentityId;
+use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Value\InstitutionAuthorizationContextInterface;
class RaListingQuery extends AbstractQuery
{
- /**
- * @var string|\Surfnet\Stepup\Identity\Value\Institution
- */
- public $institution;
+ public string|Institution|null $institution = null;
- /**
- * @var IdentityId
- */
- public $identityId;
+ public ?IdentityId $identityId = null;
- /**
- * @var string|null
- */
- public $name;
+ public ?string $name = null;
- /**
- * @var string|null
- */
- public $email;
+ public ?string $email = null;
- /**
- * @var string|null
- */
- public $role;
+ public ?string $role = null;
- /**
- * @var string|null
- */
- public $raInstitution;
+ public ?string $raInstitution = null;
- /**
- * @var string
- */
- public $orderBy;
+ public string $orderBy;
- /**
- * @var string
- */
- public $orderDirection;
+ public string $orderDirection;
- /**
- * @var InstitutionAuthorizationContextInterface
- */
- public $authorizationContext;
+ public InstitutionAuthorizationContextInterface $authorizationContext;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaSecondFactorQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaSecondFactorQuery.php
index 050f6d11f..7c26d277d 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaSecondFactorQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaSecondFactorQuery.php
@@ -22,48 +22,30 @@
final class RaSecondFactorQuery extends AbstractQuery
{
- /**
- * @var string|null
- */
- public $name;
+ public ?string $name = null;
- /**
- * @var string|null
- */
- public $type;
+ public ?string $type = null;
- /**
- * @var string|null The second factor type's ID (eg. Yubikey public ID)
+ /*
+ * The second factor type's ID (eg. Yubikey public ID)
*/
- public $secondFactorId;
+ public ?string $secondFactorId = null;
- /**
- * @var string|null
- */
- public $email;
+ public ?string $email = null;
- /**
- * @var string|null the filter value, not to be confused with the actorInstitution which is used for authorizations.
+ /*
+ * the filter value, not to be confused with the actorInstitution which is used for authorizations.
*/
- public $institution;
+ public ?string $institution = null;
- /**
- * @var string|null One of the ApiBundle\Identity\Entity\RaSecondFactor::STATUS_* constants.
+ /*
+ * One of the ApiBundle\Identity\Entity\RaSecondFactor::STATUS_* constants.
*/
- public $status;
+ public ?string $status = null;
- /**
- * @var string|null
- */
- public $orderBy;
+ public ?string $orderBy = null;
- /**
- * @var string|null
- */
- public $orderDirection;
+ public ?string $orderDirection = null;
- /**
- * @var InstitutionAuthorizationContextInterface
- */
- public $authorizationContext;
+ public InstitutionAuthorizationContextInterface $authorizationContext;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaaQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaaQuery.php
index d1ec1fc95..85da685e5 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaaQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RaaQuery.php
@@ -18,15 +18,17 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Query;
+use Surfnet\Stepup\Identity\Value\Institution;
+
class RaaQuery extends AbstractQuery
{
/**
- * @var string|\Surfnet\Stepup\Identity\Value\Institution
+ * @var string|Institution
*/
- public $institution;
+ public string|Institution $institution;
/**
* @var string
*/
- public $nameId;
+ public string|null $nameId;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RecoveryTokenQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RecoveryTokenQuery.php
index 46dfb981a..713c64be2 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RecoveryTokenQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/RecoveryTokenQuery.php
@@ -23,48 +23,21 @@
class RecoveryTokenQuery extends AbstractQuery
{
- /**
- * @var IdentityId
- */
- public $identityId;
+ public ?IdentityId $identityId = null;
- /**
- * @var string|null
- */
- public $type;
+ public ?string $type = null;
- /**
- * @var string|null
- */
- public $status;
+ public ?string $status = null;
- /**
- * @var string|null
- */
- public $institution;
+ public ?string $institution = null;
- /**
- * @var string|null
- */
- public $name;
+ public ?string $name = null;
- /**
- * @var string|null
- */
- public $email;
+ public ?string $email = null;
- /**
- * @var string|null
- */
- public $orderBy;
+ public ?string $orderBy = null;
- /**
- * @var string|null
- */
- public $orderDirection;
+ public ?string $orderDirection = null;
- /**
- * @var InstitutionAuthorizationContextInterface
- */
- public $authorizationContext;
+ public ?InstitutionAuthorizationContextInterface $authorizationContext = null;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/SecondFactorAuditLogQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/SecondFactorAuditLogQuery.php
index d03f1ab4f..f7e2fb3ef 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/SecondFactorAuditLogQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/SecondFactorAuditLogQuery.php
@@ -26,20 +26,20 @@ final class SecondFactorAuditLogQuery extends AbstractQuery
/**
* @var Institution
*/
- public $identityInstitution;
+ public Institution $identityInstitution;
/**
* @var IdentityId
*/
- public $identityId;
+ public IdentityId $identityId;
/**
* @var string
*/
- public $orderBy = 'recordedOn';
+ public string $orderBy = 'recordedOn';
/**
* @var string
*/
- public $orderDirection = 'desc';
+ public string $orderDirection = 'desc';
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/UnverifiedSecondFactorQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/UnverifiedSecondFactorQuery.php
index 59bfb3224..45d7327fb 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/UnverifiedSecondFactorQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/UnverifiedSecondFactorQuery.php
@@ -22,13 +22,10 @@
class UnverifiedSecondFactorQuery extends AbstractQuery
{
- /**
- * @var IdentityId
- */
- public $identityId;
+ public ?IdentityId $identityId = null;
/**
* @var string|null
*/
- public $verificationNonce;
+ public ?string $verificationNonce = null;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VerifiedSecondFactorOfIdentityQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VerifiedSecondFactorOfIdentityQuery.php
index 42fe3fb56..fb5775f15 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VerifiedSecondFactorOfIdentityQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VerifiedSecondFactorOfIdentityQuery.php
@@ -22,8 +22,5 @@
class VerifiedSecondFactorOfIdentityQuery extends AbstractQuery
{
- /**
- * @var IdentityId|null
- */
- public $identityId;
+ public ?IdentityId $identityId = null;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VerifiedSecondFactorQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VerifiedSecondFactorQuery.php
index bf19570e2..f8a9b2e1a 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VerifiedSecondFactorQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VerifiedSecondFactorQuery.php
@@ -24,23 +24,14 @@
class VerifiedSecondFactorQuery extends AbstractQuery
{
- /**
- * @var IdentityId|null
- */
- public $identityId;
+ public ?IdentityId $identityId = null;
- /**
- * @var SecondFactorId|null
- */
- public $secondFactorId;
+ public ?SecondFactorId $secondFactorId = null;
- /**
- * @var string|null
- */
- public $registrationCode;
+ public ?string $registrationCode = null;
/**
* @var InstitutionAuthorizationContext
*/
- public $authorizationContext;
+ public InstitutionAuthorizationContext $authorizationContext;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VettedSecondFactorQuery.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VettedSecondFactorQuery.php
index 727e20d3c..d8d1cad7c 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VettedSecondFactorQuery.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Query/VettedSecondFactorQuery.php
@@ -22,8 +22,5 @@
class VettedSecondFactorQuery extends AbstractQuery
{
- /**
- * @var IdentityId
- */
- public $identityId;
+ public ?IdentityId $identityId = null;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuditLogRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuditLogRepository.php
index 38bc03950..0642c7947 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuditLogRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuditLogRepository.php
@@ -19,13 +19,47 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\Query;
+use Doctrine\Persistence\ManagerRegistry;
+use Surfnet\Stepup\Identity\Event\AppointedAsRaaEvent;
+use Surfnet\Stepup\Identity\Event\AppointedAsRaaForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\AppointedAsRaEvent;
+use Surfnet\Stepup\Identity\Event\AppointedAsRaForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\CompliedWithRecoveryCodeRevocationEvent;
+use Surfnet\Stepup\Identity\Event\CompliedWithUnverifiedSecondFactorRevocationEvent;
+use Surfnet\Stepup\Identity\Event\CompliedWithVerifiedSecondFactorRevocationEvent;
+use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
+use Surfnet\Stepup\Identity\Event\EmailVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\GssfPossessionProvenAndVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\GssfPossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaEvent;
+use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaEvent;
+use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\PhonePossessionProvenAndVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\PhonePossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\PhoneRecoveryTokenPossessionProvenEvent;
+use Surfnet\Stepup\Identity\Event\RecoveryTokenRevokedEvent;
+use Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedEvent;
+use Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedForInstitutionEvent;
+use Surfnet\Stepup\Identity\Event\SafeStoreSecretRecoveryTokenPossessionPromisedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorMigratedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorMigratedToEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession;
+use Surfnet\Stepup\Identity\Event\UnverifiedSecondFactorRevokedEvent;
+use Surfnet\Stepup\Identity\Event\VerifiedSecondFactorRevokedEvent;
+use Surfnet\Stepup\Identity\Event\VettedSecondFactorRevokedEvent;
+use Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenAndVerifiedEvent;
+use Surfnet\Stepup\Identity\Event\YubikeySecondFactorBootstrappedEvent;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\StepupMiddleware\ApiBundle\Exception\RuntimeException;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\AuditLogEntry;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\SecondFactorAuditLogQuery;
+/**
+ * @extends ServiceEntityRepository
+ */
class AuditLogRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -38,47 +72,45 @@ public function __construct(ManagerRegistry $registry)
*
* @var string[]
*/
- private static $secondFactorEvents = [
- 'Surfnet\Stepup\Identity\Event\YubikeySecondFactorBootstrappedEvent',
- 'Surfnet\Stepup\Identity\Event\GssfPossessionProvenEvent',
- 'Surfnet\Stepup\Identity\Event\PhonePossessionProvenEvent',
- 'Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenAndVerifiedEvent',
- 'Surfnet\Stepup\Identity\Event\GssfPossessionProvenAndVerifiedEvent',
- 'Surfnet\Stepup\Identity\Event\PhonePossessionProvenAndVerifiedEvent',
- 'Surfnet\Stepup\Identity\Event\EmailVerifiedEvent',
- 'Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent',
- 'Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession',
- 'Surfnet\Stepup\Identity\Event\SecondFactorMigratedEvent',
- 'Surfnet\Stepup\Identity\Event\SecondFactorMigratedToEvent',
- 'Surfnet\Stepup\Identity\Event\UnverifiedSecondFactorRevokedEvent',
- 'Surfnet\Stepup\Identity\Event\VerifiedSecondFactorRevokedEvent',
- 'Surfnet\Stepup\Identity\Event\VettedSecondFactorRevokedEvent',
- 'Surfnet\Stepup\Identity\Event\CompliedWithUnverifiedSecondFactorRevocationEvent',
- 'Surfnet\Stepup\Identity\Event\CompliedWithVerifiedSecondFactorRevocationEvent',
- 'Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent',
- 'Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaEvent',
- 'Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaEvent',
- 'Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaForInstitutionEvent',
- 'Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaaForInstitutionEvent',
- 'Surfnet\Stepup\Identity\Event\AppointedAsRaaEvent',
- 'Surfnet\Stepup\Identity\Event\AppointedAsRaForInstitutionEvent',
- 'Surfnet\Stepup\Identity\Event\AppointedAsRaaForInstitutionEvent',
- 'Surfnet\Stepup\Identity\Event\AppointedAsRaEvent',
- 'Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedEvent',
- 'Surfnet\Stepup\Identity\Event\RegistrationAuthorityRetractedForInstitutionEvent',
- 'Surfnet\Stepup\Identity\Event\SafeStoreSecretRecoveryTokenPossessionPromisedEvent',
- 'Surfnet\Stepup\Identity\Event\RecoveryTokenRevokedEvent',
- 'Surfnet\Stepup\Identity\Event\PhoneRecoveryTokenPossessionProvenEvent',
- 'Surfnet\Stepup\Identity\Event\CompliedWithRecoveryCodeRevocationEvent',
+ private static array $secondFactorEvents = [
+ YubikeySecondFactorBootstrappedEvent::class,
+ GssfPossessionProvenEvent::class,
+ PhonePossessionProvenEvent::class,
+ YubikeyPossessionProvenAndVerifiedEvent::class,
+ GssfPossessionProvenAndVerifiedEvent::class,
+ PhonePossessionProvenAndVerifiedEvent::class,
+ EmailVerifiedEvent::class,
+ SecondFactorVettedEvent::class,
+ SecondFactorVettedWithoutTokenProofOfPossession::class,
+ SecondFactorMigratedEvent::class,
+ SecondFactorMigratedToEvent::class,
+ UnverifiedSecondFactorRevokedEvent::class,
+ VerifiedSecondFactorRevokedEvent::class,
+ VettedSecondFactorRevokedEvent::class,
+ CompliedWithUnverifiedSecondFactorRevocationEvent::class,
+ CompliedWithVerifiedSecondFactorRevocationEvent::class,
+ CompliedWithVettedSecondFactorRevocationEvent::class,
+ IdentityAccreditedAsRaaEvent::class,
+ IdentityAccreditedAsRaEvent::class,
+ IdentityAccreditedAsRaForInstitutionEvent::class,
+ IdentityAccreditedAsRaaForInstitutionEvent::class,
+ AppointedAsRaaEvent::class,
+ AppointedAsRaForInstitutionEvent::class,
+ AppointedAsRaaForInstitutionEvent::class,
+ AppointedAsRaEvent::class,
+ RegistrationAuthorityRetractedEvent::class,
+ RegistrationAuthorityRetractedForInstitutionEvent::class,
+ SafeStoreSecretRecoveryTokenPossessionPromisedEvent::class,
+ RecoveryTokenRevokedEvent::class,
+ PhoneRecoveryTokenPossessionProvenEvent::class,
+ CompliedWithRecoveryCodeRevocationEvent::class,
];
/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity) - The filtering switch triggers the CyclomaticComplexity, it does
* not actually make the class complex or hard to maintain.
- * @param SecondFactorAuditLogQuery $query
- * @return Query
*/
- public function createSecondFactorSearchQuery(SecondFactorAuditLogQuery $query)
+ public function createSecondFactorSearchQuery(SecondFactorAuditLogQuery $query): Query
{
$queryBuilder = $this
->createQueryBuilder('al')
@@ -89,31 +121,28 @@ public function createSecondFactorSearchQuery(SecondFactorAuditLogQuery $query)
->setParameter('identityId', $query->identityId)
->setParameter('secondFactorEvents', self::$secondFactorEvents);
- switch ($query->orderBy) {
- case 'secondFactorType':
- case 'secondFactorIdentifier':
- case 'recoveryTokenType':
- case 'recoveryTokenIdentifier':
- case 'recordedOn':
- case 'actorCommonName':
- case 'actorInstitution':
- $queryBuilder->orderBy(
- sprintf('al.%s', $query->orderBy),
- $query->orderDirection === 'desc' ? 'DESC' : 'ASC'
- );
- break;
- default:
- throw new RuntimeException(sprintf('Unknown order by column "%s"', $query->orderBy));
- }
+ match ($query->orderBy) {
+ 'secondFactorType',
+ 'secondFactorIdentifier',
+ 'recoveryTokenType',
+ 'recoveryTokenIdentifier',
+ 'recordedOn',
+ 'actorCommonName',
+ 'actorInstitution'
+ => $queryBuilder->orderBy(
+ sprintf('al.%s', $query->orderBy),
+ $query->orderDirection === 'desc' ? 'DESC' : 'ASC',
+ ),
+ default => throw new RuntimeException(sprintf('Unknown order by column "%s"', $query->orderBy)),
+ };
return $queryBuilder->getQuery();
}
/**
- * @param IdentityId $actorId
* @return AuditLogEntry[]
*/
- public function findEntriesWhereIdentityIsActorOnly(IdentityId $actorId)
+ public function findEntriesWhereIdentityIsActorOnly(IdentityId $actorId): array
{
return $this->createQueryBuilder('al')
->where('al.actorId = :actorId')
@@ -124,10 +153,9 @@ public function findEntriesWhereIdentityIsActorOnly(IdentityId $actorId)
}
/**
- * @param IdentityId $actorId
* @return AuditLogEntry[]
*/
- public function findByIdentityId(IdentityId $identityId)
+ public function findByIdentityId(IdentityId $identityId): array
{
return $this->createQueryBuilder('al')
->where('al.identityId = :identityId')
@@ -136,17 +164,14 @@ public function findByIdentityId(IdentityId $identityId)
->getResult();
}
- /**
- * @param AuditLogEntry $entry
- */
- public function save(AuditLogEntry $entry)
+ public function save(AuditLogEntry $entry): void
{
$entityManager = $this->getEntityManager();
$entityManager->persist($entry);
$entityManager->flush();
}
- public function saveAll(array $entries)
+ public function saveAll(array $entries): void
{
$entityManager = $this->getEntityManager();
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuthorizationRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuthorizationRepository.php
index 8d20c2e5f..c141be035 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuthorizationRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuthorizationRepository.php
@@ -19,8 +19,8 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\Query\Expr\Join;
+use Doctrine\Persistence\ManagerRegistry;
use Psr\Log\LoggerInterface;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
use Surfnet\Stepup\Identity\Collection\InstitutionCollection;
@@ -29,6 +29,7 @@
use Surfnet\Stepup\Identity\Value\RegistrationAuthorityRole;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\ConfiguredInstitution;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionAuthorization;
+use Surfnet\StepupMiddleware\ApiBundle\Exception\RuntimeException;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\AuditLogEntry;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing;
@@ -36,18 +37,15 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @extends ServiceEntityRepository
*/
class AuthorizationRepository extends ServiceEntityRepository
{
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- public function __construct(ManagerRegistry $registry, LoggerInterface $logger)
- {
+ public function __construct(
+ ManagerRegistry $registry,
+ private readonly LoggerInterface $logger,
+ ) {
parent::__construct($registry, AuditLogEntry::class);
- $this->logger = $logger;
}
/**
@@ -56,10 +54,10 @@ public function __construct(ManagerRegistry $registry, LoggerInterface $logger)
*
* @return InstitutionCollection
*/
- public function getInstitutionsForRole(RegistrationAuthorityRole $role, IdentityId $actorId) :InstitutionCollection
+ public function getInstitutionsForRole(RegistrationAuthorityRole $role, IdentityId $actorId): InstitutionCollection
{
$result = new InstitutionCollection();
- $qb = $this->_em->createQueryBuilder()
+ $qb = $this->getEntityManager()->createQueryBuilder()
->select("a.institution")
->from(ConfiguredInstitution::class, 'i')
->innerJoin(RaListing::class, 'r', Join::WITH, "i.institution = r.raInstitution")
@@ -67,7 +65,7 @@ public function getInstitutionsForRole(RegistrationAuthorityRole $role, Identity
InstitutionAuthorization::class,
'a',
Join::WITH,
- "i.institution = a.institutionRelation AND a.institutionRole IN (:authorizationRoles)"
+ "i.institution = a.institutionRelation AND a.institutionRole IN (:authorizationRoles)",
)
->where("r.identityId = :identityId AND r.role IN(:roles)")
->groupBy("a.institution");
@@ -75,18 +73,18 @@ public function getInstitutionsForRole(RegistrationAuthorityRole $role, Identity
$qb->setParameter('identityId', (string)$actorId);
$qb->setParameter(
'authorizationRoles',
- $this->getAllowedInstitutionRoles($role)
+ $this->getAllowedInstitutionRoles($role),
);
$identityRoles = $this->getAllowedIdentityRoles($role);
$qb->setParameter(
'roles',
- $identityRoles
+ $identityRoles,
);
$institutions = $qb->getQuery()->getArrayResult();
foreach ($institutions as $institution) {
$this->logger->notice(
- sprintf('Adding %s to authorized institutions', $institution['institution'])
+ sprintf('Adding %s to authorized institutions', $institution['institution']),
);
$result->add(new Institution((string)$institution['institution']));
}
@@ -94,13 +92,18 @@ public function getInstitutionsForRole(RegistrationAuthorityRole $role, Identity
// Also get the institutions that are linked to the user via the 'institution_relation' field.
// Effectively getting the use_raa relation.
// See https://www.pivotaltracker.com/story/show/181537313
- $qb = $this->_em->createQueryBuilder()
+ $qb = $this->getEntityManager()->createQueryBuilder()
->select('ia.institution')
->from(InstitutionAuthorization::class, 'ia')
// Filter the RA listing on the authorizations that apply for the RA(A) listed there
// For example, when testing a USE_RA institution authorization, the listed RA should have
// at least a RA or RAA role
- ->join(RaListing::class, 'r', Join::WITH, 'r.raInstitution = ia.institutionRelation AND r.role IN (:identityRoles)')
+ ->join(
+ RaListing::class,
+ 'r',
+ Join::WITH,
+ 'r.raInstitution = ia.institutionRelation AND r.role IN (:identityRoles)',
+ )
->where('r.identityId = :identityId')
->andWhere("ia.institutionRole = :role") // Only filter on use_ra and use_raa roles here.
->groupBy('ia.institution');
@@ -115,7 +118,11 @@ public function getInstitutionsForRole(RegistrationAuthorityRole $role, Identity
if (!$result->contains($institutionVo)) {
$result->add($institutionVo);
$this->logger->notice(
- sprintf('Adding %s to authorized institutions from %s', $role->getType(), $institution['institution'])
+ sprintf(
+ 'Adding %s to authorized institutions from %s',
+ $role,
+ $institution['institution'],
+ ),
);
}
}
@@ -127,9 +134,9 @@ public function getInstitutionsForRole(RegistrationAuthorityRole $role, Identity
* Finds the institutions that have the Select RAA authorization based on
* the institution of the specified identity.
*/
- public function getInstitutionsForSelectRaaRole(IdentityId $actorId)
+ public function getInstitutionsForSelectRaaRole(IdentityId $actorId): InstitutionCollection
{
- $qb = $this->_em->createQueryBuilder()
+ $qb = $this->getEntityManager()->createQueryBuilder()
->select("ci.institution")
->from(InstitutionAuthorization::class, 'ia')
->innerJoin(ConfiguredInstitution::class, 'ci', Join::WITH, 'ia.institutionRelation = ci.institution')
@@ -142,12 +149,12 @@ public function getInstitutionsForSelectRaaRole(IdentityId $actorId)
// The identity requires RAA role to perform this search
$qb->setParameter(
'authorizationRole',
- AuthorityRole::ROLE_RAA
+ AuthorityRole::ROLE_RAA,
);
// Filter on the SELECT_RAA authorization in the institution authorization projection
$qb->setParameter(
'institutionRole',
- InstitutionRole::ROLE_SELECT_RAA
+ InstitutionRole::ROLE_SELECT_RAA,
);
$institutions = $qb->getQuery()->getArrayResult();
@@ -167,14 +174,11 @@ public function getInstitutionsForSelectRaaRole(IdentityId $actorId)
*/
private function getAllowedInstitutionRoles(RegistrationAuthorityRole $role): array
{
- switch (true) {
- case $role->equals(RegistrationAuthorityRole::ra()):
- return [InstitutionRole::ROLE_USE_RA];
- case $role->equals(RegistrationAuthorityRole::raa()):
- return [InstitutionRole::ROLE_USE_RAA];
- default:
- return [];
- }
+ return match (true) {
+ $role->equals(RegistrationAuthorityRole::ra()) => [InstitutionRole::ROLE_USE_RA],
+ $role->equals(RegistrationAuthorityRole::raa()) => [InstitutionRole::ROLE_USE_RAA],
+ default => [],
+ };
}
/**
@@ -185,23 +189,27 @@ private function getAllowedInstitutionRoles(RegistrationAuthorityRole $role): ar
*/
private function getAllowedIdentityRoles(RegistrationAuthorityRole $role): array
{
- switch (true) {
- case $role->equals(RegistrationAuthorityRole::ra()):
- return [AuthorityRole::ROLE_RA, AuthorityRole::ROLE_RAA];
- case $role->equals(RegistrationAuthorityRole::raa()):
- return [AuthorityRole::ROLE_RAA];
- default:
- return [];
- }
+ return match (true) {
+ $role->equals(RegistrationAuthorityRole::ra()) => [AuthorityRole::ROLE_RA, AuthorityRole::ROLE_RAA],
+ $role->equals(RegistrationAuthorityRole::raa()) => [AuthorityRole::ROLE_RAA],
+ default => [],
+ };
}
private function getInstitutionRoleByRaRole(RegistrationAuthorityRole $role): string
{
- switch (true) {
- case $role->equals(RegistrationAuthorityRole::ra()):
- return AuthorityRole::ROLE_RA;
- case $role->equals(RegistrationAuthorityRole::raa()):
- return AuthorityRole::ROLE_RAA;
+ if ($role->equals(RegistrationAuthorityRole::ra())) {
+ return AuthorityRole::ROLE_RA;
+ }
+ if ($role->equals(RegistrationAuthorityRole::raa())) {
+ return AuthorityRole::ROLE_RAA;
}
+
+ throw new RuntimeException(
+ sprintf(
+ 'The role "%s did not match any of our supported AuthorityRoles (ra, raa)',
+ $role->jsonSerialize()
+ )
+ );
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/IdentityRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/IdentityRepository.php
index 28a026f8e..16e84b468 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/IdentityRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/IdentityRepository.php
@@ -20,34 +20,26 @@
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Collections\ArrayCollection;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\ORM\Query;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\NameId;
-use Surfnet\StepupMiddleware\ApiBundle\Authorization\Filter\InstitutionAuthorizationRepositoryFilter;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\IdentityQuery;
+/**
+ * @extends ServiceEntityRepository
+ */
class IdentityRepository extends ServiceEntityRepository
{
- /**
- * @var InstitutionAuthorizationRepositoryFilter
- */
- private $authorizationRepositoryFilter;
-
- public function __construct(ManagerRegistry $registry, InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter)
- {
+ public function __construct(
+ ManagerRegistry $registry,
+ ) {
parent::__construct($registry, Identity::class);
- $this->authorizationRepositoryFilter = $authorizationRepositoryFilter;
}
- /**
- * @param string $id
- * @param null $lockMode
- * @param null $lockVersion
- * @return Identity|null
- */
- public function find($id, $lockMode = null, $lockVersion = null)
+ public function find(mixed $id, $lockMode = null, $lockVersion = null): ?Identity
{
/** @var Identity|null $identity */
$identity = parent::find($id);
@@ -55,10 +47,7 @@ public function find($id, $lockMode = null, $lockVersion = null)
return $identity;
}
- /**
- * @param Identity $identity
- */
- public function save(Identity $identity)
+ public function save(Identity $identity): void
{
$entityManager = $this->getEntityManager();
$entityManager->persist($identity);
@@ -66,12 +55,11 @@ public function save(Identity $identity)
}
/**
- * @param IdentityQuery $query
- * @return \Doctrine\ORM\Query
+ * @return Query
*/
public function createSearchQuery(
- IdentityQuery $query
- ) {
+ IdentityQuery $query,
+ ): Query {
$queryBuilder = $this->createQueryBuilder('i');
if ($query->institution) {
@@ -105,11 +93,11 @@ public function createSearchQuery(
* @param string[] $nameIds
* @return Identity[] Indexed by NameID.
*/
- public function findByNameIdsIndexed(array $nameIds)
+ public function findByNameIdsIndexed(array $nameIds): array
{
return $this->getEntityManager()->createQueryBuilder()
->select('i')
- ->from('Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity', 'i', 'i.nameId')
+ ->from(Identity::class, 'i', 'i.nameId')
->where('i.nameId IN (:nameIds)')
->setParameter('nameIds', $nameIds)
->getQuery()
@@ -117,12 +105,10 @@ public function findByNameIdsIndexed(array $nameIds)
}
/**
- * @param NameId $nameId
- * @param Institution $institution
*
* @return bool
*/
- public function hasIdentityWithNameIdAndInstitution(NameId $nameId, Institution $institution)
+ public function hasIdentityWithNameIdAndInstitution(NameId $nameId, Institution $institution): bool
{
$identityCount = $this->createQueryBuilder('i')
->select('COUNT(i.id)')
@@ -137,46 +123,21 @@ public function hasIdentityWithNameIdAndInstitution(NameId $nameId, Institution
}
/**
- * @param NameId $nameId
- * @param Institution $institution
* @return Identity
*/
- public function findOneByNameIdAndInstitution(NameId $nameId, Institution $institution)
+ public function findOneByNameIdAndInstitution(NameId $nameId, Institution $institution): Identity
{
return $this->createQueryBuilder('i')
- ->where('i.nameId = :nameId')
- ->setParameter('nameId', $nameId->getNameId())
- ->andWhere('i.institution = :institution')
- ->setParameter('institution', $institution->getInstitution())
- ->getQuery()
- ->getSingleResult();
- }
-
- public function findOneByNameId(string $nameId) :? Identity
- {
- return $this->findOneBy(['nameId' => $nameId]);
- }
-
- public function removeByIdentityId(IdentityId $identityId)
- {
- $this->getEntityManager()->createQueryBuilder()
- ->delete($this->_entityName, 'i')
- ->where('i.id = :identityId')
- ->setParameter('identityId', $identityId->getIdentityId())
+ ->where('i.nameId = :nameId')
+ ->setParameter('nameId', $nameId->getNameId())
+ ->andWhere('i.institution = :institution')
+ ->setParameter('institution', $institution->getInstitution())
->getQuery()
- ->execute();
+ ->getSingleResult();
}
- /**
- * @param Institution $institution
- * @return ArrayCollection|Identity[]
- */
- public function findByInstitution(Institution $institution)
+ public function findOneByNameId(string $nameId): ?Identity
{
- return $this->createQueryBuilder('i')
- ->where('i.institution = :institution')
- ->setParameter('institution', $institution->getInstitution())
- ->getQuery()
- ->getResult();
+ return $this->findOneBy(['nameId' => $nameId]);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/IdentitySelfAssertedTokenOptionsRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/IdentitySelfAssertedTokenOptionsRepository.php
index 43ce4fa80..94bd56bb0 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/IdentitySelfAssertedTokenOptionsRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/IdentitySelfAssertedTokenOptionsRepository.php
@@ -19,24 +19,26 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
-use Surfnet\StepupMiddleware\ApiBundle\Authorization\Filter\InstitutionAuthorizationRepositoryFilter;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\IdentitySelfAssertedTokenOptions;
+/**
+ * @extends ServiceEntityRepository
+ */
class IdentitySelfAssertedTokenOptionsRepository extends ServiceEntityRepository
{
- public function __construct(ManagerRegistry $registry, InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter)
- {
+ public function __construct(
+ ManagerRegistry $registry,
+ ) {
parent::__construct($registry, IdentitySelfAssertedTokenOptions::class);
- $this->authorizationRepositoryFilter = $authorizationRepositoryFilter;
}
- public function find($id, $lockMode = null, $lockVersion = null)
+ public function find(mixed $id, $lockMode = null, $lockVersion = null): ?IdentitySelfAssertedTokenOptions
{
return parent::find($id);
}
- public function save(IdentitySelfAssertedTokenOptions $options)
+ public function save(IdentitySelfAssertedTokenOptions $options): void
{
$entityManager = $this->getEntityManager();
$entityManager->persist($options);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/InstitutionListingRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/InstitutionListingRepository.php
index 38c0d8b1b..909decef4 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/InstitutionListingRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/InstitutionListingRepository.php
@@ -19,13 +19,15 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Identity\Value\Institution;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\InstitutionListing;
/**
* @deprecated This could probably be removed and is only used in migrations
* @see app/DoctrineMigrations/Version20160719090052.php#L51
+ * @extends ServiceEntityRepository
*/
class InstitutionListingRepository extends ServiceEntityRepository
{
@@ -34,13 +36,13 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, InstitutionListing::class);
}
- public function save(InstitutionListing $institution)
+ public function save(InstitutionListing $institution): void
{
$this->getEntityManager()->persist($institution);
$this->getEntityManager()->flush();
}
- public function addIfNotExists(Institution $institution)
+ public function addIfNotExists(Institution $institution): void
{
$existsQuery = $this->createQueryBuilder('i')
->where('i.institution = :institution')
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaCandidateRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaCandidateRepository.php
index 24802dba0..47576a71b 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaCandidateRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaCandidateRepository.php
@@ -19,8 +19,10 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\ORM\Query;
use Doctrine\ORM\Query\Expr\Join;
+use Doctrine\ORM\QueryBuilder;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Identity\Value\VettingType;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Filter\InstitutionAuthorizationRepositoryFilter;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionAuthorization;
@@ -33,25 +35,21 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
+ * @extends ServiceEntityRepository
*/
class RaCandidateRepository extends ServiceEntityRepository
{
- /**
- * @var InstitutionAuthorizationRepositoryFilter
- */
- private $authorizationRepositoryFilter;
-
- public function __construct(ManagerRegistry $registry, InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter)
- {
+ public function __construct(
+ ManagerRegistry $registry,
+ private readonly InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter,
+ ) {
parent::__construct($registry, RaCandidate::class);
- $this->authorizationRepositoryFilter = $authorizationRepositoryFilter;
}
/**
- * @param RaCandidateQuery $query
- * @return \Doctrine\ORM\Query
+ * @return Query
*/
- public function createSearchQuery(RaCandidateQuery $query)
+ public function createSearchQuery(RaCandidateQuery $query): Query
{
$queryBuilder = $this->getBaseQuery();
@@ -63,7 +61,7 @@ public function createSearchQuery(RaCandidateQuery $query)
$queryBuilder,
$query->authorizationContext,
'i.institution',
- 'iac'
+ 'iac',
);
if ($query->institution) {
@@ -72,19 +70,19 @@ public function createSearchQuery(RaCandidateQuery $query)
->setParameter('institution', $query->institution);
}
- if ($query->commonName) {
+ if ($query->commonName !== '' && $query->commonName !== '0') {
$queryBuilder
->andWhere('i.commonName LIKE :commonName')
->setParameter('commonName', sprintf('%%%s%%', $query->commonName));
}
- if ($query->email) {
+ if ($query->email !== '' && $query->email !== '0') {
$queryBuilder
->andWhere('i.email LIKE :email')
->setParameter('email', sprintf('%%%s%%', $query->email));
}
- if (!empty($query->secondFactorTypes)) {
+ if (isset($query->secondFactorTypes) && $query->secondFactorTypes !== []) {
$queryBuilder
->andWhere('vsf.type IN (:secondFactorTypes)')
->setParameter('secondFactorTypes', $query->secondFactorTypes);
@@ -108,10 +106,9 @@ public function createSearchQuery(RaCandidateQuery $query)
}
/**
- * @param RaCandidateQuery $query
- * @return \Doctrine\ORM\Query
+ * @return Query
*/
- public function createOptionsQuery(RaCandidateQuery $query)
+ public function createOptionsQuery(RaCandidateQuery $query): Query
{
$queryBuilder = $this->getEntityManager()->createQueryBuilder()
->select('a.institution')
@@ -126,7 +123,7 @@ public function createOptionsQuery(RaCandidateQuery $query)
$queryBuilder,
$query->authorizationContext,
'a.institution',
- 'iac'
+ 'iac',
);
return $queryBuilder->getQuery();
@@ -135,7 +132,7 @@ public function createOptionsQuery(RaCandidateQuery $query)
/**
* @return array|null
*/
- public function findOneByIdentityId(string $identityId)
+ public function findOneByIdentityId(string $identityId): ?array
{
// Finds a single identity by its identity id. Returns the identity as an array
$queryBuilder = $this->getBaseQuery()
@@ -148,20 +145,22 @@ public function findOneByIdentityId(string $identityId)
}
/**
- * @return \Doctrine\ORM\QueryBuilder
+ * @return QueryBuilder
*/
- private function getBaseQuery()
+ private function getBaseQuery(): QueryBuilder
{
// Base query to get all allowed ra candidates
$queryBuilder = $this->getEntityManager()->createQueryBuilder()
- ->select('i.id as identity_id, i.institution, i.commonName as common_name, i.email, i.nameId AS name_id, a.institution AS ra_institution')
+ ->select(
+ 'i.id as identity_id, i.institution, i.commonName as common_name, i.email, i.nameId AS name_id, a.institution AS ra_institution',
+ )
->from(VettedSecondFactor::class, 'vsf')
->innerJoin(Identity::class, 'i', Join::WITH, "vsf.identityId = i.id")
->innerJoin(
InstitutionAuthorization::class,
'a',
Join::WITH,
- "a.institutionRole = 'select_raa' AND a.institutionRelation = i.institution"
+ "a.institutionRole = 'select_raa' AND a.institutionRelation = i.institution",
);
// Filter out candidates who are already ra
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaListingRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaListingRepository.php
index ac409511c..8515f6056 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaListingRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaListingRepository.php
@@ -20,7 +20,8 @@
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Collections\ArrayCollection;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\ORM\Query;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Filter\InstitutionAuthorizationRepositoryFilter;
@@ -31,54 +32,35 @@
/**
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
+ * @extends ServiceEntityRepository
*/
class RaListingRepository extends ServiceEntityRepository
{
- /**
- * @var InstitutionAuthorizationRepositoryFilter
- */
- private $authorizationRepositoryFilter;
-
- public function __construct(ManagerRegistry $registry, InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter)
- {
+ public function __construct(
+ ManagerRegistry $registry,
+ private readonly InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter,
+ ) {
parent::__construct($registry, RaListing::class);
- $this->authorizationRepositoryFilter = $authorizationRepositoryFilter;
}
- /**
- * @param IdentityId $identityId The RA's identity id.
- * @return null|RaListing[]
- */
- public function findByIdentityId(IdentityId $identityId)
+ public function findByIdentityId(IdentityId $identityId): ?array
{
- return parent::findBy(['identityId' => (string) $identityId]);
+ return parent::findBy(['identityId' => (string)$identityId]);
}
- /**
- * @param IdentityId $identityId The RA's identity id.
- * @param Institution $raInstitution
- * @return null|RaListing
- */
- public function findByIdentityIdAndRaInstitution(IdentityId $identityId, Institution $raInstitution)
+ public function findByIdentityIdAndRaInstitution(IdentityId $identityId, Institution $raInstitution): ?RaListing
{
return parent::findOneBy([
- 'identityId' => (string) $identityId,
- 'raInstitution' => (string) $raInstitution,
+ 'identityId' => (string)$identityId,
+ 'raInstitution' => (string)$raInstitution,
]);
}
-
- /**
- * @param IdentityId $identityId The RA's identity id.
- * @param Institution $raInstitution
- * @param InstitutionAuthorizationContextInterface $authorizationContext
- * @return null|RaListing
- */
public function findByIdentityIdAndRaInstitutionWithContext(
IdentityId $identityId,
Institution $raInstitution,
- InstitutionAuthorizationContextInterface $authorizationContext
- ) {
+ InstitutionAuthorizationContextInterface $authorizationContext,
+ ): ?RaListing {
$queryBuilder = $this->createQueryBuilder('r')
->where('r.identityId = :identityId')
->andWhere('r.raInstitution = :raInstitution')
@@ -94,26 +76,24 @@ public function findByIdentityIdAndRaInstitutionWithContext(
$queryBuilder,
$authorizationContext,
'r.raInstitution',
- 'iac'
+ 'iac',
);
return $queryBuilder->getQuery()->getOneOrNullResult();
}
/**
- * @param IdentityId $identityId The RA's identity id.
- * @param Institution $institution
* @return RaListing[]
*/
- public function findByIdentityIdAndInstitution(IdentityId $identityId, Institution $institution)
+ public function findByIdentityIdAndInstitution(IdentityId $identityId, Institution $institution): array
{
return parent::findBy([
- 'identityId' => (string) $identityId,
- 'institution' => (string) $institution,
+ 'identityId' => (string)$identityId,
+ 'institution' => (string)$institution,
]);
}
- public function save(RaListing $raListingEntry)
+ public function save(RaListing $raListingEntry): void
{
$this->getEntityManager()->persist($raListingEntry);
$this->getEntityManager()->flush();
@@ -122,11 +102,8 @@ public function save(RaListing $raListingEntry)
/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity) The amount of if statements do not necessarily make the method
* @SuppressWarnings(PHPMD.NPathComplexity) below complex or hard to maintain.
- *
- * @param RaListingQuery $query
- * @return \Doctrine\ORM\Query
*/
- public function createSearchQuery(RaListingQuery $query)
+ public function createSearchQuery(RaListingQuery $query): Query
{
$queryBuilder = $this->createQueryBuilder('r');
@@ -136,10 +113,10 @@ public function createSearchQuery(RaListingQuery $query)
->setParameter('institution', $query->institution);
}
- if ($query->identityId) {
+ if ($query->identityId instanceof IdentityId) {
$queryBuilder
->andWhere('r.identityId = :identityId')
- ->setParameter('identityId', (string) $query->identityId);
+ ->setParameter('identityId', (string)$query->identityId);
}
if ($query->name) {
@@ -157,13 +134,13 @@ public function createSearchQuery(RaListingQuery $query)
if ($query->role) {
$queryBuilder
->andWhere('r.role = :role')
- ->setParameter('role', (string) $query->role);
+ ->setParameter('role', (string)$query->role);
}
if ($query->raInstitution) {
$queryBuilder
->andWhere('r.raInstitution = :raInstitution')
- ->setParameter('raInstitution', (string) $query->raInstitution);
+ ->setParameter('raInstitution', (string)$query->raInstitution);
}
// Modify query to filter on authorization:
@@ -174,31 +151,24 @@ public function createSearchQuery(RaListingQuery $query)
$queryBuilder,
$query->authorizationContext,
'r.raInstitution',
- 'iac'
+ 'iac',
);
- if (!$query->orderBy) {
+ if ($query->orderBy === '' || $query->orderBy === '0') {
return $queryBuilder->getQuery();
}
$orderDirection = $query->orderDirection === 'asc' ? 'ASC' : 'DESC';
- switch ($query->orderBy) {
- case 'commonName':
- $queryBuilder->orderBy('r.commonName', $orderDirection);
- break;
- default:
- throw new RuntimeException(sprintf('Unknown order by column "%s"', $query->orderBy));
- }
+ match ($query->orderBy) {
+ 'commonName' => $queryBuilder->orderBy('r.commonName', $orderDirection),
+ default => throw new RuntimeException(sprintf('Unknown order by column "%s"', $query->orderBy)),
+ };
return $queryBuilder->getQuery();
}
- /**
- * @param RaListingQuery $query
- * @return \Doctrine\ORM\Query
- */
- public function createOptionsQuery(RaListingQuery $query)
+ public function createOptionsQuery(RaListingQuery $query): Query
{
$queryBuilder = $this->createQueryBuilder('r')
->select('r.institution, r.raInstitution')
@@ -212,17 +182,16 @@ public function createOptionsQuery(RaListingQuery $query)
$queryBuilder,
$query->authorizationContext,
'r.raInstitution',
- 'iac'
+ 'iac',
);
return $queryBuilder->getQuery();
}
/**
- * @param Institution $raInstitution
- * @return ArrayCollection
+ * @return ArrayCollection
*/
- public function listRasFor(Institution $raInstitution)
+ public function listRasFor(Institution $raInstitution): ArrayCollection
{
$listings = $this->createQueryBuilder('rl')
->where('rl.raInstitution = :institution')
@@ -233,14 +202,10 @@ public function listRasFor(Institution $raInstitution)
return new ArrayCollection($listings);
}
- /**
- * @param IdentityId $identityId
- * @return void
- */
- public function removeByIdentityId(IdentityId $identityId, Institution $institution)
+ public function removeByIdentityId(IdentityId $identityId, Institution $institution): void
{
$this->getEntityManager()->createQueryBuilder()
- ->delete($this->_entityName, 'ral')
+ ->delete($this->getEntityName(), 'ral')
->where('ral.identityId = :identityId')
->andWhere('ral.raInstitution = :institution')
->setParameter('identityId', $identityId->getIdentityId())
@@ -249,15 +214,10 @@ public function removeByIdentityId(IdentityId $identityId, Institution $institut
->execute();
}
- /**
- * @param IdentityId $identityId
- * @param Institution $raInstitution
- * @return void
- */
- public function removeByIdentityIdAndRaInstitution(IdentityId $identityId, Institution $raInstitution)
+ public function removeByIdentityIdAndRaInstitution(IdentityId $identityId, Institution $raInstitution): void
{
$this->getEntityManager()->createQueryBuilder()
- ->delete($this->_entityName, 'ral')
+ ->delete($this->getEntityName(), 'ral')
->where('ral.identityId = :identityId')
->andWhere('ral.raInstitution = :institution')
->setParameter('identityId', $identityId->getIdentityId())
@@ -266,15 +226,10 @@ public function removeByIdentityIdAndRaInstitution(IdentityId $identityId, Insti
->execute();
}
- /**
- * @param IdentityId $identityId
- * @param Institution $institution
- * @return void
- */
- public function removeByIdentityIdAndInstitution(IdentityId $identityId, Institution $institution)
+ public function removeByIdentityIdAndInstitution(IdentityId $identityId, Institution $institution): void
{
$this->getEntityManager()->createQueryBuilder()
- ->delete($this->_entityName, 'ral')
+ ->delete($this->getEntityName(), 'ral')
->where('ral.identityId = :identityId')
->andWhere('ral.institution = :institution')
->setParameter('identityId', $identityId->getIdentityId())
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaSecondFactorRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaSecondFactorRepository.php
index 49b9179a6..2d2b57a8d 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaSecondFactorRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaSecondFactorRepository.php
@@ -19,9 +19,9 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Query;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Exception\RuntimeException;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Filter\InstitutionAuthorizationRepositoryFilter;
@@ -30,25 +30,19 @@
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RaSecondFactorQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\SecondFactorStatus;
+/**
+ * @extends ServiceEntityRepository
+ */
class RaSecondFactorRepository extends ServiceEntityRepository
{
- /**
- * @var InstitutionAuthorizationRepositoryFilter
- */
- private $authorizationRepositoryFilter;
-
- public function __construct(ManagerRegistry $registry, InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter)
- {
+ public function __construct(
+ ManagerRegistry $registry,
+ private readonly InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter,
+ ) {
parent::__construct($registry, RaSecondFactor::class);
- $this->authorizationRepositoryFilter = $authorizationRepositoryFilter;
}
-
- /**
- * @param string $id
- * @return RaSecondFactor|null
- */
- public function find($id, $lockMode = null, $lockVersion = null)
+ public function find(mixed $id, $lockMode = null, $lockVersion = null): ?RaSecondFactor
{
/** @var RaSecondFactor|null $secondFactor */
$secondFactor = parent::find($id);
@@ -57,20 +51,18 @@ public function find($id, $lockMode = null, $lockVersion = null)
}
/**
- * @param string $identityId
* @return RaSecondFactor[]
*/
- public function findByIdentityId($identityId)
+ public function findByIdentityId(string $identityId): array
{
return parent::findBy(['identityId' => $identityId]);
}
/**
- * @param string $institution
* @return RaSecondFactor[]
*/
- public function findByInstitution($institution)
+ public function findByInstitution(string $institution): array
{
return parent::findBy(['institution' => $institution]);
}
@@ -79,12 +71,8 @@ public function findByInstitution($institution)
* @SuppressWarnings(PHPMD.CyclomaticComplexity) The amount of if statements do not necessarily make the method
* below complex or hard to maintain.
* @SuppressWarnings(PHPMD.NPathComplexity)
- *
- * @param RaSecondFactorQuery $query
- * @return Query
- * @throws \Doctrine\DBAL\DBALException
*/
- public function createSearchQuery(RaSecondFactorQuery $query)
+ public function createSearchQuery(RaSecondFactorQuery $query): Query
{
$queryBuilder = $this
->createQueryBuilder('sf');
@@ -95,7 +83,7 @@ public function createSearchQuery(RaSecondFactorQuery $query)
$queryBuilder,
$query->authorizationContext,
'sf.institution',
- 'iac'
+ 'iac',
);
if ($query->name) {
@@ -123,10 +111,12 @@ public function createSearchQuery(RaSecondFactorQuery $query)
if ($query->status) {
$stringStatus = $query->status;
if (!SecondFactorStatus::isValidStatus($stringStatus)) {
- throw new RuntimeException(sprintf(
- 'Received invalid status "%s" in RaSecondFactorRepository::createSearchQuery',
- is_object($stringStatus) ? get_class($stringStatus) : (string) $stringStatus
- ));
+ throw new RuntimeException(
+ sprintf(
+ 'Received invalid status "%s" in RaSecondFactorRepository::createSearchQuery',
+ $stringStatus,
+ ),
+ );
}
// we need to resolve the string value to database value using the correct doctrine type. Normally this is
@@ -137,34 +127,27 @@ public function createSearchQuery(RaSecondFactorQuery $query)
$databaseValue = $doctrineType->convertToDatabaseValue(
$secondFactorStatus,
- $this->getEntityManager()->getConnection()->getDatabasePlatform()
+ $this->getEntityManager()->getConnection()->getDatabasePlatform(),
);
$queryBuilder->andWhere('sf.status = :status')->setParameter('status', $databaseValue);
}
- switch ($query->orderBy) {
- case 'name':
- case 'type':
- case 'secondFactorId':
- case 'email':
- case 'institution':
- case 'status':
- $queryBuilder->orderBy(
- sprintf('sf.%s', $query->orderBy),
- $query->orderDirection === 'desc' ? 'DESC' : 'ASC'
- );
- break;
- }
+ match ($query->orderBy) {
+ 'name', 'type', 'secondFactorId', 'email', 'institution', 'status' => $queryBuilder->orderBy(
+ sprintf('sf.%s', $query->orderBy),
+ $query->orderDirection === 'desc' ? 'DESC' : 'ASC',
+ ),
+ default => $queryBuilder->getQuery(),
+ };
return $queryBuilder->getQuery();
}
/**
- * @param RaSecondFactorQuery $query
- * @return \Doctrine\ORM\Query
+ * @return Query
*/
- public function createOptionsQuery(RaSecondFactorQuery $query)
+ public function createOptionsQuery(RaSecondFactorQuery $query): Query
{
$queryBuilder = $this->createQueryBuilder('sf')
->select('sf.institution')
@@ -176,27 +159,26 @@ public function createOptionsQuery(RaSecondFactorQuery $query)
$queryBuilder,
$query->authorizationContext,
'sf.institution',
- 'iac'
+ 'iac',
);
return $queryBuilder->getQuery();
}
/**
- * @param IdentityId $identityId
* @return void
*/
- public function removeByIdentityId(IdentityId $identityId)
+ public function removeByIdentityId(IdentityId $identityId): void
{
$this->getEntityManager()->createQueryBuilder()
- ->delete($this->_entityName, 'rasf')
+ ->delete($this->getEntityName(), 'rasf')
->where('rasf.identityId = :identityId')
->setParameter('identityId', $identityId->getIdentityId())
->getQuery()
->execute();
}
- public function save(RaSecondFactor $secondFactor)
+ public function save(RaSecondFactor $secondFactor): void
{
$this->getEntityManager()->persist($secondFactor);
$this->getEntityManager()->flush();
@@ -205,7 +187,7 @@ public function save(RaSecondFactor $secondFactor)
/**
* @param RaSecondFactor[] $secondFactors
*/
- public function saveAll(array $secondFactors)
+ public function saveAll(array $secondFactors): void
{
$entityManager = $this->getEntityManager();
@@ -216,10 +198,10 @@ public function saveAll(array $secondFactors)
$entityManager->flush();
}
- public function updateStatusByIdentityIdToForgotten(IdentityId $identityId)
+ public function updateStatusByIdentityIdToForgotten(IdentityId $identityId): void
{
$this->getEntityManager()->createQueryBuilder()
- ->update($this->_entityName, 'rasf')
+ ->update($this->getEntityName(), 'rasf')
->set('rasf.status', ":forgotten")
->where('rasf.identityId = :identityId')
->setParameter('identityId', $identityId->getIdentityId())
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RecoveryTokenRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RecoveryTokenRepository.php
index 720f1345f..e1b7331d7 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RecoveryTokenRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RecoveryTokenRepository.php
@@ -19,30 +19,28 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Query;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Filter\InstitutionAuthorizationRepositoryFilter;
+use Surfnet\StepupMiddleware\ApiBundle\Authorization\Value\InstitutionAuthorizationContextInterface;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\RecoveryTokenStatusType;
use Surfnet\StepupMiddleware\ApiBundle\Exception\RuntimeException;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RecoveryToken;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RecoveryTokenQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RecoveryTokenStatus;
+/**
+ * @extends ServiceEntityRepository
+ */
class RecoveryTokenRepository extends ServiceEntityRepository
{
- /**
- * @var InstitutionAuthorizationRepositoryFilter
- */
- private $authorizationRepositoryFilter;
-
public function __construct(
ManagerRegistry $registry,
- InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter
+ private readonly InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter,
) {
parent::__construct($registry, RecoveryToken::class);
- $this->authorizationRepositoryFilter = $authorizationRepositoryFilter;
}
public function save(RecoveryToken $entry): void
@@ -62,21 +60,21 @@ public function remove(RecoveryToken $recoveryToken): void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
- public function createSearchQuery(RecoveryTokenQuery $query)
+ public function createSearchQuery(RecoveryTokenQuery $query): Query
{
$queryBuilder = $this->createQueryBuilder('rt');
- if ($query->authorizationContext) {
+ if ($query->authorizationContext instanceof InstitutionAuthorizationContextInterface) {
// Modify query to filter on authorization context
// We want to list all recovery tokens of the institution we are RA for.
$this->authorizationRepositoryFilter->filter(
$queryBuilder,
$query->authorizationContext,
'rt.institution',
- 'iac'
+ 'iac',
);
}
- if ($query->identityId) {
+ if ($query->identityId instanceof IdentityId) {
$queryBuilder
->andWhere('rt.identityId = :identityId')
->setParameter('identityId', $query->identityId);
@@ -89,10 +87,12 @@ public function createSearchQuery(RecoveryTokenQuery $query)
if ($query->status) {
$stringStatus = $query->status;
if (!RecoveryTokenStatus::isValidStatus($stringStatus)) {
- throw new RuntimeException(sprintf(
- 'Received invalid status "%s" in RecoveryTokenRepository::createSearchQuery',
- is_object($stringStatus) ? get_class($stringStatus) : (string) $stringStatus
- ));
+ throw new RuntimeException(
+ sprintf(
+ 'Received invalid status "%s" in RecoveryTokenRepository::createSearchQuery',
+ $stringStatus,
+ ),
+ );
}
// we need to resolve the string value to database value using the correct doctrine type. Normally this is
@@ -103,7 +103,7 @@ public function createSearchQuery(RecoveryTokenQuery $query)
$databaseValue = $doctrineType->convertToDatabaseValue(
$secondFactorStatus,
- $this->getEntityManager()->getConnection()->getDatabasePlatform()
+ $this->getEntityManager()->getConnection()->getDatabasePlatform(),
);
$queryBuilder->andWhere('rt.status = :status')->setParameter('status', $databaseValue);
@@ -123,18 +123,13 @@ public function createSearchQuery(RecoveryTokenQuery $query)
->andWhere('rt.institution = :institution')
->setParameter('institution', $query->institution);
}
- switch ($query->orderBy) {
- case 'name':
- case 'type':
- case 'email':
- case 'institution':
- case 'status':
- $queryBuilder->orderBy(
- sprintf('rt.%s', $query->orderBy),
- $query->orderDirection === 'desc' ? 'DESC' : 'ASC'
- );
- break;
- }
+ match ($query->orderBy) {
+ 'name', 'type', 'email', 'institution', 'status' => $queryBuilder->orderBy(
+ sprintf('rt.%s', $query->orderBy),
+ $query->orderDirection === 'desc' ? 'DESC' : 'ASC',
+ ),
+ default => $queryBuilder->getQuery(),
+ };
return $queryBuilder->getQuery();
}
@@ -145,14 +140,14 @@ public function createOptionsQuery(RecoveryTokenQuery $query): Query
->select('sf.institution')
->groupBy('sf.institution');
- if ($query->authorizationContext) {
+ if ($query->authorizationContext instanceof InstitutionAuthorizationContextInterface) {
// Modify query to filter on authorization context
// We want to list all second factors of the institution we are RA for.
$this->authorizationRepositoryFilter->filter(
$queryBuilder,
$query->authorizationContext,
'sf.institution',
- 'iac'
+ 'iac',
);
}
return $queryBuilder->getQuery();
@@ -161,7 +156,7 @@ public function createOptionsQuery(RecoveryTokenQuery $query): Query
public function removeByIdentity(IdentityId $identityId): void
{
$this->getEntityManager()->createQueryBuilder()
- ->delete($this->_entityName, 'rt')
+ ->delete($this->getEntityName(), 'rt')
->where('rt.identityId = :identityId')
->setParameter('identityId', $identityId->getIdentityId())
->getQuery()
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/SecondFactorRevocationRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/SecondFactorRevocationRepository.php
index 6245baeab..6bc37cca7 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/SecondFactorRevocationRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/SecondFactorRevocationRepository.php
@@ -19,9 +19,12 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\SecondFactorRevocation;
+/**
+ * @extends ServiceEntityRepository
+ */
class SecondFactorRevocationRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -29,10 +32,7 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, SecondFactorRevocation::class);
}
- /**
- * @param SecondFactorRevocation $revocation
- */
- public function save(SecondFactorRevocation $revocation)
+ public function save(SecondFactorRevocation $revocation): void
{
$entityManager = $this->getEntityManager();
$entityManager->persist($revocation);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/SraaRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/SraaRepository.php
index f1700a26d..bcbe4b93f 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/SraaRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/SraaRepository.php
@@ -19,11 +19,14 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\StepupMiddleware\ApiBundle\Exception\InvalidArgumentException;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Sraa;
+/**
+ * @extends ServiceEntityRepository
+ */
class SraaRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -34,22 +37,22 @@ public function __construct(ManagerRegistry $registry)
/**
* Removes all SRAA's from the database
*/
- public function removeAll()
+ public function removeAll(): void
{
$this
->getEntityManager()
->createQuery(
- 'DELETE FROM Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Sraa'
+ 'DELETE FROM '.Sraa::class,
)
->execute();
+
+ $this->getEntityManager()->clear();
}
/**
* Saves all SRAAs to the database, using inserts only
- *
- * @param array $sraaList
*/
- public function saveAll(array $sraaList)
+ public function saveAll(array $sraaList): void
{
$invalid = [];
foreach ($sraaList as $index => $sraa) {
@@ -58,20 +61,21 @@ public function saveAll(array $sraaList)
}
}
- if (count($invalid)) {
+ if ($invalid !== []) {
$invalidIndications = [];
foreach ($invalid as $index => $value) {
$invalidIndications[] = sprintf(
'"%s" at index "%d"',
- is_object($value) ? get_class($value) : gettype($value)
+ get_debug_type($value),
+ $index
);
}
throw new InvalidArgumentException(
sprintf(
'Expected array of Raa Objects, got %s',
- implode(', ', $invalidIndications)
- )
+ implode(', ', $invalidIndications),
+ ),
);
}
@@ -84,20 +88,15 @@ public function saveAll(array $sraaList)
$entityManager->flush();
}
- /**
- * @param NameId $nameId
- * @return null|\Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Sraa
- */
- public function findByNameId(NameId $nameId)
+ public function findByNameId(NameId $nameId): ?Sraa
{
- return $this->findOneBy(['nameId' => (string) $nameId]);
+ return $this->findOneBy(['nameId' => (string)$nameId]);
}
/**
- * @param NameId $nameId
* @return boolean
*/
- public function contains(NameId $nameId)
+ public function contains(NameId $nameId): bool
{
return $this->findByNameId($nameId) !== null;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/UnverifiedSecondFactorRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/UnverifiedSecondFactorRepository.php
index cb8c78f55..e95c72ecf 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/UnverifiedSecondFactorRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/UnverifiedSecondFactorRepository.php
@@ -19,12 +19,15 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\Query;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\UnverifiedSecondFactor;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\UnverifiedSecondFactorQuery;
+/**
+ * @extends ServiceEntityRepository
+ */
class UnverifiedSecondFactorRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -32,13 +35,7 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, UnverifiedSecondFactor::class);
}
- /**
- * @param string $id
- * @param null $lockMode
- * @param null $lockVersion
- * @return UnverifiedSecondFactor|null
- */
- public function find($id, $lockMode = null, $lockVersion = null)
+ public function find(mixed $id, $lockMode = null, $lockVersion = null): ?UnverifiedSecondFactor
{
/** @var UnverifiedSecondFactor|null $secondFactor */
$secondFactor = parent::find($id);
@@ -47,17 +44,16 @@ public function find($id, $lockMode = null, $lockVersion = null)
}
/**
- * @param UnverifiedSecondFactorQuery $query
* @return Query
*/
- public function createSearchQuery(UnverifiedSecondFactorQuery $query)
+ public function createSearchQuery(UnverifiedSecondFactorQuery $query): Query
{
$queryBuilder = $this->createQueryBuilder('sf');
- if ($query->identityId) {
+ if ($query->identityId instanceof \Surfnet\Stepup\Identity\Value\IdentityId) {
$queryBuilder
->andWhere('sf.identityId = :identityId')
- ->setParameter('identityId', (string) $query->identityId);
+ ->setParameter('identityId', (string)$query->identityId);
}
if ($query->verificationNonce) {
@@ -68,26 +64,23 @@ public function createSearchQuery(UnverifiedSecondFactorQuery $query)
return $queryBuilder->getQuery();
}
- public function removeByIdentityId(IdentityId $identityId)
+ public function removeByIdentityId(IdentityId $identityId): void
{
$this->getEntityManager()->createQueryBuilder()
- ->delete($this->_entityName, 'sf')
+ ->delete($this->getEntityName(), 'sf')
->where('sf.identityId = :identityId')
->setParameter('identityId', $identityId->getIdentityId())
->getQuery()
->execute();
}
- /**
- * @param UnverifiedSecondFactor $secondFactor
- */
- public function save(UnverifiedSecondFactor $secondFactor)
+ public function save(UnverifiedSecondFactor $secondFactor): void
{
$this->getEntityManager()->persist($secondFactor);
$this->getEntityManager()->flush();
}
- public function remove(UnverifiedSecondFactor $secondFactor)
+ public function remove(UnverifiedSecondFactor $secondFactor): void
{
$this->getEntityManager()->remove($secondFactor);
$this->getEntityManager()->flush();
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VerifiedSecondFactorRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VerifiedSecondFactorRepository.php
index cc20b6e38..5d3dd5f19 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VerifiedSecondFactorRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VerifiedSecondFactorRepository.php
@@ -20,37 +20,27 @@
use DateTime;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
-use Doctrine\ORM\EntityManager;
-use Doctrine\ORM\EntityRepository;
-use Doctrine\ORM\Mapping;
use Doctrine\ORM\Query;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Filter\InstitutionAuthorizationRepositoryFilter;
-use Surfnet\StepupMiddleware\ApiBundle\Authorization\Value\InstitutionAuthorizationContextInterface;
-use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\VerifiedSecondFactor;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\VerifiedSecondFactorOfIdentityQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\VerifiedSecondFactorQuery;
+/**
+ * @extends ServiceEntityRepository
+ */
class VerifiedSecondFactorRepository extends ServiceEntityRepository
{
- /**
- * @var InstitutionAuthorizationRepositoryFilter
- */
- private $authorizationRepositoryFilter;
-
- public function __construct(ManagerRegistry $registry, InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter)
- {
+ public function __construct(
+ ManagerRegistry $registry,
+ private readonly InstitutionAuthorizationRepositoryFilter $authorizationRepositoryFilter,
+ ) {
parent::__construct($registry, VerifiedSecondFactor::class);
- $this->authorizationRepositoryFilter = $authorizationRepositoryFilter;
}
- /**
- * @param string $id
- * @return VerifiedSecondFactor|null
- */
- public function find($id, $lockMode = null, $lockVersion = null)
+ public function find(mixed $id, $lockMode = null, $lockVersion = null): ?VerifiedSecondFactor
{
/** @var VerifiedSecondFactor|null $secondFactor */
$secondFactor = parent::find($id);
@@ -59,13 +49,12 @@ public function find($id, $lockMode = null, $lockVersion = null)
}
/**
- * @param DateTime $requestedAt
* @return VerifiedSecondFactor[]
*/
- public function findByDate(DateTime $requestedAt)
+ public function findByDate(DateTime $requestedAt): array
{
$fromDate = clone $requestedAt;
- $fromDate->setTime(0, 0, 0);
+ $fromDate->setTime(0, 0);
$toDate = clone $requestedAt;
$toDate->setTime(23, 59, 59);
@@ -80,23 +69,22 @@ public function findByDate(DateTime $requestedAt)
}
/**
- * @param VerifiedSecondFactorQuery $query
* @return Query
*/
- public function createSearchQuery(VerifiedSecondFactorQuery $query)
+ public function createSearchQuery(VerifiedSecondFactorQuery $query): Query
{
$queryBuilder = $this->createQueryBuilder('sf');
- if ($query->identityId) {
+ if ($query->identityId instanceof \Surfnet\Stepup\Identity\Value\IdentityId) {
$queryBuilder
->andWhere('sf.identityId = :identityId')
- ->setParameter('identityId', (string) $query->identityId);
+ ->setParameter('identityId', (string)$query->identityId);
}
- if ($query->secondFactorId) {
+ if ($query->secondFactorId instanceof \Surfnet\Stepup\Identity\Value\SecondFactorId) {
$queryBuilder
->andWhere('sf.id = :secondFactorId')
- ->setParameter('secondFactorId', (string) $query->secondFactorId);
+ ->setParameter('secondFactorId', (string)$query->secondFactorId);
}
if (is_string($query->registrationCode)) {
@@ -111,47 +99,40 @@ public function createSearchQuery(VerifiedSecondFactorQuery $query)
$queryBuilder,
$query->authorizationContext,
'sf.institution',
- 'iac'
+ 'iac',
);
return $queryBuilder->getQuery();
}
- /**
- * @param VerifiedSecondFactorOfIdentityQuery $query
- * @return Query
- */
- public function createSearchForIdentityQuery(VerifiedSecondFactorOfIdentityQuery $query)
+ public function createSearchForIdentityQuery(VerifiedSecondFactorOfIdentityQuery $query): Query
{
$queryBuilder = $this->createQueryBuilder('sf');
$queryBuilder
->andWhere('sf.identityId = :identityId')
- ->setParameter('identityId', (string) $query->identityId);
+ ->setParameter('identityId', (string)$query->identityId);
return $queryBuilder->getQuery();
}
- public function removeByIdentityId(IdentityId $identityId)
+ public function removeByIdentityId(IdentityId $identityId): void
{
$this->getEntityManager()->createQueryBuilder()
- ->delete($this->_entityName, 'sf')
+ ->delete($this->getEntityName(), 'sf')
->where('sf.identityId = :identityId')
->setParameter('identityId', $identityId->getIdentityId())
->getQuery()
->execute();
}
- /**
- * @param VerifiedSecondFactor $secondFactor
- */
- public function save(VerifiedSecondFactor $secondFactor)
+ public function save(VerifiedSecondFactor $secondFactor): void
{
$this->getEntityManager()->persist($secondFactor);
$this->getEntityManager()->flush();
}
- public function remove(VerifiedSecondFactor $secondFactor)
+ public function remove(VerifiedSecondFactor $secondFactor): void
{
$this->getEntityManager()->remove($secondFactor);
$this->getEntityManager()->flush();
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VettedSecondFactorRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VettedSecondFactorRepository.php
index 5b2a929ae..ef86bb5d1 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VettedSecondFactorRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VettedSecondFactorRepository.php
@@ -19,12 +19,15 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\Query;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\VettedSecondFactor;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\VettedSecondFactorQuery;
+/**
+ * @extends ServiceEntityRepository
+ */
class VettedSecondFactorRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -32,11 +35,7 @@ public function __construct(ManagerRegistry $registry)
parent::__construct($registry, VettedSecondFactor::class);
}
- /**
- * @param string $id
- * @return VettedSecondFactor|null
- */
- public function find($id, $lockMode = null, $lockVersion = null)
+ public function find(mixed $id, $lockMode = null, $lockVersion = null): ?VettedSecondFactor
{
/** @var VettedSecondFactor|null $secondFactor */
$secondFactor = parent::find($id);
@@ -44,43 +43,36 @@ public function find($id, $lockMode = null, $lockVersion = null)
return $secondFactor;
}
- /**
- * @param VettedSecondFactorQuery $query
- * @return Query
- */
- public function createSearchQuery(VettedSecondFactorQuery $query)
+ public function createSearchQuery(VettedSecondFactorQuery $query): Query
{
$queryBuilder = $this->createQueryBuilder('sf');
- if ($query->identityId) {
+ if ($query->identityId instanceof \Surfnet\Stepup\Identity\Value\IdentityId) {
$queryBuilder
->andWhere('sf.identityId = :identityId')
- ->setParameter('identityId', (string) $query->identityId);
+ ->setParameter('identityId', (string)$query->identityId);
}
return $queryBuilder->getQuery();
}
- public function removeByIdentityId(IdentityId $identityId)
+ public function removeByIdentityId(IdentityId $identityId): void
{
$this->getEntityManager()->createQueryBuilder()
- ->delete($this->_entityName, 'sf')
+ ->delete($this->getEntityName(), 'sf')
->where('sf.identityId = :identityId')
->setParameter('identityId', $identityId->getIdentityId())
->getQuery()
->execute();
}
- /**
- * @param VettedSecondFactor $secondFactor
- */
- public function save(VettedSecondFactor $secondFactor)
+ public function save(VettedSecondFactor $secondFactor): void
{
$this->getEntityManager()->persist($secondFactor);
$this->getEntityManager()->flush();
}
- public function remove(VettedSecondFactor $secondFactor)
+ public function remove(VettedSecondFactor $secondFactor): void
{
$this->getEntityManager()->remove($secondFactor);
$this->getEntityManager()->flush();
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VettingTypeHintRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VettingTypeHintRepository.php
index 3fadb100a..a28dbc8a9 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VettingTypeHintRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VettingTypeHintRepository.php
@@ -19,9 +19,12 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\VettingTypeHint;
+/**
+ * @extends ServiceEntityRepository
+ */
class VettingTypeHintRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/WhitelistEntryRepository.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/WhitelistEntryRepository.php
index dc574f242..0754382a6 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/WhitelistEntryRepository.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/WhitelistEntryRepository.php
@@ -20,10 +20,13 @@
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Collections\ArrayCollection;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\WhitelistEntry;
+/**
+ * @extends ServiceEntityRepository
+ */
class WhitelistEntryRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -35,7 +38,7 @@ public function __construct(ManagerRegistry $registry)
* @param Institution[] $institutions
* @return array
*/
- public function findEntriesByInstitutions(array $institutions)
+ public function findEntriesByInstitutions(array $institutions): array
{
$qb = $this->createQueryBuilder('w');
@@ -48,7 +51,7 @@ public function findEntriesByInstitutions(array $institutions)
/**
* @param WhitelistEntry[] $whitelistEntries
*/
- public function saveEntries(array $whitelistEntries)
+ public function saveEntries(array $whitelistEntries): void
{
$entityManager = $this->getEntityManager();
@@ -62,19 +65,21 @@ public function saveEntries(array $whitelistEntries)
/**
* Removes all WhitelistEntries
*/
- public function removeAll()
+ public function removeAll(): void
{
$this->createQueryBuilder('w')
->delete()
->where('1 = 1')
->getQuery()
->execute();
+
+ $this->getEntityManager()->clear();
}
/**
* @param WhitelistEntry[] $whitelistEntries
*/
- public function remove(array $whitelistEntries)
+ public function remove(array $whitelistEntries): void
{
$entityManager = $this->getEntityManager();
@@ -85,7 +90,7 @@ public function remove(array $whitelistEntries)
$entityManager->flush();
}
- public function hasEntryFor($institution)
+ public function hasEntryFor(string $institution): bool
{
$count = $this->createQueryBuilder('w')
->select('COUNT(w.institution)')
@@ -94,13 +99,13 @@ public function hasEntryFor($institution)
->getQuery()
->getSingleScalarResult();
- return (bool) $count;
+ return (bool)$count;
}
/**
- * @return ArrayCollection
+ * @return ArrayCollection
*/
- public function getAll()
+ public function getAll(): ArrayCollection
{
$results = $this->findAll();
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/AbstractSearchService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/AbstractSearchService.php
index 91bc0abbd..eea808ed4 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/AbstractSearchService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/AbstractSearchService.php
@@ -20,21 +20,18 @@
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
-use Pagerfanta\Adapter\DoctrineORMAdapter;
+use Pagerfanta\Doctrine\ORM\QueryAdapter;
use Pagerfanta\Pagerfanta;
use Surfnet\StepupMiddleware\ApiBundle\Exception\InvalidArgumentException;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\AbstractQuery;
class AbstractSearchService
{
- /**
- * @param \Doctrine\ORM\QueryBuilder|\Doctrine\ORM\Query $doctrineQuery
- * @param AbstractQuery $query
- * @param bool $fetchCollection
- * @return Pagerfanta
- */
- protected function createPaginatorFrom($doctrineQuery, AbstractQuery $query, $fetchCollection = true)
- {
+ protected function createPaginatorFrom(
+ QueryBuilder|Query $doctrineQuery,
+ AbstractQuery $query,
+ bool $fetchCollection = true,
+ ): Pagerfanta {
$queryObject = $doctrineQuery;
if ($doctrineQuery instanceof QueryBuilder) {
$queryObject = $doctrineQuery->getQuery();
@@ -44,11 +41,11 @@ protected function createPaginatorFrom($doctrineQuery, AbstractQuery $query, $fe
throw InvalidArgumentException::invalidType(
'Doctrine\ORM\Query or Doctrine\ORM\QueryBuilder',
'searchQuery',
- $doctrineQuery
+ $doctrineQuery,
);
}
- $adapter = new DoctrineORMAdapter($doctrineQuery, $fetchCollection);
+ $adapter = new QueryAdapter($doctrineQuery, $fetchCollection);
$paginator = new Pagerfanta($adapter);
$paginator->setMaxPerPage($query->itemsPerPage);
$paginator->setCurrentPage($query->pageNumber);
@@ -58,17 +55,16 @@ protected function createPaginatorFrom($doctrineQuery, AbstractQuery $query, $fe
}
/**
- * @param Query $doctrineQuery
- * @return array
+ * @return array>
*/
- protected function getFilteredQueryOptions(Query $doctrineQuery)
+ protected function getFilteredQueryOptions(Query $doctrineQuery): array
{
$filters = [];
$results = $doctrineQuery->getArrayResult();
foreach ($results as $options) {
foreach ($options as $key => $value) {
$val = (string)$value;
- $filters[$key][$val] = (string)$val;
+ $filters[$key][$val] = $val;
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/AuditLogService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/AuditLogService.php
index fe372b503..e520657c1 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/AuditLogService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/AuditLogService.php
@@ -19,31 +19,23 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Service;
use Pagerfanta\Pagerfanta;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\AuditLogEntry;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\SecondFactorAuditLogQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuditLogRepository;
class AuditLogService extends AbstractSearchService
{
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuditLogRepository
- */
- private $repository;
-
- public function __construct(AuditLogRepository $repository)
+ public function __construct(private readonly AuditLogRepository $repository)
{
- $this->repository = $repository;
}
/**
- * @param SecondFactorAuditLogQuery $query
- * @return Pagerfanta
+ * @return Pagerfanta
*/
- public function searchSecondFactorAuditLog(SecondFactorAuditLogQuery $query)
+ public function searchSecondFactorAuditLog(SecondFactorAuditLogQuery $query): Pagerfanta
{
$doctrineQuery = $this->repository->createSecondFactorSearchQuery($query);
- $paginator = $this->createPaginatorFrom($doctrineQuery, $query);
-
- return $paginator;
+ return $this->createPaginatorFrom($doctrineQuery, $query);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/IdentityService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/IdentityService.php
index 4df023f32..82d01a89a 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/IdentityService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/IdentityService.php
@@ -18,10 +18,11 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Service;
+use Iterator;
+use Pagerfanta\Pagerfanta;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\NameId;
-use Surfnet\StepupMiddleware\ApiBundle\Authorization\Value\InstitutionRoleSet;
use Surfnet\StepupMiddleware\ApiBundle\Exception\RuntimeException;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\IdentitySelfAssertedTokenOptions;
@@ -37,83 +38,44 @@
*/
class IdentityService extends AbstractSearchService
{
- /**
- * @var IdentityRepository
- */
- private $repository;
-
- /**
- * @var IdentitySelfAssertedTokenOptionsRepository
- */
- private $identitySelfAssertedTokensOptionsRepository;
-
- /**
- * @var RaListingRepository
- */
- private $raListingRepository;
-
- /**
- * @var SraaRepository
- */
- private $sraaRepository;
-
public function __construct(
- IdentityRepository $repository,
- IdentitySelfAssertedTokenOptionsRepository $identitySelfAssertedTokenOptionsRepository,
- RaListingRepository $raListingRepository,
- SraaRepository $sraaRepository
+ private readonly IdentityRepository $repository,
+ private readonly IdentitySelfAssertedTokenOptionsRepository $identitySelfAssertedTokensOptionsRepository,
+ private readonly RaListingRepository $raListingRepository,
+ private readonly SraaRepository $sraaRepository,
) {
- $this->repository = $repository;
- $this->identitySelfAssertedTokensOptionsRepository = $identitySelfAssertedTokenOptionsRepository;
- $this->raListingRepository = $raListingRepository;
- $this->sraaRepository = $sraaRepository;
}
- /**
- * @param string $id
- * @return \Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity|null
- */
- public function find($id)
+ public function find(string $id): ?Identity
{
return $this->repository->find($id);
}
/**
- * @param IdentityQuery $query
- * @param InstitutionRoleSet $institutionRoles
- * @return \Pagerfanta\Pagerfanta
+ * @return Pagerfanta
*/
- public function search(IdentityQuery $query)
+ public function search(IdentityQuery $query): Pagerfanta
{
$searchQuery = $this->repository->createSearchQuery($query);
- $paginator = $this->createPaginatorFrom($searchQuery, $query);
-
- return $paginator;
+ return $this->createPaginatorFrom($searchQuery, $query);
}
- /**
- * @param string $identityId
- * @return null|RegistrationAuthorityCredentials
- */
- public function findRegistrationAuthorityCredentialsOf($identityId)
+ public function findRegistrationAuthorityCredentialsOf(string $identityId): ?RegistrationAuthorityCredentials
{
$identity = $this->find($identityId);
- if (!$identity) {
+ if (!$identity instanceof Identity) {
return null;
}
return $this->findRegistrationAuthorityCredentialsByIdentity($identity);
}
- /**
- * @param NameId $nameId
- * @param Institution $institution
- * @return RegistrationAuthorityCredentials|null
- */
- public function findRegistrationAuthorityCredentialsByNameIdAndInstitution(NameId $nameId, Institution $institution)
- {
+ public function findRegistrationAuthorityCredentialsByNameIdAndInstitution(
+ NameId $nameId,
+ Institution $institution
+ ): ?RegistrationAuthorityCredentials {
$query = new IdentityQuery();
$query->nameId = $nameId->getNameId();
$query->institution = $institution->getInstitution();
@@ -128,39 +90,40 @@ public function findRegistrationAuthorityCredentialsByNameIdAndInstitution(NameI
}
if ($identityCount > 1) {
- throw new RuntimeException(sprintf(
- 'Found more than one identity matching NameID "%s" within institution "%s"',
- $nameId->getNameId(),
- $institution->getInstitution()
- ));
+ throw new RuntimeException(
+ sprintf(
+ 'Found more than one identity matching NameID "%s" within institution "%s"',
+ $nameId->getNameId(),
+ $institution->getInstitution(),
+ ),
+ );
}
+ /** @var Iterator $collection */
+ $collection = $identities->getIterator();
+
/** @var Identity $identity */
- $identity = $identities->getIterator()->current();
+ $identity = $collection->current();
return $this->findRegistrationAuthorityCredentialsByIdentity($identity);
}
- /**
- * @param Identity $identity
- * @return null|RegistrationAuthorityCredentials
- */
- private function findRegistrationAuthorityCredentialsByIdentity(Identity $identity)
+ private function findRegistrationAuthorityCredentialsByIdentity(Identity $identity): ?RegistrationAuthorityCredentials
{
$raListing = $this->raListingRepository->findByIdentityId(new IdentityId($identity->id));
$sraa = $this->sraaRepository->findByNameId($identity->nameId);
- if (!empty($raListing)) {
+ if ($raListing !== []) {
$credentials = RegistrationAuthorityCredentials::fromRaListings($raListing);
- if ($sraa) {
+ if ($sraa !== null) {
$credentials = $credentials->grantSraa();
}
return $credentials;
}
- if ($sraa) {
+ if ($sraa !== null) {
return RegistrationAuthorityCredentials::fromSraa($sraa, $identity);
}
@@ -169,11 +132,11 @@ private function findRegistrationAuthorityCredentialsByIdentity(Identity $identi
public function getSelfAssertedTokenRegistrationOptions(
Identity $identity,
- bool $hasVettedSecondFactor
+ bool $hasVettedSecondFactor,
): IdentitySelfAssertedTokenOptions {
$options = $this->identitySelfAssertedTokensOptionsRepository->find($identity->id);
// Backward compatibility for Identities from the pre SAT era
- if (!$options) {
+ if (!$options instanceof IdentitySelfAssertedTokenOptions) {
$options = new IdentitySelfAssertedTokenOptions();
// Safe to say they did not have a SAT
$options->possessedSelfAssertedToken = false;
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/ProfileService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/ProfileService.php
index e23a3f3d2..570fb68b5 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/ProfileService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/ProfileService.php
@@ -21,35 +21,16 @@
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\RegistrationAuthorityRole;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Service\AuthorizationContextService;
-use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaListingRepository;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\AuthorizedInstitutionCollection;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\Profile;
class ProfileService extends AbstractSearchService
{
- /**
- * @var RaListingRepository
- */
- private $raListingRepository;
-
- /**
- * @var IdentityService
- */
- private $identityService;
-
- /**
- * @var AuthorizationContextService
- */
- private $authorizationService;
-
public function __construct(
- RaListingRepository $raListingRepository,
- IdentityService $identityService,
- AuthorizationContextService $institutionAuthorizationService
+ private readonly IdentityService $identityService,
+ private readonly AuthorizationContextService $authorizationService,
) {
- $this->raListingRepository = $raListingRepository;
- $this->identityService = $identityService;
- $this->authorizationService = $institutionAuthorizationService;
}
/**
@@ -64,36 +45,33 @@ public function __construct(
* Profile. Its possible to retrieve profile data for a non RA user, in that case no authorization data is set
* on the profile. The same goes for the SRAA user. As that user is allowed all authorizations for all institutions.
* An additional isSraa flag is set to true for these administrators.
- *
- * @param string $identityId
- * @return Profile|null
*/
- public function createProfile($identityId)
+ public function createProfile(string $identityId): ?Profile
{
$identity = $this->identityService->find($identityId);
- if ($identity === null) {
+ if (!$identity instanceof Identity) {
return null;
}
$authorizationContextRa = $this->authorizationService->buildInstitutionAuthorizationContext(
new IdentityId($identityId),
- RegistrationAuthorityRole::ra()
+ RegistrationAuthorityRole::ra(),
);
$authorizationContextRaa = $this->authorizationService->buildInstitutionAuthorizationContext(
new IdentityId($identityId),
- RegistrationAuthorityRole::raa()
+ RegistrationAuthorityRole::raa(),
);
$authorizations = AuthorizedInstitutionCollection::from(
$authorizationContextRa->getInstitutions(),
- $authorizationContextRaa->getInstitutions()
+ $authorizationContextRaa->getInstitutions(),
);
return new Profile(
$identity,
$authorizations,
- $authorizationContextRa->isActorSraa()
+ $authorizationContextRa->isActorSraa(),
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaCandidateService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaCandidateService.php
index 7f9bb0b9f..3fdd6d16f 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaCandidateService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaCandidateService.php
@@ -18,61 +18,50 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Service;
+use Pagerfanta\Pagerfanta;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Value\InstitutionAuthorizationContext;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaCandidate;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RaCandidateQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaCandidateRepository;
class RaCandidateService extends AbstractSearchService
{
- /**
- * @var RaCandidateRepository
- */
- private $raCandidateRepository;
-
- /**
- * @param RaCandidateRepository $raCandidateRepository
- */
- public function __construct(RaCandidateRepository $raCandidateRepository)
+ public function __construct(private readonly RaCandidateRepository $raCandidateRepository)
{
- $this->raCandidateRepository = $raCandidateRepository;
}
/**
- * @param RaCandidateQuery $query
- * @return \Pagerfanta\Pagerfanta
+ * @return Pagerfanta
*/
- public function search(RaCandidateQuery $query)
+ public function search(RaCandidateQuery $query): Pagerfanta
{
$doctrineQuery = $this->raCandidateRepository->createSearchQuery($query);
- $paginator = $this->createPaginatorFrom($doctrineQuery, $query, false);
-
- return $paginator;
+ return $this->createPaginatorFrom($doctrineQuery, $query, false);
}
/**
- * @param RaCandidateQuery $query
* @return array
*/
- public function getFilterOptions(RaCandidateQuery $query)
+ public function getFilterOptions(RaCandidateQuery $query): array
{
return $this->getFilteredQueryOptions($this->raCandidateRepository->createOptionsQuery($query));
}
/**
- * @param string $identityId
* @return null|array
*/
- public function findOneByIdentityId($identityId)
+ public function findOneByIdentityId(string $identityId): ?array
{
return $this->raCandidateRepository->findOneByIdentityId($identityId);
}
/**
* Set the RA candidates USE RA(A) institutions on the Identity he is going to promote.
+ * @return non-empty-array[]
*/
- public function setUseRaInstitutionsOnRaCandidate(InstitutionAuthorizationContext $actor, array $raCandidate)
+ public function setUseRaInstitutionsOnRaCandidate(InstitutionAuthorizationContext $actor, array $raCandidate): array
{
$result = [];
foreach ($actor->getInstitutions() as $raInstitution) {
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaListingService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaListingService.php
index b174e0693..22f0f58a5 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaListingService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaListingService.php
@@ -18,6 +18,7 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Service;
+use Pagerfanta\Pagerfanta;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Value\InstitutionAuthorizationContextInterface;
@@ -28,64 +29,49 @@
class RaListingService extends AbstractSearchService
{
- /**
- * @var RaListingRepository
- */
- private $raListingRepository;
-
- public function __construct(RaListingRepository $raListingRepository)
+ public function __construct(private readonly RaListingRepository $raListingRepository)
{
- $this->raListingRepository = $raListingRepository;
}
- /**
- * @param IdentityId $identityId
- * @param Institution $raInstitution
- * @param InstitutionAuthorizationContextInterface $authorizationContext
- * @return null|\Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing
- */
public function findByIdentityIdAndRaInstitutionWithContext(
IdentityId $identityId,
Institution $raInstitution,
- InstitutionAuthorizationContextInterface $authorizationContext
- ) {
- return $this->raListingRepository->findByIdentityIdAndRaInstitutionWithContext($identityId, $raInstitution, $authorizationContext);
+ InstitutionAuthorizationContextInterface $authorizationContext,
+ ): ?RaListing {
+ return $this->raListingRepository->findByIdentityIdAndRaInstitutionWithContext(
+ $identityId,
+ $raInstitution,
+ $authorizationContext,
+ );
}
/**
- * @param RaListingQuery $query
- * @return \Pagerfanta\Pagerfanta
+ * @return Pagerfanta
*/
- public function search(RaListingQuery $query)
+ public function search(RaListingQuery $query): Pagerfanta
{
$doctrineQuery = $this->raListingRepository->createSearchQuery($query);
- $paginator = $this->createPaginatorFrom($doctrineQuery, $query);
-
- return $paginator;
+ return $this->createPaginatorFrom($doctrineQuery, $query);
}
/**
- * @param RaListingQuery $query
- * @return array
+ * @return array>
*/
- public function getFilterOptions(RaListingQuery $query)
+ public function getFilterOptions(RaListingQuery $query): array
{
return $this->getFilteredQueryOptions($this->raListingRepository->createOptionsQuery($query));
}
/**
- * @param Institution $institution
* @return RegistrationAuthorityCredentials[]
*/
- public function listRegistrationAuthoritiesFor(Institution $institution)
+ public function listRegistrationAuthoritiesFor(Institution $institution): array
{
$raListings = $this->raListingRepository->listRasFor($institution);
return $raListings
- ->map(function (RaListing $raListing) {
- return RegistrationAuthorityCredentials::fromRaListing($raListing);
- })
+ ->map(fn(RaListing $raListing): RegistrationAuthorityCredentials => RegistrationAuthorityCredentials::fromRaListing($raListing))
->toArray();
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaSecondFactorService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaSecondFactorService.php
index 9bd5961ea..1de65395c 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaSecondFactorService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RaSecondFactorService.php
@@ -18,51 +18,39 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Service;
+use Pagerfanta\Pagerfanta;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaSecondFactor;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RaSecondFactorQuery;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaSecondFactorRepository;
class RaSecondFactorService extends AbstractSearchService
{
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaSecondFactorRepository
- */
- private $repository;
-
- /**
- * @param RaSecondFactorRepository $repository
- */
- public function __construct(RaSecondFactorRepository $repository)
+ public function __construct(private readonly RaSecondFactorRepository $repository)
{
- $this->repository = $repository;
}
/**
- * @param RaSecondFactorQuery $query
- * @return \Pagerfanta\Pagerfanta
+ * @return Pagerfanta
*/
- public function search(RaSecondFactorQuery $query)
+ public function search(RaSecondFactorQuery $query): Pagerfanta
{
$doctrineQuery = $this->repository->createSearchQuery($query);
- $paginator = $this->createPaginatorFrom($doctrineQuery, $query);
-
- return $paginator;
+ return $this->createPaginatorFrom($doctrineQuery, $query);
}
/**
- * @param RaSecondFactorQuery $query
* @return array
*/
- public function getFilterOptions(RaSecondFactorQuery $query)
+ public function getFilterOptions(RaSecondFactorQuery $query): array
{
return $this->getFilteredQueryOptions($this->repository->createOptionsQuery($query));
}
/**
- * @param RaSecondFactorQuery $query
* @return array
*/
- public function searchUnpaginated(RaSecondFactorQuery $query)
+ public function searchUnpaginated(RaSecondFactorQuery $query): array
{
return $this->repository->createSearchQuery($query)->getResult();
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RecoveryTokenService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RecoveryTokenService.php
index 202aeadb5..6ddfdeaea 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RecoveryTokenService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/RecoveryTokenService.php
@@ -29,16 +29,13 @@
class RecoveryTokenService extends AbstractSearchService
{
- /**
- * @var RecoveryTokenRepository
- */
- private $recoveryTokenRepository;
-
- public function __construct(RecoveryTokenRepository $recoveryTokenRepository)
+ public function __construct(private readonly RecoveryTokenRepository $recoveryTokenRepository)
{
- $this->recoveryTokenRepository = $recoveryTokenRepository;
}
+ /**
+ * @return Pagerfanta
+ */
public function search(RecoveryTokenQuery $query): Pagerfanta
{
$doctrineQuery = $this->recoveryTokenRepository->createSearchQuery($query);
@@ -55,7 +52,7 @@ public function get(RecoveryTokenId $id): RecoveryToken
return $recoveryToken;
}
- public function getFilterOptions(RecoveryTokenQuery $query)
+ public function getFilterOptions(RecoveryTokenQuery $query): array
{
return $this->getFilteredQueryOptions($this->recoveryTokenRepository->createOptionsQuery($query));
}
@@ -65,10 +62,10 @@ public function identityHasActiveRecoveryToken(Identity $identity): bool
$recoveryTokens = $this->recoveryTokenRepository->findBy(
[
'identityId' => $identity->id,
- 'status' => RecoveryTokenStatus::active()
- ]
+ 'status' => RecoveryTokenStatus::active(),
+ ],
);
- return count($recoveryTokens) > 0;
+ return $recoveryTokens !== [];
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/SecondFactorService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/SecondFactorService.php
index 602937a12..8ae2f6ae3 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/SecondFactorService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/SecondFactorService.php
@@ -18,6 +18,7 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Service;
+use Pagerfanta\Pagerfanta;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\UnverifiedSecondFactor;
@@ -37,121 +38,72 @@
*/
class SecondFactorService extends AbstractSearchService
{
- /**
- * @var UnverifiedSecondFactorRepository
- */
- private $unverifiedRepository;
-
- /**
- * @var VerifiedSecondFactorRepository
- */
- private $verifiedRepository;
-
- /**
- * @var VettedSecondFactorRepository
- */
- private $vettedRepository;
-
- /**
- * @param UnverifiedSecondFactorRepository $unverifiedRepository
- * @param VerifiedSecondFactorRepository $verifiedRepository
- * @param VettedSecondFactorRepository $vettedRepository
- */
public function __construct(
- UnverifiedSecondFactorRepository $unverifiedRepository,
- VerifiedSecondFactorRepository $verifiedRepository,
- VettedSecondFactorRepository $vettedRepository
+ private readonly UnverifiedSecondFactorRepository $unverifiedRepository,
+ private readonly VerifiedSecondFactorRepository $verifiedRepository,
+ private readonly VettedSecondFactorRepository $vettedRepository,
) {
- $this->unverifiedRepository = $unverifiedRepository;
- $this->verifiedRepository = $verifiedRepository;
- $this->vettedRepository = $vettedRepository;
}
/**
- * @param UnverifiedSecondFactorQuery $query
- * @return \Pagerfanta\Pagerfanta
+ * @return Pagerfanta
*/
- public function searchUnverifiedSecondFactors(UnverifiedSecondFactorQuery $query)
+ public function searchUnverifiedSecondFactors(UnverifiedSecondFactorQuery $query): Pagerfanta
{
$doctrineQuery = $this->unverifiedRepository->createSearchQuery($query);
- $paginator = $this->createPaginatorFrom($doctrineQuery, $query);
-
- return $paginator;
+ return $this->createPaginatorFrom($doctrineQuery, $query);
}
/**
- * @param VerifiedSecondFactorQuery $query
- * @return \Pagerfanta\Pagerfanta
+ * @return Pagerfanta
*/
- public function searchVerifiedSecondFactors(VerifiedSecondFactorQuery $query)
+ public function searchVerifiedSecondFactors(VerifiedSecondFactorQuery $query): Pagerfanta
{
$doctrineQuery = $this->verifiedRepository->createSearchQuery($query);
- $paginator = $this->createPaginatorFrom($doctrineQuery, $query);
-
- return $paginator;
+ return $this->createPaginatorFrom($doctrineQuery, $query);
}
/**
- * @param VerifiedSecondFactorOfIdentityQuery $query
- * @return \Pagerfanta\Pagerfanta
+ * @return Pagerfanta
*/
- public function searchVerifiedSecondFactorsOfIdentity(VerifiedSecondFactorOfIdentityQuery $query)
+ public function searchVerifiedSecondFactorsOfIdentity(VerifiedSecondFactorOfIdentityQuery $query): Pagerfanta
{
$doctrineQuery = $this->verifiedRepository->createSearchForIdentityQuery($query);
- $paginator = $this->createPaginatorFrom($doctrineQuery, $query);
-
- return $paginator;
+ return $this->createPaginatorFrom($doctrineQuery, $query);
}
/**
- * @param VettedSecondFactorQuery $query
- * @return \Pagerfanta\Pagerfanta
+ * @return Pagerfanta
*/
- public function searchVettedSecondFactors(VettedSecondFactorQuery $query)
+ public function searchVettedSecondFactors(VettedSecondFactorQuery $query): Pagerfanta
{
$doctrineQuery = $this->vettedRepository->createSearchQuery($query);
- $paginator = $this->createPaginatorFrom($doctrineQuery, $query);
-
- return $paginator;
+ return $this->createPaginatorFrom($doctrineQuery, $query);
}
- /**
- * @param SecondFactorId $id
- * @return null|UnverifiedSecondFactor
- */
- public function findUnverified(SecondFactorId $id)
+ public function findUnverified(SecondFactorId $id): ?UnverifiedSecondFactor
{
return $this->unverifiedRepository->find($id);
}
-
- /**
- * @param SecondFactorId $id
- * @return null|VerifiedSecondFactor
- */
- public function findVerified(SecondFactorId $id)
+ public function findVerified(SecondFactorId $id): ?VerifiedSecondFactor
{
return $this->verifiedRepository->find($id);
}
-
- /**
- * @param SecondFactorId $id
- * @return null|VettedSecondFactor
- */
- public function findVetted(SecondFactorId $id)
+ public function findVetted(SecondFactorId $id): ?VettedSecondFactor
{
return $this->vettedRepository->find($id);
}
public function hasVettedByIdentity(IdentityId $id): bool
{
- $vettedSecondFactors = $this->vettedRepository->findBy(['identityId' => (string) $id]);
- return count($vettedSecondFactors) > 0;
+ $vettedSecondFactors = $this->vettedRepository->findBy(['identityId' => (string)$id]);
+ return $vettedSecondFactors !== [];
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/SraaService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/SraaService.php
index cc4f3e50f..5ab04a439 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/SraaService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/SraaService.php
@@ -24,21 +24,11 @@
class SraaService
{
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SraaRepository
- */
- private $sraaRepository;
-
- public function __construct(SraaRepository $sraaRepository)
+ public function __construct(private readonly SraaRepository $sraaRepository)
{
- $this->sraaRepository = $sraaRepository;
}
- /**
- * @param NameId $nameId
- * @return Sraa|null
- */
- public function findByNameId(NameId $nameId)
+ public function findByNameId(NameId $nameId): ?Sraa
{
return $this->sraaRepository->findByNameId($nameId);
}
@@ -46,16 +36,12 @@ public function findByNameId(NameId $nameId)
/**
* @return Sraa[]
*/
- public function findAll()
+ public function findAll(): array
{
return $this->sraaRepository->findAll();
}
- /**
- * @param NameId $nameId
- * @return bool
- */
- public function contains(NameId $nameId)
+ public function contains(NameId $nameId): bool
{
return $this->sraaRepository->contains($nameId);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/WhitelistService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/WhitelistService.php
index 0a90cbd59..ce2fd5af6 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/WhitelistService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Service/WhitelistService.php
@@ -18,26 +18,25 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Service;
+use Doctrine\Common\Collections\ArrayCollection;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\WhitelistEntry;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\WhitelistEntryRepository;
class WhitelistService
{
- /**
- * @var WhitelistEntryRepository
- */
- private $whitelistEntryRepository;
-
- public function __construct(WhitelistEntryRepository $whitelistEntryRepository)
+ public function __construct(private readonly WhitelistEntryRepository $whitelistEntryRepository)
{
- $this->whitelistEntryRepository = $whitelistEntryRepository;
}
- public function isWhitelisted($institution)
+ public function isWhitelisted(string $institution): bool
{
return $this->whitelistEntryRepository->hasEntryFor($institution);
}
- public function getAllEntries()
+ /**
+ * @return ArrayCollection
+ */
+ public function getAllEntries(): ArrayCollection
{
return $this->whitelistEntryRepository->getAll();
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Specification/SpecificationInterface.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Specification/SpecificationInterface.php
index 80bff46e2..d21ac121d 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Specification/SpecificationInterface.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Specification/SpecificationInterface.php
@@ -22,9 +22,5 @@
interface SpecificationInterface
{
- /**
- * @param EntityRepository $entityRepository
- * @return mixed
- */
- public function apply(EntityRepository $entityRepository);
+ public function apply(EntityRepository $entityRepository): mixed;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/AuthorityRole.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/AuthorityRole.php
index 47eb9880f..c707a387b 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/AuthorityRole.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/AuthorityRole.php
@@ -18,28 +18,29 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Value;
+use Stringable;
use Surfnet\Stepup\Identity\Value\RegistrationAuthorityRole;
use Surfnet\StepupMiddleware\ApiBundle\Exception\InvalidArgumentException;
use Surfnet\StepupMiddleware\ApiBundle\Exception\RuntimeException;
-class AuthorityRole
+class AuthorityRole implements Stringable
{
- const ROLE_RA = 'ra';
- const ROLE_RAA = 'raa';
- const ROLE_SRAA = 'sraa';
+ public const ROLE_RA = 'ra';
+ public const ROLE_RAA = 'raa';
+ public const ROLE_SRAA = 'sraa';
/**
* @var string
*/
- private $role;
+ private readonly string $role;
- public function __construct($role)
+ public function __construct(string $role)
{
if (!in_array($role, [self::ROLE_RA, self::ROLE_RAA, self::ROLE_SRAA])) {
throw InvalidArgumentException::invalidType(
'One of AuthorityRole::ROLE_RA, AuthorityRole::ROLE_RAA or AuthorityRole::ROLE_SRAA',
'role',
- $role
+ $role,
);
}
@@ -52,7 +53,7 @@ public function __construct($role)
*
* @return AuthorityRole
*/
- public static function ra()
+ public static function ra(): self
{
return new self(self::ROLE_RA);
}
@@ -62,16 +63,15 @@ public static function ra()
*
* @return AuthorityRole
*/
- public static function raa()
+ public static function raa(): self
{
return new self(self::ROLE_RAA);
}
/**
- * @param RegistrationAuthorityRole $registrationAuthorityRole
* @return AuthorityRole
*/
- public static function fromRegistrationAuthorityRole(RegistrationAuthorityRole $registrationAuthorityRole)
+ public static function fromRegistrationAuthorityRole(RegistrationAuthorityRole $registrationAuthorityRole): AuthorityRole
{
if ($registrationAuthorityRole->isRa()) {
return static::ra();
@@ -79,17 +79,18 @@ public static function fromRegistrationAuthorityRole(RegistrationAuthorityRole $
return static::raa();
}
- throw new RuntimeException(sprintf(
- 'AuthorityRole cannot be created from RegistrationAuthorityRole of value "%s"',
- (string) $registrationAuthorityRole
- ));
+ throw new RuntimeException(
+ sprintf(
+ 'AuthorityRole cannot be created from RegistrationAuthorityRole of value "%s"',
+ $registrationAuthorityRole,
+ ),
+ );
}
/**
- * @param AuthorityRole $other
* @return bool
*/
- public function equals(AuthorityRole $other)
+ public function equals(AuthorityRole $other): bool
{
return $this->role === $other->role;
}
@@ -97,12 +98,12 @@ public function equals(AuthorityRole $other)
/**
* @return string
*/
- public function getRole()
+ public function getRole(): string
{
return $this->role;
}
- public function __toString()
+ public function __toString(): string
{
return $this->role;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/AuthorizedInstitutionCollection.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/AuthorizedInstitutionCollection.php
index a47d24e8d..eef708ae3 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/AuthorizedInstitutionCollection.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/AuthorizedInstitutionCollection.php
@@ -32,37 +32,36 @@ class AuthorizedInstitutionCollection
* 'institution-3' => [select_raa],
* ]
*
- * @var string[]
+ * @var array>
*/
- private $authorizations = [];
+ private array $authorizations = [];
- /**
- * @param InstitutionCollection $raInstitutions
- * @param InstitutionCollection|null $raaInstitutions
- * @return AuthorizedInstitutionCollection
- */
- public static function from(InstitutionCollection $raInstitutions, InstitutionCollection $raaInstitutions = null)
- {
+ public static function from(
+ InstitutionCollection $raInstitutions,
+ ?InstitutionCollection $raaInstitutions = null,
+ ): self {
$collection = new self();
+ /** @var string $institution */
foreach ($raInstitutions as $institution) {
- $collection->authorizations[(string) $institution][] = (string) AuthorityRole::ROLE_RA;
+ $collection->authorizations[(string)$institution][] = AuthorityRole::ROLE_RA;
}
- if ($raaInstitutions) {
+ if ($raaInstitutions instanceof InstitutionCollection) {
+ /** @var string $institution */
foreach ($raaInstitutions as $institution) {
// Override existing lower role
- if (isset($collection->authorizations[(string) $institution])
- && in_array(AuthorityRole::ROLE_RA, $collection->authorizations[(string) $institution])
+ if (isset($collection->authorizations[(string)$institution])
+ && in_array(AuthorityRole::ROLE_RA, $collection->authorizations[(string)$institution])
) {
- $collection->authorizations[(string) $institution] = [];
+ $collection->authorizations[(string)$institution] = [];
}
- $collection->authorizations[(string) $institution][] = (string) AuthorityRole::ROLE_RAA;
+ $collection->authorizations[(string)$institution][] = AuthorityRole::ROLE_RAA;
}
}
return $collection;
}
- public function getAuthorizations()
+ public function getAuthorizations(): array
{
return $this->authorizations;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/Profile.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/Profile.php
index 5f3ec9517..78eb988bd 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/Profile.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/Profile.php
@@ -19,43 +19,19 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Value;
use JsonSerializable;
-use Surfnet\Stepup\Identity\Collection\InstitutionCollection;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
class Profile implements JsonSerializable
{
- /**
- * @var Identity
- */
- private $identity;
-
- /**
- * @var AuthorizedInstitutionCollection
- */
- private $authorizedInstitutionCollection;
-
- /**
- * @var bool
- */
- private $isSraa;
-
- /**
- * @param Identity $identity
- * @param AuthorizedInstitutionCollection $authorizedInstitutionCollection
- *
- * @param bool $isSraa
- */
+
public function __construct(
- Identity $identity,
- AuthorizedInstitutionCollection $authorizedInstitutionCollection,
- $isSraa
+ private readonly Identity $identity,
+ private readonly AuthorizedInstitutionCollection $authorizedInstitutionCollection,
+ private bool $isSraa,
) {
- $this->identity = $identity;
- $this->authorizedInstitutionCollection = $authorizedInstitutionCollection;
- $this->isSraa = $isSraa;
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
$profile = $this->identity->jsonSerialize();
$profile["is_sraa"] = $this->isSraa;
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/RecoveryTokenStatus.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/RecoveryTokenStatus.php
index 650f638e9..b12d5c5c2 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/RecoveryTokenStatus.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/RecoveryTokenStatus.php
@@ -18,13 +18,10 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Value;
-final class RecoveryTokenStatus
-{
- /**
- * @var string
- */
- private $status;
+use Stringable;
+final readonly class RecoveryTokenStatus implements Stringable
+{
public static function active(): self
{
return new self('active');
@@ -45,9 +42,8 @@ public static function isValidStatus(string $status): bool
return in_array($status, ['active', 'revoked', 'forgotten']);
}
- private function __construct(string $status)
+ private function __construct(private string $status)
{
- $this->status = $status;
}
public function equals(RecoveryTokenStatus $other): bool
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/RegistrationAuthorityCredentials.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/RegistrationAuthorityCredentials.php
index 6a05e0d12..12892943a 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/RegistrationAuthorityCredentials.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/RegistrationAuthorityCredentials.php
@@ -19,6 +19,7 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Value;
use Assert\Assertion;
+use JsonSerializable;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\ContactInformation;
use Surfnet\Stepup\Identity\Value\Institution;
@@ -26,75 +27,29 @@
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Sraa;
+use function assert;
-class RegistrationAuthorityCredentials implements \JsonSerializable
+class RegistrationAuthorityCredentials implements JsonSerializable
{
- /**
- * @var string
- */
- private $identityId;
+ private Institution $institution;
- /**
- * @var Institution
- */
- private $institution;
+ private CommonName $commonName;
- /**
- * @var CommonName
- */
- private $commonName;
+ private ?Location $location = null;
- /**
- * @var Location|null
- */
- private $location;
-
- /**
- * @var ContactInformation|null
- */
- private $contactInformation;
+ private ?ContactInformation $contactInformation = null;
- /**
- * @var bool
- */
- private $isRa;
-
- /**
- * @var bool
- */
- private $isRaa;
-
- /**
- * @var bool
- */
- private $isSraa;
-
- /**
- * @param string $identityId
- * @param bool $isRa
- * @param bool $isRaa
- * @param bool $isSraa
- */
private function __construct(
- $identityId,
- $isRa,
- $isRaa,
- $isSraa
+ private readonly string $identityId,
+ private readonly bool $isRa,
+ private readonly bool $isRaa,
+ private bool $isSraa
) {
- $this->identityId = $identityId;
- $this->isRa = $isRa;
- $this->isRaa = $isRaa;
- $this->isSraa = $isSraa;
}
- /**
- * @param Sraa $sraa
- * @param Identity $identity
- * @return RegistrationAuthorityCredentials
- */
- public static function fromSraa(Sraa $sraa, Identity $identity)
+ public static function fromSraa(Sraa $sraa, Identity $identity): self
{
- static::assertEquals($sraa->nameId, $identity->nameId);
+ self::assertEquals($sraa->nameId, $identity->nameId);
$credentials = new self($identity->id, true, true, true);
$credentials->commonName = $identity->commonName;
@@ -104,11 +59,11 @@ public static function fromSraa(Sraa $sraa, Identity $identity)
/**
* @param RaListing[] $raListings
- * @return RegistrationAuthorityCredentials
*/
- public static function fromRaListings(array $raListings)
+ public static function fromRaListings(array $raListings): self
{
$raListingCredentials = current($raListings);
+ assert($raListingCredentials instanceof RaListing, 'The provided raListings are empty');
$isRa = false;
$isRaa = false;
@@ -126,7 +81,7 @@ public static function fromRaListings(array $raListings)
$raListingCredentials->identityId,
$isRa,
$isRaa,
- false
+ false,
);
$credentials->institution = $raListingCredentials->institution;
@@ -137,42 +92,29 @@ public static function fromRaListings(array $raListings)
return $credentials;
}
-
- /**
- * @param RaListing $raListing
- * @return RegistrationAuthorityCredentials
- */
- public static function fromRaListing(RaListing $raListing)
+ public static function fromRaListing(RaListing $raListing): self
{
$credentials = new self(
$raListing->identityId,
$raListing->role->equals(AuthorityRole::ra()),
$raListing->role->equals(AuthorityRole::raa()),
- false
+ false,
);
- $credentials->institution = $raListing->institution;
- $credentials->commonName = $raListing->commonName;
- $credentials->location = $raListing->location;
+ $credentials->institution = $raListing->institution;
+ $credentials->commonName = $raListing->commonName;
+ $credentials->location = $raListing->location;
$credentials->contactInformation = $raListing->contactInformation;
return $credentials;
}
- /**
- * @param string $nameId
- * @param string $identityNameId
- * @return void
- */
- private static function assertEquals($nameId, $identityNameId)
+ private static function assertEquals(string $nameId, string $identityNameId): void
{
Assertion::eq($nameId, $identityNameId);
}
- /**
- * @return RegistrationAuthorityCredentials
- */
- public function grantSraa()
+ public function grantSraa(): static
{
$copy = clone $this;
$copy->isSraa = true;
@@ -180,91 +122,63 @@ public function grantSraa()
return $copy;
}
- /**
- * @param RegistrationAuthorityCredentials $other
- * @return bool
- */
- public function equals(RegistrationAuthorityCredentials $other)
+ public function equals(RegistrationAuthorityCredentials $other): bool
{
return $other->jsonSerialize() === $this->jsonSerialize();
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return [
'id' => $this->identityId,
'attributes' => [
- 'institution' => $this->institution,
- 'common_name' => $this->commonName,
- 'location' => $this->location,
+ 'institution' => $this->institution,
+ 'common_name' => $this->commonName,
+ 'location' => $this->location,
'contact_information' => $this->contactInformation,
- 'is_ra' => ($this->isRa || $this->isSraa),
- 'is_raa' => ($this->isRaa || $this->isSraa),
- 'is_sraa' => $this->isSraa,
- ]
+ 'is_ra' => ($this->isRa || $this->isSraa),
+ 'is_raa' => ($this->isRaa || $this->isSraa),
+ 'is_sraa' => $this->isSraa,
+ ],
];
}
- /**
- * @return string
- */
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->identityId;
}
- /**
- * @return Institution
- */
- public function getInstitution()
+ public function getInstitution(): Institution
{
return $this->institution;
}
- /**
- * @return CommonName
- */
- public function getCommonName()
+ public function getCommonName(): CommonName
{
return $this->commonName;
}
- /**
- * @return string
- */
- public function getLocation()
+ public function getLocation(): string
{
return $this->location;
}
- /**
- * @return string
- */
- public function getContactInformation()
+ public function getContactInformation(): string
{
return $this->contactInformation;
}
- /**
- * @return boolean
- */
- public function isRa()
+ public function isRa(): bool
{
return $this->isRa;
}
- /**
- * @return boolean
- */
- public function isRaa()
+ public function isRaa(): bool
{
return $this->isRaa;
}
- /**
- * @return boolean
- */
- public function isSraa()
+ public function isSraa(): bool
{
return $this->isSraa;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/SecondFactorStatus.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/SecondFactorStatus.php
index b87b13195..63f66c185 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/SecondFactorStatus.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/SecondFactorStatus.php
@@ -18,60 +18,51 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Value;
-final class SecondFactorStatus
-{
- /**
- * @var string
- */
- private $status;
+use Stringable;
- public static function unverified()
+final readonly class SecondFactorStatus implements Stringable
+{
+ public static function unverified(): self
{
return new self('unverified');
}
- public static function verified()
+ public static function verified(): self
{
return new self('verified');
}
- public static function vetted()
+ public static function vetted(): self
{
return new self('vetted');
}
- public static function revoked()
+ public static function revoked(): self
{
return new self('revoked');
}
- public static function forgotten()
+ public static function forgotten(): self
{
return new self('forgotten');
}
/**
- * @param string $status
* @return bool
*/
- public static function isValidStatus($status)
+ public static function isValidStatus(string $status): bool
{
return in_array($status, ['unverified', 'verified', 'vetted', 'revoked', 'forgotten', true]);
}
- /**
- * @param string $status
- */
- private function __construct($status)
+ private function __construct(private string $status)
{
- $this->status = $status;
}
/**
- * @param SecondFactorStatus $other
* @return bool
*/
- public function equals(SecondFactorStatus $other)
+ public function equals(SecondFactorStatus $other): bool
{
return $this->status === $other->status;
}
@@ -79,7 +70,7 @@ public function equals(SecondFactorStatus $other)
/**
* @return string
*/
- public function __toString()
+ public function __toString(): string
{
return $this->status;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/VerifiedTokenInformation.php b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/VerifiedTokenInformation.php
index 85d1646f7..15bea2d24 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/VerifiedTokenInformation.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Identity/Value/VerifiedTokenInformation.php
@@ -18,109 +18,75 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Value;
+use Surfnet\Stepup\DateTime\DateTime;
+use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\VerifiedSecondFactor;
class VerifiedTokenInformation
{
- private $email;
-
- private $tokenId;
-
- private $tokenType;
-
- private $commonName;
-
- private $requestedAt;
-
- private $preferredLocale;
-
- private $institution;
-
- private $registrationCode;
-
- /**
- * @param $email
- * @param $tokenId
- * @param $tokenType
- * @param $commonName
- * @param $requestedAt
- * @param $preferredLocale
- * @param $institution
- * @param $registrationCode
- */
public function __construct(
- $email,
- $tokenId,
- $tokenType,
- $commonName,
- $requestedAt,
- $preferredLocale,
- $institution,
- $registrationCode
+ private readonly string $email,
+ private readonly string $tokenId,
+ private readonly string $tokenType,
+ private readonly string $commonName,
+ private readonly DateTime $requestedAt,
+ private readonly string $preferredLocale,
+ private readonly Institution $institution,
+ private readonly string $registrationCode,
) {
- $this->email = $email;
- $this->tokenId = $tokenId;
- $this->tokenType = $tokenType;
- $this->commonName = $commonName;
- $this->requestedAt = $requestedAt;
- $this->preferredLocale = $preferredLocale;
- $this->institution = $institution;
- $this->registrationCode = $registrationCode;
}
- public static function fromEntity(VerifiedSecondFactor $token, Identity $identity)
+ public static function fromEntity(VerifiedSecondFactor $token, Identity $identity): self
{
- $tokenInformation = new self(
- (string) $identity->email,
+ return new self(
+ (string)$identity->email,
$token->id,
$token->type,
- (string) $identity->commonName,
+ (string)$identity->commonName,
$token->registrationRequestedAt,
- (string) $identity->preferredLocale,
+ (string)$identity->preferredLocale,
$identity->institution,
- $token->registrationCode
+ $token->registrationCode,
);
-
- return $tokenInformation;
}
- public function getEmail()
+ public function getEmail(): string
{
return $this->email;
}
- public function getTokenId()
+ public function getTokenId(): string
{
return $this->tokenId;
}
- public function getTokenType()
+ public function getTokenType(): string
{
return $this->tokenType;
}
- public function getCommonName()
+ public function getCommonName(): string
{
return $this->commonName;
}
- public function getRequestedAt()
+ public function getRequestedAt(): DateTime
{
return $this->requestedAt;
}
- public function getPreferredLocale()
+ public function getPreferredLocale(): string
{
return $this->preferredLocale;
}
- public function getInstitution()
+ public function getInstitution(): Institution
{
return $this->institution;
}
- public function getRegistrationCode()
+ public function getRegistrationCode(): string
{
return $this->registrationCode;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Request/CommandParamConverter.php b/src/Surfnet/StepupMiddleware/ApiBundle/Request/CommandValueResolver.php
similarity index 66%
rename from src/Surfnet/StepupMiddleware/ApiBundle/Request/CommandParamConverter.php
rename to src/Surfnet/StepupMiddleware/ApiBundle/Request/CommandValueResolver.php
index 73242fc0a..20afc63f9 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Request/CommandParamConverter.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Request/CommandValueResolver.php
@@ -18,60 +18,61 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Request;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
use Surfnet\StepupMiddleware\ApiBundle\Exception\BadCommandRequestException;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
+use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
-class CommandParamConverter implements ParamConverterInterface
+class CommandValueResolver implements ValueResolverInterface
{
/**
- * @SuppressWarnings(PHPMD.MissingImport)
- * The line above could be removed in newer releases were dynamic imports are allowed
- * @see https://github.com/phpmd/phpmd/issues/673
+ * @return AbstractCommand[]
*/
- public function apply(Request $request, ParamConverter $configuration)
+ public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
+ $argumentType = $argument->getType();
+ if (!$argumentType
+ || (!is_subclass_of($argumentType, Command::class, true) && Command::class !== $argumentType)
+ ) {
+ return [];
+ }
+
$data = json_decode($request->getContent(), true);
$this->assertIsValidCommandStructure($data);
$commandName = [];
- preg_match('~^(\w+):([\w\\.]+)$~', $data['command']['name'], $commandName);
+ preg_match('~^(\w+):([\w\\.]+)$~', (string)$data['command']['name'], $commandName);
$commandClassName = sprintf(
'Surfnet\StepupMiddleware\CommandHandlingBundle\%s\Command\%sCommand',
$commandName[1],
- str_replace('.', '\\', $commandName[2])
+ str_replace('.', '\\', $commandName[2]),
);
+ /** @var AbstractCommand $command */
$command = new $commandClassName;
- $command->UUID = $data['command']['uuid'];
+ $command->UUID = (string)$data['command']['uuid'];
- foreach ($data['command']['payload'] as $property => $value) {
- $properlyCasedProperty = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $property))));
+ foreach ((array)$data['command']['payload'] as $property => $value) {
+ $properlyCasedProperty = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', (string)$property))));
$command->$properlyCasedProperty = $value;
}
- $request->attributes->set('command', $command);
- }
-
- public function supports(ParamConverter $configuration)
- {
- return $configuration->getName() === 'command'
- && $configuration->getClass() === 'Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command';
+ return [$command];
}
/**
- * @param mixed $data
* @throws BadCommandRequestException
*/
- private function assertIsValidCommandStructure($data)
+ private function assertIsValidCommandStructure(mixed $data): void
{
if (!is_array($data)) {
$type = gettype($data);
throw new BadCommandRequestException(
- [sprintf('Command is not valid: body must be a JSON object, but is of type %s', $type)]
+ [sprintf('Command is not valid: body must be a JSON object, but is of type %s', $type)],
);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Request/ConfigurationInstitutionParamConverter.php b/src/Surfnet/StepupMiddleware/ApiBundle/Request/ConfigurationInstitutionValueResolver.php
similarity index 56%
rename from src/Surfnet/StepupMiddleware/ApiBundle/Request/ConfigurationInstitutionParamConverter.php
rename to src/Surfnet/StepupMiddleware/ApiBundle/Request/ConfigurationInstitutionValueResolver.php
index 15e6895f9..472241550 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Request/ConfigurationInstitutionParamConverter.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Request/ConfigurationInstitutionValueResolver.php
@@ -18,47 +18,49 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Request;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Exception\BadApiRequestException;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
+use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
-class ConfigurationInstitutionParamConverter implements ParamConverterInterface
+class ConfigurationInstitutionValueResolver implements ValueResolverInterface
{
- const INSTITUTION = 'institution';
+ public const INSTITUTION = 'institution';
- public function apply(Request $request, ParamConverter $configuration)
+ /**
+ * @return Institution[]
+ */
+ public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
- $request->attributes->set(self::INSTITUTION, new Institution($this->getInstitutionFromRequest($request)));
- }
+ $argumentType = $argument->getType();
+ if (!$argumentType || $argumentType !== Institution::class
+ ) {
+ return [];
+ }
- public function supports(ParamConverter $configuration)
- {
- return $configuration->getName() === self::INSTITUTION
- && $configuration->getClass() === 'Surfnet\Stepup\Configuration\Value\Institution';
+ return [new Institution($this->getInstitutionFromRequest($request))];
}
/**
- * @param Request $request
* @return string
*/
- private function getInstitutionFromRequest(Request $request)
+ private function getInstitutionFromRequest(Request $request): string
{
- $institution = $request->attributes->get(self::INSTITUTION, false);
+ $institution = $request->attributes->get(self::INSTITUTION);
$request->attributes->remove(self::INSTITUTION);
- if (is_string($institution) && !empty($institution)) {
+ if (is_string($institution) && ($institution !== '' && $institution !== '0')) {
return $institution;
}
- $institution = $request->query->get(self::INSTITUTION, false);
+ $institution = $request->query->get(self::INSTITUTION);
$request->query->remove(self::INSTITUTION);
- if (is_string($institution) && !empty($institution)) {
+ if (is_string($institution) && ($institution !== '' && $institution !== '0')) {
return $institution;
}
- throw new BadApiRequestException(['This API-call MUST include the institution in the path or query parameters']);
+ throw new BadApiRequestException(['This API-call MUST include the institution in the path or query parameters'],);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Request/InstitutionParamConverter.php b/src/Surfnet/StepupMiddleware/ApiBundle/Request/InstitutionValueResolver.php
similarity index 57%
rename from src/Surfnet/StepupMiddleware/ApiBundle/Request/InstitutionParamConverter.php
rename to src/Surfnet/StepupMiddleware/ApiBundle/Request/InstitutionValueResolver.php
index aeefc884f..9959ab824 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Request/InstitutionParamConverter.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Request/InstitutionValueResolver.php
@@ -18,31 +18,33 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Request;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Exception\BadApiRequestException;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
+use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
-class InstitutionParamConverter implements ParamConverterInterface
+class InstitutionValueResolver implements ValueResolverInterface
{
- public function apply(Request $request, ParamConverter $configuration)
+ /**
+ * @return Institution[]
+ */
+ public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
+ $argumentType = $argument->getType();
+ if (!$argumentType
+ || $argumentType !== Institution::class
+ ) {
+ return [];
+ }
+
$query = $request->query;
- $institution = $query->get('institution', false);
+ $institution = $query->get('institution');
- if ($institution === false) {
+ if (!is_string($institution)) {
throw new BadApiRequestException(['This API-call MUST include the institution as get parameter']);
}
- $query->remove('institution');
-
- $request->attributes->set('institution', new Institution($institution));
- }
-
- public function supports(ParamConverter $configuration)
- {
- return $configuration->getName() === 'institution'
- && $configuration->getClass() === 'Surfnet\Stepup\Identity\Value\Institution';
+ return [new Institution($institution)];
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Request/MetadataParamConverter.php b/src/Surfnet/StepupMiddleware/ApiBundle/Request/MetadataValueResolver.php
similarity index 66%
rename from src/Surfnet/StepupMiddleware/ApiBundle/Request/MetadataParamConverter.php
rename to src/Surfnet/StepupMiddleware/ApiBundle/Request/MetadataValueResolver.php
index 79bf81227..fa8a31f02 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Request/MetadataParamConverter.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Request/MetadataValueResolver.php
@@ -18,35 +18,39 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Request;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
use Surfnet\StepupMiddleware\ApiBundle\Exception\BadCommandRequestException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Metadata;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
+use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
use Symfony\Component\Validator\Validator\ValidatorInterface;
-class MetadataParamConverter implements ParamConverterInterface
+class MetadataValueResolver implements ValueResolverInterface
{
- /**
- * @var \Symfony\Component\Validator\Validator\ValidatorInterface
- */
- private $validator;
-
- public function __construct(ValidatorInterface $validator)
+ public function __construct(private readonly ValidatorInterface $validator)
{
- $this->validator = $validator;
}
- public function apply(Request $request, ParamConverter $configuration)
+ /**
+ * @return Metadata[]
+ */
+ public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
+ $argumentType = $argument->getType();
+ if (!$argumentType
+ || $argumentType !== Metadata::class
+ ) {
+ return [];
+ }
+
$data = json_decode($request->getContent());
$this->assertIsValidMetadataStructure($data);
$metadata = new Metadata();
- foreach ($data->meta as $property => $value) {
- $properlyCasedProperty = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $property))));
+ foreach ((array)$data->meta as $property => $value) {
+ $properlyCasedProperty = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', (string)$property))));
$metadata->$properlyCasedProperty = $value;
}
@@ -55,26 +59,19 @@ public function apply(Request $request, ParamConverter $configuration)
throw BadCommandRequestException::withViolations('Command metadata is not valid', $violations);
}
- $request->attributes->set('metadata', $metadata);
- }
-
- public function supports(ParamConverter $configuration)
- {
- return $configuration->getName() === 'metadata'
- && $configuration->getClass() === 'Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Metadata';
+ return [$metadata];
}
/**
- * @param mixed $data
* @throws BadCommandRequestException
*/
- private function assertIsValidMetadataStructure($data)
+ private function assertIsValidMetadataStructure(mixed $data): void
{
if (!is_object($data)) {
$type = gettype($data);
throw new BadCommandRequestException(
- [sprintf('Command metadata is not valid: body must be a JSON object, but is of type %s', $type)]
+ [sprintf('Command metadata is not valid: body must be a JSON object, but is of type %s', $type)],
);
}
@@ -88,8 +85,8 @@ private function assertIsValidMetadataStructure($data)
throw new BadCommandRequestException([
sprintf(
"Command metadata is not valid: 'meta' key value must be a JSON object, but is of type %s",
- $type
- )
+ $type,
+ ),
]);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/projection.yml b/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/projection.yml
index c1eaf77bf..1fc45e6a6 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/projection.yml
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/projection.yml
@@ -1,110 +1,110 @@
services:
- surfnet_stepup_middleware_api.projector.identity:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\IdentityProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.identity"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.identity_self_asserted_token_options:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\IdentitySelfAssertedTokenOptionsProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.identity_self_asserted_token_options"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.institution_listing:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\InstitutionListingProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.institution_listing"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.second_factor:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\SecondFactorProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.unverified_second_factor"
- - "@surfnet_stepup_middleware_api.repository.verified_second_factor"
- - "@surfnet_stepup_middleware_api.repository.vetted_second_factor"
- - "@surfnet_stepup_middleware_api.repository.identity"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.ra_second_factor:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\RaSecondFactorProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.ra_second_factor"
- - "@surfnet_stepup_middleware_api.repository.identity"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.ra_listing:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\RaListingProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.ra_listing"
- - "@surfnet_stepup_middleware_api.repository.identity"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.sraa:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\SraaProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.sraa"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.recovery_token:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\RecoveryTokenProjector
- arguments:
- - "@Surfnet\\StepupMiddleware\\ApiBundle\\Identity\\Repository\\RecoveryTokenRepository"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.vetting_type_hint:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\VettingTypeHintProjector
- arguments:
- - '@surfnet_stepup_middleware_api.repository.vetting_type_hint'
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.audit_log:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\AuditLogProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.audit_log"
- - "@surfnet_stepup_middleware_api.repository.identity"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.second_factor_revocation:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\SecondFactorRevocationProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.second_factor_revocation"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.whitelist_entry:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\WhitelistProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.whitelist_entry"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.ra_location:
- class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector\RaLocationProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.ra_location"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.configured_institution:
- class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector\ConfiguredInstitutionProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.configured_institution"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.institution_configuration_options:
- class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector\InstitutionConfigurationOptionsProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.institution_configuration_options"
- - "@surfnet_stepup_middleware_api.repository.allowed_second_factor"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.allowed_second_factor:
- class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector\AllowedSecondFactorListProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.allowed_second_factor"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
-
- surfnet_stepup_middleware_api.projector.institution_authorization:
- class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector\InstitutionAuthorizationProjector
- arguments:
- - "@surfnet_stepup_middleware_api.repository.institution_authorization"
- - "@surfnet_stepup_middleware_api.repository.institution_configuration_options"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
+ surfnet_stepup_middleware_api.projector.identity:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\IdentityProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.identity"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.identity_self_asserted_token_options:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\IdentitySelfAssertedTokenOptionsProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.identity_self_asserted_token_options"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.institution_listing:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\InstitutionListingProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.institution_listing"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.second_factor:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\SecondFactorProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.unverified_second_factor"
+ - "@surfnet_stepup_middleware_api.repository.verified_second_factor"
+ - "@surfnet_stepup_middleware_api.repository.vetted_second_factor"
+ - "@surfnet_stepup_middleware_api.repository.identity"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.ra_second_factor:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\RaSecondFactorProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.ra_second_factor"
+ - "@surfnet_stepup_middleware_api.repository.identity"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.ra_listing:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\RaListingProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.ra_listing"
+ - "@surfnet_stepup_middleware_api.repository.identity"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.sraa:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\SraaProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.sraa"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.recovery_token:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\RecoveryTokenProjector
+ arguments:
+ - '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RecoveryTokenRepository'
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.vetting_type_hint:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\VettingTypeHintProjector
+ arguments:
+ - '@surfnet_stepup_middleware_api.repository.vetting_type_hint'
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.audit_log:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\AuditLogProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.audit_log"
+ - "@surfnet_stepup_middleware_api.repository.identity"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.second_factor_revocation:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\SecondFactorRevocationProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.second_factor_revocation"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.whitelist_entry:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\WhitelistProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.whitelist_entry"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.ra_location:
+ class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector\RaLocationProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.ra_location"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.configured_institution:
+ class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector\ConfiguredInstitutionProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.configured_institution"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.institution_configuration_options:
+ class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector\InstitutionConfigurationOptionsProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.institution_configuration_options"
+ - "@surfnet_stepup_middleware_api.repository.allowed_second_factor"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.allowed_second_factor:
+ class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector\AllowedSecondFactorListProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.allowed_second_factor"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
+
+ surfnet_stepup_middleware_api.projector.institution_authorization:
+ class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector\InstitutionAuthorizationProjector
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.institution_authorization"
+ - "@surfnet_stepup_middleware_api.repository.institution_configuration_options"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/routing.yml b/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/routing.yml
index 050363171..4f387b69c 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/routing.yml
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/routing.yml
@@ -1,243 +1,243 @@
command_handle:
- path: /command
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\CommandController::handleAction }
- methods: [POST]
- condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /command
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\CommandController::handle }
+ methods: [ POST ]
+ condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
authorization_self_asserted_tokens:
- path: /authorization/may-register-self-asserted-tokens/{identityId}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\AuthorizationController::mayRegisterSelfAssertedTokensAction }
- methods: [ GET ]
- requirements:
- identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /authorization/may-register-self-asserted-tokens/{identityId}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\AuthorizationController::mayRegisterSelfAssertedTokens }
+ methods: [ GET ]
+ requirements:
+ identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
authorization_self_vet_self_asserted_tokens:
- path: /authorization/may-self-vet-using-self-asserted-token/{identityId}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\AuthorizationController::maySelfVetSelfAssertedTokenAction }
- methods: [ GET ]
- requirements:
- identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /authorization/may-self-vet-using-self-asserted-token/{identityId}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\AuthorizationController::maySelfVetSelfAssertedToken }
+ methods: [ GET ]
+ requirements:
+ identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
authorization_recovery_tokens:
- path: /authorization/may-register-recovery-tokens/{identityId}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\AuthorizationController::mayRegisterRecoveryTokensAction }
- methods: [ GET ]
- requirements:
- identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /authorization/may-register-recovery-tokens/{identityId}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\AuthorizationController::mayRegisterRecoveryTokens }
+ methods: [ GET ]
+ requirements:
+ identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
deprovision_dry_run:
- path: /deprovision/{collabPersonId}/dry-run
- requirements:
- collabPersonId: .+
- defaults:
- _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\DeprovisionController::dryRunAction
- _format: json
+ path: /deprovision/{collabPersonId}/dry-run
+ requirements:
+ collabPersonId: .+
+ defaults:
+ _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\DeprovisionController::dryRun
+ _format: json
deprovision:
- path: /deprovision/{collabPersonId}
- requirements:
- collabPersonId: .+
- defaults:
- _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\DeprovisionController::deprovisionAction
- _format: json
- methods: [DELETE]
+ path: /deprovision/{collabPersonId}
+ requirements:
+ collabPersonId: .+
+ defaults:
+ _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\DeprovisionController::deprovision
+ _format: json
+ methods: [ DELETE ]
identity:
- path: /identity/{id}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\IdentityController::getAction }
- methods: [GET]
- requirements:
- id: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /identity/{id}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\IdentityController::get }
+ methods: [ GET ]
+ requirements:
+ id: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
identity_collection:
- path: /identity
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\IdentityController::collectionAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /identity
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\IdentityController::collection }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
profile:
- path: /profile/{identityId}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\ProfileController::getAction }
- methods: [GET]
- requirements:
- id: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /profile/{identityId}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\ProfileController::get }
+ methods: [ GET ]
+ requirements:
+ id: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
unverified_second_factors:
- path: /unverified-second-factors
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\UnverifiedSecondFactorController::collectionAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /unverified-second-factors
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\UnverifiedSecondFactorController::collection }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
verified_second_factors:
- path: /verified-second-factors
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VerifiedSecondFactorController::collectionAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /verified-second-factors
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VerifiedSecondFactorController::collection }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
verified_second_factors_of_identity:
- path: /verified-second-factors-of-identity
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VerifiedSecondFactorController::collectionOfIdentityAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /verified-second-factors-of-identity
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VerifiedSecondFactorController::collectionOfIdentity }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
vetted_second_factors:
- path: /vetted-second-factors
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VettedSecondFactorController::collectionAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /vetted-second-factors
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VettedSecondFactorController::collection }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
unverified_second_factor:
- path: /unverified-second-factor/{id}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\UnverifiedSecondFactorController::getAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /unverified-second-factor/{id}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\UnverifiedSecondFactorController::get }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
verified_second_factor:
- path: /verified-second-factor/{id}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VerifiedSecondFactorController::getAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /verified-second-factor/{id}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VerifiedSecondFactorController::get }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
verified_second_factor_can_skip_prove_posession:
- path: /verified-second-factor/{id}/skip-prove-possession
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VerifiedSecondFactorController::getCanSkipProvePossessionAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /verified-second-factor/{id}/skip-prove-possession
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VerifiedSecondFactorController::getCanSkipProvePossession }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
vetted_second_factor:
- path: /vetted-second-factor/{id}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VettedSecondFactorController::getAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /vetted-second-factor/{id}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VettedSecondFactorController::get }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
recovery_token:
- path: /recovery_token/{id}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RecoveryTokenController::getAction }
- methods: [GET]
- requirements:
- id: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /recovery_token/{id}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RecoveryTokenController::get }
+ methods: [ GET ]
+ requirements:
+ id: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
recovery_tokens:
- path: /recovery_tokens
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RecoveryTokenController::collectionAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /recovery_tokens
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RecoveryTokenController::collection }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
ra_second_factors:
- path: /ra-second-factors
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaSecondFactorController::collectionAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /ra-second-factors
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaSecondFactorController::collection }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
ra_second_factors_export:
- path: /ra-second-factors-export
- defaults: { _controller: SurfnetStepupMiddlewareApiBundle:RaSecondFactor:export }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /ra-second-factors-export
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaSecondFactorController::export }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
identity_ra_list:
- path: /registration-authority
- defaults: { _controller: SurfnetStepupMiddlewareApiBundle:Ra:list }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /registration-authority
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaController::list }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
identity_ra_listing:
- path: /ra-listing
- defaults: { _controller: SurfnetStepupMiddlewareApiBundle:RaListing:search }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /ra-listing
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaListingController::search }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
identity_ra_listing_get:
- path: /ra-listing/{identityId}/{institution}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaListingController::getAction }
- methods: [GET]
- requirements:
- identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
- institution: '.+'
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /ra-listing/{identityId}/{institution}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaListingController::get }
+ methods: [ GET ]
+ requirements:
+ identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
+ institution: '.+'
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
identity_sraa_list:
- path: /sraa
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\SraaController::listAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /sraa
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\SraaController::list }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
identity_sraa_get:
- path: /sraa/{nameId}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\SraaController::getAction }
- methods: [GET]
- requirements:
- nameId: ".+"
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /sraa/{nameId}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\SraaController::get }
+ methods: [ GET ]
+ requirements:
+ nameId: ".+"
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
audit_log:
- path: /audit-log/second-factors
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\AuditLogController::secondFactorAuditLogAction }
- methods: [GET]
- requirements:
- identityId: ".+"
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /audit-log/second-factors
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\AuditLogController::secondFactorAuditLog }
+ methods: [ GET ]
+ requirements:
+ identityId: ".+"
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
identity_registration_authority_credentials:
- path: /registration-authority/{identityId}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\IdentityController::getRegistrationAuthorityCredentialsAction }
- methods: [GET]
- requirements:
- identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /registration-authority/{identityId}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\IdentityController::getRegistrationAuthorityCredentials }
+ methods: [ GET ]
+ requirements:
+ identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
institution_listing:
- path: /institution-listing
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\ConfiguredInstitutionController::collectionAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /institution-listing
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\ConfiguredInstitutionController::collection }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
ra_candidate_search:
- path: /ra-candidate
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaCandidateController::searchAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /ra-candidate
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaCandidateController::search }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
ra_candidate:
- path: /ra-candidate/{identityId}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaCandidateController::getAction }
- methods: [GET]
- requirements:
- identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /ra-candidate/{identityId}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaCandidateController::get }
+ methods: [ GET ]
+ requirements:
+ identityId: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
ra_location_listing:
- path: /ra-location
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaLocationController::searchAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /ra-location
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaLocationController::search }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
ra_location:
- path: /ra-location/{raLocationId}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaLocationController::getAction }
- methods: [GET]
- requirements:
- raLocationId: ".+"
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /ra-location/{raLocationId}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\RaLocationController::get }
+ methods: [ GET ]
+ requirements:
+ raLocationId: ".+"
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
institution_configuration_options_for_institution:
- path: /institution-configuration-options/{institutionName}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\InstitutionConfigurationOptionsController::getForInstitutionAction }
- methods: [GET]
- requirements:
- institution: ".+"
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /institution-configuration-options/{institutionName}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\InstitutionConfigurationOptionsController::getForInstitution }
+ methods: [ GET ]
+ requirements:
+ institution: ".+"
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
vetting_type_hint:
- path: /vetting-type-hint/{institution}
- defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VettingTypeHintController::getAction }
- methods: [GET]
- requirements:
- institution: ".+"
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /vetting-type-hint/{institution}
+ defaults: { _controller: Surfnet\StepupMiddleware\ApiBundle\Controller\VettingTypeHintController::get }
+ methods: [ GET ]
+ requirements:
+ institution: ".+"
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/services.yml b/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/services.yml
index d9927a554..e7c1b9d76 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/services.yml
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Resources/config/services.yml
@@ -1,185 +1,162 @@
services:
- _defaults:
- bind:
- $numberOfTokensPerIdentity: '%number_of_tokens_per_identity%'
-
- Surfnet\StepupMiddleware\ApiBundle\:
- resource: '../../*'
- autowire: true
- exclude: '../../{DependencyInjection,Entity,Repository,Migrations,Tests,Controller}'
-
- # The ManagementBundle controllers are available as a service
- Surfnet\StepupMiddleware\ApiBundle\Controller\:
- resource: '../../Controller'
- autowire: true
- tags: ['controller.service_arguments']
-
- Surfnet\StepupMiddleware\ApiBundle\Controller\DeprovisionController:
- arguments:
- $deprovisionService: '@Surfnet\StepupMiddleware\ApiBundle\Service\DeprovisionService'
- $formatHelper: '@Surfnet\Stepup\Helper\UserDataFormatterInterface'
- tags: [ 'controller.service_arguments' ]
-
- # Repositories
- surfnet_stepup_middleware_api.repository.configured_institution: '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\ConfiguredInstitutionRepository'
- surfnet_stepup_middleware_api.repository.institution_configuration_options: '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionConfigurationOptionsRepository'
- surfnet_stepup_middleware_api.repository.allowed_second_factor: '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\AllowedSecondFactorRepository'
- surfnet_stepup_middleware_api.repository.institution_authorization: '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionAuthorizationRepository'
- surfnet_stepup_middleware_api.repository.ra_location: '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\RaLocationRepository'
- surfnet_stepup_middleware_api.repository.identity: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository'
- surfnet_stepup_middleware_api.repository.identity_self_asserted_token_options: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentitySelfAssertedTokenOptionsRepository'
- surfnet_stepup_middleware_api.repository.institution_listing: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\InstitutionListingRepository'
- surfnet_stepup_middleware_api.repository.ra_candidate: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaCandidateRepository'
- surfnet_stepup_middleware_api.repository.ra_listing: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaListingRepository'
- surfnet_stepup_middleware_api.repository.sraa: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SraaRepository'
- surfnet_stepup_middleware_api.repository.unverified_second_factor: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\UnverifiedSecondFactorRepository'
- surfnet_stepup_middleware_api.repository.verified_second_factor: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VerifiedSecondFactorRepository'
- surfnet_stepup_middleware_api.repository.vetted_second_factor: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettedSecondFactorRepository'
- surfnet_stepup_middleware_api.repository.vetting_type_hint: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettingTypeHintRepository'
- surfnet_stepup_middleware_api.repository.ra_second_factor: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaSecondFactorRepository'
- surfnet_stepup_middleware_api.repository.audit_log: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuditLogRepository'
- surfnet_stepup_middleware_api.repository.second_factor_revocation: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SecondFactorRevocationRepository'
- surfnet_stepup_middleware_api.repository.whitelist_entry: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\WhitelistEntryRepository'
- surfnet_stepup_middleware_api.repository.authorization: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuthorizationRepository'
-
- Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuthorizationRepository:
- arguments:
- - '@Doctrine\Common\Persistence\ManagerRegistry'
- - '@logger'
- public: true
-
- # Repository filter
- surfnet_stepup_middleware_api.repository_filter.authorization:
- class: Surfnet\StepupMiddleware\ApiBundle\Authorization\Filter\InstitutionAuthorizationRepositoryFilter
-
- # Domain Services
- surfnet_stepup_middleware_api.service.institution_configuration_options:
- class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionConfigurationOptionsService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.institution_configuration_options"
- - "%number_of_tokens_per_identity%"
-
- surfnet_stepup_middleware_api.service.allowed_second_factor_list:
- class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\AllowedSecondFactorListService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.allowed_second_factor"
- - "@surfnet_stepup_middleware_api.repository.configured_institution"
-
- surfnet_stepup_middleware_api.service.institution_authorization:
- class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionAuthorizationService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.institution_authorization"
-
- surfnet_stepup_middleware_api.service.configured_institutions:
- class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\ConfiguredInstitutionService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.configured_institution"
-
- surfnet_stepup_middleware_api.service.ra_location:
- class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\RaLocationService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.ra_location"
-
- surfnet_stepup_middleware_api.service.second_factor:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\SecondFactorService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.unverified_second_factor"
- - "@surfnet_stepup_middleware_api.repository.verified_second_factor"
- - "@surfnet_stepup_middleware_api.repository.vetted_second_factor"
-
- surfnet_stepup_middleware_api.service.ra_candidate:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaCandidateService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.ra_candidate"
-
- surfnet_stepup_middleware_api.service.ra_second_factor:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaSecondFactorService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.ra_second_factor"
-
- surfnet_stepup_middleware_api.service.identity:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.identity"
- - "@surfnet_stepup_middleware_api.repository.identity_self_asserted_token_options"
- - "@surfnet_stepup_middleware_api.repository.ra_listing"
- - "@surfnet_stepup_middleware_api.repository.sraa"
-
- surfnet_stepup_middleware_api.service.ra_listing:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaListingService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.ra_listing"
-
- surfnet_stepup_middleware_api.service.sraa:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\SraaService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.sraa"
-
- surfnet_stepup_middleware_api.service.audit_log:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\AuditLogService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.audit_log"
-
- surfnet_stepup_middleware_api.service.whitelist_entry:
- class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\WhitelistService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.whitelist_entry"
-
- # Param Converters
- surfnet_stepup_middleware_api.request.command_param_converter:
- class: Surfnet\StepupMiddleware\ApiBundle\Request\CommandParamConverter
- tags:
- - { name: request.param_converter, priority: -10, converter: surfnet_stepup_middleware_api.command }
-
- surfnet_stepup_middleware_api.request.metadata_param_converter:
- class: Surfnet\StepupMiddleware\ApiBundle\Request\MetadataParamConverter
- arguments:
- - "@validator"
- tags:
- - { name: request.param_converter, priority: -15, converter: surfnet_stepup_middleware_api.metadata }
-
- surfnet_stepup_middleware_api.request.institution_param_converter:
- class: Surfnet\StepupMiddleware\ApiBundle\Request\InstitutionParamConverter
- tags:
- - { name: request.param_converter, priority: -5, converter: surfnet_step_middleware.institution }
-
- surfnet_stepup_middleware_api.request.configuration_institution_param_converter:
- class: Surfnet\StepupMiddleware\ApiBundle\Request\ConfigurationInstitutionParamConverter
- tags:
- - name: request.param_converter
- priority: -4
- converter: surfnet_stepup_middleware_api.configuration_institution
-
- # Exception Listeners
- surfnet_stepup_middleware_api.listener.exception_listener:
- class: Surfnet\StepupMiddleware\ApiBundle\EventListener\ExceptionListener
- arguments:
- - "@logger"
- tags:
- - { name: kernel.event_listener, event: kernel.exception}
-
- # Security Entry Point
- surfnet_stepup_middleware_api.security.json_basic_auth_entry_point:
- class: Surfnet\StepupMiddleware\ApiBundle\Security\Http\EntryPoint\JsonBasicAuthenticationEntryPoint
- arguments:
- - ~ # HTTP Basic realm string, see extension
-
- # Security Services
- surfnet_stepup_middleware_api.security.institution_authorization:
- class: Surfnet\StepupMiddleware\ApiBundle\Authorization\Service\AuthorizationContextService
- arguments:
- - '@surfnet_stepup_middleware_api.service.sraa'
- - '@surfnet_stepup_middleware_api.service.identity'
- - '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\ConfiguredInstitutionRepository'
- - '@surfnet_stepup_middleware_api.repository.authorization'
-
- Surfnet\StepupMiddleware\ApiBundle\Service\DeprovisionService:
- arguments:
- $pipeline: '@surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline'
- $eventSourcingRepository: '@surfnet_stepup.repository.identity'
- $apiRepository: '@surfnet_stepup_middleware_api.repository.identity'
- $logger: '@logger'
-
- Surfnet\Stepup\Helper\RecoveryTokenSecretHelper:
- class: Surfnet\Stepup\Helper\RecoveryTokenSecretHelper
+ _defaults:
+ autowire: true
+ autoconfigure: true
+ public: false
+ bind:
+ $numberOfTokensPerIdentity: '%number_of_tokens_per_identity%'
+
+ Surfnet\StepupMiddleware\ApiBundle\:
+ resource: '../../*'
+ exclude: '../../{DependencyInjection,Entity,Repository,Migrations,Tests,Controller}'
+
+ # The ManagementBundle controllers are available as a service
+ Surfnet\StepupMiddleware\ApiBundle\Controller\:
+ resource: '../../Controller'
+ autowire: true
+ tags: [ 'controller.service_arguments' ]
+
+ Surfnet\StepupMiddleware\ApiBundle\Controller\DeprovisionController:
+ arguments:
+ $deprovisionService: '@Surfnet\StepupMiddleware\ApiBundle\Service\DeprovisionService'
+ $formatHelper: '@Surfnet\Stepup\Helper\UserDataFormatterInterface'
+ tags: [ 'controller.service_arguments' ]
+
+ # Repositories
+ surfnet_stepup_middleware_api.repository.configured_institution: '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\ConfiguredInstitutionRepository'
+ surfnet_stepup_middleware_api.repository.institution_configuration_options: '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionConfigurationOptionsRepository'
+ surfnet_stepup_middleware_api.repository.allowed_second_factor: '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\AllowedSecondFactorRepository'
+ surfnet_stepup_middleware_api.repository.institution_authorization: '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionAuthorizationRepository'
+ surfnet_stepup_middleware_api.repository.ra_location: '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\RaLocationRepository'
+ surfnet_stepup_middleware_api.repository.identity: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository'
+ surfnet_stepup_middleware_api.repository.identity_self_asserted_token_options: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentitySelfAssertedTokenOptionsRepository'
+ surfnet_stepup_middleware_api.repository.institution_listing: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\InstitutionListingRepository'
+ surfnet_stepup_middleware_api.repository.ra_candidate: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaCandidateRepository'
+ surfnet_stepup_middleware_api.repository.ra_listing: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaListingRepository'
+ surfnet_stepup_middleware_api.repository.sraa: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SraaRepository'
+ surfnet_stepup_middleware_api.repository.unverified_second_factor: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\UnverifiedSecondFactorRepository'
+ surfnet_stepup_middleware_api.repository.verified_second_factor: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VerifiedSecondFactorRepository'
+ surfnet_stepup_middleware_api.repository.vetted_second_factor: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettedSecondFactorRepository'
+ surfnet_stepup_middleware_api.repository.vetting_type_hint: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettingTypeHintRepository'
+ surfnet_stepup_middleware_api.repository.ra_second_factor: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaSecondFactorRepository'
+ surfnet_stepup_middleware_api.repository.audit_log: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuditLogRepository'
+ surfnet_stepup_middleware_api.repository.second_factor_revocation: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SecondFactorRevocationRepository'
+ surfnet_stepup_middleware_api.repository.whitelist_entry: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\WhitelistEntryRepository'
+ surfnet_stepup_middleware_api.repository.authorization: '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuthorizationRepository'
+
+ Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuthorizationRepository:
+ arguments:
+ - '@Doctrine\Common\Persistence\ManagerRegistry'
+ - '@logger'
+ public: true
+
+ # Repository filter
+ surfnet_stepup_middleware_api.repository_filter.authorization:
+ class: Surfnet\StepupMiddleware\ApiBundle\Authorization\Filter\InstitutionAuthorizationRepositoryFilter
+
+ # Domain Services
+ surfnet_stepup_middleware_api.service.institution_configuration_options:
+ class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionConfigurationOptionsService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.institution_configuration_options"
+ - "%number_of_tokens_per_identity%"
+
+ surfnet_stepup_middleware_api.service.allowed_second_factor_list:
+ class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\AllowedSecondFactorListService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.allowed_second_factor"
+ - "@surfnet_stepup_middleware_api.repository.configured_institution"
+
+ surfnet_stepup_middleware_api.service.institution_authorization:
+ class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionAuthorizationService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.institution_authorization"
+
+ surfnet_stepup_middleware_api.service.configured_institutions:
+ class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\ConfiguredInstitutionService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.configured_institution"
+
+ surfnet_stepup_middleware_api.service.ra_location:
+ class: Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\RaLocationService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.ra_location"
+
+ surfnet_stepup_middleware_api.service.second_factor:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\SecondFactorService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.unverified_second_factor"
+ - "@surfnet_stepup_middleware_api.repository.verified_second_factor"
+ - "@surfnet_stepup_middleware_api.repository.vetted_second_factor"
+
+ surfnet_stepup_middleware_api.service.ra_candidate:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaCandidateService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.ra_candidate"
+
+ surfnet_stepup_middleware_api.service.ra_second_factor:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaSecondFactorService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.ra_second_factor"
+
+ surfnet_stepup_middleware_api.service.identity:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.identity"
+ - "@surfnet_stepup_middleware_api.repository.identity_self_asserted_token_options"
+ - "@surfnet_stepup_middleware_api.repository.ra_listing"
+ - "@surfnet_stepup_middleware_api.repository.sraa"
+
+ surfnet_stepup_middleware_api.service.ra_listing:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaListingService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.ra_listing"
+
+ surfnet_stepup_middleware_api.service.sraa:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\SraaService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.sraa"
+
+ surfnet_stepup_middleware_api.service.audit_log:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\AuditLogService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.audit_log"
+
+ surfnet_stepup_middleware_api.service.whitelist_entry:
+ class: Surfnet\StepupMiddleware\ApiBundle\Identity\Service\WhitelistService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.whitelist_entry"
+
+ # Exception Listeners
+ surfnet_stepup_middleware_api.listener.exception_listener:
+ class: Surfnet\StepupMiddleware\ApiBundle\EventListener\ExceptionListener
+ arguments:
+ - "@logger"
+ tags:
+ - { name: kernel.event_listener, event: kernel.exception }
+
+ # Security Entry Point
+ surfnet_stepup_middleware_api.security.json_basic_auth_entry_point:
+ class: Surfnet\StepupMiddleware\ApiBundle\Security\Http\EntryPoint\JsonBasicAuthenticationEntryPoint
+ arguments:
+ - ~ # HTTP Basic realm string, see extension
+
+ # Security Services
+ surfnet_stepup_middleware_api.security.institution_authorization:
+ class: Surfnet\StepupMiddleware\ApiBundle\Authorization\Service\AuthorizationContextService
+ arguments:
+ - '@surfnet_stepup_middleware_api.service.sraa'
+ - '@surfnet_stepup_middleware_api.service.identity'
+ - '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\ConfiguredInstitutionRepository'
+ - '@surfnet_stepup_middleware_api.repository.authorization'
+
+ Surfnet\StepupMiddleware\ApiBundle\Service\DeprovisionService:
+ arguments:
+ $pipeline: '@surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline'
+ $eventSourcingRepository: '@surfnet_stepup.repository.identity'
+ $apiRepository: '@surfnet_stepup_middleware_api.repository.identity'
+ $logger: '@logger'
+
+ Surfnet\Stepup\Helper\RecoveryTokenSecretHelper:
+ class: Surfnet\Stepup\Helper\RecoveryTokenSecretHelper
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonAuthorizationResponse.php b/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonAuthorizationResponse.php
index 2d12134f1..de44f9381 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonAuthorizationResponse.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonAuthorizationResponse.php
@@ -30,16 +30,16 @@ public function __construct(int $code, array $errors = [])
Assertion::allString($errors, 'The error messages should all be strings');
$data = [
- 'code' => $code
+ 'code' => $code,
];
- if ($errors) {
+ if ($errors !== []) {
$data['errors'] = $errors;
}
// Don't confuse the HTTP status code with the authorization status code
parent::__construct($data, 200);
}
- public static function from(AuthorizationDecision $decision)
+ public static function from(AuthorizationDecision $decision): self
{
return new self($decision->getCode(), $decision->getErrorMessages());
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonCollectionResponse.php b/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonCollectionResponse.php
index 37928647d..385b887ca 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonCollectionResponse.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonCollectionResponse.php
@@ -23,37 +23,25 @@
class JsonCollectionResponse extends JsonResponse
{
- public static function fromPaginator(Pagerfanta $paginator, $filters = array())
+ public static function fromPaginator(Pagerfanta $paginator, array $filters = []): self
{
return new self(
$paginator->getNbResults(),
$paginator->getCurrentPage(),
$paginator->getMaxPerPage(),
- (array) $paginator->getCurrentPageResults(),
- array(),
- $filters
+ (array)$paginator->getCurrentPageResults(),
+ [],
+ $filters,
);
}
- /**
- * @param int $totalItems
- * @param int $page
- * @param int $pageSize
- * @param array $collection
- * @param array $headers
- * @param array $filters
- */
- public function __construct($totalItems, $page, $pageSize, array $collection, $headers = array(), $filters = array())
+ public function __construct(int $totalItems, int $page, int $pageSize, array $collection, array $headers = [], array $filters = [])
{
- $data = array(
- 'collection' => array(
- 'total_items' => $totalItems,
- 'page' => $page,
- 'page_size' => $pageSize,
- ),
- 'items' => $collection,
- 'filters' => $filters,
- );
+ $data = [
+ 'collection' => ['total_items' => $totalItems, 'page' => $page, 'page_size' => $pageSize],
+ 'items' => $collection,
+ 'filters' => $filters,
+ ];
parent::__construct($data, 200, $headers);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonNotFoundResponse.php b/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonNotFoundResponse.php
index b3e3b4bc0..eacecf54a 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonNotFoundResponse.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Response/JsonNotFoundResponse.php
@@ -25,7 +25,7 @@ class JsonNotFoundResponse extends JsonResponse
/**
* @param array $headers
*/
- public function __construct($headers = array())
+ public function __construct(array $headers = [])
{
parent::__construct(null, 404, $headers);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Security/Http/EntryPoint/JsonBasicAuthenticationEntryPoint.php b/src/Surfnet/StepupMiddleware/ApiBundle/Security/Http/EntryPoint/JsonBasicAuthenticationEntryPoint.php
index 7424799ee..692fd8063 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Security/Http/EntryPoint/JsonBasicAuthenticationEntryPoint.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Security/Http/EntryPoint/JsonBasicAuthenticationEntryPoint.php
@@ -20,6 +20,7 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
@@ -28,27 +29,22 @@
*/
class JsonBasicAuthenticationEntryPoint implements AuthenticationEntryPointInterface
{
- private $realmName;
-
- public function __construct($realmName)
+ public function __construct(private string $realmName)
{
- $this->realmName = $realmName;
}
/**
* {@inheritdoc}
*/
- public function start(Request $request, AuthenticationException $authException = null)
+ public function start(Request $request, AuthenticationException $authException = null): Response
{
- $authExceptionMessage = $authException ? $authException->getMessage() : '';
+ $authExceptionMessage = $authException instanceof AuthenticationException ? $authException->getMessage() : '';
$error = sprintf('You are required to authorise before accessing this API (%s).', $authExceptionMessage);
- $response = new JsonResponse(
+ return new JsonResponse(
['errors' => [$error]],
- 401,
- ['WWW-Authenticate' => sprintf('Basic realm="%s"', $this->realmName)]
+ Response::HTTP_UNAUTHORIZED,
+ ['WWW-Authenticate' => sprintf('Basic realm="%s"', $this->realmName)],
);
-
- return $response;
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Service/DeprovisionService.php b/src/Surfnet/StepupMiddleware/ApiBundle/Service/DeprovisionService.php
index afc8fa1a0..2c50edb93 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Service/DeprovisionService.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Service/DeprovisionService.php
@@ -19,7 +19,7 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Service;
use Psr\Log\LoggerInterface;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Identity\EventSourcing\IdentityRepository;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\StepupMiddleware\ApiBundle\Exception\UserNotFoundException;
@@ -31,36 +31,12 @@
class DeprovisionService implements DeprovisionServiceInterface
{
- /**
- * @var Pipeline
- */
- private $pipeline;
-
- /**
- * @var IdentityRepository
- */
- private $eventSourcingRepository;
-
- /**
- * @var ApiIdentityRepository
- */
- private $apiRepository;
-
- /**
- * @var LoggerInterface
- */
- private $logger;
-
public function __construct(
- Pipeline $pipeline,
- IdentityRepository $eventSourcingRepository,
- ApiIdentityRepository $apiRepository,
- LoggerInterface $logger
+ private readonly Pipeline $pipeline,
+ private readonly IdentityRepository $eventSourcingRepository,
+ private readonly ApiIdentityRepository $apiRepository,
+ private readonly LoggerInterface $logger,
) {
- $this->pipeline = $pipeline;
- $this->eventSourcingRepository = $eventSourcingRepository;
- $this->apiRepository = $apiRepository;
- $this->logger = $logger;
}
public function readUserData(string $collabPersonId): array
@@ -71,7 +47,7 @@ public function readUserData(string $collabPersonId): array
return $this->eventSourcingRepository->obtainInformation(new IdentityId($identity->id));
} catch (UserNotFoundException $e) {
$this->logger->notice(
- $e->getMessage()
+ $e->getMessage(),
);
return [];
}
@@ -84,7 +60,7 @@ public function deprovision(string $collabPersonId): void
$user = $this->getIdentityByNameId($collabPersonId);
} catch (UserNotFoundException $e) {
$this->logger->notice(
- $e->getMessage()
+ $e->getMessage(),
);
return;
}
@@ -99,12 +75,12 @@ public function deprovision(string $collabPersonId): void
private function getIdentityByNameId(string $collabPersonId): Identity
{
$user = $this->apiRepository->findOneByNameId($collabPersonId);
- if (!$user) {
+ if (!$user instanceof Identity) {
throw new UserNotFoundException(
sprintf(
'User identified by: %s was not found. Unable to provide deprovision data.',
- $collabPersonId
- )
+ $collabPersonId,
+ ),
);
}
return $user;
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Filter/InstitutionAuthorizationRepositoryFilterTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Filter/InstitutionAuthorizationRepositoryFilterTest.php
index 614861f3a..6269e4105 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Filter/InstitutionAuthorizationRepositoryFilterTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Filter/InstitutionAuthorizationRepositoryFilterTest.php
@@ -18,9 +18,10 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Authorization\Filter;
-
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Surfnet\Stepup\Identity\Collection\InstitutionCollection;
use Surfnet\Stepup\Identity\Value\Institution as InstitutionValue;
@@ -29,51 +30,56 @@
class InstitutionAuthorizationRepositoryFilterTest extends TestCase
{
- /**
- * @var QueryBuilder
- */
- private $queryBuilder;
+ use MockeryPHPUnitIntegration;
- /**
- * @var EntityManager
- */
- private $entityManager;
+ private QueryBuilder $queryBuilder;
- /**
- * @var InstitutionAuthorizationContextInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- private $mockedAuthorizationContext;
+ private EntityManager&MockObject $entityManager;
+
+ private InstitutionAuthorizationContextInterface&MockObject $mockedAuthorizationContext;
public function setUp(): void
{
$this->mockedAuthorizationContext = $this->createMock(InstitutionAuthorizationContextInterface::class);
- $this->entityManager = $this->getMockBuilder(EntityManager::class)
+ $this->entityManager = $this->getMockBuilder(EntityManager::class)
->disableOriginalConstructor()
->getMock();
$this->queryBuilder = new QueryBuilder($this->entityManager);
- $this->queryBuilder->from('institution', 'i');
+ $this->queryBuilder->from(InstitutionValue::class, 'i');
}
/**
* @test
* @group domain
*/
- public function a_querybuilder_object_is_filtered_with_an_institution_authorization_context()
+ public function a_querybuilder_object_is_filtered_with_an_institution_authorization_context(): void
{
$this->mockedAuthorizationContext->method('getInstitutions')
- ->willReturn(new InstitutionCollection([
- new InstitutionValue('institution-a'),
- new InstitutionValue('institution-c'),
- ]));
+ ->willReturn(
+ new InstitutionCollection([
+ new InstitutionValue('institution-a'),
+ new InstitutionValue('institution-c'),
+ ]),
+ );
$authorizationRepositoryFilter = new InstitutionAuthorizationRepositoryFilter();
- $authorizationRepositoryFilter->filter($this->queryBuilder, $this->mockedAuthorizationContext, 'i.institution', 'iacalias');
+ $authorizationRepositoryFilter->filter(
+ $this->queryBuilder,
+ $this->mockedAuthorizationContext,
+ 'i.institution',
+ 'iacalias',
+ );
- $this->assertEquals('SELECT FROM institution i WHERE i.institution IN (:iacalias_institutions)', $this->queryBuilder->getDQL());
+ $this->assertEquals(
+ sprintf('SELECT FROM %s i WHERE i.institution IN (:iacalias_institutions)', InstitutionValue::class),
+ $this->queryBuilder->getDQL(),
+ );
$this->assertEquals(1, $this->queryBuilder->getParameters()->count());
- $this->assertEquals(['institution-a','institution-c'], $this->queryBuilder->getParameter('iacalias_institutions')->getValue());
+ $this->assertEquals(
+ ['institution-a', 'institution-c'],
+ $this->queryBuilder->getParameter('iacalias_institutions')->getValue()
+ );
}
-
-}
\ No newline at end of file
+}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/AuthorizationContextServiceTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/AuthorizationContextServiceTest.php
index 23b56248a..0e0aaec99 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/AuthorizationContextServiceTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/AuthorizationContextServiceTest.php
@@ -19,7 +19,10 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Authorization\Service;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
+use Surfnet\Stepup\Configuration\Value\Institution as StepupConfigurationInstitution;
use Surfnet\Stepup\Identity\Collection\InstitutionCollection;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
@@ -31,6 +34,7 @@
use Surfnet\StepupMiddleware\ApiBundle\Authorization\Service\AuthorizationContextService;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\ConfiguredInstitution;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\ConfiguredInstitutionRepository;
+use Surfnet\StepupMiddleware\ApiBundle\Exception\InvalidArgumentException;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Sraa;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuthorizationRepository;
@@ -39,29 +43,17 @@
class AuthorizationContextServiceTest extends TestCase
{
- /**
- * @var AuthorizationContextService
- */
- private $service;
+ use MockeryPHPUnitIntegration;
- /**
- * @var IdentityService|m\Mock
- */
- private $identityService;
+ private AuthorizationContextService $service;
- /**
- * @var SraaService|m\Mock
- */
- private $sraaService;
+ private IdentityService&MockInterface $identityService;
- /**
- * @var AuthorizationRepository|m\Mock
- */
- private $authorizationRepository;
- /**
- * @var m\Mock&ConfiguredInstitutionRepository
- */
- private $institutionRepo;
+ private SraaService&MockInterface $sraaService;
+
+ private AuthorizationRepository&MockInterface $authorizationRepository;
+
+ private MockInterface&ConfiguredInstitutionRepository $institutionRepo;
public function setUp(): void
{
@@ -73,7 +65,7 @@ public function setUp(): void
$sraaService,
$identityService,
$this->institutionRepo,
- $authorizationRepository
+ $authorizationRepository,
);
$this->identityService = $identityService;
@@ -86,7 +78,7 @@ public function setUp(): void
* @test
* @group domain
*/
- public function it_can_build_a_context()
+ public function it_can_build_a_context(): void
{
$actorInstitution = new Institution('institution-a');
$role = RegistrationAuthorityRole::raa();
@@ -106,7 +98,7 @@ public function it_can_build_a_context()
$arbitraryNameId,
new Email('foo@bar.com'),
new CommonName('Foobar'),
- new Locale('en_GB')
+ new Locale('en_GB'),
);
$identityId = new IdentityId($arbitraryId);
@@ -128,7 +120,7 @@ public function it_can_build_a_context()
$context = $this->service->buildInstitutionAuthorizationContext(
$identityId,
- $role
+ $role,
);
$this->assertEquals($institutions, $context->getInstitutions());
@@ -139,7 +131,7 @@ public function it_can_build_a_context()
* @test
* @group domain
*/
- public function it_can_build_a_context_with_sraa_actor()
+ public function it_can_build_a_context_with_sraa_actor(): void
{
$actorInstitution = new Institution('institution-a');
$role = RegistrationAuthorityRole::raa();
@@ -159,7 +151,7 @@ public function it_can_build_a_context_with_sraa_actor()
$adminNameId,
new Email('foo@bar.com'),
new CommonName('Foobar'),
- new Locale('en_GB')
+ new Locale('en_GB'),
);
$sraa = m::mock(Sraa::class);
@@ -183,21 +175,21 @@ public function it_can_build_a_context_with_sraa_actor()
$configuredInstitutions = [];
foreach ($institutions as $institution) {
$ci = new ConfiguredInstitution();
- $ci->institution = $institution->getInstitution();
+ $ci->institution = new StepupConfigurationInstitution($institution->getInstitution());
$configuredInstitutions[] = $ci;
}
$this->institutionRepo->shouldReceive('findAll')->andReturn($configuredInstitutions);
$context = $this->service->buildInstitutionAuthorizationContext(
$identityId,
- $role
+ $role,
);
$this->assertEquals($institutions, $context->getInstitutions());
$this->assertTrue($context->isActorSraa());
}
- public function test_it_can_retrieve_select_raa_institutions()
+ public function test_it_can_retrieve_select_raa_institutions(): void
{
$actorInstitution = new Institution('institution-a');
@@ -216,7 +208,7 @@ public function test_it_can_retrieve_select_raa_institutions()
$arbitraryNameId,
new Email('foo@bar.com'),
new CommonName('Foobar'),
- new Locale('en_GB')
+ new Locale('en_GB'),
);
$identityId = new IdentityId($arbitraryId);
@@ -237,7 +229,7 @@ public function test_it_can_retrieve_select_raa_institutions()
->andReturn($institutions);
$context = $this->service->buildSelectRaaInstitutionAuthorizationContext(
- $identityId
+ $identityId,
);
$this->assertEquals($institutions, $context->getInstitutions());
@@ -248,10 +240,10 @@ public function test_it_can_retrieve_select_raa_institutions()
* @test
* @group domain
*/
- public function it_rejects_unknown_actor()
+ public function it_rejects_unknown_actor(): void
{
$this->expectExceptionMessage("The provided id is not associated with any known identity");
- $this->expectException(\Surfnet\StepupMiddleware\ApiBundle\Exception\InvalidArgumentException::class);
+ $this->expectException(InvalidArgumentException::class);
$role = RegistrationAuthorityRole::raa();
@@ -264,7 +256,7 @@ public function it_rejects_unknown_actor()
$this->service->buildInstitutionAuthorizationContext(
new IdentityId($actorId),
- $role
+ $role,
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/AuthorizationServiceTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/AuthorizationServiceTest.php
index 249fced6c..85df68298 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/AuthorizationServiceTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/AuthorizationServiceTest.php
@@ -18,7 +18,9 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Authorization\Service;
+use Doctrine\Common\Collections\ArrayCollection;
use Mockery as m;
+use Mockery\MockInterface;
use Pagerfanta\Pagerfanta;
use PHPUnit\Framework\TestCase;
use Surfnet\Stepup\Configuration\Value\SelfAssertedTokensOption;
@@ -39,30 +41,15 @@ class AuthorizationServiceTest extends TestCase
{
use m\Adapter\Phpunit\MockeryPHPUnitIntegration;
- /**
- * @var m\MockInterface|IdentityService
- */
- private $identityService;
+ private MockInterface&IdentityService $identityService;
- /**
- * @var m\MockInterface|InstitutionConfigurationOptionsService
- */
- private $institutionConfigurationService;
+ private MockInterface&InstitutionConfigurationOptionsService $institutionConfigurationService;
- /**
- * @var m\MockInterface|SecondFactorService
- */
- private $secondFactorService;
+ private MockInterface&SecondFactorService $secondFactorService;
- /**
- * @var m\MockInterface|RecoveryTokenService
- */
- private $recoveryTokenService;
+ private MockInterface&RecoveryTokenService $recoveryTokenService;
- /**
- * @var AuthorizationService
- */
- private $service;
+ private AuthorizationService $service;
protected function setUp(): void
{
@@ -75,11 +62,11 @@ protected function setUp(): void
$this->identityService,
$this->institutionConfigurationService,
$this->secondFactorService,
- $this->recoveryTokenService
+ $this->recoveryTokenService,
);
}
- public function test_it_rejects_unknown_user()
+ public function test_it_rejects_unknown_user(): void
{
$this->identityService
->shouldReceive('find')
@@ -93,7 +80,7 @@ public function test_it_rejects_unknown_user()
$this->assertEquals('Identity not found', reset($messages));
}
- public function test_it_rejects_unknown_institution_configuration()
+ public function test_it_rejects_unknown_institution_configuration(): void
{
$identity = new Identity();
$identity->institution = new Institution('Unknown institution');
@@ -112,10 +99,13 @@ public function test_it_rejects_unknown_institution_configuration()
$messages = $decision->getErrorMessages();
$this->assertEquals(403, $decision->getCode());
- $this->assertEquals('Institution configuration could not be found, unable to ascertain if self-asserted tokens feature is enabled', reset($messages));
+ $this->assertEquals(
+ 'Institution configuration could not be found, unable to ascertain if self-asserted tokens feature is enabled',
+ reset($messages),
+ );
}
- public function test_it_rejects_disabled_self_asserted_tokens_feature_flag_on_institution()
+ public function test_it_rejects_disabled_self_asserted_tokens_feature_flag_on_institution(): void
{
$identity = new Identity();
$identity->institution = new Institution('Known institution');
@@ -139,7 +129,7 @@ public function test_it_rejects_disabled_self_asserted_tokens_feature_flag_on_in
$this->assertEquals('Institution "known institution", does not allow self-asserted tokens', reset($messages));
}
- public function test_it_rejects_when_identity_has_vetted_token()
+ public function test_it_rejects_when_identity_has_vetted_token(): void
{
$identity = new Identity();
$identity->institution = new Institution('Known institution');
@@ -179,7 +169,7 @@ public function test_it_rejects_when_identity_has_vetted_token()
$this->assertEquals('Identity already has a vetted second factor', reset($messages));
}
- public function test_it_rejects_when_identity_had_prior_non_sat_token()
+ public function test_it_rejects_when_identity_had_prior_non_sat_token(): void
{
$identity = new Identity();
$identity->institution = new Institution('Known institution');
@@ -216,10 +206,13 @@ public function test_it_rejects_when_identity_had_prior_non_sat_token()
$messages = $decision->getErrorMessages();
$this->assertEquals(403, $decision->getCode());
- $this->assertEquals('Identity never possessed a self-asserted token, but did/does possess one of the other types', reset($messages));
+ $this->assertEquals(
+ 'Identity never possessed a self-asserted token, but did/does possess one of the other types',
+ reset($messages),
+ );
}
- public function test_recovery_tokens_never_owned_a_sat_token_but_did_own_other_token_type()
+ public function test_recovery_tokens_never_owned_a_sat_token_but_did_own_other_token_type(): void
{
$identity = new Identity();
$identity->institution = new Institution('Known institution');
@@ -256,10 +249,13 @@ public function test_recovery_tokens_never_owned_a_sat_token_but_did_own_other_t
$messages = $decision->getErrorMessages();
$this->assertEquals(403, $decision->getCode());
- $this->assertEquals('Identity never possessed a self-asserted token, deny access to recovery token CRUD actions', reset($messages));
+ $this->assertEquals(
+ 'Identity never possessed a self-asserted token, deny access to recovery token CRUD actions',
+ reset($messages),
+ );
}
- public function test_you_cant_sat_when_you_lost_both_rt_and_sf_tokens()
+ public function test_you_cant_sat_when_you_lost_both_rt_and_sf_tokens(): void
{
$identity = new Identity();
$identity->institution = new Institution('Known institution');
@@ -302,10 +298,13 @@ public function test_you_cant_sat_when_you_lost_both_rt_and_sf_tokens()
$messages = $decision->getErrorMessages();
$this->assertEquals(403, $decision->getCode());
- $this->assertEquals('Identity lost both Recovery and Second Factor token, SAT is not allowed', reset($messages));
+ $this->assertEquals(
+ 'Identity lost both Recovery and Second Factor token, SAT is not allowed',
+ reset($messages),
+ );
}
- public function test_recovery_tokens_all_requirements_met()
+ public function test_recovery_tokens_all_requirements_met(): void
{
$identity = new Identity();
$identity->institution = new Institution('Known institution');
@@ -345,7 +344,7 @@ public function test_recovery_tokens_all_requirements_met()
$this->assertEmpty($messages);
}
- public function test_it_allows_when_identity_meets_all_requirements()
+ public function test_it_allows_when_identity_meets_all_requirements(): void
{
$identity = new Identity();
$identity->institution = new Institution('Known institution');
@@ -391,7 +390,7 @@ public function test_it_allows_when_identity_meets_all_requirements()
$this->assertEmpty($messages);
}
- public function test_it_allows_when_identity_with_prior_sat_meets_all_requirements()
+ public function test_it_allows_when_identity_with_prior_sat_meets_all_requirements(): void
{
$identity = new Identity();
$identity->institution = new Institution('Known institution');
@@ -437,7 +436,7 @@ public function test_it_allows_when_identity_with_prior_sat_meets_all_requiremen
$this->assertEmpty($messages);
}
- public function test_it_allows_self_vetting_when_one_sat_present()
+ public function test_it_allows_self_vetting_when_one_sat_present(): void
{
$identity = new Identity();
$identity->institution = new Institution('Known institution');
@@ -461,7 +460,7 @@ public function test_it_allows_self_vetting_when_one_sat_present()
$vettedSecondFactor->vettingType = VettingType::TYPE_SELF_ASSERTED_REGISTRATION;
$collection = m::mock(Pagerfanta::class);
- $collection->shouldReceive('getIterator')->andReturn([$vettedSecondFactor]);
+ $collection->shouldReceive('getIterator')->andReturn(new ArrayCollection([$vettedSecondFactor]));
$this->secondFactorService
->shouldReceive('searchVettedSecondFactors')
@@ -474,7 +473,7 @@ public function test_it_allows_self_vetting_when_one_sat_present()
$this->assertEmpty($messages);
}
- public function test_it_allows_self_vetting_when_multiple_sat_present()
+ public function test_it_allows_self_vetting_when_multiple_sat_present(): void
{
$identity = new Identity();
$identity->institution = new Institution('Known institution');
@@ -497,7 +496,7 @@ public function test_it_allows_self_vetting_when_multiple_sat_present()
$vettedSecondFactor->vettingType = VettingType::TYPE_SELF_ASSERTED_REGISTRATION;
$collection = m::mock(Pagerfanta::class);
- $collection->shouldReceive('getIterator')->andReturn([$vettedSecondFactor, $vettedSecondFactor]);
+ $collection->shouldReceive('getIterator')->andReturn(new ArrayCollection([$vettedSecondFactor, $vettedSecondFactor]));
$this->secondFactorService
->shouldReceive('searchVettedSecondFactors')
@@ -510,7 +509,7 @@ public function test_it_allows_self_vetting_when_multiple_sat_present()
$this->assertEmpty($messages);
}
- public function test_it_denies_self_vetting_when_other_vetting_type()
+ public function test_it_denies_self_vetting_when_other_vetting_type(): void
{
$identity = new Identity();
$identity->institution = new Institution('Known institution');
@@ -534,7 +533,7 @@ public function test_it_denies_self_vetting_when_other_vetting_type()
$vettedSecondFactor->vettingType = VettingType::TYPE_ON_PREMISE;
$collection = m::mock(Pagerfanta::class);
- $collection->shouldReceive('getIterator')->andReturn([$vettedSecondFactor, $vettedSecondFactor]);
+ $collection->shouldReceive('getIterator')->andReturn(new ArrayCollection([$vettedSecondFactor, $vettedSecondFactor]));
$this->secondFactorService
->shouldReceive('searchVettedSecondFactors')
@@ -544,6 +543,9 @@ public function test_it_denies_self_vetting_when_other_vetting_type()
$messages = $decision->getErrorMessages();
$this->assertEquals(403, $decision->getCode());
- $this->assertEquals('Self-vetting using SAT is only allowed when only SAT tokens are in possession', reset($messages));
+ $this->assertEquals(
+ 'Self-vetting using SAT is only allowed when only SAT tokens are in possession',
+ reset($messages),
+ );
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/CommandAuthorizationServiceTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/CommandAuthorizationServiceTest.php
index 8842f7586..276a28616 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/CommandAuthorizationServiceTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Authorization/Service/CommandAuthorizationServiceTest.php
@@ -19,9 +19,11 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Authorization\Service;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Identity\Collection\InstitutionCollection;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
@@ -33,40 +35,64 @@
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\WhitelistService;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RegistrationAuthorityCredentials;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\RaExecutable;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\SelfAsserted;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\SelfServiceExecutable;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\AddRaLocationCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\ChangeRaLocationCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\CreateInstitutionConfigurationCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\ReconfigureInstitutionConfigurationOptionsCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\RemoveInstitutionConfigurationByUnnormalizedIdCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\RemoveRaLocationCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\UpdateConfigurationCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\AccreditIdentityCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\AddToWhitelistCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\AmendRegistrationAuthorityInformationCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\AppointRoleCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\BootstrapIdentityWithYubikeySecondFactorCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\CreateIdentityCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ExpressLocalePreferenceCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ForgetIdentityCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\MigrateVettedSecondFactorCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\PromiseSafeStoreSecretTokenPossessionCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ProveGssfPossessionCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ProvePhonePossessionCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ProvePhoneRecoveryTokenPossessionCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ProveU2fDevicePossessionCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ProveYubikeyPossessionCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\RegisterSelfAssertedSecondFactorCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\RemoveFromWhitelistCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ReplaceWhitelistCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\RetractRegistrationAuthorityCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\RevokeOwnRecoveryTokenCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\RevokeOwnSecondFactorCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\RevokeRegistrantsRecoveryTokenCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\RevokeRegistrantsSecondFactorCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\SaveVettingTypeHintCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\SelfVetSecondFactorCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\SendSecondFactorRegistrationEmailCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\SendVerifiedSecondFactorRemindersCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\UpdateIdentityCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\VerifyEmailCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\VetSecondFactorCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Command\FixedUuidStubCommand;
+use function is_array;
+use function is_string;
+use function property_exists;
class CommandAuthorizationServiceTest extends TestCase
{
- /**
- * @var WhitelistService|m\MockInterface
- */
- private $whitelistService;
- /**
- * @var IdentityService|m\MockInterface
- */
- private $identityService;
- /**
- * @var LoggerInterface|m\MockInterface
- */
- private $logger;
- /**
- * @var AuthorizationContextService|m\MockInterface
- */
- private $authorizationContextService;
+ use MockeryPHPUnitIntegration;
- /**
- * @var CommandAuthorizationService
- */
- private $service;
+ private IdentityService&MockInterface $identityService;
+
+ private LoggerInterface&MockInterface $logger;
+
+ private AuthorizationContextService&MockInterface $authorizationContextService;
+
+ private CommandAuthorizationService $service;
public function setUp(): void
{
@@ -75,9 +101,13 @@ public function setUp(): void
$logger = m::mock(LoggerInterface::class);
$authorizationContextService = m::mock(AuthorizationContextService::class);
- $service = new CommandAuthorizationService($whitelistService, $identityService, $logger, $authorizationContextService);
+ $service = new CommandAuthorizationService(
+ $whitelistService,
+ $identityService,
+ $logger,
+ $authorizationContextService,
+ );
- $this->whitelistService = $whitelistService;
$this->identityService = $identityService;
$this->logger = $logger;
$this->authorizationContextService = $authorizationContextService;
@@ -85,7 +115,7 @@ public function setUp(): void
$this->service = $service;
}
- public function test_shared_ra_and_ss_commands_are_correctly_authorized()
+ public function test_shared_ra_and_ss_commands_are_correctly_authorized(): void
{
$actorId = new IdentityId('123');
$actorInstitution = new Institution('institution');
@@ -111,10 +141,8 @@ public function test_shared_ra_and_ss_commands_are_correctly_authorized()
/**
* @test
* @dataProvider availableCommands
- *
- * @param mixed $value
*/
- public function a_sraa_should_be_able_to_execute_all_commands($file, $command)
+ public function a_sraa_should_be_able_to_execute_all_commands(string $file, Command $command): void
{
$this->assertInstanceOf(Command::class, $command);
@@ -139,18 +167,16 @@ public function a_sraa_should_be_able_to_execute_all_commands($file, $command)
/**
* @test
* @dataProvider availableCommands
- *
- * @param mixed $value
*/
- public function an_identity_should_be_able_to_execute_own_selfservice_commands($file, $command)
+ public function an_identity_should_be_able_to_execute_own_selfservice_commands(string $file, mixed $command): void
{
$this->assertInstanceOf(Command::class, $command);
- if ($command instanceof SelfServiceExecutable && !$command instanceof RaExecutable) {
-
+ if ($command instanceof SelfServiceExecutable && !$command instanceof RaExecutable) {
$actorId = new IdentityId('123');
$actorInstitution = new Institution('institution');
+ /** @var SelfServiceExecutable&AbstractCommand&MockInterface $command */
$command = m::mock($command);
$command->shouldReceive('getIdentityId')
->andReturn($actorId->getIdentityId());
@@ -174,19 +200,20 @@ public function an_identity_should_be_able_to_execute_own_selfservice_commands($
/**
* @test
* @dataProvider availableCommands
- *
- * @param mixed $value
*/
- public function an_identity_should_be_able_to_execute_configured_ra_commands($file, $command)
+ public function an_identity_should_be_able_to_execute_configured_ra_commands(string $file, mixed $command): void
{
$this->assertInstanceOf(Command::class, $command);
- if ($command instanceof RaExecutable && !$command instanceof SelfServiceExecutable) {
-
+ if ($command instanceof RaExecutable && !$command instanceof SelfServiceExecutable) {
$actorId = new IdentityId('123');
$actorInstitution = new Institution('institution');
+ /** @var RaExecutable&AbstractCommand&MockInterface $command */
$command = m::mock($command);
+ if (property_exists($command, 'identityId')) {
+ $command->identityId = $actorId;
+ }
$command->shouldReceive('getRaInstitution')
->andReturn($actorInstitution->getInstitution());
@@ -207,7 +234,7 @@ public function an_identity_should_be_able_to_execute_configured_ra_commands($fi
$authorizationContext = new InstitutionAuthorizationContext(
$institutionCollection,
- false
+ false,
);
$role = RegistrationAuthorityRole::raa();
@@ -225,9 +252,7 @@ public function an_identity_should_be_able_to_execute_configured_ra_commands($fi
}
$this->authorizationContextService->shouldReceive('buildInstitutionAuthorizationContext')
- ->with($actorId, m::on(function($arg) use ($role){
- return $arg == $role;
- }))
+ ->with($actorId, m::on(fn($arg): bool => $arg == $role))
->andReturn($authorizationContext);
$this->assertTrue($this->service->maySelfServiceCommandBeExecutedOnBehalfOf($command, $actorId));
@@ -239,18 +264,16 @@ public function an_identity_should_be_able_to_execute_configured_ra_commands($fi
/**
* @test
* @dataProvider availableCommands
- *
- * @param mixed $value
*/
- public function an_identity_should_be_able_to_execute_configured_ra_and_selfservice_commands($file, $command)
+ public function an_identity_should_be_able_to_execute_configured_ra_and_selfservice_commands(string $file, mixed $command): void
{
$this->assertInstanceOf(Command::class, $command);
- if ($command instanceof RaExecutable && $command instanceof SelfServiceExecutable) {
-
+ if ($command instanceof RaExecutable && $command instanceof SelfServiceExecutable) {
$actorId = new IdentityId('123');
$actorInstitution = new Institution('institution');
+ /** @var RaExecutable&AbstractCommand&MockInterface $command */
$command = m::mock($command);
$command->shouldReceive('getRaInstitution')
->andReturn($actorInstitution->getInstitution());
@@ -275,7 +298,7 @@ public function an_identity_should_be_able_to_execute_configured_ra_and_selfserv
$authorizationContext = new InstitutionAuthorizationContext(
$institutionCollection,
- false
+ false,
);
$role = RegistrationAuthorityRole::raa();
@@ -285,9 +308,7 @@ public function an_identity_should_be_able_to_execute_configured_ra_and_selfserv
}
$this->authorizationContextService->shouldReceive('buildInstitutionAuthorizationContext')
- ->with($actorId, m::on(function($arg) use ($role){
- return $arg == $role;
- }))
+ ->with($actorId, m::on(fn($arg): bool => $arg == $role))
->andReturn($authorizationContext);
@@ -300,18 +321,16 @@ public function an_identity_should_be_able_to_execute_configured_ra_and_selfserv
/**
* @test
* @dataProvider availableCommands
- *
- * @param mixed $value
*/
- public function an_identity_should_not_be_able_to_execute_someone_elses_selfservice_commands($file, $command)
+ public function an_identity_should_not_be_able_to_execute_someone_elses_selfservice_commands(string $file, mixed $command): void
{
$this->assertInstanceOf(Command::class, $command);
- if ($command instanceof SelfServiceExecutable && !$command instanceof RaExecutable) {
-
+ if ($command instanceof SelfServiceExecutable && !$command instanceof RaExecutable) {
$actorId = new IdentityId('123');
$actorInstitution = new Institution('institution');
+ /** @var SelfServiceExecutable&AbstractCommand&MockInterface $command */
$command = m::mock($command);
$command->shouldReceive('getIdentityId')
->andReturn(new IdentityId('someone else'));
@@ -343,18 +362,16 @@ public function an_identity_should_not_be_able_to_execute_someone_elses_selfserv
/**
* @test
* @dataProvider availableCommands
- *
- * @param mixed $value
*/
- public function an_identity_should_be_able_to_execute_unconfigured_ra_commands($file, $command)
+ public function an_identity_should_be_able_to_execute_unconfigured_ra_commands(string $file, mixed $command): void
{
$this->assertInstanceOf(Command::class, $command);
- if ($command instanceof RaExecutable && !$command instanceof SelfServiceExecutable) {
-
+ if ($command instanceof RaExecutable && !$command instanceof SelfServiceExecutable) {
$actorId = new IdentityId('123');
$actorInstitution = new Institution('institution');
+ /** @var RaExecutable&AbstractCommand&MockInterface $command */
$command = m::mock($command);
$command->shouldReceive('getRaInstitution')
->andReturn($actorInstitution->getInstitution());
@@ -375,7 +392,7 @@ public function an_identity_should_be_able_to_execute_unconfigured_ra_commands($
$authorizationContext = new InstitutionAuthorizationContext(
$institutionCollection,
- false
+ false,
);
$role = RegistrationAuthorityRole::raa();
@@ -383,6 +400,9 @@ public function an_identity_should_be_able_to_execute_unconfigured_ra_commands($
|| $command instanceof RevokeRegistrantsSecondFactorCommand
|| $command instanceof RevokeRegistrantsRecoveryTokenCommand
) {
+ if (property_exists($command, 'identityId')) {
+ $command->identityId = $actorId;
+ }
$role = RegistrationAuthorityRole::ra();
$mockInstitution = new Institution('mock institution');
$mockIdentity = m::mock(Identity::class);
@@ -393,9 +413,7 @@ public function an_identity_should_be_able_to_execute_unconfigured_ra_commands($
}
$this->authorizationContextService->shouldReceive('buildInstitutionAuthorizationContext')
- ->with($actorId, m::on(function($arg) use ($role) {
- return $arg == $role;
- }))
+ ->with($actorId, m::on(fn($arg): bool => $arg == $role))
->andReturn($authorizationContext);
$this->assertTrue($this->service->maySelfServiceCommandBeExecutedOnBehalfOf($command, $actorId));
@@ -406,79 +424,85 @@ public function an_identity_should_be_able_to_execute_unconfigured_ra_commands($
/**
* @test
- *
- * @param mixed $value
*/
- public function all_available_commands_should_be_tested()
+ public function all_available_commands_should_be_tested(): void
{
- $tested = array (
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Configuration\\Command\\AddRaLocationCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Configuration\\Command\\ChangeRaLocationCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Configuration\\Command\\CreateInstitutionConfigurationCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Configuration\\Command\\ReconfigureInstitutionConfigurationOptionsCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Configuration\\Command\\RemoveInstitutionConfigurationByUnnormalizedIdCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Configuration\\Command\\RemoveRaLocationCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Configuration\\Command\\UpdateConfigurationCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\AccreditIdentityCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\AddToWhitelistCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\AmendRegistrationAuthorityInformationCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\AppointRoleCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\BootstrapIdentityWithYubikeySecondFactorCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\CreateIdentityCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\ExpressLocalePreferenceCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\ForgetIdentityCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\MigrateVettedSecondFactorCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\PromiseSafeStoreSecretTokenPossessionCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\ProveGssfPossessionCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\ProvePhonePossessionCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\ProvePhoneRecoveryTokenPossessionCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\ProveU2fDevicePossessionCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\ProveYubikeyPossessionCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\RegisterSelfAssertedSecondFactorCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\RemoveFromWhitelistCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\ReplaceWhitelistCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\RetractRegistrationAuthorityCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\RevokeOwnRecoveryTokenCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\RevokeOwnSecondFactorCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\RevokeRegistrantsRecoveryTokenCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\RevokeRegistrantsSecondFactorCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\SaveVettingTypeHintCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\SelfVetSecondFactorCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\SendSecondFactorRegistrationEmailCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\SendVerifiedSecondFactorRemindersCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\UpdateIdentityCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\VerifyEmailCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Identity\\Command\\VetSecondFactorCommand',
- 'Surfnet\\StepupMiddleware\\CommandHandlingBundle\\Tests\\Command\\FixedUuidStubCommand',
- );
+ $tested = [
+ AddRaLocationCommand::class,
+ ChangeRaLocationCommand::class,
+ CreateInstitutionConfigurationCommand::class,
+ ReconfigureInstitutionConfigurationOptionsCommand::class,
+ RemoveInstitutionConfigurationByUnnormalizedIdCommand::class,
+ RemoveRaLocationCommand::class,
+ UpdateConfigurationCommand::class,
+ AccreditIdentityCommand::class,
+ AddToWhitelistCommand::class,
+ AmendRegistrationAuthorityInformationCommand::class,
+ AppointRoleCommand::class,
+ BootstrapIdentityWithYubikeySecondFactorCommand::class,
+ CreateIdentityCommand::class,
+ ExpressLocalePreferenceCommand::class,
+ ForgetIdentityCommand::class,
+ MigrateVettedSecondFactorCommand::class,
+ PromiseSafeStoreSecretTokenPossessionCommand::class,
+ ProveGssfPossessionCommand::class,
+ ProvePhonePossessionCommand::class,
+ ProvePhoneRecoveryTokenPossessionCommand::class,
+ ProveU2fDevicePossessionCommand::class,
+ ProveYubikeyPossessionCommand::class,
+ RegisterSelfAssertedSecondFactorCommand::class,
+ RemoveFromWhitelistCommand::class,
+ ReplaceWhitelistCommand::class,
+ RetractRegistrationAuthorityCommand::class,
+ RevokeOwnRecoveryTokenCommand::class,
+ RevokeOwnSecondFactorCommand::class,
+ RevokeRegistrantsRecoveryTokenCommand::class,
+ RevokeRegistrantsSecondFactorCommand::class,
+ SaveVettingTypeHintCommand::class,
+ SelfVetSecondFactorCommand::class,
+ SendSecondFactorRegistrationEmailCommand::class,
+ SendVerifiedSecondFactorRemindersCommand::class,
+ UpdateIdentityCommand::class,
+ VerifyEmailCommand::class,
+ VetSecondFactorCommand::class,
+ FixedUuidStubCommand::class,
+ ];
$available = $this->availableCommands();
$classNames = [];
foreach ($available as $command) {
- $classNames[] = get_class($command[1]);
+ $classNames[] = $command[1]::class;
}
$this->assertSame($tested, $classNames);
}
- public function availableCommands()
+ /**
+ * @return string[][]|Command[][]
+ */
+ public function availableCommands(): array
{
$rootPath = realpath(__DIR__ . '/../../../../../../../src');
- $basePath = realPath($rootPath . '/Surfnet/StepupMiddleware/CommandHandlingBundle').'/*';
+ assert(is_string($rootPath), 'Root path could not be determined correctly');
+ $basePath = realPath($rootPath . '/Surfnet/StepupMiddleware/CommandHandlingBundle') . '/*';
$commands = [];
// get folders
$folders = glob($basePath, GLOB_ONLYDIR);
+ assert(is_array($folders), 'Unable to grab the CommandHandlingBundle folders');
foreach ($folders as $folder) {
-
$commandPath = $folder . '/Command/*Command.php';
$files = glob($commandPath);
if ($files === false) {
continue;
}
+ assert(
+ is_array($files),
+ sprintf('Unable to grab the files from %s with pattern %s', $folder , $commandPath)
+ );
foreach ($files as $file) {
$className = str_replace($rootPath, '', $file);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Entity/ConfiguredInstitutionTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Entity/ConfiguredInstitutionTest.php
index e4338aee7..636923ec4 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Entity/ConfiguredInstitutionTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Entity/ConfiguredInstitutionTest.php
@@ -18,25 +18,27 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Configuration\Entity;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\ConfiguredInstitution;
class ConfiguredInstitutionTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
/**
* @test
* @group entity
*/
- public function a_configured_institution_is_correctly_serialized_to_json()
+ public function a_configured_institution_is_correctly_serialized_to_json(): void
{
$deserializedConfiguredInstitution = ['institution' => 'surfnet.nl'];
$configuredInstitution = ConfiguredInstitution::createFrom(
- new Institution($deserializedConfiguredInstitution['institution'])
+ new Institution($deserializedConfiguredInstitution['institution']),
);
$expectedSerializedConfiguredInstitution = json_encode($deserializedConfiguredInstitution);
- $actualSerializedConfiguredInstitution = json_encode($configuredInstitution);
+ $actualSerializedConfiguredInstitution = json_encode($configuredInstitution);
$this->assertSame($expectedSerializedConfiguredInstitution, $actualSerializedConfiguredInstitution);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Entity/RaLocationTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Entity/RaLocationTest.php
index 4b09d03de..bb9bf4cd6 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Entity/RaLocationTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Entity/RaLocationTest.php
@@ -18,6 +18,7 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Configuration\Entity;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
use Surfnet\Stepup\Configuration\Value\ContactInformation;
use Surfnet\Stepup\Configuration\Value\Institution;
@@ -27,17 +28,18 @@
class RaLocationTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
/**
* @test
* @group entity
*/
- public function an_ra_location_is_correctly_serialized_to_json()
+ public function an_ra_location_is_correctly_serialized_to_json(): void
{
$deserializedRaLocation = [
- 'id' => 'An id',
- 'institution' => 'surfnet.nl',
- 'name' => 'An RA location',
- 'location' => 'A location',
+ 'id' => 'An id',
+ 'institution' => 'surfnet.nl',
+ 'name' => 'An RA location',
+ 'location' => 'A location',
'contact_information' => 'Contact information',
];
@@ -46,12 +48,12 @@ public function an_ra_location_is_correctly_serialized_to_json()
new Institution($deserializedRaLocation['institution']),
new RaLocationName($deserializedRaLocation['name']),
new Location($deserializedRaLocation['location']),
- new ContactInformation($deserializedRaLocation['contact_information'])
+ new ContactInformation($deserializedRaLocation['contact_information']),
);
$expectedSerialization = json_encode($deserializedRaLocation);
- $actualSerialization = json_encode($raLocation);
+ $actualSerialization = json_encode($raLocation);
- $this->assertSame($expectedSerialization, $actualSerialization);
+ $this->assertSame($expectedSerialization, $actualSerialization);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/AllowedSecondFactorMapTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/AllowedSecondFactorMapTest.php
index e8257b962..9ca2ef191 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/AllowedSecondFactorMapTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/AllowedSecondFactorMapTest.php
@@ -18,6 +18,7 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Configuration\Service;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
use Surfnet\Stepup\Configuration\Value\AllowedSecondFactorList;
use Surfnet\Stepup\Configuration\Value\Institution;
@@ -27,11 +28,12 @@
class AllowedSecondFactorMapTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
/**
* @test
* @group domain
*/
- public function an_allowed_second_factor_that_contains_a_given_institution_will_result_in_a_filled_allowed_second_factor_list()
+ public function an_allowed_second_factor_that_contains_a_given_institution_will_result_in_a_filled_allowed_second_factor_list(): void
{
$institution = new Institution('institution-with-filled-list.test');
$allowedSecondFactors = [
@@ -54,7 +56,7 @@ public function an_allowed_second_factor_that_contains_a_given_institution_will_
* @test
* @group domain
*/
- public function an_allowed_second_factor_map_that_does_not_contain_a_given_institution_will_result_in_a_blank_allowed_second_factor_list()
+ public function an_allowed_second_factor_map_that_does_not_contain_a_given_institution_will_result_in_a_blank_allowed_second_factor_list(): void
{
$institution = new Institution('institution-with-blank-list.test');
$allowedSecondFactors = [];
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionAuthorizationOptionMapTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionAuthorizationOptionMapTest.php
index 674b3e3dc..572025608 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionAuthorizationOptionMapTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionAuthorizationOptionMapTest.php
@@ -18,7 +18,7 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Configuration\Service;
-
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
@@ -27,10 +27,11 @@
class InstitutionAuthorizationOptionMapTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
/**
* @var Institution
*/
- private $institution;
+ private Institution $institution;
public function setUp(): void
{
@@ -41,7 +42,7 @@ public function setUp(): void
* @test
* @group domain
*/
- public function an_array_initialized_with_authorizations_should_return_valid_institutions_per_role()
+ public function an_array_initialized_with_authorizations_should_return_valid_institutions_per_role(): void
{
$testData = [
['inst ', 'inst', 'use_ra'],
@@ -57,26 +58,66 @@ public function an_array_initialized_with_authorizations_should_return_valid_ins
$institutionAuthorizations = [];
foreach ($testData as $data) {
- $institutionAuthorizations[] = InstitutionAuthorization::create(new Institution($data[0]), new Institution($data[1]), new InstitutionRole($data[2]));
+ $institutionAuthorizations[] = InstitutionAuthorization::create(
+ new Institution($data[0]),
+ new Institution($data[1]),
+ new InstitutionRole($data[2]),
+ );
}
- $institutionAuthorizationMap = InstitutionAuthorizationOptionMap::fromInstitutionAuthorizations($this->institution, $institutionAuthorizations);
+ $institutionAuthorizationMap = InstitutionAuthorizationOptionMap::fromInstitutionAuthorizations(
+ $this->institution,
+ $institutionAuthorizations,
+ );
- $this->assertEquals(['inst','insta','instb'], $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::useRa())->getInstitutions($this->institution));
- $this->assertEquals(['insta','instb'], $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::useRaa())->getInstitutions($this->institution));
- $this->assertEquals(['insta'], $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::selectRaa())->getInstitutions($this->institution));
+ $this->assertEquals(
+ ['inst', 'insta', 'instb'],
+ $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::useRa())->getInstitutions(
+ $this->institution,
+ )
+ );
+ $this->assertEquals(
+ ['insta', 'instb'],
+ $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::useRaa())->getInstitutions(
+ $this->institution,
+ )
+ );
+ $this->assertEquals(
+ ['insta'],
+ $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::selectRaa())->getInstitutions(
+ $this->institution,
+ )
+ );
}
/**
* @test
* @group domain
*/
- public function an_array_initialized_with_no_authorizations_should_return_valid_institutions_per_role()
+ public function an_array_initialized_with_no_authorizations_should_return_valid_institutions_per_role(): void
{
- $institutionAuthorizationMap = InstitutionAuthorizationOptionMap::fromInstitutionAuthorizations($this->institution, []);
+ $institutionAuthorizationMap = InstitutionAuthorizationOptionMap::fromInstitutionAuthorizations(
+ $this->institution,
+ [],
+ );
- $this->assertEquals([], $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::useRa())->getInstitutions($this->institution));
- $this->assertEquals([], $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::useRaa())->getInstitutions($this->institution));
- $this->assertEquals([], $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::selectRaa())->getInstitutions($this->institution));
+ $this->assertEquals(
+ [],
+ $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::useRa())->getInstitutions(
+ $this->institution,
+ )
+ );
+ $this->assertEquals(
+ [],
+ $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::useRaa())->getInstitutions(
+ $this->institution,
+ )
+ );
+ $this->assertEquals(
+ [],
+ $institutionAuthorizationMap->getAuthorizationOptionsByRole(InstitutionRole::selectRaa())->getInstitutions(
+ $this->institution,
+ )
+ );
}
-}
\ No newline at end of file
+}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionAuthorizationServiceTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionAuthorizationServiceTest.php
index bbb8df3bb..712974d06 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionAuthorizationServiceTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionAuthorizationServiceTest.php
@@ -19,6 +19,8 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Configuration\Service;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase as TestCase;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
@@ -28,22 +30,18 @@
class InstitutionAuthorizationServiceTest extends TestCase
{
- /**
- * @var InstitutionAuthorizationService
- */
- private $service;
+ use MockeryPHPUnitIntegration;
- /**
- * @var InstitutionAuthorizationRepository|Mock
- */
- private $repository;
+ private InstitutionAuthorizationService $service;
+
+ private InstitutionAuthorizationRepository&MockInterface $repository;
public function setUp(): void
{
$this->repository = m::mock(InstitutionAuthorizationRepository::class);
$this->service = new InstitutionAuthorizationService(
- $this->repository
+ $this->repository,
);
}
@@ -51,7 +49,7 @@ public function setUp(): void
* Simulates the use case where an institution does have a specific institution config, but the token setting is
* disabled.
*/
- public function test_get_institution_options_from_service()
+ public function test_get_institution_options_from_service(): void
{
$institution = new Institution('surfnet.nl');
@@ -72,7 +70,10 @@ public function test_get_institution_options_from_service()
$this->assertEquals(InstitutionRole::useRa(), $institutionOptions->getInstitutionRole());
}
- private function buildAuthorizations($expectedInstitutions)
+ /**
+ * @return mixed[]
+ */
+ private function buildAuthorizations(array $expectedInstitutions): array
{
$authorizations = [];
foreach ($expectedInstitutions as $institution) {
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionConfigurationOptionsServiceTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionConfigurationOptionsServiceTest.php
index ce690c8a8..caed99a9a 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionConfigurationOptionsServiceTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Configuration/Service/InstitutionConfigurationOptionsServiceTest.php
@@ -19,6 +19,8 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Configuration\Service;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase as TestCase;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption;
@@ -28,22 +30,17 @@
class InstitutionConfigurationOptionsServiceTest extends TestCase
{
- /**
- * @var InstitutionConfigurationOptionsService
- */
- private $service;
+ use MockeryPHPUnitIntegration;
- /**
- * @var InstitutionConfigurationOptionsRepository|Mock
- */
- private $repository;
+ private InstitutionConfigurationOptionsService $service;
+
+ private InstitutionConfigurationOptionsRepository&MockInterface $repository;
/**
* A representation of the globally configured application setting for the numberOfTokensPerIdentity, this value
* is configured in the parameters.yml under the moniker of 'number_of_tokens_per_identity'
- * @var int
*/
- private $numberOfTokensPerIdentityDefault = 13;
+ private int $numberOfTokensPerIdentityDefault = 13;
public function setUp(): void
{
@@ -51,11 +48,11 @@ public function setUp(): void
$this->service = new InstitutionConfigurationOptionsService(
$this->repository,
- $this->numberOfTokensPerIdentityDefault
+ $this->numberOfTokensPerIdentityDefault,
);
}
- public function test_get_max_number_of_tokens_for_with_available_institution_configuration()
+ public function test_get_max_number_of_tokens_for_with_available_institution_configuration(): void
{
$institution = new Institution('surfnet.nl');
@@ -75,7 +72,7 @@ public function test_get_max_number_of_tokens_for_with_available_institution_con
* Simulates the use case where an institution does have a specific institution config, but the token setting is
* disabled.
*/
- public function test_get_max_number_of_tokens_for_with_default_institution_configuration_settings()
+ public function test_get_max_number_of_tokens_for_with_default_institution_configuration_settings(): void
{
$institution = new Institution('surfnet.nl');
@@ -97,7 +94,7 @@ public function test_get_max_number_of_tokens_for_with_default_institution_confi
* Simulates the use case where an institution does not have specific institution config, but defaults are used
* instead.
*/
- public function test_nullable_tokens_per_identity_options_in_institution_configuration_settings()
+ public function test_nullable_tokens_per_identity_options_in_institution_configuration_settings(): void
{
$institution = new Institution('surfnet.nl');
@@ -112,7 +109,7 @@ public function test_nullable_tokens_per_identity_options_in_institution_configu
$this->assertEquals($expectedNumberOfTokens, $numberOfTokens);
}
- private function buildConfigurationOption($expectedNumberOfTokens)
+ private function buildConfigurationOption(int $expectedNumberOfTokens): InstitutionConfigurationOptions&MockInterface
{
$numberOfTokensOptionMock = m::mock(NumberOfTokensPerIdentityOption::class);
$numberOfTokensOptionMock
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/AuthorityRoleTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/AuthorityRoleTypeTest.php
index f69e400d1..47fb8152c 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/AuthorityRoleTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/AuthorityRoleTypeTest.php
@@ -18,37 +18,37 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\AuthorityRoleType;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\AuthorityRole;
class AuthorityRoleTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
*/
public static function setUpBeforeClass(): void
{
- Type::addType(AuthorityRoleType::NAME, 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\AuthorityRoleType');
+ Type::addType(AuthorityRoleType::NAME, AuthorityRoleType::class);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$authorityRole = Type::getType(AuthorityRoleType::NAME);
@@ -61,11 +61,11 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$authorityRole = Type::getType(AuthorityRoleType::NAME);
- $input = AuthorityRole::raa();
+ $input = AuthorityRole::raa();
$output = $authorityRole->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
@@ -76,7 +76,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$authorityRole = Type::getType(AuthorityRoleType::NAME);
@@ -89,7 +89,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_an_authority_role_value_object()
+ public function a_non_null_value_is_converted_to_an_authority_role_value_object(): void
{
$authorityRole = Type::getType(AuthorityRoleType::NAME);
@@ -97,7 +97,7 @@ public function a_non_null_value_is_converted_to_an_authority_role_value_object(
$output = $authorityRole->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\StepupMiddleware\ApiBundle\Identity\Value\AuthorityRole', $output);
+ $this->assertInstanceOf(AuthorityRole::class, $output);
$this->assertEquals(new AuthorityRole($input), $output);
}
@@ -105,9 +105,9 @@ public function a_non_null_value_is_converted_to_an_authority_role_value_object(
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$authorityRole = Type::getType(AuthorityRoleType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/CommonNameTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/CommonNameTypeTest.php
index 6d106141f..f1bd6b66b 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/CommonNameTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/CommonNameTypeTest.php
@@ -18,37 +18,38 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\CommonNameType;
class CommonNameTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
*/
public static function setUpBeforeClass(): void
{
- Type::addType(CommonNameType::NAME, 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\CommonNameType');
+ Type::addType(CommonNameType::NAME, CommonNameType::class);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$commonName = Type::getType(CommonNameType::NAME);
@@ -61,11 +62,11 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$commonName = Type::getType(CommonNameType::NAME);
- $input = new CommonName('Arthur Dent');
+ $input = new CommonName('Arthur Dent');
$output = $commonName->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
@@ -76,7 +77,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$commonName = Type::getType(CommonNameType::NAME);
@@ -89,15 +90,15 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_stepup_common_name_object()
+ public function a_non_null_value_is_converted_to_the_stepup_common_name_object(): void
{
$commonName = Type::getType(CommonNameType::NAME);
- $input = 'Arthur Dent';
+ $input = 'Arthur Dent';
$output = $commonName->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Identity\Value\CommonName', $output);
+ $this->assertInstanceOf(CommonName::class, $output);
$this->assertEquals(new CommonName($input), $output);
}
@@ -105,9 +106,9 @@ public function a_non_null_value_is_converted_to_the_stepup_common_name_object()
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$commonName = Type::getType(CommonNameType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationContactInformationTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationContactInformationTypeTest.php
index fc1345167..cf8276298 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationContactInformationTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationContactInformationTypeTest.php
@@ -1,5 +1,7 @@
platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
@@ -52,11 +55,10 @@ public function setUp(): void
* @group doctrine
*
* @dataProvider \Surfnet\StepupMiddleware\ApiBundle\Tests\TestDataProvider::notNull
- * @param $incorrectValue
*/
- public function a_value_can_only_be_converted_to_sql_if_it_is_contact_information_or_null($incorrectValue)
+ public function a_value_can_only_be_converted_to_sql_if_it_is_contact_information_or_null(mixed $incorrectValue): void
{
- $this->expectException('Doctrine\DBAL\Types\ConversionException');
+ $this->expectException(ConversionException::class);
$configurationContactInformation = Type::getType(ConfigurationContactInformationType::NAME);
$configurationContactInformation->convertToDatabaseValue($incorrectValue, $this->platform);
@@ -66,7 +68,7 @@ public function a_value_can_only_be_converted_to_sql_if_it_is_contact_informatio
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$configurationContactInformation = Type::getType(ConfigurationContactInformationType::NAME);
@@ -79,12 +81,12 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$configurationContactInformation = Type::getType(ConfigurationContactInformationType::NAME);
$expected = 'Call me maybe';
- $input = new ContactInformation($expected);
+ $input = new ContactInformation($expected);
$output = $configurationContactInformation->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
@@ -95,7 +97,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$configurationContactInformation = Type::getType(ConfigurationContactInformationType::NAME);
@@ -108,7 +110,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_contact_information_value_object()
+ public function a_non_null_value_is_converted_to_a_contact_information_value_object(): void
{
$configurationContactInformation = Type::getType(ConfigurationContactInformationType::NAME);
@@ -116,7 +118,7 @@ public function a_non_null_value_is_converted_to_a_contact_information_value_obj
$output = $configurationContactInformation->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Configuration\Value\ContactInformation', $output);
+ $this->assertInstanceOf(ContactInformation::class, $output);
$this->assertEquals(new ContactInformation($input), $output);
}
@@ -124,9 +126,9 @@ public function a_non_null_value_is_converted_to_a_contact_information_value_obj
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$configurationContactInformation = Type::getType(ConfigurationContactInformationType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationInstitutionTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationInstitutionTypeTest.php
index e04a0860d..6eceb3e08 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationInstitutionTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationInstitutionTypeTest.php
@@ -18,18 +18,19 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\ConfigurationInstitutionType;
class ConfigurationInstitutionTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
@@ -38,20 +39,20 @@ public static function setUpBeforeClass(): void
{
Type::addType(
ConfigurationInstitutionType::NAME,
- 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\ConfigurationInstitutionType'
+ ConfigurationInstitutionType::class,
);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$configurationInstitution = Type::getType(ConfigurationInstitutionType::NAME);
@@ -65,11 +66,10 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @group doctrine
*
* @dataProvider \Surfnet\StepupMiddleware\ApiBundle\Tests\TestDataProvider::notNull
- * @param $incorrectValue
*/
- public function a_value_can_only_be_converted_to_sql_if_it_is_an_institution_or_null($incorrectValue)
+ public function a_value_can_only_be_converted_to_sql_if_it_is_an_institution_or_null(mixed $incorrectValue): void
{
- $this->expectException('Doctrine\DBAL\Types\ConversionException');
+ $this->expectException(ConversionException::class);
$configurationContactInformation = Type::getType(ConfigurationInstitutionType::NAME);
$configurationContactInformation->convertToDatabaseValue($incorrectValue, $this->platform);
@@ -79,14 +79,14 @@ public function a_value_can_only_be_converted_to_sql_if_it_is_an_institution_or_
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$configurationInstitution = Type::getType(ConfigurationInstitutionType::NAME);
$input = 'An institution';
$expected = 'an institution';
- $input = new Institution($input);
- $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
+ $input = new Institution($input);
+ $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
$this->assertEquals($expected, $output);
@@ -96,7 +96,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$configurationInstitution = Type::getType(ConfigurationInstitutionType::NAME);
@@ -109,7 +109,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_configuration_institution_value_object()
+ public function a_non_null_value_is_converted_to_a_configuration_institution_value_object(): void
{
$configurationInstitution = Type::getType(ConfigurationInstitutionType::NAME);
@@ -117,7 +117,7 @@ public function a_non_null_value_is_converted_to_a_configuration_institution_val
$output = $configurationInstitution->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Configuration\Value\Institution', $output);
+ $this->assertInstanceOf(Institution::class, $output);
$this->assertEquals(new Institution($input), $output);
}
@@ -125,9 +125,9 @@ public function a_non_null_value_is_converted_to_a_configuration_institution_val
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$configurationInstitution = Type::getType(ConfigurationInstitutionType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationLocationTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationLocationTypeTest.php
index 51edb2ae3..2e6cb23b6 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationLocationTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ConfigurationLocationTypeTest.php
@@ -1,5 +1,7 @@
platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$configurationLocation = Type::getType(ConfigurationLocationType::NAME);
@@ -65,11 +68,10 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @group doctrine
*
* @dataProvider \Surfnet\StepupMiddleware\ApiBundle\Tests\TestDataProvider::notNull
- * @param $incorrectValue
*/
- public function a_value_can_only_be_converted_to_sql_if_it_is_a_location_or_null($incorrectValue)
+ public function a_value_can_only_be_converted_to_sql_if_it_is_a_location_or_null(mixed $incorrectValue): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$configurationContactInformation = Type::getType(ConfigurationLocationType::NAME);
$configurationContactInformation->convertToDatabaseValue($incorrectValue, $this->platform);
@@ -79,13 +81,13 @@ public function a_value_can_only_be_converted_to_sql_if_it_is_a_location_or_null
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$configurationLocation = Type::getType(ConfigurationLocationType::NAME);
$expected = 'Somewhere behind you';
- $input = new Location($expected);
- $output = $configurationLocation->convertToDatabaseValue($input, $this->platform);
+ $input = new Location($expected);
+ $output = $configurationLocation->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
$this->assertEquals($expected, $output);
@@ -95,7 +97,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$configurationLocation = Type::getType(ConfigurationLocationType::NAME);
@@ -108,7 +110,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_configuration_location_value_object()
+ public function a_non_null_value_is_converted_to_a_configuration_location_value_object(): void
{
$configurationLocation = Type::getType(ConfigurationLocationType::NAME);
@@ -116,7 +118,7 @@ public function a_non_null_value_is_converted_to_a_configuration_location_value_
$output = $configurationLocation->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Configuration\Value\Location', $output);
+ $this->assertInstanceOf(Location::class, $output);
$this->assertEquals(new Location($input), $output);
}
@@ -124,9 +126,9 @@ public function a_non_null_value_is_converted_to_a_configuration_location_value_
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$configurationLocation = Type::getType(ConfigurationLocationType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ContactInformationTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ContactInformationTypeTest.php
index 865281b1e..334641892 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ContactInformationTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ContactInformationTypeTest.php
@@ -1,5 +1,7 @@
platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$contactInformation = Type::getType(ContactInformationType::NAME);
@@ -64,12 +68,12 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$contactInformation = Type::getType(ContactInformationType::NAME);
$expected = 'Call me maybe';
- $input = new ContactInformation($expected);
+ $input = new ContactInformation($expected);
$output = $contactInformation->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
@@ -80,7 +84,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$contactInformation = Type::getType(ContactInformationType::NAME);
@@ -93,7 +97,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_contact_information_value_object()
+ public function a_non_null_value_is_converted_to_a_contact_information_value_object(): void
{
$contactInformation = Type::getType(ContactInformationType::NAME);
@@ -101,7 +105,7 @@ public function a_non_null_value_is_converted_to_a_contact_information_value_obj
$output = $contactInformation->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Identity\Value\ContactInformation', $output);
+ $this->assertInstanceOf(ContactInformation::class, $output);
$this->assertEquals(new ContactInformation($input), $output);
}
@@ -109,9 +113,9 @@ public function a_non_null_value_is_converted_to_a_contact_information_value_obj
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$contactInformation = Type::getType(ContactInformationType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/DateTimeTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/DateTimeTypeTest.php
index 0b1e3b42d..4bb52952b 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/DateTimeTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/DateTimeTypeTest.php
@@ -20,37 +20,40 @@
use DateTime as CoreDateTime;
use DateTimeZone;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\DateTime\DateTime;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\DateTimeType;
+use function assert;
class DateTimeTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
*/
public static function setUpBeforeClass(): void
{
- Type::addType(DateTimeType::NAME, 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\DateTimeType');
+ Type::addType(DateTimeType::NAME, DateTimeType::class);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$dateTime = Type::getType(DateTimeType::NAME);
@@ -63,7 +66,7 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$dateTime = Type::getType(DateTimeType::NAME);
@@ -78,7 +81,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$dateTime = Type::getType(DateTimeType::NAME);
@@ -91,17 +94,17 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_string_is_converted_to_the_stepup_datetime_object()
+ public function a_string_is_converted_to_the_stepup_datetime_object(): void
{
$dateTime = Type::getType(DateTimeType::NAME);
- $databaseValue = '2015-02-17 10:48:22';
- $actualDateTime = $dateTime->convertToPHPValue($databaseValue, $this->platform);
- $expectedDateTime = new DateTime(
- CoreDateTime::createFromFormat('Y-m-d H:i:s', $databaseValue, new DateTimeZone('UTC'))
- );
+ $databaseValue = '2015-02-17 10:48:22';
+ $actualDateTime = $dateTime->convertToPHPValue($databaseValue, $this->platform);
+ $coreDateTime = CoreDateTime::createFromFormat('Y-m-d H:i:s', $databaseValue, new DateTimeZone('UTC'));
+ assert($coreDateTime instanceof CoreDateTime, 'Unable to create a DateTime object');
+ $expectedDateTime = new DateTime($coreDateTime);
- $this->assertInstanceOf('Surfnet\Stepup\DateTime\DateTime', $actualDateTime);
+ $this->assertInstanceOf(DateTime::class, $actualDateTime);
$this->assertEquals($expectedDateTime, $actualDateTime);
}
@@ -110,9 +113,9 @@ public function a_string_is_converted_to_the_stepup_datetime_object()
* @group doctrine
*
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$dateTime = Type::getType(DateTimeType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/DocumentNumberTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/DocumentNumberTypeTest.php
index c40641c97..33ddfb91b 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/DocumentNumberTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/DocumentNumberTypeTest.php
@@ -1,5 +1,7 @@
platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$type = Type::getType(DocumentNumberType::NAME);
@@ -61,7 +66,7 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_normal_document_number_is_converted_to_a_database_value()
+ public function a_normal_document_number_is_converted_to_a_database_value(): void
{
$type = Type::getType(DocumentNumberType::NAME);
@@ -76,7 +81,7 @@ public function a_normal_document_number_is_converted_to_a_database_value()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$type = Type::getType(DocumentNumberType::NAME);
@@ -90,11 +95,10 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @group doctrine
*
* @dataProvider \Surfnet\StepupMiddleware\ApiBundle\Tests\TestDataProvider::notNull
- * @param $incorrectValue
*/
- public function a_value_can_only_be_converted_to_sql_if_it_is_a_document_number_or_null($incorrectValue)
+ public function a_value_can_only_be_converted_to_sql_if_it_is_a_document_number_or_null(mixed $incorrectValue): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$configurationContactInformation = Type::getType(DocumentNumberType::NAME);
$configurationContactInformation->convertToDatabaseValue($incorrectValue, $this->platform);
@@ -104,14 +108,14 @@ public function a_value_can_only_be_converted_to_sql_if_it_is_a_document_number_
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_stepup_document_number_object()
+ public function a_non_null_value_is_converted_to_the_stepup_document_number_object(): void
{
$type = Type::getType(DocumentNumberType::NAME);
$input = '12345';
$output = $type->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Identity\Value\DocumentNumber', $output);
+ $this->assertInstanceOf(DocumentNumber::class, $output);
$this->assertTrue((new DocumentNumber($input))->equals($output));
}
@@ -119,9 +123,9 @@ public function a_non_null_value_is_converted_to_the_stepup_document_number_obje
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\InvalidArgumentException::class);
+ $this->expectException(TypeError::class);
$type = Type::getType(DocumentNumberType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/EmailTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/EmailTypeTest.php
index f630b2a8f..6c4ed6837 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/EmailTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/EmailTypeTest.php
@@ -18,37 +18,38 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Identity\Value\Email;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\EmailType;
class EmailTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
*/
public static function setUpBeforeClass(): void
{
- Type::addType(EmailType::NAME, 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\EmailType');
+ Type::addType(EmailType::NAME, EmailType::class);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$email = Type::getType(EmailType::NAME);
@@ -61,11 +62,11 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$email = Type::getType(EmailType::NAME);
- $input = new Email('arthur@babelfish.invalid');
+ $input = new Email('arthur@babelfish.invalid');
$output = $email->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
@@ -76,7 +77,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$email = Type::getType(EmailType::NAME);
@@ -89,7 +90,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_stepup_email_object()
+ public function a_non_null_value_is_converted_to_the_stepup_email_object(): void
{
$email = Type::getType(EmailType::NAME);
@@ -97,7 +98,7 @@ public function a_non_null_value_is_converted_to_the_stepup_email_object()
$output = $email->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Identity\Value\Email', $output);
+ $this->assertInstanceOf(Email::class, $output);
$this->assertEquals(new Email($input), $output);
}
@@ -105,9 +106,9 @@ public function a_non_null_value_is_converted_to_the_stepup_email_object()
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$email = Type::getType(EmailType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/InstitutionRoleTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/InstitutionRoleTypeTest.php
index 08a2c71d8..c7cb82c67 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/InstitutionRoleTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/InstitutionRoleTypeTest.php
@@ -18,19 +18,19 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
-use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\InstitutionRoleType;
class InstitutionRoleTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
@@ -39,20 +39,20 @@ public static function setUpBeforeClass(): void
{
Type::addType(
InstitutionRoleType::NAME,
- 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\InstitutionRoleType'
+ InstitutionRoleType::class,
);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$configurationInstitution = Type::getType(InstitutionRoleType::NAME);
@@ -65,13 +65,13 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$configurationInstitution = Type::getType(InstitutionRoleType::NAME);
$expected = 'use_ra';
- $input = new InstitutionRole($expected);
- $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
+ $input = new InstitutionRole($expected);
+ $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
$this->assertEquals($expected, $output);
@@ -81,7 +81,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$configurationInstitution = Type::getType(InstitutionRoleType::NAME);
@@ -94,7 +94,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_configuration_institution_value_object()
+ public function a_non_null_value_is_converted_to_a_configuration_institution_value_object(): void
{
$configurationInstitution = Type::getType(InstitutionRoleType::NAME);
@@ -102,7 +102,7 @@ public function a_non_null_value_is_converted_to_a_configuration_institution_val
$output = $configurationInstitution->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Configuration\Value\InstitutionRole', $output);
+ $this->assertInstanceOf(InstitutionRole::class, $output);
$this->assertEquals(new InstitutionRole($input), $output);
}
@@ -110,9 +110,9 @@ public function a_non_null_value_is_converted_to_a_configuration_institution_val
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$configurationInstitution = Type::getType(InstitutionRoleType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/InstitutionTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/InstitutionTypeTest.php
index 1c3c1ff33..edb107a84 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/InstitutionTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/InstitutionTypeTest.php
@@ -18,18 +18,19 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\InstitutionType;
class InstitutionTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
@@ -38,20 +39,20 @@ public static function setUpBeforeClass(): void
{
Type::addType(
InstitutionType::NAME,
- 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\InstitutionType'
+ InstitutionType::class,
);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$configurationInstitution = Type::getType(InstitutionType::NAME);
@@ -64,13 +65,13 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$configurationInstitution = Type::getType(InstitutionType::NAME);
$expected = 'an institution';
- $input = new Institution($expected);
- $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
+ $input = new Institution($expected);
+ $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
$this->assertEquals($expected, $output);
@@ -80,7 +81,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$configurationInstitution = Type::getType(InstitutionType::NAME);
@@ -93,7 +94,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_configuration_institution_value_object()
+ public function a_non_null_value_is_converted_to_a_configuration_institution_value_object(): void
{
$configurationInstitution = Type::getType(InstitutionType::NAME);
@@ -101,7 +102,7 @@ public function a_non_null_value_is_converted_to_a_configuration_institution_val
$output = $configurationInstitution->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Identity\Value\Institution', $output);
+ $this->assertInstanceOf(Institution::class, $output);
$this->assertEquals(new Institution($input), $output);
}
@@ -109,9 +110,9 @@ public function a_non_null_value_is_converted_to_a_configuration_institution_val
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$configurationInstitution = Type::getType(InstitutionType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/LocaleTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/LocaleTypeTest.php
index 4770cd7da..d34e64068 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/LocaleTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/LocaleTypeTest.php
@@ -1,5 +1,7 @@
platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$locale = Type::getType(LocaleType::NAME);
@@ -61,12 +64,12 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$locale = Type::getType(LocaleType::NAME);
$expected = 'en_GB';
- $input = new Locale('en_GB');
+ $input = new Locale('en_GB');
$output = $locale->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
@@ -77,7 +80,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$locale = Type::getType(LocaleType::NAME);
@@ -90,7 +93,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_locale_value_object()
+ public function a_non_null_value_is_converted_to_a_locale_value_object(): void
{
$locale = Type::getType(LocaleType::NAME);
@@ -98,7 +101,7 @@ public function a_non_null_value_is_converted_to_a_locale_value_object()
$output = $locale->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Identity\Value\Locale', $output);
+ $this->assertInstanceOf(Locale::class, $output);
$this->assertEquals(new Locale($input), $output);
}
@@ -106,9 +109,9 @@ public function a_non_null_value_is_converted_to_a_locale_value_object()
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$locale = Type::getType(LocaleType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/LocationTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/LocationTypeTest.php
index 46f08157e..3b228596e 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/LocationTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/LocationTypeTest.php
@@ -1,5 +1,7 @@
platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$location = Type::getType(LocationType::NAME);
@@ -64,13 +68,13 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$location = Type::getType(LocationType::NAME);
$expected = 'Somewhere behind you';
- $input = new Location($expected);
- $output = $location->convertToDatabaseValue($input, $this->platform);
+ $input = new Location($expected);
+ $output = $location->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
$this->assertEquals($expected, $output);
@@ -80,7 +84,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$location = Type::getType(LocationType::NAME);
@@ -93,7 +97,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_location_value_object()
+ public function a_non_null_value_is_converted_to_a_location_value_object(): void
{
$location = Type::getType(LocationType::NAME);
@@ -101,7 +105,7 @@ public function a_non_null_value_is_converted_to_a_location_value_object()
$output = $location->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Identity\Value\Location', $output);
+ $this->assertInstanceOf(Location::class, $output);
$this->assertEquals(new Location($input), $output);
}
@@ -109,9 +113,9 @@ public function a_non_null_value_is_converted_to_a_location_value_object()
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$location = Type::getType(LocationType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/NameIdTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/NameIdTypeTest.php
index 79e36da52..6c40a2c0d 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/NameIdTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/NameIdTypeTest.php
@@ -18,37 +18,39 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\NameIdType;
class NameIdTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
*/
public static function setUpBeforeClass(): void
{
- Type::addType(NameIdType::NAME, 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\NameIdType');
+ Type::addType(NameIdType::NAME, NameIdType::class);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$nameId = Type::getType(NameIdType::NAME);
@@ -61,12 +63,12 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$nameId = Type::getType(NameIdType::NAME);
$expected = md5('someNameId');
- $input = new NameId($expected);
+ $input = new NameId($expected);
$output = $nameId->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
@@ -77,7 +79,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$nameId = Type::getType(NameIdType::NAME);
@@ -90,7 +92,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_name_id_value_object()
+ public function a_non_null_value_is_converted_to_a_name_id_value_object(): void
{
$nameId = Type::getType(NameIdType::NAME);
@@ -98,7 +100,7 @@ public function a_non_null_value_is_converted_to_a_name_id_value_object()
$output = $nameId->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Identity\Value\NameId', $output);
+ $this->assertInstanceOf(NameId::class, $output);
$this->assertEquals(new NameId($input), $output);
}
@@ -106,9 +108,9 @@ public function a_non_null_value_is_converted_to_a_name_id_value_object()
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$nameId = Type::getType(NameIdType::NAME);
@@ -119,9 +121,9 @@ public function an_invalid_database_value_causes_an_exception_upon_conversion()
* @test
* @group doctrine
*/
- public function a_excessive_long_database_value_causes_an_exception_upon_conversion()
+ public function a_excessive_long_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$nameId = Type::getType(NameIdType::NAME);
// the bin2hex openssle random bytes combination creates a string of 256 characters long.
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/NumberOfTokensPerIdentityTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/NumberOfTokensPerIdentityTypeTest.php
index f44998ed6..ef7bd8bc2 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/NumberOfTokensPerIdentityTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/NumberOfTokensPerIdentityTypeTest.php
@@ -18,19 +18,20 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\NumberOfTokensPerIdentityType;
-
class NumberOfTokensPerIdentityTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
@@ -39,20 +40,20 @@ public static function setUpBeforeClass(): void
{
Type::addType(
NumberOfTokensPerIdentityType::NAME,
- 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\NumberOfTokensPerIdentityType'
+ NumberOfTokensPerIdentityType::class,
);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$numberOfTokensPerIdentity = Type::getType(NumberOfTokensPerIdentityType::NAME);
@@ -66,11 +67,10 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @group doctrine
*
* @dataProvider \Surfnet\StepupMiddleware\ApiBundle\Tests\TestDataProvider::notNull
- * @param $incorrectValue
*/
- public function a_value_can_only_be_converted_to_sql_if_it_is_an_option_type_or_null($incorrectValue)
+ public function a_value_can_only_be_converted_to_sql_if_it_is_an_option_type_or_null(mixed $incorrectValue): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$numberOfTokensPerIdentity = Type::getType(NumberOfTokensPerIdentityType::NAME);
$numberOfTokensPerIdentity->convertToDatabaseValue($incorrectValue, $this->platform);
@@ -80,13 +80,13 @@ public function a_value_can_only_be_converted_to_sql_if_it_is_an_option_type_or_
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$numberOfTokensPerIdentity = Type::getType(NumberOfTokensPerIdentityType::NAME);
$expected = 4;
- $input = new NumberOfTokensPerIdentityOption($expected);
- $output = $numberOfTokensPerIdentity->convertToDatabaseValue($input, $this->platform);
+ $input = new NumberOfTokensPerIdentityOption($expected);
+ $output = $numberOfTokensPerIdentity->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_numeric($output));
$this->assertEquals($expected, $output);
@@ -96,7 +96,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$numberOfTokensPerIdentity = Type::getType(NumberOfTokensPerIdentityType::NAME);
@@ -109,7 +109,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_an_option_value_object()
+ public function a_non_null_value_is_converted_to_an_option_value_object(): void
{
$numberOfTokensPerIdentity = Type::getType(NumberOfTokensPerIdentityType::NAME);
@@ -117,7 +117,7 @@ public function a_non_null_value_is_converted_to_an_option_value_object()
$output = $numberOfTokensPerIdentity->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption', $output);
+ $this->assertInstanceOf(NumberOfTokensPerIdentityOption::class, $output);
$this->assertEquals(new NumberOfTokensPerIdentityOption(2), $output);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/RaLocationNameTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/RaLocationNameTypeTest.php
index b868f6197..cfdb117de 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/RaLocationNameTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/RaLocationNameTypeTest.php
@@ -18,18 +18,19 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Configuration\Value\RaLocationName;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\RaLocationNameType;
class RaLocationNameTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
@@ -38,20 +39,20 @@ public static function setUpBeforeClass(): void
{
Type::addType(
RaLocationNameType::NAME,
- 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\RaLocationNameType'
+ RaLocationNameType::class,
);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$raLocationName = Type::getType(RaLocationNameType::NAME);
@@ -64,13 +65,13 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$raLocationName = Type::getType(RaLocationNameType::NAME);
$expected = 'An RA Location Name';
- $input = new RaLocationName($expected);
- $output = $raLocationName->convertToDatabaseValue($input, $this->platform);
+ $input = new RaLocationName($expected);
+ $output = $raLocationName->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_string($output));
$this->assertEquals($expected, $output);
@@ -81,11 +82,10 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @group doctrine
*
* @dataProvider \Surfnet\StepupMiddleware\ApiBundle\Tests\TestDataProvider::notNull
- * @param $incorrectValue
*/
- public function a_value_can_only_be_converted_to_sql_if_it_is_an_ra_location_or_null($incorrectValue)
+ public function a_value_can_only_be_converted_to_sql_if_it_is_an_ra_location_or_null(mixed $incorrectValue): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$configurationContactInformation = Type::getType(RaLocationNameType::NAME);
$configurationContactInformation->convertToDatabaseValue($incorrectValue, $this->platform);
@@ -95,7 +95,7 @@ public function a_value_can_only_be_converted_to_sql_if_it_is_an_ra_location_or_
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$raLocationName = Type::getType(RaLocationNameType::NAME);
@@ -108,7 +108,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_ra_location_name_value_object()
+ public function a_non_null_value_is_converted_to_a_ra_location_name_value_object(): void
{
$raLocationName = Type::getType(RaLocationNameType::NAME);
@@ -116,7 +116,7 @@ public function a_non_null_value_is_converted_to_a_ra_location_name_value_object
$output = $raLocationName->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Configuration\Value\RaLocationName', $output);
+ $this->assertInstanceOf(RaLocationName::class, $output);
$this->assertEquals(new RaLocationName($input), $output);
}
@@ -124,9 +124,9 @@ public function a_non_null_value_is_converted_to_a_ra_location_name_value_object
* @test
* @group doctrine
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion()
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$raLocationName = Type::getType(RaLocationNameType::NAME);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/RecoveryTokenStatusTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/RecoveryTokenStatusTypeTest.php
index 1358bf4c8..6267e421d 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/RecoveryTokenStatusTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/RecoveryTokenStatusTypeTest.php
@@ -18,18 +18,20 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
+use stdClass;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\RecoveryTokenStatusType;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RecoveryTokenStatus;
class RecoveryTokenStatusTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
@@ -41,18 +43,18 @@ public static function setUpBeforeClass(): void
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
- public function invalidPhpValues()
+ public function invalidPhpValues(): array
{
return [
'null' => [null],
'string' => ['string'],
'int' => [9],
'float' => [9.1],
- 'array' => [array()],
- 'object of a different type' => [new \stdClass],
+ 'array' => [[]],
+ 'object of a different type' => [new stdClass],
'resource' => [fopen('php://memory', 'w')],
];
}
@@ -61,18 +63,16 @@ public function invalidPhpValues()
* @test
* @dataProvider invalidPhpValues
* @group doctrine
- *
- * @param mixed $value
*/
- public function an_invalid_php_value_is_not_accepted_in_to_sql_conversion($value)
+ public function an_invalid_php_value_is_not_accepted_in_to_sql_conversion(mixed $value): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$type = Type::getType(RecoveryTokenStatusType::NAME);
$type->convertToDatabaseValue($value, $this->platform);
}
- public function validPhpValues()
+ public function validPhpValues(): array
{
return [
'active' => [RecoveryTokenStatus::active(), 0],
@@ -85,25 +85,24 @@ public function validPhpValues()
* @test
* @dataProvider validPhpValues
* @group doctrine
- *
- * @param mixed $phpValue
- * @param mixed $databaseValue
*/
- public function a_valid_php_value_is_converted_to_a_sql_value($phpValue, $databaseValue)
- {
+ public function a_valid_php_value_is_converted_to_a_sql_value(
+ RecoveryTokenStatus $phpValue,
+ int $databaseValue,
+ ): void {
$type = Type::getType(RecoveryTokenStatusType::NAME);
$this->assertSame($databaseValue, $type->convertToDatabaseValue($phpValue, $this->platform));
}
- public function invalidDatabaseValues()
+ public function invalidDatabaseValues(): array
{
return [
'null' => [null],
'invalid string' => ['string'],
'int' => [9],
'float' => [9.1],
- 'array' => [array()],
- 'object of a different type' => [new \stdClass],
+ 'array' => [[]],
+ 'object of a different type' => [new stdClass],
'resource' => [fopen('php://memory', 'w')],
];
}
@@ -112,18 +111,16 @@ public function invalidDatabaseValues()
* @test
* @dataProvider invalidDatabaseValues
* @group doctrine
- *
- * @param mixed $input
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion($input)
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(mixed $input): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$type = Type::getType(RecoveryTokenStatusType::NAME);
$type->convertToPHPValue($input, $this->platform);
}
- public function validDatabaseValues()
+ public function validDatabaseValues(): array
{
return [
'active' => ['0', RecoveryTokenStatus::active()],
@@ -136,12 +133,11 @@ public function validDatabaseValues()
* @test
* @dataProvider validDatabaseValues
* @group doctrine
- *
- * @param int $databaseValue
- * @param mixed $phpValue
*/
- public function a_valid_database_value_is_converted_to_a_sql_value($databaseValue, $phpValue)
- {
+ public function a_valid_database_value_is_converted_to_a_sql_value(
+ string $databaseValue,
+ RecoveryTokenStatus $phpValue,
+ ): void {
$type = Type::getType(RecoveryTokenStatusType::NAME);
$this->assertTrue($phpValue->equals($type->convertToPHPValue($databaseValue, $this->platform)));
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/SecondFactorStatusTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/SecondFactorStatusTypeTest.php
index 69b4cacee..6fa40236d 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/SecondFactorStatusTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/SecondFactorStatusTypeTest.php
@@ -18,41 +18,44 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
+use stdClass;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\SecondFactorStatusType;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\SecondFactorStatus;
class SecondFactorStatusTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
*/
public static function setUpBeforeClass(): void
{
- Type::addType(SecondFactorStatusType::NAME, 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\SecondFactorStatusType');
+ Type::addType(SecondFactorStatusType::NAME, SecondFactorStatusType::class);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
- public function invalidPhpValues()
+ public function invalidPhpValues(): array
{
return [
'null' => [null],
'string' => ['string'],
'int' => [9],
'float' => [9.1],
- 'array' => [array()],
- 'object of a different type' => [new \stdClass],
+ 'array' => [[]],
+ 'object of a different type' => [new stdClass],
'resource' => [fopen('php://memory', 'w')],
];
}
@@ -61,18 +64,16 @@ public function invalidPhpValues()
* @test
* @dataProvider invalidPhpValues
* @group doctrine
- *
- * @param mixed $value
*/
- public function an_invalid_php_value_is_not_accepted_in_to_sql_conversion($value)
+ public function an_invalid_php_value_is_not_accepted_in_to_sql_conversion(mixed $value): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$type = Type::getType(SecondFactorStatusType::NAME);
$type->convertToDatabaseValue($value, $this->platform);
}
- public function validPhpValues()
+ public function validPhpValues(): array
{
return [
'unverified' => [SecondFactorStatus::unverified(), 0],
@@ -87,25 +88,22 @@ public function validPhpValues()
* @test
* @dataProvider validPhpValues
* @group doctrine
- *
- * @param mixed $phpValue
- * @param int $databaseValue
*/
- public function a_valid_php_value_is_converted_to_a_sql_value($phpValue, $databaseValue)
+ public function a_valid_php_value_is_converted_to_a_sql_value(mixed $phpValue, int $databaseValue): void
{
$type = Type::getType(SecondFactorStatusType::NAME);
$this->assertSame($databaseValue, $type->convertToDatabaseValue($phpValue, $this->platform));
}
- public function invalidDatabaseValues()
+ public function invalidDatabaseValues(): array
{
return [
'null' => [null],
'invalid string' => ['string'],
'int' => [9],
'float' => [9.1],
- 'array' => [array()],
- 'object of a different type' => [new \stdClass],
+ 'array' => [[]],
+ 'object of a different type' => [new stdClass],
'resource' => [fopen('php://memory', 'w')],
];
}
@@ -114,18 +112,16 @@ public function invalidDatabaseValues()
* @test
* @dataProvider invalidDatabaseValues
* @group doctrine
- *
- * @param mixed $input
*/
- public function an_invalid_database_value_causes_an_exception_upon_conversion($input)
+ public function an_invalid_database_value_causes_an_exception_upon_conversion(mixed $input): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$type = Type::getType(SecondFactorStatusType::NAME);
$type->convertToPHPValue($input, $this->platform);
}
- public function validDatabaseValues()
+ public function validDatabaseValues(): array
{
return [
'unverified' => ['0', SecondFactorStatus::unverified()],
@@ -140,11 +136,8 @@ public function validDatabaseValues()
* @test
* @dataProvider validDatabaseValues
* @group doctrine
- *
- * @param int $databaseValue
- * @param mixed $phpValue
*/
- public function a_valid_database_value_is_converted_to_a_sql_value($databaseValue, $phpValue)
+ public function a_valid_database_value_is_converted_to_a_sql_value(string $databaseValue, mixed $phpValue): void
{
$type = Type::getType(SecondFactorStatusType::NAME);
$this->assertTrue($phpValue->equals($type->convertToPHPValue($databaseValue, $this->platform)));
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/SelfVetOptionTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/SelfVetOptionTypeTest.php
index 449945e99..33bf62589 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/SelfVetOptionTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/SelfVetOptionTypeTest.php
@@ -18,18 +18,20 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Configuration\Value\SelfVetOption;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\SelfVetOptionType;
class SelfVetOptionTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
@@ -38,20 +40,20 @@ public static function setUpBeforeClass(): void
{
Type::addType(
SelfVetOptionType::NAME,
- 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\SelfVetOptionType'
+ SelfVetOptionType::class,
);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$configurationInstitution = Type::getType(SelfVetOptionType::NAME);
@@ -65,11 +67,10 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @group doctrine
*
* @dataProvider \Surfnet\StepupMiddleware\ApiBundle\Tests\TestDataProvider::notNull
- * @param $incorrectValue
*/
- public function a_value_can_only_be_converted_to_sql_if_it_is_an_option_type_or_null($incorrectValue)
+ public function a_value_can_only_be_converted_to_sql_if_it_is_an_option_type_or_null(mixed $incorrectValue): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$configurationContactInformation = Type::getType(SelfVetOptionType::NAME);
$configurationContactInformation->convertToDatabaseValue($incorrectValue, $this->platform);
@@ -79,13 +80,13 @@ public function a_value_can_only_be_converted_to_sql_if_it_is_an_option_type_or_
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$configurationInstitution = Type::getType(SelfVetOptionType::NAME);
$expected = true;
- $input = new SelfVetOption($expected);
- $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
+ $input = new SelfVetOption($expected);
+ $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_numeric($output));
$this->assertEquals($expected, $output);
@@ -95,7 +96,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$configurationInstitution = Type::getType(SelfVetOptionType::NAME);
@@ -108,7 +109,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_an_option_valu_object()
+ public function a_non_null_value_is_converted_to_an_option_valu_object(): void
{
$configurationInstitution = Type::getType(SelfVetOptionType::NAME);
@@ -116,7 +117,7 @@ public function a_non_null_value_is_converted_to_an_option_valu_object()
$output = $configurationInstitution->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Configuration\Value\SelfVetOption', $output);
+ $this->assertInstanceOf(\Surfnet\Stepup\Configuration\Value\SelfVetOption::class, $output);
$this->assertEquals(new SelfVetOption($input), $output);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ShowRaaContactInformationOptionTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ShowRaaContactInformationOptionTypeTest.php
index 19505c17b..1466d15cf 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ShowRaaContactInformationOptionTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/ShowRaaContactInformationOptionTypeTest.php
@@ -18,8 +18,10 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\ShowRaaContactInformationOptionType;
@@ -27,10 +29,10 @@
class ShowRaaContactInformationOptionTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
@@ -39,20 +41,20 @@ public static function setUpBeforeClass(): void
{
Type::addType(
ShowRaaContactInformationOptionType::NAME,
- 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\ShowRaaContactInformationOptionType'
+ ShowRaaContactInformationOptionType::class,
);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$configurationInstitution = Type::getType(ShowRaaContactInformationOptionType::NAME);
@@ -66,11 +68,11 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @group doctrine
*
* @dataProvider \Surfnet\StepupMiddleware\ApiBundle\Tests\TestDataProvider::notNull
- * @param $incorrectValue
*/
- public function a_value_can_only_be_converted_to_sql_if_it_is_a_show_raa_contact_information_option_or_null($incorrectValue)
- {
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ public function a_value_can_only_be_converted_to_sql_if_it_is_a_show_raa_contact_information_option_or_null(
+ mixed $incorrectValue,
+ ): void {
+ $this->expectException(ConversionException::class);
$configurationContactInformation = Type::getType(ShowRaaContactInformationOptionType::NAME);
$configurationContactInformation->convertToDatabaseValue($incorrectValue, $this->platform);
@@ -80,13 +82,13 @@ public function a_value_can_only_be_converted_to_sql_if_it_is_a_show_raa_contact
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$configurationInstitution = Type::getType(ShowRaaContactInformationOptionType::NAME);
$expected = true;
- $input = new ShowRaaContactInformationOption($expected);
- $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
+ $input = new ShowRaaContactInformationOption($expected);
+ $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_numeric($output));
$this->assertEquals($expected, $output);
@@ -96,7 +98,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$configurationInstitution = Type::getType(ShowRaaContactInformationOptionType::NAME);
@@ -109,7 +111,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_show_raa_contact_information_option_value_object()
+ public function a_non_null_value_is_converted_to_a_show_raa_contact_information_option_value_object(): void
{
$configurationInstitution = Type::getType(ShowRaaContactInformationOptionType::NAME);
@@ -117,7 +119,7 @@ public function a_non_null_value_is_converted_to_a_show_raa_contact_information_
$output = $configurationInstitution->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption', $output);
+ $this->assertInstanceOf(ShowRaaContactInformationOption::class, $output);
$this->assertEquals(new ShowRaaContactInformationOption($input), $output);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/UseRaLocationsOptionTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/UseRaLocationsOptionTypeTest.php
index 693c10e5a..4e7462fcb 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/UseRaLocationsOptionTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/UseRaLocationsOptionTypeTest.php
@@ -18,18 +18,20 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\UseRaLocationsOptionType;
class UseRaLocationsOptionTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
@@ -38,20 +40,20 @@ public static function setUpBeforeClass(): void
{
Type::addType(
UseRaLocationsOptionType::NAME,
- 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\UseRaLocationsOptionType'
+ UseRaLocationsOptionType::class,
);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$configurationInstitution = Type::getType(UseRaLocationsOptionType::NAME);
@@ -65,11 +67,10 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @group doctrine
*
* @dataProvider \Surfnet\StepupMiddleware\ApiBundle\Tests\TestDataProvider::notNull
- * @param $incorrectValue
*/
- public function a_value_can_only_be_converted_to_sql_if_it_is_a_use_ra_locations_option_or_null($incorrectValue)
+ public function a_value_can_only_be_converted_to_sql_if_it_is_a_use_ra_locations_option_or_null(mixed $incorrectValue,): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$configurationContactInformation = Type::getType(UseRaLocationsOptionType::NAME);
$configurationContactInformation->convertToDatabaseValue($incorrectValue, $this->platform);
@@ -79,13 +80,13 @@ public function a_value_can_only_be_converted_to_sql_if_it_is_a_use_ra_locations
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$configurationInstitution = Type::getType(UseRaLocationsOptionType::NAME);
$expected = true;
- $input = new UseRaLocationsOption($expected);
- $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
+ $input = new UseRaLocationsOption($expected);
+ $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_numeric($output));
$this->assertEquals($expected, $output);
@@ -95,7 +96,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$configurationInstitution = Type::getType(UseRaLocationsOptionType::NAME);
@@ -108,7 +109,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_a_use_ra_locations_option_value_object()
+ public function a_non_null_value_is_converted_to_a_use_ra_locations_option_value_object(): void
{
$configurationInstitution = Type::getType(UseRaLocationsOptionType::NAME);
@@ -116,7 +117,7 @@ public function a_non_null_value_is_converted_to_a_use_ra_locations_option_value
$output = $configurationInstitution->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Configuration\Value\UseRaLocationsOption', $output);
+ $this->assertInstanceOf(UseRaLocationsOption::class, $output);
$this->assertEquals(new UseRaLocationsOption($input), $output);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/VerifyEmailOptionTypeTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/VerifyEmailOptionTypeTest.php
index 8524a3479..367fe53d4 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/VerifyEmailOptionTypeTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Doctrine/Type/VerifyEmailOptionTypeTest.php
@@ -18,18 +18,19 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Doctrine\Type;
-use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\MariaDBPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
use Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\VerifyEmailOptionType;
class VerifyEmailOptionTypeTest extends UnitTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\MySqlPlatform
- */
- private $platform;
+ use MockeryPHPUnitIntegration;
+
+ private MariaDBPlatform $platform;
/**
* Register the type, since we're forced to use the factory method.
@@ -38,20 +39,20 @@ public static function setUpBeforeClass(): void
{
Type::addType(
VerifyEmailOptionType::NAME,
- 'Surfnet\StepupMiddleware\ApiBundle\Doctrine\Type\VerifyEmailOptionType'
+ VerifyEmailOptionType::class,
);
}
public function setUp(): void
{
- $this->platform = new MySqlPlatform();
+ $this->platform = new MariaDBPlatform();
}
/**
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_in_to_sql_conversion()
+ public function a_null_value_remains_null_in_to_sql_conversion(): void
{
$configurationInstitution = Type::getType(VerifyEmailOptionType::NAME);
@@ -65,11 +66,10 @@ public function a_null_value_remains_null_in_to_sql_conversion()
* @group doctrine
*
* @dataProvider \Surfnet\StepupMiddleware\ApiBundle\Tests\TestDataProvider::notNull
- * @param $incorrectValue
*/
- public function a_value_can_only_be_converted_to_sql_if_it_is_an_option_type_or_null($incorrectValue)
+ public function a_value_can_only_be_converted_to_sql_if_it_is_an_option_type_or_null(mixed $incorrectValue): void
{
- $this->expectException(\Doctrine\DBAL\Types\ConversionException::class);
+ $this->expectException(ConversionException::class);
$configurationContactInformation = Type::getType(VerifyEmailOptionType::NAME);
$configurationContactInformation->convertToDatabaseValue($incorrectValue, $this->platform);
@@ -79,13 +79,13 @@ public function a_value_can_only_be_converted_to_sql_if_it_is_an_option_type_or_
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_the_correct_format()
+ public function a_non_null_value_is_converted_to_the_correct_format(): void
{
$configurationInstitution = Type::getType(VerifyEmailOptionType::NAME);
$expected = true;
- $input = new VerifyEmailOption($expected);
- $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
+ $input = new VerifyEmailOption($expected);
+ $output = $configurationInstitution->convertToDatabaseValue($input, $this->platform);
$this->assertTrue(is_numeric($output));
$this->assertEquals($expected, $output);
@@ -95,7 +95,7 @@ public function a_non_null_value_is_converted_to_the_correct_format()
* @test
* @group doctrine
*/
- public function a_null_value_remains_null_when_converting_from_db_to_php_value()
+ public function a_null_value_remains_null_when_converting_from_db_to_php_value(): void
{
$configurationInstitution = Type::getType(VerifyEmailOptionType::NAME);
@@ -108,7 +108,7 @@ public function a_null_value_remains_null_when_converting_from_db_to_php_value()
* @test
* @group doctrine
*/
- public function a_non_null_value_is_converted_to_an_option_valu_object()
+ public function a_non_null_value_is_converted_to_an_option_valu_object(): void
{
$configurationInstitution = Type::getType(VerifyEmailOptionType::NAME);
@@ -116,7 +116,7 @@ public function a_non_null_value_is_converted_to_an_option_valu_object()
$output = $configurationInstitution->convertToPHPValue($input, $this->platform);
- $this->assertInstanceOf('Surfnet\Stepup\Configuration\Value\VerifyEmailOption', $output);
+ $this->assertInstanceOf(VerifyEmailOption::class, $output);
$this->assertEquals(new VerifyEmailOption($input), $output);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/ConfiguredInstitutionControllerTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/ConfiguredInstitutionControllerTest.php
index 405752aa2..160a9ccfe 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/ConfiguredInstitutionControllerTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/ConfiguredInstitutionControllerTest.php
@@ -16,41 +16,67 @@
* limitations under the License.
*/
-namespace Surfnet\StepupMiddleware\AoiBundle\Tests\Endpoint;
+namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Endpoint;
+use Doctrine\Persistence\ManagerRegistry;
use Generator;
-use Liip\TestFixturesBundle\Test\FixturesTrait;
+use Liip\TestFixturesBundle\Services\DatabaseToolCollection;
+use Liip\TestFixturesBundle\Services\DatabaseTools\AbstractDatabaseTool;
+use Liip\TestFixturesBundle\Services\DatabaseTools\ORMSqliteDatabaseTool;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
+use Symfony\Component\HttpFoundation\Response;
+use function is_string;
class ConfiguredInstitutionControllerTest extends WebTestCase
{
- use FixturesTrait;
+ use MockeryPHPUnitIntegration;
- /**
- * @var \Symfony\Bundle\FrameworkBundle\Client
- */
- private $client;
+ private KernelBrowser $client;
/**
* @var string[]
*/
- private $accounts;
+ private array $accounts;
/**
* @var string
*/
- private $endpoint;
+ private string $endpoint;
+
+ private AbstractDatabaseTool $databaseTool;
+
public function setUp(): void
{
- // Initialises schema.
- $this->loadFixtures([]);
+ self::ensureKernelShutdown();
+
$this->client = static::createClient();
+ $databaseTool = $this->client->getContainer()->get(DatabaseToolCollection::class);
+ if (!$databaseTool instanceof DatabaseToolCollection) {
+ $this->fail('Unable to grab the ORMSqliteDatabaseTool from the container');
+ }
+ $this->databaseTool = $databaseTool->get();
+
+ $registry = static::getContainer()->get(ManagerRegistry::class);
+ assert($registry instanceof ManagerRegistry, 'ManagerRegistry could not be fetched from the container');
+ $this->databaseTool->setRegistry($registry);
+
+ $this->databaseTool->setObjectManagerName('middleware');
+ // Initialises schema.
+ $this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
+ $this->databaseTool->loadFixtures();
+
$passwordSs = $this->client->getKernel()->getContainer()->getParameter('selfservice_api_password');
$passwordRa = $this->client->getKernel()->getContainer()->getParameter('registration_authority_api_password');
$passwordRo = $this->client->getKernel()->getContainer()->getParameter('readonly_api_password');
+ assert(is_string($passwordSs), 'Parameter selfservice_api_password must be of type string');
+ assert(is_string($passwordRa), 'Parameter registration_authority_api_password must be of type string');
+ assert(is_string($passwordRo), 'Parameter readonly_api_password must be of type string');
+
$this->accounts = ['ss' => $passwordSs, 'ra' => $passwordRa, 'apireader' => $passwordRo];
$this->endpoint = '/institution-listing';
@@ -67,7 +93,7 @@ public function tearDown(): void
*
* @dataProvider invalidHttpMethodProvider
*/
- public function only_get_requests_are_accepted($invalidHttpMethod)
+ public function only_get_requests_are_accepted(string $invalidHttpMethod): void
{
$this->client->request(
$invalidHttpMethod,
@@ -75,13 +101,13 @@ public function only_get_requests_are_accepted($invalidHttpMethod)
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json'
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('405', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_METHOD_NOT_ALLOWED, $this->client->getResponse()->getStatusCode());
}
/**
@@ -89,7 +115,7 @@ public function only_get_requests_are_accepted($invalidHttpMethod)
* @group api
* @dataProvider notAllowedAccountsProvider
*/
- public function no_access_for_not_allowed_account(string $account)
+ public function no_access_for_not_allowed_account(string $account): void
{
$this->client->request(
'GET',
@@ -97,22 +123,22 @@ public function no_access_for_not_allowed_account(string $account)
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => $account,
- 'PHP_AUTH_PW' => $this->accounts[$account],
+ 'PHP_AUTH_PW' => $this->accounts[$account],
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('403', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_FORBIDDEN, $this->client->getResponse()->getStatusCode());
}
/**
* @test
* @group api
*/
- public function json_is_returned_from_the_api()
+ public function json_is_returned_from_the_api(): void
{
$this->client->request(
'GET',
@@ -120,19 +146,19 @@ public function json_is_returned_from_the_api()
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => 'ra',
- 'PHP_AUTH_PW' => $this->accounts['ra'],
+ 'PHP_AUTH_PW' => $this->accounts['ra'],
],
- json_encode([])
+ '[]',
);
$this->assertTrue(
$this->client->getResponse()->headers->contains(
'Content-Type',
- 'application/json'
- )
+ 'application/json',
+ ),
);
}
@@ -141,7 +167,7 @@ public function json_is_returned_from_the_api()
* @group api
* @dataProvider allowedAccountsProvider
*/
- public function correct_institutions_are_returned(string $account)
+ public function correct_institutions_are_returned(string $account): void
{
$this->client->request(
'GET',
@@ -149,29 +175,31 @@ public function correct_institutions_are_returned(string $account)
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => $account,
- 'PHP_AUTH_PW' => $this->accounts[$account],
+ 'PHP_AUTH_PW' => $this->accounts[$account],
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('200', $this->client->getResponse()->getStatusCode());
- $response = json_decode($this->client->getResponse()->getContent());
+ $this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
+ $content = $this->client->getResponse()->getContent();
+ assert(is_string($content), 'Unable to get the Response Content from the browser client');
+ $response = json_decode($content);
$this->assertEquals([], $response);
}
/**
* Dataprovider for only_get_requests_are_accepted
*/
- public function invalidHttpMethodProvider()
+ public function invalidHttpMethodProvider(): array
{
return [
'POST' => ['POST'],
'DELETE' => ['DELETE'],
'PUT' => ['PUT'],
- 'OPTIONS' => ['OPTIONS']
+ 'OPTIONS' => ['OPTIONS'],
];
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/SraaControllerTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/SraaControllerTest.php
index 973bfccb6..dce2051c0 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/SraaControllerTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Endpoint/SraaControllerTest.php
@@ -16,41 +16,55 @@
* limitations under the License.
*/
-namespace Surfnet\StepupMiddleware\AoiBundle\Tests\Endpoint;
+namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Endpoint;
use Generator;
-use Liip\TestFixturesBundle\Test\FixturesTrait;
+use Liip\TestFixturesBundle\Services\DatabaseToolCollection;
+use Liip\TestFixturesBundle\Services\DatabaseTools\AbstractDatabaseTool;
+use Liip\TestFixturesBundle\Services\DatabaseTools\ORMSqliteDatabaseTool;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
+use Symfony\Component\HttpFoundation\Response;
+use function is_string;
class SraaControllerTest extends WebTestCase
{
- use FixturesTrait;
+ use MockeryPHPUnitIntegration;
- /**
- * @var \Symfony\Bundle\FrameworkBundle\Client
- */
- private $client;
+ private KernelBrowser $client;
/**
* @var string[]
*/
- private $accounts;
+ private array $accounts;
- /**
- * @var string
- */
- private $endpoint;
+ private string $endpoint;
+
+ private AbstractDatabaseTool $databaseTool;
public function setUp(): void
{
- // Initialises schema.
- $this->loadFixtures([]);
$this->client = static::createClient();
+ $databaseTool = $this->client->getContainer()->get(DatabaseToolCollection::class);
+ if (!$databaseTool instanceof DatabaseToolCollection) {
+ $this->fail('Unable to grab the ORMSqliteDatabaseTool from the container');
+ }
+ $this->databaseTool = $databaseTool->get();
+
+ // Initialises schema.
+ $this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
+ $this->databaseTool->loadFixtures([]);
+
$passwordSs = $this->client->getKernel()->getContainer()->getParameter('selfservice_api_password');
$passwordRa = $this->client->getKernel()->getContainer()->getParameter('registration_authority_api_password');
$passwordRo = $this->client->getKernel()->getContainer()->getParameter('readonly_api_password');
+ assert(is_string($passwordSs));
+ assert(is_string($passwordRa));
+ assert(is_string($passwordRo));
+
$this->accounts = ['ss' => $passwordSs, 'ra' => $passwordRa, 'apireader' => $passwordRo];
$this->endpoint = '/sraa';
@@ -67,7 +81,7 @@ public function tearDown(): void
*
* @dataProvider invalidHttpMethodProvider
*/
- public function only_get_requests_are_accepted($invalidHttpMethod)
+ public function only_get_requests_are_accepted(string $invalidHttpMethod): void
{
$this->client->request(
$invalidHttpMethod,
@@ -75,13 +89,13 @@ public function only_get_requests_are_accepted($invalidHttpMethod)
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json'
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('405', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_METHOD_NOT_ALLOWED, $this->client->getResponse()->getStatusCode());
}
/**
@@ -89,7 +103,7 @@ public function only_get_requests_are_accepted($invalidHttpMethod)
* @group api
* @dataProvider notAllowedAccountsProvider
*/
- public function no_access_for_not_allowed_account(string $account)
+ public function no_access_for_not_allowed_account(string $account): void
{
$this->client->request(
'GET',
@@ -97,22 +111,22 @@ public function no_access_for_not_allowed_account(string $account)
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => $account,
- 'PHP_AUTH_PW' => $this->accounts[$account],
+ 'PHP_AUTH_PW' => $this->accounts[$account],
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('403', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_FORBIDDEN, $this->client->getResponse()->getStatusCode());
}
/**
* @test
* @group api
*/
- public function json_is_returned_from_the_api()
+ public function json_is_returned_from_the_api(): void
{
$this->client->request(
'GET',
@@ -120,19 +134,19 @@ public function json_is_returned_from_the_api()
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => 'ra',
- 'PHP_AUTH_PW' => $this->accounts['ra'],
+ 'PHP_AUTH_PW' => $this->accounts['ra'],
],
- json_encode([])
+ '[]',
);
$this->assertTrue(
$this->client->getResponse()->headers->contains(
'Content-Type',
- 'application/json'
- )
+ 'application/json',
+ ),
);
}
@@ -141,7 +155,7 @@ public function json_is_returned_from_the_api()
* @group api
* @dataProvider allowedAccountsProvider
*/
- public function correct_institutions_are_returned(string $account)
+ public function correct_institutions_are_returned(string $account): void
{
$this->client->request(
'GET',
@@ -149,29 +163,31 @@ public function correct_institutions_are_returned(string $account)
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => $account,
- 'PHP_AUTH_PW' => $this->accounts[$account],
+ 'PHP_AUTH_PW' => $this->accounts[$account],
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('200', $this->client->getResponse()->getStatusCode());
- $response = json_decode($this->client->getResponse()->getContent());
+ $this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
+ $content = $this->client->getResponse()->getContent();
+ assert(is_string($content), 'Response content must be of type string');
+ $response = json_decode($content);
$this->assertEquals([], $response);
}
/**
* Dataprovider for only_get_requests_are_accepted
*/
- public function invalidHttpMethodProvider()
+ public function invalidHttpMethodProvider(): array
{
return [
'POST' => ['POST'],
'DELETE' => ['DELETE'],
'PUT' => ['PUT'],
- 'OPTIONS' => ['OPTIONS']
+ 'OPTIONS' => ['OPTIONS'],
];
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Projector/AuditLogProjectorTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Projector/AuditLogProjectorTest.php
index adc25c7d8..1a6590498 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Projector/AuditLogProjectorTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Projector/AuditLogProjectorTest.php
@@ -23,9 +23,12 @@
use Broadway\Domain\Metadata as MessageMetadata;
use DateTime as CoreDateTime;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\Matcher\MatcherAbstract;
use PHPUnit\Framework\TestCase;
use Surfnet\Stepup\DateTime\DateTime as StepupDateTime;
use Surfnet\Stepup\Identity\AuditLog\Metadata;
+use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
@@ -35,13 +38,17 @@
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\AuditLogEntry;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Projector\AuditLogProjector;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuditLogRepository;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository;
use Surfnet\StepupMiddleware\ApiBundle\Tests\Identity\Projector\Event\EventStub;
final class AuditLogProjectorTest extends TestCase
{
- private static $actorCommonName = 'Actor CommonName';
+ use MockeryPHPUnitIntegration;
- public function auditable_events()
+ private static string $actorCommonName = 'Actor CommonName';
+
+ public function auditable_events(): array
{
return [
'no actor, with second factor' => [
@@ -49,51 +56,48 @@ public function auditable_events()
'id',
0,
new MessageMetadata(),
- new EventStub($this->createAuditLogMetadata(
- new IdentityId('abcd'),
- new Institution('efgh'),
- new SecondFactorId('ijkl'),
- new SecondFactorType('yubikey'),
- new YubikeyPublicId('99992222')
- )),
- BroadwayDateTime::fromString('1970-01-01H00:00:00.000')
+ new EventStub(
+ $this->createAuditLogMetadata(
+ new IdentityId('abcd'),
+ new Institution('efgh'),
+ new SecondFactorId('ijkl'),
+ new SecondFactorType('yubikey'),
+ new YubikeyPublicId('99992222'),
+ ),
+ ),
+ BroadwayDateTime::fromString('1970-01-01H00:00:00.000'),
),
$this->createExpectedAuditLogEntry(
- null,
- null,
new IdentityId('abcd'),
new Institution('efgh'),
+ EventStub::class,
+ new StepupDateTime(new CoreDateTime('1970-01-01H00:00:00.000')),
+ null,
+ null,
new SecondFactorId('ijkl'),
new SecondFactorType('yubikey'),
new YubikeyPublicId('99992222'),
- 'Surfnet\StepupMiddleware\ApiBundle\Tests\Identity\Projector\Event\EventStub',
- new StepupDateTime(new CoreDateTime('1970-01-01H00:00:00.000'))
- )
+ ),
],
'no actor, without second factor' => [
new DomainMessage(
'id',
0,
new MessageMetadata(),
- new EventStub($this->createAuditLogMetadata(
- new IdentityId('abcd'),
- new Institution('efgh'),
- null,
- null
- )),
- BroadwayDateTime::fromString('1970-01-01H00:00:00.000')
+ new EventStub(
+ $this->createAuditLogMetadata(
+ new IdentityId('abcd'),
+ new Institution('efgh'),
+ ),
+ ),
+ BroadwayDateTime::fromString('1970-01-01H00:00:00.000'),
),
$this->createExpectedAuditLogEntry(
- null,
- null,
new IdentityId('abcd'),
new Institution('efgh'),
- null,
- null,
- null,
- 'Surfnet\StepupMiddleware\ApiBundle\Tests\Identity\Projector\Event\EventStub',
- new StepupDateTime(new CoreDateTime('1970-01-01H00:00:00.000'))
- )
+ EventStub::class,
+ new StepupDateTime(new CoreDateTime('1970-01-01H00:00:00.000')),
+ ),
],
'with actor, with second factor' => [
new DomainMessage(
@@ -103,27 +107,29 @@ public function auditable_events()
'actorId' => '0123',
'actorInstitution' => '4567',
]),
- new EventStub($this->createAuditLogMetadata(
- new IdentityId('abcd'),
- new Institution('efgh'),
- new SecondFactorId('ijkl'),
- new SecondFactorType('yubikey'),
- new YubikeyPublicId('99992222')
- )),
- BroadwayDateTime::fromString('1970-01-01H00:00:00.000')
+ new EventStub(
+ $this->createAuditLogMetadata(
+ new IdentityId('abcd'),
+ new Institution('efgh'),
+ new SecondFactorId('ijkl'),
+ new SecondFactorType('yubikey'),
+ new YubikeyPublicId('99992222'),
+ ),
+ ),
+ BroadwayDateTime::fromString('1970-01-01H00:00:00.000'),
),
$this->createExpectedAuditLogEntry(
- new IdentityId('0123'),
- new Institution('4567'),
new IdentityId('abcd'),
new Institution('efgh'),
+ EventStub::class,
+ new StepupDateTime(new CoreDateTime('1970-01-01H00:00:00.000')),
+ new IdentityId('0123'),
+ new Institution('4567'),
new SecondFactorId('ijkl'),
new SecondFactorType('yubikey'),
new YubikeyPublicId('99992222'),
- 'Surfnet\StepupMiddleware\ApiBundle\Tests\Identity\Projector\Event\EventStub',
- new StepupDateTime(new CoreDateTime('1970-01-01H00:00:00.000')),
- self::$actorCommonName
- )
+ new CommonName(self::$actorCommonName),
+ ),
],
];
}
@@ -132,20 +138,17 @@ public function auditable_events()
* @test
* @group api-projector
* @dataProvider auditable_events
- *
- * @param DomainMessage $message
- * @param AuditLogEntry $expectedEntry
*/
- public function it_creates_entries_for_auditable_events(DomainMessage $message, AuditLogEntry $expectedEntry)
+ public function it_creates_entries_for_auditable_events(DomainMessage $message, AuditLogEntry $expectedEntry): void
{
- $repository = m::mock('Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\AuditLogRepository');
- $repository->shouldReceive('save')->once()->with(self::spy($actualEntry));
+ $repository = m::mock(AuditLogRepository::class);
+ $repository->shouldReceive('save')->with($this->spy($actualEntry));
- $identityRepository = m::mock('Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository');
+ $identityRepository = m::mock(IdentityRepository::class);
- $identity = new Identity();
- $identity->commonName = self::$actorCommonName;
- $identityRepository->shouldReceive('find')->between(0, 1)->andReturn($identity);
+ $identity = new Identity();
+ $identity->commonName = new CommonName(self::$actorCommonName);
+ $identityRepository->shouldReceive('find')->andReturn($identity);
$projector = new AuditLogProjector($repository, $identityRepository);
$projector->handle($message);
@@ -162,8 +165,8 @@ private function createAuditLogMetadata(
Institution $institution,
SecondFactorId $secondFactorId = null,
SecondFactorType $secondFactorType = null,
- SecondFactorIdentifier $secondFactorIdentifier = null
- ) {
+ SecondFactorIdentifier $secondFactorIdentifier = null,
+ ): Metadata {
$metadata = new Metadata();
$metadata->identityId = $identityId;
$metadata->identityInstitution = $institution;
@@ -175,25 +178,25 @@ private function createAuditLogMetadata(
}
private function createExpectedAuditLogEntry(
- IdentityId $actorId = null,
- Institution $actorInstitution = null,
IdentityId $identityId,
Institution $identityInstitution,
+ string $event,
+ StepupDateTime $recordedOn,
+ IdentityId $actorId = null,
+ Institution $actorInstitution = null,
SecondFactorId $secondFactorId = null,
SecondFactorType $secondFactorType = null,
- SecondFactorIdentifier $secondFactorIdentifier = null,
- $event,
- StepupDateTime $recordedOn,
- $actorCommonName = null
- ) {
+ ?YubikeyPublicId $secondFactorIdentifier = null,
+ ?CommonName $actorCommonName = null,
+ ): AuditLogEntry {
$entry = new AuditLogEntry();
- $entry->actorId = $actorId ? (string) $actorId : null;
- $entry->actorInstitution = $actorInstitution ? (string) $actorInstitution : null;
- $entry->identityId = (string) $identityId;
+ $entry->actorId = $actorId instanceof IdentityId ? $actorId : null;
+ $entry->actorInstitution = $actorInstitution instanceof Institution ? $actorInstitution : null;
+ $entry->identityId = $identityId;
$entry->identityInstitution = $identityInstitution;
- $entry->secondFactorId = $secondFactorId ? (string) $secondFactorId : null;
- $entry->secondFactorType = $secondFactorType ? (string) $secondFactorType : null;
- $entry->secondFactorIdentifier = $secondFactorIdentifier ? (string) $secondFactorIdentifier : null;
+ $entry->secondFactorId = $secondFactorId instanceof SecondFactorId ? $secondFactorId : null;
+ $entry->secondFactorType = $secondFactorType instanceof SecondFactorType ? $secondFactorType : null;
+ $entry->secondFactorIdentifier = $secondFactorIdentifier instanceof YubikeyPublicId ? $secondFactorIdentifier : null;
$entry->event = $event;
$entry->recordedOn = $recordedOn;
$entry->actorCommonName = $actorCommonName;
@@ -202,17 +205,16 @@ private function createExpectedAuditLogEntry(
}
/**
- * @param mixed &$spy
- * @return \Mockery\Matcher\MatcherAbstract
+ * @return MatcherAbstract
*/
- private static function spy(&$spy)
+ private function spy(mixed &$spy): MatcherAbstract
{
return m::on(
- function ($value) use (&$spy) {
+ function ($value) use (&$spy): bool {
$spy = $value;
return true;
- }
+ },
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Projector/Event/EventStub.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Projector/Event/EventStub.php
index 701175b41..62f74267d 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Projector/Event/EventStub.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Projector/Event/EventStub.php
@@ -21,19 +21,14 @@
use Surfnet\Stepup\Identity\AuditLog\Metadata;
use Surfnet\Stepup\Identity\Event\AuditableEvent;
-final class EventStub implements AuditableEvent
+final readonly class EventStub implements AuditableEvent
{
- /**
- * @var \Surfnet\Stepup\Identity\AuditLog\Metadata
- */
- private $metadata;
-
- public function __construct(Metadata $metadata)
- {
- $this->metadata = $metadata;
+ public function __construct(
+ private Metadata $metadata,
+ ) {
}
- public function getAuditLogMetadata()
+ public function getAuditLogMetadata(): Metadata
{
return $this->metadata;
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Value/AuthorizedInstitutionCollectionTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Value/AuthorizedInstitutionCollectionTest.php
index ba0d6ef48..16edab40d 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Value/AuthorizedInstitutionCollectionTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Identity/Value/AuthorizedInstitutionCollectionTest.php
@@ -28,7 +28,7 @@ final class AuthorizedInstitutionCollectionTest extends TestCase
/**
* @test
*/
- public function empty_collection()
+ public function empty_collection(): void
{
$collection = AuthorizedInstitutionCollection::from($this->buildInstitutionCollection([]), null);
$this->assertEmpty($collection->getAuthorizations());
@@ -37,11 +37,11 @@ public function empty_collection()
/**
* @test
*/
- public function retrieve_institutions()
+ public function retrieve_institutions(): void
{
$collection = AuthorizedInstitutionCollection::from(
$this->buildInstitutionCollection(['a', 'b']),
- $this->buildInstitutionCollection(['a', 'b'])
+ $this->buildInstitutionCollection(['a', 'b']),
);
$this->assertCount(2, $collection->getAuthorizations());
@@ -54,11 +54,11 @@ public function retrieve_institutions()
/**
* @test
*/
- public function retrieve_institutions_only_raa()
+ public function retrieve_institutions_only_raa(): void
{
$collection = AuthorizedInstitutionCollection::from(
$this->buildInstitutionCollection([]),
- $this->buildInstitutionCollection(['a', 'b'])
+ $this->buildInstitutionCollection(['a', 'b']),
);
$this->assertCount(2, $collection->getAuthorizations());
@@ -68,7 +68,10 @@ public function retrieve_institutions_only_raa()
$this->assertEquals('raa', $collection->getAuthorizations()['b'][0]);
}
- private function buildInstitutionCollection(array $institutions)
+ /**
+ * @param string[] $institutions
+ */
+ private function buildInstitutionCollection(array $institutions): InstitutionCollection
{
$institutionList = [];
foreach ($institutions as $institution) {
@@ -77,7 +80,7 @@ private function buildInstitutionCollection(array $institutions)
return new InstitutionCollection($institutionList);
}
- private function buildInstitution($name)
+ private function buildInstitution(string $name): Institution
{
return new Institution($name);
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/CommandParamConverterTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/CommandParamConverterTest.php
deleted file mode 100644
index d422feb65..000000000
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/CommandParamConverterTest.php
+++ /dev/null
@@ -1,173 +0,0 @@
-expectException(\Surfnet\StepupMiddleware\ApiBundle\Exception\BadCommandRequestException::class);
-
- $request = m::mock('Symfony\Component\HttpFoundation\Request')
- ->shouldReceive('getContent')->with()->andReturn($commandJson)
- ->getMock();
- $configuration = m::mock('Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter');
-
- $converter = new CommandParamConverter();
- $converter->apply($request, $configuration);
- }
-
- /**
- * @test
- * @group api-bundle
- * @dataProvider convertibleCommandNames
- * @param string $expectedCommandClass
- * @param string $commandName
- */
- public function it_can_convert_command_name_notation($expectedCommandClass, $commandName)
- {
- $command = ['command' => ['name' => $commandName, 'uuid' => 'abcdef', 'payload' => new \stdClass]];
-
- $request = m::mock('Symfony\Component\HttpFoundation\Request')
- ->shouldReceive('getContent')->with()->andReturn(json_encode($command))
- ->getMock();
- $request->attributes = m::mock()
- ->shouldReceive('set')->with('command', m::type($expectedCommandClass))
- ->getMock();
- $configuration = m::mock('Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter');
-
- $converter = new CommandParamConverter();
- $converter->apply($request, $configuration);
-
- $this->assertInstanceOf(CommandParamConverter::class, $converter);
- }
-
- /**
- * @test
- * @group api-bundle
- */
- public function it_sets_uuid()
- {
- $command = ['command' => ['name' => 'Root:FooBar', 'uuid' => 'abcdef', 'payload' => new \stdClass]];
-
- $request = m::mock('Symfony\Component\HttpFoundation\Request')
- ->shouldReceive('getContent')->with()->andReturn(json_encode($command))
- ->getMock();
- $request->attributes = m::mock()
- ->shouldReceive('set')->with('command', self::spy($spiedCommand))
- ->getMock();
- $configuration = m::mock('Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter');
-
- $converter = new CommandParamConverter();
- $converter->apply($request, $configuration);
-
- $this->assertEquals('abcdef', $spiedCommand->UUID, 'UUID mismatch');
- }
-
- /**
- * @test
- * @group api-bundle
- */
- public function it_sets_payload()
- {
- $command = ['command' => ['name' => 'Root:FooBar', 'uuid' => 'abcdef', 'payload' => ['snake_case' => true]]];
-
- $request = m::mock('Symfony\Component\HttpFoundation\Request')
- ->shouldReceive('getContent')->with()->andReturn(json_encode($command))
- ->getMock();
- $request->attributes = m::mock()
- ->shouldReceive('set')->with('command', self::spy($spiedCommand))
- ->getMock();
- $configuration = m::mock('Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter');
-
- $converter = new CommandParamConverter();
- $converter->apply($request, $configuration);
-
- $spiedPayload = (array) $spiedCommand;
- unset($spiedPayload['UUID']);
- $this->assertSame(['snakeCase' => true], $spiedPayload, 'Payload mismatch');
- }
-
- public function invalidCommandJsonStructures()
- {
- return array_map(
- function ($command) {
- return [json_encode($command)];
- },
- [
- 'Body may not be null' => null,
- 'Body may not be integer' => 1,
- 'Body may not be float' => 1.1,
- 'Body may not be array' => [],
- 'Object must contain command property' => new \stdClass,
- 'Command may not be null' => ['command' => null],
- 'Command may not be integer' => ['command' => 1],
- 'Command may not be float' => ['command' => 1.1],
- 'Command may not be array' => ['command' => []],
- 'Command must contain name' => ['command' => ['uuid' => 'foo', 'payload' => 'bar']],
- 'Command must contain uuid' => ['command' => ['name' => 'quux', 'payload' => 'wibble']],
- 'Command must contain payload' => ['command' => ['name' => 'wobble', 'uuid' => 'wubble']],
- 'Command payload may not be null' => ['command' => ['payload' => null]],
- 'Command payload may not be integer' => ['command' => ['payload' => 1]],
- 'Command payload may not be float' => ['command' => ['payload' => 1.1]],
- 'Command payload may not be array' => ['command' => ['payload' => []]],
- ]
- );
- }
-
- public function convertibleCommandNames()
- {
- return [
- 'It can convert simple command notation with a namespace' => [
- 'Surfnet\StepupMiddleware\CommandHandlingBundle\Root\Command\FooBarCommand', 'Root:FooBar',
- ],
- 'It can convert simple command notation with a namespace with trailing backslash' => [
- 'Surfnet\StepupMiddleware\CommandHandlingBundle\Root\Command\FooBarCommand', 'Root:FooBar',
- ],
- 'It can convert namespaced command notation with a namespace' => [
- 'Surfnet\StepupMiddleware\CommandHandlingBundle\Root\Command\Ns\QuuxCommand', 'Root:Ns.Quux',
- ],
- ];
- }
-
- /**
- * @param mixed &$spy
- * @return \Mockery\Matcher\MatcherAbstract
- */
- private static function spy(&$spy)
- {
- return m::on(
- function ($value) use (&$spy) {
- $spy = $value;
-
- return true;
- }
- );
- }
-}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/CommandValueResolverTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/CommandValueResolverTest.php
new file mode 100644
index 000000000..19a12d04c
--- /dev/null
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/CommandValueResolverTest.php
@@ -0,0 +1,191 @@
+expectException(BadCommandRequestException::class);
+
+ /** @var Request&MockInterface $request */
+ $request = m::mock(Request::class)
+ ->shouldReceive('getContent')->with()->andReturn($commandJson)
+ ->getMock();
+
+ /** @var ArgumentMetadata&MockInterface $argument */
+ $argument = m::mock(ArgumentMetadata::class);
+ $argument->shouldReceive('getType')
+ ->once()
+ ->andReturn(Command::class);
+
+ $converter = new CommandValueResolver();
+ $result = $converter->resolve($request, $argument);
+
+ $this->assertCount(1, $result);
+ $this->assertInstanceOf(Command::class, $result[0]);
+ }
+
+ /**
+ * @test
+ * @group api-bundle
+ * @dataProvider convertibleCommandNames
+ */
+ public function it_can_convert_command_name_notation(string $expectedCommandClass, string $commandName): void
+ {
+ $command = ['command' => ['name' => $commandName, 'uuid' => 'abcdef', 'payload' => new stdClass]];
+
+ /** @var Request&MockInterface $request */
+ $request = m::mock(Request::class)
+ ->shouldReceive('getContent')->with()->andReturn(json_encode($command))
+ ->getMock();
+
+ /** @var ArgumentMetadata&MockInterface $argument */
+ $argument = m::mock(ArgumentMetadata::class);
+ $argument->shouldReceive('getType')
+ ->once()
+ ->andReturn(Command::class);
+
+ $converter = new CommandValueResolver();
+ $result = $converter->resolve($request, $argument);
+
+ $this->assertCount(1, $result);
+ $this->assertInstanceOf($expectedCommandClass, $result[0]);
+ }
+
+ /**
+ * @test
+ * @group api-bundle
+ */
+ public function it_sets_uuid(): void
+ {
+ $command = ['command' => ['name' => 'Root:FooBar', 'uuid' => 'abcdef', 'payload' => new stdClass]];
+
+ /** @var Request $request */
+ $request = m::mock(Request::class)
+ ->shouldReceive('getContent')->with()->andReturn(json_encode($command))
+ ->getMock();
+
+ /** @var ArgumentMetadata&MockInterface $argument */
+ $argument = m::mock(ArgumentMetadata::class);
+ $argument->shouldReceive('getType')
+ ->once()
+ ->andReturn(Command::class);
+
+ $converter = new CommandValueResolver();
+ $result = $converter->resolve($request, $argument);
+
+ $this->assertCount(1, $result);
+ $this->assertEquals('abcdef', $result[0]->UUID, 'UUID mismatch');
+ }
+
+ /**
+ * @test
+ * @group api-bundle
+ */
+ public function it_sets_payload(): void
+ {
+ $command = ['command' => ['name' => 'Root:FooBar', 'uuid' => 'abcdef', 'payload' => ['snake_case' => true]]];
+
+ /** @var Request $request */
+ $request = m::mock(Request::class)
+ ->shouldReceive('getContent')->with()->andReturn(json_encode($command))
+ ->getMock();
+
+ /** @var ArgumentMetadata&MockInterface $argument */
+ $argument = m::mock(ArgumentMetadata::class);
+ $argument->shouldReceive('getType')
+ ->once()
+ ->andReturn(Command::class);
+
+ $converter = new CommandValueResolver();
+ $result = $converter->resolve($request, $argument);
+
+ $this->assertCount(1, $result);
+
+ $spiedPayload = (array)$result[0];
+ unset($spiedPayload['UUID']);
+
+ $this->assertSame(['snakeCase' => true], $spiedPayload, 'Payload mismatch');
+ }
+
+ public function invalidCommandJsonStructures(): array
+ {
+ return array_map(
+ fn($command): array => [json_encode($command)],
+ [
+ 'Body may not be null' => null,
+ 'Body may not be integer' => 1,
+ 'Body may not be float' => 1.1,
+ 'Body may not be array' => [],
+ 'Object must contain command property' => new stdClass,
+ 'Command may not be null' => ['command' => null],
+ 'Command may not be integer' => ['command' => 1],
+ 'Command may not be float' => ['command' => 1.1],
+ 'Command may not be array' => ['command' => []],
+ 'Command must contain name' => ['command' => ['uuid' => 'foo', 'payload' => 'bar']],
+ 'Command must contain uuid' => ['command' => ['name' => 'quux', 'payload' => 'wibble']],
+ 'Command must contain payload' => ['command' => ['name' => 'wobble', 'uuid' => 'wubble']],
+ 'Command payload may not be null' => ['command' => ['payload' => null]],
+ 'Command payload may not be integer' => ['command' => ['payload' => 1]],
+ 'Command payload may not be float' => ['command' => ['payload' => 1.1]],
+ 'Command payload may not be array' => ['command' => ['payload' => []]],
+ ],
+ );
+ }
+
+ public function convertibleCommandNames(): array
+ {
+ return [
+ 'It can convert simple command notation with a namespace' => [
+ FooBarCommand::class,
+ 'Root:FooBar',
+ ],
+ 'It can convert simple command notation with a namespace with trailing backslash' => [
+ FooBarCommand::class,
+ 'Root:FooBar',
+ ],
+ 'It can convert namespaced command notation with a namespace' => [
+ QuuxCommand::class,
+ 'Root:Ns.Quux',
+ ],
+ ];
+ }
+}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/InstitutionParamConverterTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/InstitutionValueResolverTest.php
similarity index 51%
rename from src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/InstitutionParamConverterTest.php
rename to src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/InstitutionValueResolverTest.php
index 551d0f134..a53e83ec5 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/InstitutionParamConverterTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/InstitutionValueResolverTest.php
@@ -19,73 +19,73 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Request;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase as UnitTest;
use Surfnet\Stepup\Identity\Value\Institution;
-use Surfnet\StepupMiddleware\ApiBundle\Request\InstitutionParamConverter;
+use Surfnet\StepupMiddleware\ApiBundle\Exception\BadApiRequestException;
+use Surfnet\StepupMiddleware\ApiBundle\Request\InstitutionValueResolver;
use Symfony\Component\HttpFoundation\ParameterBag;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
-class InstitutionParamConverterTest extends UnitTest
+class InstitutionValueResolverTest extends UnitTest
{
- /**
- * @var \Mockery\MockInterface
- */
- private $request;
+ use MockeryPHPUnitIntegration;
- /**
- * @var \Mockery\MockInterface
- */
- private $paramConverterConfig;
+ private MockInterface&Request $request;
+
+ private MockInterface&ArgumentMetadata $argument;
public function setUp(): void
{
- $this->request = m::mock('Symfony\Component\HttpFoundation\Request');
- $this->paramConverterConfig = m::mock('Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter');
+ $this->request = m::mock(Request::class);
+ $this->argument = m::mock(ArgumentMetadata::class);
+ $this->argument->shouldReceive('getType')
+ ->once()
+ ->andReturn(Institution::class);
}
/**
* @test
* @group api-bundle
*/
- public function an_exception_is_thrown_when_the_parameter_is_missing()
+ public function an_exception_is_thrown_when_the_parameter_is_missing(): void
{
- $this->expectException(\Surfnet\StepupMiddleware\ApiBundle\Exception\BadApiRequestException::class);
+ $this->expectException(BadApiRequestException::class);
$this->request->query = $this->mockQuery(false);
- $converter = new InstitutionParamConverter();
- $converter->apply($this->request, $this->paramConverterConfig);
+ $converter = new InstitutionValueResolver();
+ $converter->resolve($this->request, $this->argument);
}
/**
* @test
* @group api-bundle
*/
- public function an_institution_is_set_as_attribute()
+ public function an_institution_is_resolved(): void
{
$query = $this->mockQuery('ABC');
- $query
- ->shouldReceive('remove')
- ->with('institution')
- ->once();
$this->request->query = $query;
- $this->request->attributes = new ParameterBag();
$equal = new Institution('ABC');
- $converter = new InstitutionParamConverter();
- $converter->apply($this->request, $this->paramConverterConfig);
+ $converter = new InstitutionValueResolver();
+ $result = $converter->resolve($this->request, $this->argument);
- $this->assertTrue($this->request->attributes->get('institution')->equals($equal));
+ $this->assertCount(1, $result);
+ $this->assertEquals($equal, $result[0]);
}
- private function mockQuery($returnValue)
+ private function mockQuery(bool|string $returnValue): ParameterBag&MockInterface
{
- $query = m::mock('Symfony\Component\HttpFoundation\ParameterBag');
+ $query = m::mock(ParameterBag::class);
$query
->shouldReceive('get')
->once()
- ->with('institution', false)
+ ->with('institution')
->andReturn($returnValue);
return $query;
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/commands.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/commands.php
index 284afcd5f..40ad7bc7f 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/commands.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Request/commands.php
@@ -16,16 +16,20 @@
* limitations under the License.
*/
-namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Root\Command
-{
- class FooBarCommand
+namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Root\Command {
+
+ use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
+
+ class FooBarCommand extends AbstractCommand
{
}
}
-namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Root\Command\Ns
-{
- class QuuxCommand
+namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Root\Command\Ns {
+
+ use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
+
+ class QuuxCommand extends AbstractCommand
{
}
}
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Response/JsonAuthorizationResponseTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Response/JsonAuthorizationResponseTest.php
index 61e3c86eb..992744f07 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Response/JsonAuthorizationResponseTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Response/JsonAuthorizationResponseTest.php
@@ -19,36 +19,45 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests\Response;
use Assert\InvalidArgumentException;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
use Surfnet\StepupMiddleware\ApiBundle\Response\JsonAuthorizationResponse;
+use Symfony\Component\HttpFoundation\Response;
class JsonAuthorizationResponseTest extends TestCase
{
- public function test_happy_flow() {
+ use MockeryPHPUnitIntegration;
+
+ public function test_happy_flow(): void
+ {
$response = new JsonAuthorizationResponse(200);
- $this->assertEquals('{"code":200}',$response->getContent());
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('{"code":200}', $response->getContent());
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
}
- public function test_happy_flow_error_response() {
+ public function test_happy_flow_error_response(): void
+ {
$response = new JsonAuthorizationResponse(403);
- $this->assertEquals('{"code":403}',$response->getContent());
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('{"code":403}', $response->getContent());
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
}
- public function test_happy_flow_error_response_with_error_message() {
+ public function test_happy_flow_error_response_with_error_message(): void
+ {
$response = new JsonAuthorizationResponse(403, ['Not allowed']);
- $this->assertEquals('{"code":403,"errors":["Not allowed"]}',$response->getContent());
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('{"code":403,"errors":["Not allowed"]}', $response->getContent());
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
}
- public function test_response_code_can_be_one_of_200_or_403() {
+ public function test_response_code_can_be_one_of_200_or_403(): void
+ {
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The status code can be either 200 or 403');
new JsonAuthorizationResponse(402);
}
- public function test_all_errors_should_be_string() {
+ public function test_all_errors_should_be_string(): void
+ {
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The error messages should all be strings');
new JsonAuthorizationResponse(403, ['Test', false]);
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Service/DeprovisionServiceTest.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Service/DeprovisionServiceTest.php
index 4a187d122..7cd181948 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Service/DeprovisionServiceTest.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/Service/DeprovisionServiceTest.php
@@ -20,11 +20,11 @@
use Mockery as m;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Surfnet\Stepup\Identity\EventSourcing\IdentityRepository;
use Surfnet\Stepup\Identity\Value\Institution;
-use Surfnet\StepupMiddleware\ApiBundle\Exception\UserNotFoundException;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository as ApiIdentityRepository;
use Surfnet\StepupMiddleware\ApiBundle\Service\DeprovisionService;
@@ -35,25 +35,13 @@ class DeprovisionServiceTest extends TestCase
{
use MockeryPHPUnitIntegration;
- /**
- * @var DeprovisionService
- */
- private $deprovisionService;
+ private DeprovisionService $deprovisionService;
- /**
- * @var m\LegacyMockInterface|m\MockInterface|Pipeline
- */
- private $pipeline;
+ private MockInterface&Pipeline $pipeline;
- /**
- * @var m\LegacyMockInterface|m\MockInterface|ApiIdentityRepository
- */
- private $apiRepo;
+ private MockInterface&ApiIdentityRepository $apiRepo;
- /**
- * @var m\LegacyMockInterface|m\MockInterface|IdentityRepository
- */
- private $eventRepo;
+ private MockInterface&IdentityRepository $eventRepo;
protected function setUp(): void
{
@@ -65,7 +53,7 @@ protected function setUp(): void
$this->deprovisionService = new DeprovisionService($this->pipeline, $this->eventRepo, $this->apiRepo, $logger);
}
- public function test_it_can_be_created()
+ public function test_it_can_be_created(): void
{
$this->assertInstanceOf(DeprovisionService::class, $this->deprovisionService);
}
@@ -73,7 +61,7 @@ public function test_it_can_be_created()
/**
* @group api-bundle
*/
- public function test_it_deals_with_non_exisiting_collab_user_id()
+ public function test_it_deals_with_non_exisiting_collab_user_id(): void
{
$this->apiRepo
->shouldReceive('findOneByNameId')
@@ -87,7 +75,7 @@ public function test_it_deals_with_non_exisiting_collab_user_id()
/**
* @group api-bundle
*/
- public function test_it_can_return_data()
+ public function test_it_can_return_data(): void
{
$identity = m::mock(Identity::class);
$identity->id = '0bf0b464-a5de-11ec-b909-0242ac120002';
@@ -101,11 +89,10 @@ public function test_it_can_return_data()
$data = $this->deprovisionService->readUserData('urn:collab:person:example.com:maynard_keenan');
- $this->assertTrue(is_array($data));
$this->assertEquals($data['status'], 'OK');
}
- public function test_deprovision_does_not_deprovision_when_user_is_not_found()
+ public function test_deprovision_does_not_deprovision_when_user_is_not_found(): void
{
$this->apiRepo
->shouldReceive('findOneByNameId')
@@ -114,11 +101,10 @@ public function test_deprovision_does_not_deprovision_when_user_is_not_found()
->andReturnNull();
$this->pipeline
->shouldNotHaveReceived('process');
- $data = $this->deprovisionService->deprovision('urn:collab:person:example.com:maynard_keenan');
- $this->assertNull($data);
+ $this->deprovisionService->deprovision('urn:collab:person:example.com:maynard_keenan');
}
- public function test_deprovision_method_performs_the_right_to_be_forgotten_command()
+ public function test_deprovision_method_performs_the_right_to_be_forgotten_command(): void
{
$identity = m::mock(Identity::class);
$identity->id = '0bf0b464-a5de-11ec-b909-0242ac120002';
@@ -130,7 +116,7 @@ public function test_deprovision_method_performs_the_right_to_be_forgotten_comma
->andReturn($identity);
$this->pipeline
->shouldReceive('process')
- ->withArgs(function(ForgetIdentityCommand $command){
+ ->withArgs(function (ForgetIdentityCommand $command): bool {
$this->assertEquals($command->nameId, 'urn:collab:person:example.com:maynard_keenan');
$this->assertEquals($command->institution, 'tool');
return true;
diff --git a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/TestDataProvider.php b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/TestDataProvider.php
index 31867f1bf..cdcb23745 100644
--- a/src/Surfnet/StepupMiddleware/ApiBundle/Tests/TestDataProvider.php
+++ b/src/Surfnet/StepupMiddleware/ApiBundle/Tests/TestDataProvider.php
@@ -18,9 +18,14 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Tests;
+use StdClass;
+
final class TestDataProvider
{
- public static function notNull()
+ /**
+ * @return array
+ */
+ public static function notNull(): array
{
return [
'string' => ['a string'],
@@ -29,7 +34,7 @@ public static function notNull()
'true' => [true],
'false' => [false],
'array' => [[]],
- 'object' => [new \StdClass],
+ 'object' => [new StdClass],
];
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/AbstractCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/AbstractCommand.php
index 6c2015fc1..71cb57a87 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/AbstractCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/AbstractCommand.php
@@ -27,16 +27,16 @@
abstract class AbstractCommand implements Command
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- * @Assert\Regex(pattern="~^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$~i")
*
* @var string
*/
- public $UUID;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ #[Assert\Regex(pattern: '~^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$~i')]
+ public string $UUID = "";
- public function __toString()
+ public function __toString(): string
{
- return get_class($this) . '[' . $this->UUID . ']';
+ return static::class . '[' . $this->UUID . ']';
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/Command.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/Command.php
index d72c21b6d..877968402 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/Command.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/Command.php
@@ -20,7 +20,7 @@
/**
* Interface that must be implemented by all Step-up commands. All Step-up commands MUST sport a $UUID string
- * field, {@see \Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand}
+ * field, {@see AbstractCommand}
*/
interface Command
{
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/Metadata.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/Metadata.php
index 7d0329499..6aacdff2b 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/Metadata.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/Metadata.php
@@ -23,17 +23,16 @@
final class Metadata
{
/**
- * @Assert\Type(type="string")
- * @Assert\Regex(pattern="~^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$~i")
*
* @var string|null
*/
- public $actorId;
+ #[Assert\Type(type: 'string')]
+ #[Assert\Regex(pattern: '~^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$~i')]
+ public ?string $actorId = null;
/**
- * @Assert\Type(type="string")
- *
* @var string|null
*/
- public $actorInstitution;
+ #[Assert\Type(type: 'string')]
+ public ?string $actorInstitution = null;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/RaExecutable.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/RaExecutable.php
index 8e63188f0..34a500ccd 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/RaExecutable.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/RaExecutable.php
@@ -26,8 +26,6 @@ interface RaExecutable
{
/**
* Returns the actor institution. This is done to be able to validate if we may execute certain commands for authorization purposes
- *
- * @return string|null
*/
- public function getRaInstitution();
+ public function getRaInstitution(): ?string;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/SelfServiceExecutable.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/SelfServiceExecutable.php
index df9794c56..8f13bde0e 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/SelfServiceExecutable.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Command/SelfServiceExecutable.php
@@ -29,5 +29,5 @@ interface SelfServiceExecutable
*
* @return string
*/
- public function getIdentityId();
+ public function getIdentityId(): string;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/AddRaLocationCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/AddRaLocationCommand.php
index 0dacaf9c6..d978a2ee6 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/AddRaLocationCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/AddRaLocationCommand.php
@@ -25,48 +25,44 @@
class AddRaLocationCommand extends AbstractCommand implements RaExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
*
* @var string
*/
- public $raLocationId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $raLocationId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
*
* @var string
*/
- public $institution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $institution;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
*
* @var string
*/
- public $raLocationName;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $raLocationName;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
*
* @var string
*/
- public $location;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $location;
/**
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $contactInformation;
+ #[Assert\Type(type: 'string')]
+ public string $contactInformation;
- /**
- * @inheritDoc
- */
- public function getRaInstitution()
+ public function getRaInstitution(): string
{
return $this->institution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/ChangeRaLocationCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/ChangeRaLocationCommand.php
index 279b35635..2d0d7f94c 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/ChangeRaLocationCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/ChangeRaLocationCommand.php
@@ -25,48 +25,43 @@
class ChangeRaLocationCommand extends AbstractCommand implements RaExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $raLocationId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $raLocationId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $institution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $institution;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $raLocationName;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $raLocationName;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $location;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $location;
/**
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $contactInformation;
+ #[Assert\Type(type: 'string')]
+ public string $contactInformation;
/**
* @inheritDoc
*/
- public function getRaInstitution()
+ public function getRaInstitution(): string
{
return $this->institution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/CreateInstitutionConfigurationCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/CreateInstitutionConfigurationCommand.php
index e264ab0bd..2cf477bed 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/CreateInstitutionConfigurationCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/CreateInstitutionConfigurationCommand.php
@@ -25,10 +25,9 @@
class CreateInstitutionConfigurationCommand extends AbstractCommand implements ManagementExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $institution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $institution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/ReconfigureInstitutionConfigurationOptionsCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/ReconfigureInstitutionConfigurationOptionsCommand.php
index 684c49009..af4b27463 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/ReconfigureInstitutionConfigurationOptionsCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/ReconfigureInstitutionConfigurationOptionsCommand.php
@@ -25,74 +25,67 @@
final class ReconfigureInstitutionConfigurationOptionsCommand extends AbstractCommand implements ManagementExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $institution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $institution;
/**
- * @Assert\Type(type="boolean")
- *
* @var bool
*/
- public $useRaLocationsOption;
+ #[Assert\Type(type: 'boolean')]
+ public bool $useRaLocationsOption;
/**
- * @Assert\Type(type="boolean")
- *
* @var bool
*/
- public $showRaaContactInformationOption;
+ #[Assert\Type(type: 'boolean')]
+ public bool $showRaaContactInformationOption;
/**
- * @Assert\Type(type="boolean")
- *
* @var bool
*/
- public $verifyEmailOption;
+ #[Assert\Type(type: 'boolean')]
+ public bool $verifyEmailOption;
/**
- * @Assert\Type(type="integer")
- *
* @var int
*/
- public $numberOfTokensPerIdentityOption;
+ #[Assert\Type(type: 'integer')]
+ public int $numberOfTokensPerIdentityOption;
- /**
- * @Assert\NotNull()
- */
- public $allowedSecondFactors;
+ #[Assert\NotNull]
+ public array $allowedSecondFactors;
/**
* @var array|null
*/
- public $useRaOption;
+ public ?array $useRaOption = null;
/**
* @var array|null
*/
- public $useRaaOption;
+ public ?array $useRaaOption = null;
/**
* @var array|null
*/
- public $selectRaaOption;
+ public ?array $selectRaaOption = null;
/**
* @var bool|null
*/
- public $selfVetOption;
+ public ?bool $selfVetOption = null;
/**
* @var bool|null
*/
- public $selfAssertedTokensOption;
+ public ?bool $selfAssertedTokensOption = null;
/**
* @var bool|null
*/
- public $ssoOn2faOption;
+ public ?bool $ssoOn2faOption = null;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/RemoveInstitutionConfigurationByUnnormalizedIdCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/RemoveInstitutionConfigurationByUnnormalizedIdCommand.php
index 49433c6a6..e0c2c42a1 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/RemoveInstitutionConfigurationByUnnormalizedIdCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/RemoveInstitutionConfigurationByUnnormalizedIdCommand.php
@@ -24,10 +24,9 @@
final class RemoveInstitutionConfigurationByUnnormalizedIdCommand extends AbstractCommand
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $institution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $institution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/RemoveRaLocationCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/RemoveRaLocationCommand.php
index 2a35ff1ab..329ffef13 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/RemoveRaLocationCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/RemoveRaLocationCommand.php
@@ -25,25 +25,23 @@
class RemoveRaLocationCommand extends AbstractCommand implements RaExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $raLocationId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $raLocationId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $institution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $institution;
/**
* @inheritDoc
*/
- public function getRaInstitution()
+ public function getRaInstitution(): string
{
return $this->institution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/UpdateConfigurationCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/UpdateConfigurationCommand.php
index 2ca7a5add..19694ca35 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/UpdateConfigurationCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Command/UpdateConfigurationCommand.php
@@ -24,10 +24,7 @@
class UpdateConfigurationCommand extends AbstractCommand implements ManagementExecutable
{
- /**
- * @var string configuration as json as received in the request
- *
- * @ManagementAssert\HasValidConfigurationStructure
- */
- public $configuration;
+
+ #[ManagementAssert\HasValidConfigurationStructure]
+ public string $configuration = "";
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/CommandHandler/ConfigurationCommandHandler.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/CommandHandler/ConfigurationCommandHandler.php
index af0afbe30..4b84fdede 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/CommandHandler/ConfigurationCommandHandler.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/CommandHandler/ConfigurationCommandHandler.php
@@ -26,23 +26,15 @@
class ConfigurationCommandHandler extends SimpleCommandHandler
{
- /**
- * @var \Surfnet\Stepup\Configuration\EventSourcing\ConfigurationRepository
- */
- private $repository;
-
- /**
- * @param ConfigurationRepository $repository
- */
- public function __construct(ConfigurationRepository $repository)
- {
- $this->repository = $repository;
+ public function __construct(
+ private readonly ConfigurationRepository $repository,
+ ) {
}
- public function handleUpdateConfigurationCommand(UpdateConfigurationCommand $command)
+ public function handleUpdateConfigurationCommand(UpdateConfigurationCommand $command): void
{
$configuration = $this->getConfiguration();
- if (!$configuration) {
+ if (!$configuration instanceof Configuration) {
$configuration = Configuration::create();
}
@@ -51,14 +43,13 @@ public function handleUpdateConfigurationCommand(UpdateConfigurationCommand $com
$this->repository->save($configuration);
}
- /**
- * @return null|\Surfnet\Stepup\Configuration\Api\Configuration
- */
- private function getConfiguration()
+ private function getConfiguration(): ?Configuration
{
try {
- return $this->repository->load(Configuration::CONFIGURATION_ID);
- } catch (AggregateNotFoundException $e) {
+ /** @var Configuration $configuration */
+ $configuration = $this->repository->load(Configuration::CONFIGURATION_ID);
+ return $configuration;
+ } catch (AggregateNotFoundException) {
return null;
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/CommandHandler/InstitutionConfigurationCommandHandler.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/CommandHandler/InstitutionConfigurationCommandHandler.php
index ea018ff24..49f83ce95 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/CommandHandler/InstitutionConfigurationCommandHandler.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/CommandHandler/InstitutionConfigurationCommandHandler.php
@@ -25,6 +25,7 @@
use Surfnet\Stepup\Configuration\Value\AllowedSecondFactorList;
use Surfnet\Stepup\Configuration\Value\ContactInformation;
use Surfnet\Stepup\Configuration\Value\Institution;
+use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
use Surfnet\Stepup\Configuration\Value\Location;
@@ -36,7 +37,6 @@
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption;
use Surfnet\Stepup\Configuration\Value\SsoOn2faOption;
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption;
-use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
use Surfnet\StepupBundle\Value\SecondFactorType;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\AddRaLocationCommand;
@@ -51,17 +51,11 @@
*/
class InstitutionConfigurationCommandHandler extends SimpleCommandHandler
{
- /**
- * @var RepositoryInterface
- */
- private $repository;
-
- public function __construct(RepositoryInterface $repository)
+ public function __construct(private readonly RepositoryInterface $repository)
{
- $this->repository = $repository;
}
- public function handleCreateInstitutionConfigurationCommand(CreateInstitutionConfigurationCommand $command)
+ public function handleCreateInstitutionConfigurationCommand(CreateInstitutionConfigurationCommand $command): void
{
$institution = new Institution($command->institution);
$institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
@@ -69,11 +63,11 @@ public function handleCreateInstitutionConfigurationCommand(CreateInstitutionCon
try {
/** @var InstitutionConfiguration $institutionConfiguration */
$institutionConfiguration = $this->repository->load(
- $institutionConfigurationId->getInstitutionConfigurationId()
+ $institutionConfigurationId->getInstitutionConfigurationId(),
);
$institutionConfiguration->rebuild();
- } catch (AggregateNotFoundException $exception) {
+ } catch (AggregateNotFoundException) {
$institutionConfiguration = InstitutionConfiguration::create($institutionConfigurationId, $institution);
}
@@ -81,45 +75,52 @@ public function handleCreateInstitutionConfigurationCommand(CreateInstitutionCon
}
public function handleReconfigureInstitutionConfigurationOptionsCommand(
- ReconfigureInstitutionConfigurationOptionsCommand $command
- ) {
+ ReconfigureInstitutionConfigurationOptionsCommand $command,
+ ): void {
$institution = new Institution($command->institution);
- $allowedSecondFactors = array_map(function ($allowedSecondFactor) {
- return new SecondFactorType($allowedSecondFactor);
- }, $command->allowedSecondFactors);
+ $allowedSecondFactors = array_map(
+ fn($allowedSecondFactor): SecondFactorType => new SecondFactorType($allowedSecondFactor),
+ $command->allowedSecondFactors,
+ );
$institutionConfiguration = $this->loadInstitutionConfigurationFor($institution);
$institutionConfiguration->configureUseRaLocationsOption(
- new UseRaLocationsOption($command->useRaLocationsOption)
+ new UseRaLocationsOption($command->useRaLocationsOption),
);
$institutionConfiguration->configureVerifyEmailOption(
- new VerifyEmailOption($command->verifyEmailOption)
+ new VerifyEmailOption($command->verifyEmailOption),
);
$institutionConfiguration->configureNumberOfTokensPerIdentityOption(
- new NumberOfTokensPerIdentityOption($command->numberOfTokensPerIdentityOption)
+ new NumberOfTokensPerIdentityOption($command->numberOfTokensPerIdentityOption),
);
$institutionConfiguration->configureShowRaaContactInformationOption(
- new ShowRaaContactInformationOption($command->showRaaContactInformationOption)
+ new ShowRaaContactInformationOption($command->showRaaContactInformationOption),
);
// Configure the authorization options on the aggregate
- $institutionConfiguration->updateUseRaOption(InstitutionAuthorizationOption::fromInstitutionConfig(
- InstitutionRole::useRa(),
- $command->useRaOption
- ));
- $institutionConfiguration->updateUseRaaOption(InstitutionAuthorizationOption::fromInstitutionConfig(
- InstitutionRole::useRaa(),
- $command->useRaaOption
- ));
- $institutionConfiguration->updateSelectRaaOption(InstitutionAuthorizationOption::fromInstitutionConfig(
- InstitutionRole::selectRaa(),
- $command->selectRaaOption
- ));
+ $institutionConfiguration->updateUseRaOption(
+ InstitutionAuthorizationOption::fromInstitutionConfig(
+ InstitutionRole::useRa(),
+ $command->useRaOption,
+ ),
+ );
+ $institutionConfiguration->updateUseRaaOption(
+ InstitutionAuthorizationOption::fromInstitutionConfig(
+ InstitutionRole::useRaa(),
+ $command->useRaaOption,
+ ),
+ );
+ $institutionConfiguration->updateSelectRaaOption(
+ InstitutionAuthorizationOption::fromInstitutionConfig(
+ InstitutionRole::selectRaa(),
+ $command->selectRaaOption,
+ ),
+ );
$institutionConfiguration->updateAllowedSecondFactorList(
- AllowedSecondFactorList::ofTypes($allowedSecondFactors)
+ AllowedSecondFactorList::ofTypes($allowedSecondFactors),
);
// Handle optional options
@@ -131,13 +132,13 @@ public function handleReconfigureInstitutionConfigurationOptionsCommand(
$satOption = $command->selfAssertedTokensOption ?? SelfAssertedTokensOption::getDefault()->isEnabled();
$institutionConfiguration->configureSelfAssertedTokensOption(
- new SelfAssertedTokensOption($satOption)
+ new SelfAssertedTokensOption($satOption),
);
$this->repository->save($institutionConfiguration);
}
- public function handleAddRaLocationCommand(AddRaLocationCommand $command)
+ public function handleAddRaLocationCommand(AddRaLocationCommand $command): void
{
$institution = new Institution($command->institution);
@@ -146,13 +147,13 @@ public function handleAddRaLocationCommand(AddRaLocationCommand $command)
new RaLocationId($command->raLocationId),
new RaLocationName($command->raLocationName),
new Location($command->location),
- new ContactInformation($command->contactInformation)
+ new ContactInformation($command->contactInformation),
);
$this->repository->save($institutionConfiguration);
}
- public function handleChangeRaLocationCommand(ChangeRaLocationCommand $command)
+ public function handleChangeRaLocationCommand(ChangeRaLocationCommand $command): void
{
$institution = new Institution($command->institution);
@@ -161,13 +162,13 @@ public function handleChangeRaLocationCommand(ChangeRaLocationCommand $command)
new RaLocationId($command->raLocationId),
new RaLocationName($command->raLocationName),
new Location($command->location),
- new ContactInformation($command->contactInformation)
+ new ContactInformation($command->contactInformation),
);
$this->repository->save($institutionConfiguration);
}
- public function handleRemoveRaLocationCommand(RemoveRaLocationCommand $command)
+ public function handleRemoveRaLocationCommand(RemoveRaLocationCommand $command): void
{
$institution = new Institution($command->institution);
@@ -178,13 +179,14 @@ public function handleRemoveRaLocationCommand(RemoveRaLocationCommand $command)
}
public function handleRemoveInstitutionConfigurationByUnnormalizedIdCommand(
- RemoveInstitutionConfigurationByUnnormalizedIdCommand $command
- ) {
+ RemoveInstitutionConfigurationByUnnormalizedIdCommand $command,
+ ): void {
$institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::from($institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ /** @var InstitutionConfiguration $institutionConfiguration */
$institutionConfiguration = $this->repository->load(
- $institutionConfigurationId->getInstitutionConfigurationId()
+ $institutionConfigurationId->getInstitutionConfigurationId(),
);
$institutionConfiguration->destroy();
@@ -192,22 +194,23 @@ public function handleRemoveInstitutionConfigurationByUnnormalizedIdCommand(
}
/**
+ * @return InstitutionConfiguration
* @deprecated Should be used until existing institution configurations have been migrated to using normalized ids
*
- * @param Institution $institution
- * @return InstitutionConfiguration
*/
- private function loadInstitutionConfigurationFor(Institution $institution)
+ private function loadInstitutionConfigurationFor(Institution $institution): InstitutionConfiguration
{
try {
$institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ /** @var InstitutionConfiguration $institutionConfiguration */
$institutionConfiguration = $this->repository->load(
- $institutionConfigurationId->getInstitutionConfigurationId()
+ $institutionConfigurationId->getInstitutionConfigurationId(),
);
- } catch (AggregateNotFoundException $exception) {
+ } catch (AggregateNotFoundException) {
$institutionConfigurationId = InstitutionConfigurationId::from($institution);
+ /** @var InstitutionConfiguration $institutionConfiguration */
$institutionConfiguration = $this->repository->load(
- $institutionConfigurationId->getInstitutionConfigurationId()
+ $institutionConfigurationId->getInstitutionConfigurationId(),
);
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Dto/EmailTemplate.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Dto/EmailTemplate.php
index fe6ac0649..4ba5f02ba 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Dto/EmailTemplate.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Dto/EmailTemplate.php
@@ -23,15 +23,15 @@ final class EmailTemplate
/**
* @var string
*/
- public $name;
+ public string $name;
/**
* @var string
*/
- public $locale;
+ public string $locale;
/**
* @var string
*/
- public $htmlContent;
+ public string $htmlContent;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Processor/InstitutionConfigurationProcessor.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Processor/InstitutionConfigurationProcessor.php
index 0c5cf1b80..99d372a7d 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Processor/InstitutionConfigurationProcessor.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Processor/InstitutionConfigurationProcessor.php
@@ -19,7 +19,7 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Processor;
use Broadway\Processor\Processor;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Identity\Event\IdentityCreatedEvent;
use Surfnet\Stepup\Identity\Event\InstitutionsAddedToWhitelistEvent;
@@ -27,36 +27,22 @@
use Surfnet\Stepup\Identity\Event\WhitelistReplacedEvent;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\ConfiguredInstitutionRepository;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\CreateInstitutionConfigurationCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Pipeline;
use Symfony\Component\DependencyInjection\ContainerInterface;
final class InstitutionConfigurationProcessor extends Processor
{
- /**
- * @var ConfiguredInstitutionRepository
- */
- private $configuredInstitutionRepository;
-
- /**
- * @var ContainerInterface
- */
- private $container;
-
/**
* The container needs to be called during runtime in order to prevent a circular reference
* during container compilation.
- *
- * @param ConfiguredInstitutionRepository $configuredInstitutionRepository
- * @param ContainerInterface $container
*/
public function __construct(
- ConfiguredInstitutionRepository $configuredInstitutionRepository,
- ContainerInterface $container
+ private readonly ConfiguredInstitutionRepository $configuredInstitutionRepository,
+ private readonly Pipeline $pipeline,
) {
- $this->configuredInstitutionRepository = $configuredInstitutionRepository;
- $this->container = $container;
}
- public function handleIdentityCreatedEvent(IdentityCreatedEvent $event)
+ public function handleIdentityCreatedEvent(IdentityCreatedEvent $event): void
{
$institution = new Institution($event->identityInstitution->getInstitution());
@@ -67,7 +53,7 @@ public function handleIdentityCreatedEvent(IdentityCreatedEvent $event)
$this->createConfigurationFor($institution);
}
- public function handleWhitelistCreatedEvent(WhitelistCreatedEvent $event)
+ public function handleWhitelistCreatedEvent(WhitelistCreatedEvent $event): void
{
foreach ($event->whitelistedInstitutions as $whitelistedInstitution) {
$institution = new Institution($whitelistedInstitution->getInstitution());
@@ -80,7 +66,7 @@ public function handleWhitelistCreatedEvent(WhitelistCreatedEvent $event)
}
}
- public function handleWhitelistReplacedEvent(WhitelistReplacedEvent $event)
+ public function handleWhitelistReplacedEvent(WhitelistReplacedEvent $event): void
{
foreach ($event->whitelistedInstitutions as $whitelistedInstitution) {
$institution = new Institution($whitelistedInstitution->getInstitution());
@@ -93,7 +79,7 @@ public function handleWhitelistReplacedEvent(WhitelistReplacedEvent $event)
}
}
- public function handleInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhitelistEvent $event)
+ public function handleInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhitelistEvent $event): void
{
foreach ($event->addedInstitutions as $addedInstitution) {
$institution = new Institution($addedInstitution->getInstitution());
@@ -106,15 +92,12 @@ public function handleInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhite
}
}
- /**
- * @param Institution $institution
- */
- private function createConfigurationFor(Institution $institution)
+ private function createConfigurationFor(Institution $institution): void
{
- $command = new CreateInstitutionConfigurationCommand();
- $command->UUID = (string) Uuid::uuid4();
+ $command = new CreateInstitutionConfigurationCommand();
+ $command->UUID = (string)Uuid::uuid4();
$command->institution = $institution->getInstitution();
- $this->container->get('pipeline')->process($command);
+ $this->pipeline->process($command);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Service/EmailTemplateService.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Service/EmailTemplateService.php
index 1f18ade13..08dab4a5c 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Service/EmailTemplateService.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Configuration/Service/EmailTemplateService.php
@@ -24,11 +24,7 @@
interface EmailTemplateService
{
/**
- * @param string $name
- * @param string $preferredLocale
- * @param string $fallbackLocale
- * @return EmailTemplate
* @throws RuntimeException
*/
- public function findByName($name, $preferredLocale, $fallbackLocale);
+ public function findByName(string $name, string $preferredLocale, string $fallbackLocale): ?EmailTemplate;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddCommandBusCommandHandlersCompilerPass.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddCommandBusCommandHandlersCompilerPass.php
index 2b82f1a18..77f70bc63 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddCommandBusCommandHandlersCompilerPass.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddCommandBusCommandHandlersCompilerPass.php
@@ -24,7 +24,7 @@
class AddCommandBusCommandHandlersCompilerPass implements CompilerPassInterface
{
- public function process(ContainerBuilder $container)
+ public function process(ContainerBuilder $container): void
{
$definition = $container->getDefinition('surfnet_stepup_middleware_command_handling.command_bus');
$commandHandlerDefinitions = $container->findTaggedServiceIds('command_bus.command_handler');
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddEventBusListenersCompilerPass.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddEventBusListenersCompilerPass.php
index dd6578db0..f6c2161ef 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddEventBusListenersCompilerPass.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddEventBusListenersCompilerPass.php
@@ -25,14 +25,17 @@
class AddEventBusListenersCompilerPass implements CompilerPassInterface
{
- public function process(ContainerBuilder $container)
+ public function process(ContainerBuilder $container): void
{
$definition = $container->getDefinition('surfnet_stepup_middleware_command_handling.event_bus.buffered');
$eventListenerDefinitions = $container->findTaggedServiceIds('event_bus.event_listener');
// When replaying events, certain listeners should not be allowed to run again, for instance
// when they are no longer relevant at the time of replaying (i.e. sending emails)
- if (!in_array($container->getParameter('kernel.environment'), ['dev_event_replay', 'prod_event_replay', 'smoketest_event_replay'])) {
+ if (!in_array(
+ $container->getParameter('kernel.environment'),
+ ['dev_event_replay', 'prod_event_replay', 'smoketest_event_replay'],
+ )) {
foreach (array_keys($eventListenerDefinitions) as $serviceId) {
$definition->addMethodCall('subscribe', [new Reference($serviceId)]);
}
@@ -43,10 +46,12 @@ public function process(ContainerBuilder $container)
foreach ($eventListenerDefinitions as $serviceId => $tags) {
foreach ($tags as $attributes) {
if (!isset($attributes['disable_for_replay'])) {
- throw new LogicException(sprintf(
- 'Cannot replay events: Expected option "disable_for_replay" to be set for service id "%s"',
- $serviceId
- ));
+ throw new LogicException(
+ sprintf(
+ 'Cannot replay events: Expected option "disable_for_replay" to be set for service id "%s"',
+ $serviceId,
+ ),
+ );
}
if ($attributes['disable_for_replay']) {
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddPipelineStagesCompilerPass.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddPipelineStagesCompilerPass.php
index 9bd9a4783..f1f95c04c 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddPipelineStagesCompilerPass.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/CompilerPass/AddPipelineStagesCompilerPass.php
@@ -30,7 +30,7 @@ class AddPipelineStagesCompilerPass implements CompilerPassInterface
* {@inheritdoc} Since the priorities cannot be changed runtime but only through configuration, we're doing the
* sorting based on priority here. A higher priority means the stage is added earlier.
*/
- public function process(ContainerBuilder $container)
+ public function process(ContainerBuilder $container): void
{
$definition = $container->getDefinition('surfnet_stepup_middleware_command_handling.pipeline.staged_pipeline');
$stageDefinitions = $container->findTaggedServiceIds('pipeline.stage');
@@ -39,13 +39,15 @@ public function process(ContainerBuilder $container)
foreach ($stageDefinitions as $stageServiceId => $tagAttributes) {
$priority = $tagAttributes[0]['priority'];
if (isset($prioritized[$priority])) {
- throw new InvalidConfigurationException(sprintf(
- 'Cannot add stage with service_id "%s" to StagedPipeline at priority "%d", Stage with service_id '
- . '"%s" is already registered at that position',
- $stageServiceId,
- $tagAttributes['priority'],
- (string) $prioritized[$priority]
- ));
+ throw new InvalidConfigurationException(
+ sprintf(
+ 'Cannot add stage with service_id "%s" to StagedPipeline at priority "%d", Stage with service_id '
+ . '"%s" is already registered at that position',
+ $stageServiceId,
+ $tagAttributes['priority'],
+ (string)$prioritized[$priority],
+ ),
+ );
}
$prioritized[$priority] = new Reference($stageServiceId);
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/Configuration.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/Configuration.php
index fa6ddb265..31c6012b9 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/Configuration.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/Configuration.php
@@ -23,67 +23,60 @@
class Configuration implements ConfigurationInterface
{
- public function getConfigTreeBuilder()
+ public function getConfigTreeBuilder(): TreeBuilder
{
- $treeBuilder = new TreeBuilder();
+ $treeBuilder = new TreeBuilder('surfnet_stepup_middleware_command_handling');
+ $rootNode = $treeBuilder->getRootNode();
+ $rootNode
+ ->children()
+ ->scalarNode('self_service_email_verification_url_template')
+ ->isRequired()
+ ->info('Configures the URL where registrants can verify e-mail address ownership.')
+ ->validate()
+ ->ifTrue(function ($url): bool {
+ $parts = parse_url($url);
- $treeBuilder
- ->root('surfnet_stepup_middleware_command_handling')
- ->children()
- ->scalarNode('self_service_email_verification_url_template')
- ->isRequired()
- ->info('Configures the URL where registrants can verify e-mail address ownership.')
- ->validate()
- ->ifTrue(function ($url) {
- $parts = parse_url($url);
-
- return empty($parts['scheme']) || empty($parts['host']) || empty($parts['path']);
- })
- ->thenInvalid(
- 'Invalid Self-Service e-mail verification URL template: ' .
- "must be full Self-Service URL with scheme, host and path, '%s' given." .
- "The URL should contain a '{identityId}', '{secondFactorId}' and '{nonce}' parameter."
- )
- ->end()
- ->end()
- ->scalarNode('self_service_url')
- ->isRequired()
- ->info('Configures the URL for Self Service.')
- ->validate()
- ->ifTrue(
- function ($url) {
- return filter_var($url, FILTER_VALIDATE_URL) === false;
- }
- )
- ->thenInvalid('self_service_url must be a valid url')
- ->end()
- ->end()
- ->arrayNode('email_sender')
- ->isRequired()
- ->info('Configures the sender used for all outgoing e-mail messages')
- ->children()
- ->scalarNode('name')
- ->isRequired()
- ->validate()
- ->ifTrue(function ($name) {
- return !is_string($name) || empty($name);
- })
- ->thenInvalid("E-mail sender name must be non-empty string, got '%s'")
- ->end()
- ->end()
- ->scalarNode('email')
- ->isRequired()
- ->validate()
- ->ifTrue(function ($name) {
- return !is_string($name) || empty($name);
- })
- ->thenInvalid("E-mail sender e-mail must be non-empty string, got '%s'")
- ->end()
- ->end()
- ->end()
- ->end()
- ->scalarNode('email_fallback_locale')->isRequired()->end()
- ->end();
+ return empty($parts['scheme']) || empty($parts['host']) || empty($parts['path']);
+ })
+ ->thenInvalid(
+ 'Invalid Self-Service e-mail verification URL template: ' .
+ "must be full Self-Service URL with scheme, host and path, '%s' given." .
+ "The URL should contain a '{identityId}', '{secondFactorId}' and '{nonce}' parameter.",
+ )
+ ->end()
+ ->end()
+ ->scalarNode('self_service_url')
+ ->isRequired()
+ ->info('Configures the URL for Self Service.')
+ ->validate()
+ ->ifTrue(
+ fn($url): bool => filter_var($url, FILTER_VALIDATE_URL) === false,
+ )
+ ->thenInvalid('self_service_url must be a valid url')
+ ->end()
+ ->end()
+ ->arrayNode('email_sender')
+ ->isRequired()
+ ->info('Configures the sender used for all outgoing e-mail messages')
+ ->children()
+ ->scalarNode('name')
+ ->isRequired()
+ ->validate()
+ ->ifTrue(fn($name): bool => !is_string($name) || ($name === '' || $name === '0'))
+ ->thenInvalid("E-mail sender name must be non-empty string, got '%s'")
+ ->end()
+ ->end()
+ ->scalarNode('email')
+ ->isRequired()
+ ->validate()
+ ->ifTrue(fn($name): bool => !is_string($name) || ($name === '' || $name === '0'))
+ ->thenInvalid("E-mail sender e-mail must be non-empty string, got '%s'")
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->scalarNode('email_fallback_locale')->isRequired()->end()
+ ->end();
return $treeBuilder;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/SurfnetStepupMiddlewareCommandHandlingExtension.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/SurfnetStepupMiddlewareCommandHandlingExtension.php
index b3418b119..ba0f37992 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/SurfnetStepupMiddlewareCommandHandlingExtension.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/DependencyInjection/SurfnetStepupMiddlewareCommandHandlingExtension.php
@@ -26,11 +26,11 @@
class SurfnetStepupMiddlewareCommandHandlingExtension extends Extension
{
- public function load(array $config, ContainerBuilder $container)
+ public function load(array $config, ContainerBuilder $container): void
{
$loader = new YamlFileLoader(
$container,
- new FileLocator(__DIR__ . '/../Resources/config')
+ new FileLocator(__DIR__ . '/../Resources/config'),
);
$loader->load('command_handlers.yml');
$loader->load('event_sourcing.yml');
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Dto/VettingLocation.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Dto/VettingLocation.php
index 2de1829dd..d55dc8fc3 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Dto/VettingLocation.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Dto/VettingLocation.php
@@ -20,26 +20,7 @@
class VettingLocation
{
- /**
- * @var string
- */
- public $name;
-
- /**
- * @var string
- */
- public $location;
-
- /**
- * @var string
- */
- public $contactInformation;
-
-
- public function __construct($name, $location, $contactInformation)
+ public function __construct(public string $name, public string $location, public string $contactInformation)
{
- $this->name = $name;
- $this->location = $location;
- $this->contactInformation = $contactInformation;
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventHandling/BufferedEventBus.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventHandling/BufferedEventBus.php
index b6c495a58..9b50c3b28 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventHandling/BufferedEventBus.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventHandling/BufferedEventBus.php
@@ -23,35 +23,29 @@
use Broadway\EventHandling\EventBus as EventBusInterface;
use Broadway\EventHandling\EventListener as EventListenerInterface;
use Doctrine\ORM\EntityManagerInterface;
-use Exception;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\Exception;
+use Throwable;
class BufferedEventBus implements EventBusInterface
{
/**
* @var EventListenerInterface[]
*/
- private $eventListeners = [];
+ private array $eventListeners = [];
/**
* @var DomainMessage[]
*/
- private $buffer = [];
+ private array $buffer = [];
/**
* Flag to ensure only one loop is publishing domain messages from the buffer.
- *
- * @var bool
*/
- private $isFlushing = false;
+ private bool $isFlushing = false;
- /**
- * @var EntityManagerInterface
- */
- private $entityManager;
-
- public function __construct(EntityManagerInterface $entityManager)
- {
- $this->entityManager = $entityManager;
+ public function __construct(
+ private readonly EntityManagerInterface $entityManager,
+ ) {
}
public function subscribe(EventListenerInterface $eventListener): void
@@ -68,8 +62,9 @@ public function publish(DomainEventStreamInterface $domainMessages): void
/**
* Flushes the buffered domain messages to all event listeners.
+ * @throws Exception
*/
- public function flush()
+ public function flush(): void
{
if ($this->isFlushing) {
// If already flushing, we're in a nested pipeline. This means that an event that is currently being
@@ -95,7 +90,7 @@ public function flush()
// This comes with a caveat: event listeners cannot hold references to certain entities between events
$this->entityManager->clear();
}
- } catch (Exception $e) {
+ } catch (Throwable $e) {
$this->isFlushing = false;
array_splice($this->buffer, 0, 0, $buffer);
@@ -107,7 +102,7 @@ public function flush()
unset($buffer);
// if during the handling of events new events have been queued, we need to flush them
- if (!empty($this->buffer)) {
+ if (count($this->buffer) > 0) {
$this->flush();
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventListener/ProcessingAbortedExceptionListener.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventListener/ProcessingAbortedExceptionListener.php
index e6335ff25..867b82c72 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventListener/ProcessingAbortedExceptionListener.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventListener/ProcessingAbortedExceptionListener.php
@@ -21,17 +21,18 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Exception\ProcessingAbortedException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
+use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class ProcessingAbortedExceptionListener implements EventSubscriberInterface
{
- public static function getSubscribedEvents()
+ public static function getSubscribedEvents(): array
{
return [KernelEvents::EXCEPTION => 'onKernelException'];
}
- public function onKernelException(ExceptionEvent $event)
+ public function onKernelException(ExceptionEvent $event): void
{
$throwable = $event->getThrowable();
@@ -39,12 +40,14 @@ public function onKernelException(ExceptionEvent $event)
return;
}
- $event->setResponse(new JsonResponse(
- [
- 'exception' => get_class($throwable),
- 'errors' => $throwable->getErrors(),
- ],
- 400
- ));
+ $event->setResponse(
+ new JsonResponse(
+ [
+ 'exception' => $throwable::class,
+ 'errors' => $throwable->getErrors(),
+ ],
+ Response::HTTP_BAD_REQUEST,
+ ),
+ );
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventSourcing/MetadataEnricher.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventSourcing/MetadataEnricher.php
index 1ae4cf7ea..555c9b882 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventSourcing/MetadataEnricher.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventSourcing/MetadataEnricher.php
@@ -26,5 +26,5 @@ interface MetadataEnricher
* @param Metadata|null $metadata
* @return void
*/
- public function setMetadata(Metadata $metadata = null);
+ public function setMetadata(Metadata $metadata = null): void;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventSourcing/MetadataEnrichingEventStreamDecorator.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventSourcing/MetadataEnrichingEventStreamDecorator.php
index 4a08c89dc..e3e1848e0 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventSourcing/MetadataEnrichingEventStreamDecorator.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/EventSourcing/MetadataEnrichingEventStreamDecorator.php
@@ -19,40 +19,38 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\EventSourcing;
use Broadway\Domain\DomainEventStream;
+use Broadway\Domain\DomainMessage;
use Broadway\Domain\Metadata as BroadwayMetadata;
use Broadway\EventSourcing\EventStreamDecorator;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Metadata;
final class MetadataEnrichingEventStreamDecorator implements EventStreamDecorator, MetadataEnricher
{
- /**
- * @var Metadata|null
- */
- private $metadata;
+ private ?Metadata $metadata = null;
- public function setMetadata(Metadata $metadata = null)
+ public function setMetadata(Metadata $metadata = null): void
{
$this->metadata = $metadata;
}
public function decorateForWrite(
- $aggregateType,
- $aggregateIdentifier,
- DomainEventStream $eventStream
+ string $aggregateType,
+ string $aggregateIdentifier,
+ DomainEventStream $eventStream,
): DomainEventStream {
- if (!$this->metadata) {
+ if (!$this->metadata instanceof Metadata) {
return $eventStream;
}
$domainMessages = [];
foreach ($eventStream as $domainMessage) {
- /** @var \Broadway\Domain\DomainMessage $domainMessage */
+ /** @var DomainMessage $domainMessage */
$domainMessages[] = $domainMessage->andMetadata(
new BroadwayMetadata([
- 'actorId' => $this->metadata->actorId,
- 'actorInstitution' => $this->metadata->actorInstitution
- ])
+ 'actorId' => $this->metadata->actorId,
+ 'actorInstitution' => $this->metadata->actorInstitution,
+ ]),
);
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/Exception.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/Exception.php
index d311543e3..ce4fe5a24 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/Exception.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/Exception.php
@@ -18,6 +18,8 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Exception;
-interface Exception
+use Throwable;
+
+interface Exception extends Throwable
{
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/InvalidArgumentException.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/InvalidArgumentException.php
index cb955f458..725a658ec 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/InvalidArgumentException.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/InvalidArgumentException.php
@@ -20,20 +20,13 @@
class InvalidArgumentException extends \InvalidArgumentException implements Exception
{
- /**
- * @param string $expected description of expected type
- * @param string $parameterName
- * @param mixed $parameter the parameter that is not of the expected type.
- *
- * @return self
- */
- public static function invalidType($expected, $parameterName, $parameter)
+ public static function invalidType(string $expected, string $parameterName, mixed $parameter): self
{
$message = sprintf(
'Invalid argument type: "%s" expected, "%s" given for "%s"',
$expected,
- is_object($parameter) ? get_class($parameter) : gettype($parameter),
- $parameterName
+ get_debug_type($parameter),
+ $parameterName,
);
return new self($message);
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/SecondFactorNotAllowedException.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/SecondFactorNotAllowedException.php
index e417659e5..2b2564231 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/SecondFactorNotAllowedException.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Exception/SecondFactorNotAllowedException.php
@@ -19,23 +19,24 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Exception;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Exception\ProcessingAbortedException;
+use Throwable;
class SecondFactorNotAllowedException extends RuntimeException implements ProcessingAbortedException
{
/**
* @var string[]
*/
- private $errors;
+ private array $errors;
/**
* @return string[]
*/
- public function getErrors()
+ public function getErrors(): array
{
return $this->errors;
}
- public function __construct($message = "", $code = 0, Exception $previous = null)
+ public function __construct(string $message = "", int $code = 0, Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AccreditIdentityCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AccreditIdentityCommand.php
index 245de60ce..021d9646c 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AccreditIdentityCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AccreditIdentityCommand.php
@@ -24,58 +24,31 @@
class AccreditIdentityCommand extends AbstractCommand implements RaExecutable
{
- /**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
- */
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
- /**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
- */
- public $institution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $institution;
- /**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
- */
- public $role;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $role;
- /**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
- */
- public $location;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $location;
- /**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
- */
- public $contactInformation;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $contactInformation;
- /**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
- */
- public $raInstitution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $raInstitution;
- /**
- * @inheritDoc
- */
- public function getRaInstitution()
+ public function getRaInstitution(): ?string
{
return $this->raInstitution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AddToWhitelistCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AddToWhitelistCommand.php
index 662d29064..a979be389 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AddToWhitelistCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AddToWhitelistCommand.php
@@ -24,14 +24,10 @@
class AddToWhitelistCommand extends AbstractCommand implements ManagementExecutable
{
- /**
- * @Assert\Type(type="array")
- * @Assert\All({
- * @Assert\NotBlank,
- * @Assert\Type("string")
- * })
- *
- * @var array
- */
- public $institutionsToBeAdded;
+ #[Assert\Type(type: 'array')]
+ #[Assert\All([
+ new Assert\NotBlank(),
+ new Assert\Type("string"),
+ ])]
+ public array $institutionsToBeAdded;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AmendRegistrationAuthorityInformationCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AmendRegistrationAuthorityInformationCommand.php
index 41d815b32..1bd0f6bab 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AmendRegistrationAuthorityInformationCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AmendRegistrationAuthorityInformationCommand.php
@@ -25,41 +25,41 @@
class AmendRegistrationAuthorityInformationCommand extends AbstractCommand implements RaExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
*
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
*
* @var string
*/
- public $location;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $location;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
*
* @var string
*/
- public $contactInformation;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $contactInformation;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
*
* @var string
*/
- public $raInstitution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $raInstitution;
/**
* @inheritDoc
*/
- public function getRaInstitution()
+ public function getRaInstitution(): string
{
return $this->raInstitution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AppointRoleCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AppointRoleCommand.php
index e03948127..207f74347 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AppointRoleCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/AppointRoleCommand.php
@@ -25,33 +25,27 @@
class AppointRoleCommand extends AbstractCommand implements RaExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var
+ * @var string
*/
- public $role;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $role;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $raInstitution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $raInstitution;
- /**
- * @inheritDoc
- */
- public function getRaInstitution()
+ public function getRaInstitution(): string
{
return $this->raInstitution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/BootstrapIdentityWithYubikeySecondFactorCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/BootstrapIdentityWithYubikeySecondFactorCommand.php
index 977db5099..c7c559312 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/BootstrapIdentityWithYubikeySecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/BootstrapIdentityWithYubikeySecondFactorCommand.php
@@ -24,66 +24,66 @@
final class BootstrapIdentityWithYubikeySecondFactorCommand extends AbstractCommand
{
/**
- * @Assert\NotBlank()
- * @Assert\Type("string")
*
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type('string')]
+ public string $identityId;
/**
- * @Assert\NotBlank()
- * @Assert\Type("string")
*
* @var string
*/
- public $nameId;
+ #[Assert\NotBlank]
+ #[Assert\Type('string')]
+ public string $nameId;
/**
- * @Assert\NotBlank()
- * @Assert\Type("string")
*
* @var string
*/
- public $institution;
+ #[Assert\NotBlank]
+ #[Assert\Type('string')]
+ public string $institution;
/**
- * @Assert\NotBlank()
- * @Assert\Type("string")
*
* @var string
*/
- public $commonName;
+ #[Assert\NotBlank]
+ #[Assert\Type('string')]
+ public string $commonName;
/**
- * @Assert\NotBlank()
- * @Assert\Email()
*
* @var string
*/
- public $email;
+ #[Assert\NotBlank]
+ #[Assert\Email]
+ public string $email;
/**
- * @Assert\NotBlank()
- * @Assert\Type("string")
*
* @var string
*/
- public $preferredLocale;
+ #[Assert\NotBlank]
+ #[Assert\Type('string')]
+ public string $preferredLocale;
/**
- * @Assert\NotBlank()
- * @Assert\Type("string")
*
* @var string
*/
- public $secondFactorId;
+ #[Assert\NotBlank]
+ #[Assert\Type('string')]
+ public string $secondFactorId;
/**
- * @Assert\NotBlank()
- * @Assert\Type("string")
*
* @var string
*/
- public $yubikeyPublicId;
+ #[Assert\NotBlank]
+ #[Assert\Type('string')]
+ public string $yubikeyPublicId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/CreateIdentityCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/CreateIdentityCommand.php
index 31ddf4eeb..cba8a3242 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/CreateIdentityCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/CreateIdentityCommand.php
@@ -25,58 +25,52 @@
class CreateIdentityCommand extends AbstractCommand implements SelfServiceExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $id;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $id;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $nameId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $nameId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $email;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $email;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $institution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $institution;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $commonName;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $commonName;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $preferredLocale;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $preferredLocale;
/**
* @return string
*/
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->id;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ExpressLocalePreferenceCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ExpressLocalePreferenceCommand.php
index a5da23738..59f83188b 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ExpressLocalePreferenceCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ExpressLocalePreferenceCommand.php
@@ -26,25 +26,22 @@
class ExpressLocalePreferenceCommand extends AbstractCommand implements SelfServiceExecutable, RaExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
*
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
*
* @var string
*/
- public $preferredLocale;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $preferredLocale;
- /**
- * @inheritDoc
- */
- public function getRaInstitution()
+ public function getRaInstitution(): null
{
return null;
}
@@ -52,7 +49,7 @@ public function getRaInstitution()
/**
* @return string
*/
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->identityId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ForgetIdentityCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ForgetIdentityCommand.php
index a40d89f41..8e77903e1 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ForgetIdentityCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ForgetIdentityCommand.php
@@ -26,18 +26,18 @@
final class ForgetIdentityCommand extends AbstractCommand implements ManagementExecutable, DeprovisionExecutable
{
/**
- * @Assert\NotBlank
- * @Assert\Type("string")
*
* @var string
*/
- public $nameId;
+ #[Assert\NotBlank]
+ #[Assert\Type('string')]
+ public string $nameId;
/**
- * @Assert\NotBlank
- * @Assert\Type("string")
*
* @var string
*/
- public $institution;
+ #[Assert\NotBlank]
+ #[Assert\Type('string')]
+ public string $institution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/MigrateVettedSecondFactorCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/MigrateVettedSecondFactorCommand.php
index a85d0d514..740326e5c 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/MigrateVettedSecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/MigrateVettedSecondFactorCommand.php
@@ -1,7 +1,7 @@
identityId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveGssfPossessionCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveGssfPossessionCommand.php
index 8937b2cdc..dff30633f 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveGssfPossessionCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveGssfPossessionCommand.php
@@ -26,50 +26,42 @@ class ProveGssfPossessionCommand extends AbstractCommand implements SelfServiceE
{
/**
* The ID of an existing identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
* The ID of the second factor to create.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $secondFactorId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $secondFactorId;
/**
* The SecondFactorType identifier.
*
* For example in the case of a Tiqr GSSP it would be 'tiqr'.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $stepupProvider;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $stepupProvider;
/**
* The identifier of the generic Stepup second factor type
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $gssfId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $gssfId;
/**
* @return string
*/
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->identityId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProvePhonePossessionCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProvePhonePossessionCommand.php
index cc8a38d8b..5149acbc3 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProvePhonePossessionCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProvePhonePossessionCommand.php
@@ -26,39 +26,33 @@ class ProvePhonePossessionCommand extends AbstractCommand implements SelfService
{
/**
* The ID of an existing identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
* The ID of the second factor to create.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $secondFactorId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $secondFactorId;
/**
* The phone number
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- * @Assert\Regex(pattern="~^\+[\d\s]+ \(0\) \d+$~")
- *
* @var string
*/
- public $phoneNumber;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ #[Assert\Regex(pattern: '~^\+[\d\s]+ \(0\) \d+$~')]
+ public string $phoneNumber;
/**
* @return string
*/
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->identityId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProvePhoneRecoveryTokenPossessionCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProvePhoneRecoveryTokenPossessionCommand.php
index f7d65469a..bd2ac3ab9 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProvePhoneRecoveryTokenPossessionCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProvePhoneRecoveryTokenPossessionCommand.php
@@ -27,48 +27,31 @@ class ProvePhoneRecoveryTokenPossessionCommand extends AbstractCommand implement
{
/**
* The ID of an existing identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
* The ID of the recovery code to create.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
*/
- public $recoveryTokenId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $recoveryTokenId;
- /**
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
- */
- public $recoveryTokenType = RecoveryTokenType::TYPE_SMS;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $recoveryTokenType = RecoveryTokenType::TYPE_SMS;
/**
* The phone number
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- * @Assert\Regex(pattern="~^\+[\d\s]+ \(0\) \d+$~")
- *
- * @var string
*/
- public $phoneNumber;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ #[Assert\Regex(pattern: '~^\+[\d\s]+ \(0\) \d+$~')]
+ public string $phoneNumber;
- /**
- * @return string
- */
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->identityId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveU2fDevicePossessionCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveU2fDevicePossessionCommand.php
index 4f4529516..71d76afce 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveU2fDevicePossessionCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveU2fDevicePossessionCommand.php
@@ -26,38 +26,32 @@ class ProveU2fDevicePossessionCommand extends AbstractCommand implements SelfSer
{
/**
* The ID of an existing identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
* The ID of the second factor to create.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $secondFactorId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $secondFactorId;
/**
* The key handle issued by the U2F device
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $keyHandle;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $keyHandle;
/**
* @return string
*/
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->identityId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveYubikeyPossessionCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveYubikeyPossessionCommand.php
index d403b8b86..6971cf6a8 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveYubikeyPossessionCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ProveYubikeyPossessionCommand.php
@@ -26,38 +26,32 @@ class ProveYubikeyPossessionCommand extends AbstractCommand implements SelfServi
{
/**
* The ID of an existing identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
* The ID of the second factor to create.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $secondFactorId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $secondFactorId;
/**
* The Yubikey's public ID.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $yubikeyPublicId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $yubikeyPublicId;
/**
* @return string
*/
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->identityId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RegisterSelfAssertedSecondFactorCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RegisterSelfAssertedSecondFactorCommand.php
index 8edfd748c..04afd31ce 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RegisterSelfAssertedSecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RegisterSelfAssertedSecondFactorCommand.php
@@ -1,7 +1,7 @@
identityId;
+ return $this->identityId;
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RemoveFromWhitelistCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RemoveFromWhitelistCommand.php
index 034e6f34a..9606e45e9 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RemoveFromWhitelistCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RemoveFromWhitelistCommand.php
@@ -24,14 +24,10 @@
class RemoveFromWhitelistCommand extends AbstractCommand implements ManagementExecutable
{
- /**
- * @Assert\Type(type="array")
- * @Assert\All({
- * @Assert\NotBlank,
- * @Assert\Type("string")
- * })
- *
- * @var array
- */
- public $institutionsToBeRemoved;
+ #[Assert\Type(type: 'array')]
+ #[Assert\All([
+ new Assert\NotBlank(),
+ new Assert\Type('string'),
+ ])]
+ public array $institutionsToBeRemoved;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ReplaceWhitelistCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ReplaceWhitelistCommand.php
index 21ff62993..89ad1e4c9 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ReplaceWhitelistCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/ReplaceWhitelistCommand.php
@@ -24,14 +24,10 @@
class ReplaceWhitelistCommand extends AbstractCommand implements ManagementExecutable
{
- /**
- * @Assert\Type(type="array")
- * @Assert\All({
- * @Assert\NotBlank,
- * @Assert\Type("string")
- * })
- *
- * @var array
- */
- public $institutions;
+ #[Assert\Type(type: 'array')]
+ #[Assert\All([
+ new Assert\NotBlank(),
+ new Assert\Type("string"),
+ ])]
+ public array $institutions;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RetractRegistrationAuthorityCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RetractRegistrationAuthorityCommand.php
index 7f1e3610d..b83910e88 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RetractRegistrationAuthorityCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RetractRegistrationAuthorityCommand.php
@@ -25,25 +25,23 @@
class RetractRegistrationAuthorityCommand extends AbstractCommand implements RaExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $raInstitution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $raInstitution;
/**
* @inheritDoc
*/
- public function getRaInstitution()
+ public function getRaInstitution(): string
{
return $this->raInstitution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeOwnRecoveryTokenCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeOwnRecoveryTokenCommand.php
index 2b24bff2a..c5762ce99 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeOwnRecoveryTokenCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeOwnRecoveryTokenCommand.php
@@ -29,28 +29,24 @@ class RevokeOwnRecoveryTokenCommand extends AbstractCommand implements SelfServi
{
/**
* The ID of an existing identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
* The ID of a recovery token.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $recoveryTokenId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $recoveryTokenId;
/**
* @return string
*/
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->identityId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeOwnSecondFactorCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeOwnSecondFactorCommand.php
index 1bb0e4022..ebdb0d8ab 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeOwnSecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeOwnSecondFactorCommand.php
@@ -29,28 +29,24 @@ class RevokeOwnSecondFactorCommand extends AbstractCommand implements SelfServic
{
/**
* The ID of an existing identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
* The ID of a verified or vetted second factor.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $secondFactorId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $secondFactorId;
/**
* @return string
*/
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->identityId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeRegistrantsRecoveryTokenCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeRegistrantsRecoveryTokenCommand.php
index 14a8c493e..38c6fb96a 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeRegistrantsRecoveryTokenCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeRegistrantsRecoveryTokenCommand.php
@@ -29,38 +29,29 @@ class RevokeRegistrantsRecoveryTokenCommand extends AbstractCommand implements R
{
/**
* The ID of the identity that has the authority to issue the revocation of a registrant's second factor.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
*/
- public $authorityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $authorityId;
/**
* The ID of an identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
* The ID of a recovery token
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
- * @var string
*/
- public $recoveryTokenId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $recoveryTokenId;
/**
* @inheritDoc
*/
- public function getRaInstitution()
+ public function getRaInstitution(): ?string
{
// Returning null as opposed to having the institution on this command was done
// because the RA (actor) institution can be loaded from the authorityId
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeRegistrantsSecondFactorCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeRegistrantsSecondFactorCommand.php
index 3410e9ff6..ef02b8c5e 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeRegistrantsSecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/RevokeRegistrantsSecondFactorCommand.php
@@ -29,38 +29,32 @@ class RevokeRegistrantsSecondFactorCommand extends AbstractCommand implements Ra
{
/**
* The ID of the identity that has the authority to issue the revocation of a registrant's second factor.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $authorityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $authorityId;
/**
* The ID of an identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
* The ID of a verified or vetted second factor.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $secondFactorId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $secondFactorId;
/**
* @inheritDoc
*/
- public function getRaInstitution()
+ public function getRaInstitution(): ?string
{
// Returning null as opposed to having the institution on this command was done
// because the RA (actor) institution can be loaded from the authorityId
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SaveVettingTypeHintCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SaveVettingTypeHintCommand.php
index 148c3957d..8067f44d2 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SaveVettingTypeHintCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SaveVettingTypeHintCommand.php
@@ -34,33 +34,26 @@ class SaveVettingTypeHintCommand extends AbstractCommand implements RaExecutable
{
/**
* The ID of an existing identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $institution;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $institution;
- /**
- * @Assert\Type(type="array")
- * @Assert\All({
- * @Assert\Type("string")
- * })
- *
- * @var string[]
- */
- public $hints;
+ #[Assert\Type(type: 'array')]
+ #[Assert\All([
+ new Assert\Type("string"),
+ ])]
+ public array $hints;
- public function getRaInstitution()
+ public function getRaInstitution(): ?string
{
return null;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SelfVetSecondFactorCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SelfVetSecondFactorCommand.php
index 149917321..17c82f9b1 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SelfVetSecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SelfVetSecondFactorCommand.php
@@ -1,7 +1,7 @@
identityId;
+ return $this->identityId;
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SendSecondFactorRegistrationEmailCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SendSecondFactorRegistrationEmailCommand.php
index 8b5d6e7ca..e1f0ace67 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SendSecondFactorRegistrationEmailCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SendSecondFactorRegistrationEmailCommand.php
@@ -26,25 +26,21 @@ class SendSecondFactorRegistrationEmailCommand extends AbstractCommand implement
{
/**
* The ID of an identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
* The ID of a second factor token
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $secondFactorId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $secondFactorId;
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->identityId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SendVerifiedSecondFactorRemindersCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SendVerifiedSecondFactorRemindersCommand.php
index e065c67ce..36c59a5db 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SendVerifiedSecondFactorRemindersCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/SendVerifiedSecondFactorRemindersCommand.php
@@ -26,10 +26,10 @@ class SendVerifiedSecondFactorRemindersCommand extends AbstractCommand
/**
* @var bool
*/
- public $dryRun;
+ public bool $dryRun;
/**
* @var DateTime
*/
- public $requestedAt;
+ public DateTime $requestedAt;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/UpdateIdentityCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/UpdateIdentityCommand.php
index a8a82c9d2..addd8293c 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/UpdateIdentityCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/UpdateIdentityCommand.php
@@ -25,33 +25,30 @@
class UpdateIdentityCommand extends AbstractCommand implements SelfServiceExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $id;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $id;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $email;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $email;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $commonName;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $commonName;
/**
* @return string
*/
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->id;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/VerifyEmailCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/VerifyEmailCommand.php
index 0176351b0..4fd703fc1 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/VerifyEmailCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/VerifyEmailCommand.php
@@ -26,26 +26,23 @@ class VerifyEmailCommand extends AbstractCommand implements SelfServiceExecutabl
{
/**
* The ID of an existing identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $verificationNonce;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $verificationNonce;
/**
* @return string
*/
- public function getIdentityId()
+ public function getIdentityId(): string
{
return $this->identityId;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/VetSecondFactorCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/VetSecondFactorCommand.php
index 810c46aad..c643360e2 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/VetSecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Command/VetSecondFactorCommand.php
@@ -25,81 +25,72 @@
class VetSecondFactorCommand extends AbstractCommand implements RaExecutable
{
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $authorityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $authorityId;
/**
* The ID of an existing identity.
- *
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $identityId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $identityId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $secondFactorId;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $secondFactorId;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
*
* @var string
*/
- public $registrationCode;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $registrationCode;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $secondFactorType;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $secondFactorType;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $secondFactorIdentifier;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $secondFactorIdentifier;
/**
- * @Assert\NotBlank()
- * @Assert\Type(type="string")
- *
* @var string
*/
- public $documentNumber;
+ #[Assert\NotBlank]
+ #[Assert\Type(type: 'string')]
+ public string $documentNumber;
/**
- * @Assert\EqualTo(value=true)
- *
* @var boolean
*/
- public $identityVerified;
+ #[Assert\EqualTo(value: true)]
+ public bool $identityVerified;
/**
- * @Assert\Type(type="bool")
- *
* @var boolean
*/
- public $provePossessionSkipped;
+ #[Assert\Type(type: 'bool')]
+ public bool $provePossessionSkipped = false;
/**
* @inheritDoc
*/
- public function getRaInstitution()
+ public function getRaInstitution(): ?string
{
// Returning null as opposed to having the institution on this command was done
// because the RA (actor) institution can be loaded from the authorityId
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/Exception/DuplicateIdentityException.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/Exception/DuplicateIdentityException.php
index 095b2d05b..6521d1ba5 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/Exception/DuplicateIdentityException.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/Exception/DuplicateIdentityException.php
@@ -17,32 +17,30 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\Exception;
-use Exception;
use RuntimeException;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\NameId;
+use Throwable;
final class DuplicateIdentityException extends RuntimeException
{
- public function __construct($message = "", $code = 0, Exception $previous = null)
+ public function __construct(string $message = "", int $code = 0, Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
/**
- * @param NameId $nameId
- * @param Institution $institution
*
* @return DuplicateIdentityException
*/
- public static function forBootstrappingWithYubikeySecondFactor(NameId $nameId, Institution $institution)
+ public static function forBootstrappingWithYubikeySecondFactor(NameId $nameId, Institution $institution): self
{
return new self(
sprintf(
'Trying to bootstrap a duplicate identity: an identity with name ID "%s" from institution "%s" already exists.',
$nameId->getNameId(),
- $institution->getInstitution()
- )
+ $institution->getInstitution(),
+ ),
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/IdentityCommandHandler.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/IdentityCommandHandler.php
index a980d8f6f..96b28f315 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/IdentityCommandHandler.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/IdentityCommandHandler.php
@@ -83,82 +83,24 @@
*/
class IdentityCommandHandler extends SimpleCommandHandler
{
- /**
- * @var \Surfnet\Stepup\Identity\EventSourcing\IdentityRepository
- */
- private $eventSourcedRepository;
-
- /**
- * @var IdentityRepository
- */
- private $identityProjectionRepository;
-
- /**
- * @var \Surfnet\Stepup\Identity\Entity\ConfigurableSettings
- */
- private $configurableSettings;
-
- /**
- * @var AllowedSecondFactorListService
- */
- private $allowedSecondFactorListService;
-
- /** @var SecondFactorTypeService */
- private $secondFactorTypeService;
-
- /**
- * @var InstitutionConfigurationOptionsService
- */
- private $institutionConfigurationOptionsService;
-
- /**
- * @var LoaResolutionService
- */
- private $loaResolutionService;
-
- /**
- * @var SecondFactorProvePossessionHelper
- */
- private $provePossessionHelper;
-
- /**
- * @var RecoveryTokenSecretHelper
- */
- private $recoveryTokenSecretHelper;
-
- /**
- * @var RegistrationMailService
- */
- private $registrationMailService;
-
/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- RepositoryInterface $eventSourcedRepository,
- IdentityRepository $identityProjectionRepository,
- ConfigurableSettings $configurableSettings,
- AllowedSecondFactorListService $allowedSecondFactorListService,
- SecondFactorTypeService $secondFactorTypeService,
- SecondFactorProvePossessionHelper $provePossessionHelper,
- InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
- LoaResolutionService $loaResolutionService,
- RecoveryTokenSecretHelper $recoveryTokenSecretHelper,
- RegistrationMailService $registrationMailService
+ private readonly RepositoryInterface $eventSourcedRepository,
+ private readonly IdentityRepository $identityProjectionRepository,
+ private readonly ConfigurableSettings $configurableSettings,
+ private readonly AllowedSecondFactorListService $allowedSecondFactorListService,
+ private readonly SecondFactorTypeService $secondFactorTypeService,
+ private readonly SecondFactorProvePossessionHelper $provePossessionHelper,
+ private readonly InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
+ private readonly LoaResolutionService $loaResolutionService,
+ private readonly RecoveryTokenSecretHelper $recoveryTokenSecretHelper,
+ private readonly RegistrationMailService $registrationMailService,
) {
- $this->eventSourcedRepository = $eventSourcedRepository;
- $this->identityProjectionRepository = $identityProjectionRepository;
- $this->configurableSettings = $configurableSettings;
- $this->allowedSecondFactorListService = $allowedSecondFactorListService;
- $this->secondFactorTypeService = $secondFactorTypeService;
- $this->provePossessionHelper = $provePossessionHelper;
- $this->institutionConfigurationOptionsService = $institutionConfigurationOptionsService;
- $this->loaResolutionService = $loaResolutionService;
- $this->recoveryTokenSecretHelper = $recoveryTokenSecretHelper;
- $this->registrationMailService = $registrationMailService;
}
- public function handleCreateIdentityCommand(CreateIdentityCommand $command)
+ public function handleCreateIdentityCommand(CreateIdentityCommand $command): void
{
$preferredLocale = new Locale($command->preferredLocale);
$this->assertIsValidLocale($preferredLocale);
@@ -169,13 +111,13 @@ public function handleCreateIdentityCommand(CreateIdentityCommand $command)
new NameId($command->nameId),
new CommonName($command->commonName),
new Email($command->email),
- $preferredLocale
+ $preferredLocale,
);
$this->eventSourcedRepository->save($identity);
}
- public function handleUpdateIdentityCommand(UpdateIdentityCommand $command)
+ public function handleUpdateIdentityCommand(UpdateIdentityCommand $command): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->id));
@@ -187,8 +129,8 @@ public function handleUpdateIdentityCommand(UpdateIdentityCommand $command)
}
public function handleBootstrapIdentityWithYubikeySecondFactorCommand(
- BootstrapIdentityWithYubikeySecondFactorCommand $command
- ) {
+ BootstrapIdentityWithYubikeySecondFactorCommand $command,
+ ): void {
$preferredLocale = new Locale($command->preferredLocale);
$this->assertIsValidLocale($preferredLocale);
@@ -205,11 +147,11 @@ public function handleBootstrapIdentityWithYubikeySecondFactorCommand(
$nameId,
new CommonName($command->commonName),
new Email($command->email),
- $preferredLocale
+ $preferredLocale,
);
$configurationInstitution = new ConfigurationInstitution(
- (string) $identity->getInstitution()
+ (string)$identity->getInstitution(),
);
$tokenCount = $this->institutionConfigurationOptionsService->getMaxNumberOfTokensFor($configurationInstitution);
@@ -217,13 +159,13 @@ public function handleBootstrapIdentityWithYubikeySecondFactorCommand(
$identity->bootstrapYubikeySecondFactor(
new SecondFactorId($command->secondFactorId),
new YubikeyPublicId($command->yubikeyPublicId),
- $tokenCount
+ $tokenCount,
);
$this->eventSourcedRepository->save($identity);
}
- public function handleProveYubikeyPossessionCommand(ProveYubikeyPossessionCommand $command)
+ public function handleProveYubikeyPossessionCommand(ProveYubikeyPossessionCommand $command): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
@@ -231,7 +173,7 @@ public function handleProveYubikeyPossessionCommand(ProveYubikeyPossessionComman
$this->assertSecondFactorIsAllowedFor(new SecondFactorType('yubikey'), $identity->getInstitution());
$configurationInstitution = new ConfigurationInstitution(
- (string) $identity->getInstitution()
+ (string)$identity->getInstitution(),
);
$tokenCount = $this->institutionConfigurationOptionsService->getMaxNumberOfTokensFor($configurationInstitution);
@@ -240,16 +182,13 @@ public function handleProveYubikeyPossessionCommand(ProveYubikeyPossessionComman
new YubikeyPublicId($command->yubikeyPublicId),
$this->emailVerificationIsRequired($identity),
$this->configurableSettings->createNewEmailVerificationWindow(),
- $tokenCount
+ $tokenCount,
);
$this->eventSourcedRepository->save($identity);
}
- /**
- * @param ProvePhonePossessionCommand $command
- */
- public function handleProvePhonePossessionCommand(ProvePhonePossessionCommand $command)
+ public function handleProvePhonePossessionCommand(ProvePhonePossessionCommand $command): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
@@ -257,7 +196,7 @@ public function handleProvePhonePossessionCommand(ProvePhonePossessionCommand $c
$this->assertSecondFactorIsAllowedFor(new SecondFactorType('sms'), $identity->getInstitution());
$configurationInstitution = new ConfigurationInstitution(
- (string) $identity->getInstitution()
+ (string)$identity->getInstitution(),
);
$tokenCount = $this->institutionConfigurationOptionsService->getMaxNumberOfTokensFor($configurationInstitution);
@@ -267,16 +206,13 @@ public function handleProvePhonePossessionCommand(ProvePhonePossessionCommand $c
new PhoneNumber($command->phoneNumber),
$this->emailVerificationIsRequired($identity),
$this->configurableSettings->createNewEmailVerificationWindow(),
- $tokenCount
+ $tokenCount,
);
$this->eventSourcedRepository->save($identity);
}
- /**
- * @param ProveGssfPossessionCommand $command
- */
- public function handleProveGssfPossessionCommand(ProveGssfPossessionCommand $command)
+ public function handleProveGssfPossessionCommand(ProveGssfPossessionCommand $command): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
@@ -286,7 +222,7 @@ public function handleProveGssfPossessionCommand(ProveGssfPossessionCommand $com
$this->assertSecondFactorIsAllowedFor(new SecondFactorType($secondFactorType), $identity->getInstitution());
$configurationInstitution = new ConfigurationInstitution(
- (string) $identity->getInstitution()
+ (string)$identity->getInstitution(),
);
$tokenCount = $this->institutionConfigurationOptionsService->getMaxNumberOfTokensFor($configurationInstitution);
@@ -297,13 +233,13 @@ public function handleProveGssfPossessionCommand(ProveGssfPossessionCommand $com
new GssfId($command->gssfId),
$this->emailVerificationIsRequired($identity),
$this->configurableSettings->createNewEmailVerificationWindow(),
- $tokenCount
+ $tokenCount,
);
$this->eventSourcedRepository->save($identity);
}
- public function handleProveU2fDevicePossessionCommand(ProveU2fDevicePossessionCommand $command)
+ public function handleProveU2fDevicePossessionCommand(ProveU2fDevicePossessionCommand $command): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
@@ -311,7 +247,7 @@ public function handleProveU2fDevicePossessionCommand(ProveU2fDevicePossessionCo
$this->assertSecondFactorIsAllowedFor(new SecondFactorType('u2f'), $identity->getInstitution());
$configurationInstitution = new ConfigurationInstitution(
- (string) $identity->getInstitution()
+ (string)$identity->getInstitution(),
);
$tokenCount = $this->institutionConfigurationOptionsService->getMaxNumberOfTokensFor($configurationInstitution);
@@ -321,16 +257,13 @@ public function handleProveU2fDevicePossessionCommand(ProveU2fDevicePossessionCo
new U2fKeyHandle($command->keyHandle),
$this->emailVerificationIsRequired($identity),
$this->configurableSettings->createNewEmailVerificationWindow(),
- $tokenCount
+ $tokenCount,
);
$this->eventSourcedRepository->save($identity);
}
- /**
- * @param VerifyEmailCommand $command
- */
- public function handleVerifyEmailCommand(VerifyEmailCommand $command)
+ public function handleVerifyEmailCommand(VerifyEmailCommand $command): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
@@ -341,7 +274,7 @@ public function handleVerifyEmailCommand(VerifyEmailCommand $command)
}
- public function handleProvePhoneRecoveryTokenPossessionCommand(ProvePhoneRecoveryTokenPossessionCommand $command)
+ public function handleProvePhoneRecoveryTokenPossessionCommand(ProvePhoneRecoveryTokenPossessionCommand $command,): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
@@ -349,14 +282,15 @@ public function handleProvePhoneRecoveryTokenPossessionCommand(ProvePhoneRecover
$this->assertSelfAssertedTokensEnabled($identity->getInstitution());
$identity->provePossessionOfPhoneRecoveryToken(
new RecoveryTokenId($command->recoveryTokenId),
- new PhoneNumber($command->phoneNumber)
+ new PhoneNumber($command->phoneNumber),
);
$this->eventSourcedRepository->save($identity);
}
- public function handlePromiseSafeStoreSecretTokenPossessionCommand(PromiseSafeStoreSecretTokenPossessionCommand $command)
- {
+ public function handlePromiseSafeStoreSecretTokenPossessionCommand(
+ PromiseSafeStoreSecretTokenPossessionCommand $command,
+ ): void {
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
@@ -364,13 +298,13 @@ public function handlePromiseSafeStoreSecretTokenPossessionCommand(PromiseSafeSt
$secret = $this->recoveryTokenSecretHelper->hash(new UnhashedSecret($command->secret));
$identity->promisePossessionOfSafeStoreSecretRecoveryToken(
new RecoveryTokenId($command->recoveryTokenId),
- new SafeStore($secret)
+ new SafeStore($secret),
);
$this->eventSourcedRepository->save($identity);
}
- public function handleVetSecondFactorCommand(VetSecondFactorCommand $command)
+ public function handleVetSecondFactorCommand(VetSecondFactorCommand $command): void
{
/** @var IdentityApi $authority */
$authority = $this->eventSourcedRepository->load(new IdentityId($command->authorityId));
@@ -380,7 +314,7 @@ public function handleVetSecondFactorCommand(VetSecondFactorCommand $command)
$secondFactorType = new SecondFactorType($command->secondFactorType);
$secondFactorIdentifier = SecondFactorIdentifierFactory::forType(
$secondFactorType,
- $command->secondFactorIdentifier
+ $command->secondFactorIdentifier,
);
$authority->vetSecondFactor(
@@ -393,38 +327,38 @@ public function handleVetSecondFactorCommand(VetSecondFactorCommand $command)
$command->identityVerified,
$this->secondFactorTypeService,
$this->provePossessionHelper,
- $command->provePossessionSkipped
+ $command->provePossessionSkipped,
);
$this->eventSourcedRepository->save($authority);
$this->eventSourcedRepository->save($registrant);
}
- public function handleRegisterSelfAssertedSecondFactorCommand(RegisterSelfAssertedSecondFactorCommand $command)
+ public function handleRegisterSelfAssertedSecondFactorCommand(RegisterSelfAssertedSecondFactorCommand $command,): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
$secondFactorIdentifier = SecondFactorIdentifierFactory::forType(
new SecondFactorType($command->secondFactorType),
- $command->secondFactorIdentifier
+ $command->secondFactorIdentifier,
);
$identity->registerSelfAssertedSecondFactor(
$secondFactorIdentifier,
$this->secondFactorTypeService,
- new RecoveryTokenId($command->authoringRecoveryTokenId)
+ new RecoveryTokenId($command->authoringRecoveryTokenId),
);
$this->eventSourcedRepository->save($identity);
}
- public function handleSelfVetSecondFactorCommand(SelfVetSecondFactorCommand $command)
+ public function handleSelfVetSecondFactorCommand(SelfVetSecondFactorCommand $command): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
$secondFactorIdentifier = SecondFactorIdentifierFactory::forType(
new SecondFactorType($command->secondFactorType),
- $command->secondFactorId
+ $command->secondFactorId,
);
$loaIdentifier = null;
@@ -436,7 +370,7 @@ public function handleSelfVetSecondFactorCommand(SelfVetSecondFactorCommand $com
// @todo remove this BC construct once we drop BC support for SelfService 3.5
if ($command->authoringSecondFactorIdentifier) {
$loaIdentifier = $command->authoringSecondFactorIdentifier;
- } elseif ($command->authoringSecondFactorLoa) {
+ } elseif ($command->authoringSecondFactorLoa !== '' && $command->authoringSecondFactorLoa !== '0') {
$loaIdentifier = $command->authoringSecondFactorLoa;
}
if (!$loaIdentifier) {
@@ -448,8 +382,8 @@ public function handleSelfVetSecondFactorCommand(SelfVetSecondFactorCommand $com
throw new UnknownLoaException(
sprintf(
'Authorizing second factor with LoA %s can not be resolved',
- $command->authoringSecondFactorLoa
- )
+ $command->authoringSecondFactorLoa,
+ ),
);
}
@@ -457,16 +391,16 @@ public function handleSelfVetSecondFactorCommand(SelfVetSecondFactorCommand $com
$loa,
$command->registrationCode,
$secondFactorIdentifier,
- $this->secondFactorTypeService
+ $this->secondFactorTypeService,
);
$this->eventSourcedRepository->save($identity);
}
- public function handleMigrateVettedSecondFactorCommand(MigrateVettedSecondFactorCommand $command)
+ public function handleMigrateVettedSecondFactorCommand(MigrateVettedSecondFactorCommand $command): void
{
/** @var IdentityApi $sourceIdentity */
- /** @var IdentityApi $targetIdentity */
$sourceIdentity = $this->eventSourcedRepository->load(new IdentityId($command->sourceIdentityId));
+ /** @var IdentityApi $targetIdentity */
$targetIdentity = $this->eventSourcedRepository->load(new IdentityId($command->targetIdentityId));
// Check if second factor type is allowed by destination institution
@@ -475,7 +409,7 @@ public function handleMigrateVettedSecondFactorCommand(MigrateVettedSecondFactor
// Determine the maximum number of allowed tokens for the institution
$configurationInstitution = new ConfigurationInstitution(
- (string) $targetIdentity->getInstitution()
+ (string)$targetIdentity->getInstitution(),
);
$tokenCount = $this->institutionConfigurationOptionsService->getMaxNumberOfTokensFor($configurationInstitution);
@@ -484,12 +418,12 @@ public function handleMigrateVettedSecondFactorCommand(MigrateVettedSecondFactor
$sourceIdentity,
new SecondFactorId($command->sourceSecondFactorId),
$command->targetSecondFactorId,
- $tokenCount
+ $tokenCount,
);
$this->eventSourcedRepository->save($targetIdentity);
}
- public function handleRevokeOwnSecondFactorCommand(RevokeOwnSecondFactorCommand $command)
+ public function handleRevokeOwnSecondFactorCommand(RevokeOwnSecondFactorCommand $command): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
@@ -498,19 +432,19 @@ public function handleRevokeOwnSecondFactorCommand(RevokeOwnSecondFactorCommand
$this->eventSourcedRepository->save($identity);
}
- public function handleRevokeRegistrantsSecondFactorCommand(RevokeRegistrantsSecondFactorCommand $command)
+ public function handleRevokeRegistrantsSecondFactorCommand(RevokeRegistrantsSecondFactorCommand $command): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
$identity->complyWithSecondFactorRevocation(
new SecondFactorId($command->secondFactorId),
- new IdentityId($command->authorityId)
+ new IdentityId($command->authorityId),
);
$this->eventSourcedRepository->save($identity);
}
- public function handleRevokeOwnRecoveryTokenCommand(RevokeOwnRecoveryTokenCommand $command)
+ public function handleRevokeOwnRecoveryTokenCommand(RevokeOwnRecoveryTokenCommand $command): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
@@ -519,24 +453,24 @@ public function handleRevokeOwnRecoveryTokenCommand(RevokeOwnRecoveryTokenComman
$this->eventSourcedRepository->save($identity);
}
- public function handleRevokeRegistrantsRecoveryTokenCommand(RevokeRegistrantsRecoveryTokenCommand $command)
+ public function handleRevokeRegistrantsRecoveryTokenCommand(RevokeRegistrantsRecoveryTokenCommand $command): void
{
/** @var IdentityApi $identity */
$identity = $this->eventSourcedRepository->load(new IdentityId($command->identityId));
$identity->complyWithRecoveryTokenRevocation(
new RecoveryTokenId($command->recoveryTokenId),
- new IdentityId($command->authorityId)
+ new IdentityId($command->authorityId),
);
$this->eventSourcedRepository->save($identity);
}
- public function handleSendSecondFactorRegistrationEmailCommand(SendSecondFactorRegistrationEmailCommand $command)
+ public function handleSendSecondFactorRegistrationEmailCommand(SendSecondFactorRegistrationEmailCommand $command,): void
{
$this->registrationMailService->send($command->identityId, $command->secondFactorId);
}
- public function handleExpressLocalePreferenceCommand(ExpressLocalePreferenceCommand $command)
+ public function handleExpressLocalePreferenceCommand(ExpressLocalePreferenceCommand $command): void
{
$preferredLocale = new Locale($command->preferredLocale);
$this->assertIsValidLocale($preferredLocale);
@@ -548,37 +482,36 @@ public function handleExpressLocalePreferenceCommand(ExpressLocalePreferenceComm
$this->eventSourcedRepository->save($identity);
}
- /**
- * @param Locale $locale
- */
- private function assertIsValidLocale(Locale $locale)
+ private function assertIsValidLocale(Locale $locale): void
{
if (!$this->configurableSettings->isSupportedLocale($locale)) {
throw new UnsupportedLocaleException(
- sprintf('Given locale "%s" is not a supported locale', (string) $locale)
+ sprintf('Given locale "%s" is not a supported locale', (string)$locale),
);
}
}
- private function assertSecondFactorIsAllowedFor(SecondFactorType $secondFactor, Institution $institution)
+ private function assertSecondFactorIsAllowedFor(SecondFactorType $secondFactor, Institution $institution): void
{
$allowedSecondFactorList = $this->allowedSecondFactorListService->getAllowedSecondFactorListFor(
- new ConfigurationInstitution($institution->getInstitution())
+ new ConfigurationInstitution($institution->getInstitution()),
);
if (!$allowedSecondFactorList->allows($secondFactor)) {
- throw new SecondFactorNotAllowedException(sprintf(
- 'Institution "%s" does not support second factor "%s"',
- $institution->getInstitution(),
- $secondFactor->getSecondFactorType()
- ));
+ throw new SecondFactorNotAllowedException(
+ sprintf(
+ 'Institution "%s" does not support second factor "%s"',
+ $institution->getInstitution(),
+ $secondFactor->getSecondFactorType(),
+ ),
+ );
}
}
- public function assertSelfAssertedTokensEnabled(Institution $institution)
+ public function assertSelfAssertedTokensEnabled(Institution $institution): void
{
$configurationInstitution = new ConfigurationInstitution(
- (string) $institution
+ (string)$institution,
);
$institutionConfiguration = $this->institutionConfigurationOptionsService
@@ -587,26 +520,25 @@ public function assertSelfAssertedTokensEnabled(Institution $institution)
throw new RuntimeException(
sprintf(
'Registration of self-asserted tokens is not allowed for this institution "%s".',
- (string) $institution
- )
+ (string)$institution,
+ ),
);
}
}
/**
- * @param IdentityApi $identity
* @return bool
*/
- private function emailVerificationIsRequired(IdentityApi $identity)
+ private function emailVerificationIsRequired(IdentityApi $identity): bool
{
$institution = new ConfigurationInstitution(
- (string) $identity->getInstitution()
+ (string)$identity->getInstitution(),
);
$configuration = $this->institutionConfigurationOptionsService
->findInstitutionConfigurationOptionsFor($institution);
- if ($configuration === null) {
+ if (!$configuration instanceof \Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionConfigurationOptions) {
return true;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/RegistrationAuthorityCommandHandler.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/RegistrationAuthorityCommandHandler.php
index 4dcf0edad..9b8f57818 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/RegistrationAuthorityCommandHandler.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/RegistrationAuthorityCommandHandler.php
@@ -23,8 +23,9 @@
use Broadway\Repository\Repository as RepositoryInterface;
use Surfnet\Stepup\Configuration\EventSourcing\InstitutionConfigurationRepository;
use Surfnet\Stepup\Configuration\InstitutionConfiguration;
-use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
use Surfnet\Stepup\Configuration\Value\Institution as ConfigurationInstitution;
+use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
+use Surfnet\Stepup\Identity\Api\Identity;
use Surfnet\Stepup\Identity\Value\ContactInformation;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\Stepup\Identity\Value\Institution;
@@ -43,33 +44,19 @@
*/
class RegistrationAuthorityCommandHandler extends SimpleCommandHandler
{
- /**
- * @var \Surfnet\Stepup\Identity\EventSourcing\IdentityRepository
- */
- private $repository;
- /**
- * @var InstitutionConfigurationRepository
- */
- private $institutionConfigurationRepository;
-
- /**
- * @var VettingTypeHintService;
- */
- private $vettingTypeHintService;
-
public function __construct(
- RepositoryInterface $repository,
- InstitutionConfigurationRepository $institutionConfigurationRepository,
- VettingTypeHintService $hintService
+ private readonly RepositoryInterface $repository,
+ private readonly InstitutionConfigurationRepository $institutionConfigurationRepository,
+ /**
+ * @var VettingTypeHintService;
+ */
+ private readonly VettingTypeHintService $vettingTypeHintService,
) {
- $this->repository = $repository;
- $this->institutionConfigurationRepository = $institutionConfigurationRepository;
- $this->vettingTypeHintService = $hintService;
}
- public function handleAccreditIdentityCommand(AccreditIdentityCommand $command)
+ public function handleAccreditIdentityCommand(AccreditIdentityCommand $command): void
{
- /** @var \Surfnet\Stepup\Identity\Api\Identity $identity */
+ /** @var Identity $identity */
$identity = $this->repository->load(new IdentityId($command->identityId));
$institutionConfiguration = $this->loadInstitutionConfigurationFor(new Institution($command->raInstitution));
@@ -81,29 +68,30 @@ public function handleAccreditIdentityCommand(AccreditIdentityCommand $command)
new Institution($command->raInstitution),
new Location($command->location),
new ContactInformation($command->contactInformation),
- $institutionConfiguration
+ $institutionConfiguration,
);
$this->repository->save($identity);
}
- public function handleAmendRegistrationAuthorityInformationCommand(AmendRegistrationAuthorityInformationCommand $command)
- {
- /** @var \Surfnet\Stepup\Identity\Api\Identity $identity */
+ public function handleAmendRegistrationAuthorityInformationCommand(
+ AmendRegistrationAuthorityInformationCommand $command,
+ ): void {
+ /** @var Identity $identity */
$identity = $this->repository->load(new IdentityId($command->identityId));
$identity->amendRegistrationAuthorityInformation(
new Institution($command->raInstitution),
new Location($command->location),
- new ContactInformation($command->contactInformation)
+ new ContactInformation($command->contactInformation),
);
$this->repository->save($identity);
}
- public function handleAppointRoleCommand(AppointRoleCommand $command)
+ public function handleAppointRoleCommand(AppointRoleCommand $command): void
{
- /** @var \Surfnet\Stepup\Identity\Api\Identity $identity */
+ /** @var Identity $identity */
$identity = $this->repository->load(new IdentityId($command->identityId));
$institutionConfiguration = $this->loadInstitutionConfigurationFor(new Institution($command->raInstitution));
@@ -115,9 +103,9 @@ public function handleAppointRoleCommand(AppointRoleCommand $command)
$this->repository->save($identity);
}
- public function handleRetractRegistrationAuthorityCommand(RetractRegistrationAuthorityCommand $command)
+ public function handleRetractRegistrationAuthorityCommand(RetractRegistrationAuthorityCommand $command): void
{
- /** @var \Surfnet\Stepup\Identity\Api\Identity $identity */
+ /** @var Identity $identity */
$identity = $this->repository->load(new IdentityId($command->identityId));
$identity->retractRegistrationAuthority(new Institution($command->raInstitution));
@@ -125,23 +113,22 @@ public function handleRetractRegistrationAuthorityCommand(RetractRegistrationAut
$this->repository->save($identity);
}
- public function handleSaveVettingTypeHintCommand(SaveVettingTypeHintCommand $command)
+ public function handleSaveVettingTypeHintCommand(SaveVettingTypeHintCommand $command): void
{
+ /** @var Identity $identity */
$identity = $this->repository->load(new IdentityId($command->identityId));
$collection = $this->vettingTypeHintService->collectionFrom($command->hints);
$identity->saveVettingTypeHints(
new Institution($command->institution),
- $collection
+ $collection,
);
$this->repository->save($identity);
}
/**
- * @param string $role
- * @param string $commandId
* @return RegistrationAuthorityRole
*/
- private function assertValidRoleAndConvertIfValid($role, $commandId)
+ private function assertValidRoleAndConvertIfValid(string $role, string $commandId): RegistrationAuthorityRole
{
if ($role === 'ra') {
return new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA);
@@ -149,34 +136,33 @@ private function assertValidRoleAndConvertIfValid($role, $commandId)
return new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA);
}
- throw new RuntimeException(sprintf(
- 'Unknown role "%s" given by AccreditIdentityCommand "%s", must be "ra" or "raa"',
- $role,
- $commandId
- ));
+ throw new RuntimeException(
+ sprintf(
+ 'Unknown role "%s" given by AccreditIdentityCommand "%s", must be "ra" or "raa"',
+ $role,
+ $commandId,
+ ),
+ );
}
/**
* @deprecated Should be used until existing institution configurations have been migrated to using normalized ids
- *
- * @param Institution $institution
- * @return InstitutionConfiguration
*/
- private function loadInstitutionConfigurationFor(Institution $institution)
+ private function loadInstitutionConfigurationFor(Institution $institution): InstitutionConfiguration
{
$institution = new ConfigurationInstitution($institution->getInstitution());
try {
$institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
$institutionConfiguration = $this->institutionConfigurationRepository->load(
- $institutionConfigurationId->getInstitutionConfigurationId()
+ $institutionConfigurationId->getInstitutionConfigurationId(),
);
- } catch (AggregateNotFoundException $exception) {
+ } catch (AggregateNotFoundException) {
$institutionConfigurationId = InstitutionConfigurationId::from($institution);
$institutionConfiguration = $this->institutionConfigurationRepository->load(
- $institutionConfigurationId->getInstitutionConfigurationId()
+ $institutionConfigurationId->getInstitutionConfigurationId(),
);
}
-
+ assert($institutionConfiguration instanceof InstitutionConfiguration);
return $institutionConfiguration;
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/ReminderEmailCommandHandler.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/ReminderEmailCommandHandler.php
index 9c9168d5d..df010dcff 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/ReminderEmailCommandHandler.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/ReminderEmailCommandHandler.php
@@ -24,24 +24,16 @@
class ReminderEmailCommandHandler extends SimpleCommandHandler
{
- /**
- * @var VerifiedSecondFactorReminderService
- */
- private $verifiedSecondFactorReminderService;
-
- /**
- * @param VerifiedSecondFactorReminderService $verifiedSecondFactorReminderService
- */
- public function __construct(VerifiedSecondFactorReminderService $verifiedSecondFactorReminderService)
- {
- $this->verifiedSecondFactorReminderService = $verifiedSecondFactorReminderService;
+ public function __construct(
+ private readonly VerifiedSecondFactorReminderService $verifiedSecondFactorReminderService,
+ ) {
}
- public function handleSendVerifiedSecondFactorRemindersCommand(SendVerifiedSecondFactorRemindersCommand $command)
+ public function handleSendVerifiedSecondFactorRemindersCommand(SendVerifiedSecondFactorRemindersCommand $command,): void
{
$this->verifiedSecondFactorReminderService->sendReminders(
$command->requestedAt,
- $command->dryRun
+ $command->dryRun,
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/RightToBeForgottenCommandHandler.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/RightToBeForgottenCommandHandler.php
index de0180cf2..19aae954d 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/RightToBeForgottenCommandHandler.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/RightToBeForgottenCommandHandler.php
@@ -32,45 +32,15 @@
final class RightToBeForgottenCommandHandler extends SimpleCommandHandler
{
- /**
- * @var \Surfnet\Stepup\Identity\EventSourcing\IdentityRepository
- */
- private $repository;
-
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository
- */
- private $apiIdentityRepository;
-
- /**
- * @var \Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Service\SensitiveDataService
- */
- private $sensitiveDataService;
-
- /**
- * @var \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SraaRepository
- */
- private $sraaRepository;
-
- /**
- * @param IdentityRepository $repository
- * @param ApiIdentityRepository $apiIdentityRepository
- * @param SensitiveDataService $sensitiveDataService
- * @param SraaRepository $sraaRepository
- */
public function __construct(
- IdentityRepository $repository,
- ApiIdentityRepository $apiIdentityRepository,
- SensitiveDataService $sensitiveDataService,
- SraaRepository $sraaRepository
+ private readonly IdentityRepository $repository,
+ private readonly ApiIdentityRepository $apiIdentityRepository,
+ private readonly SensitiveDataService $sensitiveDataService,
+ private readonly SraaRepository $sraaRepository,
) {
- $this->repository = $repository;
- $this->apiIdentityRepository = $apiIdentityRepository;
- $this->sensitiveDataService = $sensitiveDataService;
- $this->sraaRepository = $sraaRepository;
}
- public function handleForgetIdentityCommand(ForgetIdentityCommand $command)
+ public function handleForgetIdentityCommand(ForgetIdentityCommand $command): void
{
$nameId = new NameId($command->nameId);
@@ -80,7 +50,7 @@ public function handleForgetIdentityCommand(ForgetIdentityCommand $command)
$apiIdentity = $this->apiIdentityRepository->findOneByNameIdAndInstitution(
$nameId,
- new Institution($command->institution)
+ new Institution($command->institution),
);
$identityId = new IdentityId($apiIdentity->id);
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/WhitelistCommandHandler.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/WhitelistCommandHandler.php
index e908adc49..9ebe2d578 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/WhitelistCommandHandler.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/CommandHandler/WhitelistCommandHandler.php
@@ -30,23 +30,12 @@
class WhitelistCommandHandler extends SimpleCommandHandler
{
- /**
- * @var \Surfnet\Stepup\Identity\EventSourcing\WhitelistRepository
- */
- private $repository;
-
- /**
- * @param RepositoryInterface $repository
- */
- public function __construct(RepositoryInterface $repository)
- {
- $this->repository = $repository;
+ public function __construct(
+ private readonly RepositoryInterface $repository,
+ ) {
}
- /**
- * @param ReplaceWhitelistCommand $command
- */
- public function handleReplaceWhitelistCommand(ReplaceWhitelistCommand $command)
+ public function handleReplaceWhitelistCommand(ReplaceWhitelistCommand $command): void
{
$whitelist = $this->getWhitelist();
@@ -56,10 +45,7 @@ public function handleReplaceWhitelistCommand(ReplaceWhitelistCommand $command)
$this->repository->save($whitelist);
}
- /**
- * @param AddToWhitelistCommand $command
- */
- public function handleAddToWhitelistCommand(AddToWhitelistCommand $command)
+ public function handleAddToWhitelistCommand(AddToWhitelistCommand $command): void
{
$whitelist = $this->getWhitelist();
@@ -69,10 +55,7 @@ public function handleAddToWhitelistCommand(AddToWhitelistCommand $command)
$this->repository->save($whitelist);
}
- /**
- * @param RemoveFromWhitelistCommand $command
- */
- public function handleRemoveFromWhitelistCommand(RemoveFromWhitelistCommand $command)
+ public function handleRemoveFromWhitelistCommand(RemoveFromWhitelistCommand $command): void
{
$whitelist = $this->getWhitelist();
@@ -82,26 +65,22 @@ public function handleRemoveFromWhitelistCommand(RemoveFromWhitelistCommand $com
$this->repository->save($whitelist);
}
- /**
- * @return Whitelist
- */
- private function getWhitelist()
+ private function getWhitelist(): Whitelist
{
try {
- return $this->repository->load(Whitelist::WHITELIST_AGGREGATE_ID);
- } catch (AggregateNotFoundException $e) {
+ $whitelist = $this->repository->load(Whitelist::WHITELIST_AGGREGATE_ID);
+ assert($whitelist instanceof Whitelist);
+ return $whitelist;
+ } catch (AggregateNotFoundException) {
return Whitelist::create(new InstitutionCollection());
}
}
/**
- * @param array $institutions
* @return Institution[]
*/
- private function mapArrayToInstitutions(array $institutions)
+ private function mapArrayToInstitutions(array $institutions): array
{
- return array_map(function ($institutionName) {
- return new Institution($institutionName);
- }, $institutions);
+ return array_map(fn($institutionName): Institution => new Institution($institutionName), $institutions);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/EmailVerificationMailService.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/EmailVerificationMailService.php
index 1a0417a44..8db83e1a3 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/EmailVerificationMailService.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/EmailVerificationMailService.php
@@ -19,75 +19,36 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service;
use Assert\Assertion;
+use Assert\AssertionFailedException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Service\EmailTemplateService;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Value\Sender;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\MailerInterface as Mailer;
use Symfony\Component\Mime\Address;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
final class EmailVerificationMailService
{
- /**
- * @var TranslatorInterface
- */
- private $translator;
-
- /**
- * @var EmailTemplateService
- */
- private $emailTemplateService;
-
- /**
- * @var string
- */
- private $emailVerificationUrlTemplate;
-
- /**
- * @var string
- */
- private $fallbackLocale;
+ private readonly string $emailVerificationUrlTemplate;
/**
- * @var Mailer
- */
- private $mailer;
-
- /**
- * @var Sender
- */
- private $sender;
-
- /**
- * @var string
- */
- private $selfServiceUrl;
-
- /**
- * @throws \Assert\AssertionFailedException
+ * @throws AssertionFailedException
*/
public function __construct(
- Mailer $mailer,
- Sender $sender,
- TranslatorInterface $translator,
+ private readonly Mailer $mailer,
+ private readonly Sender $sender,
+ private readonly TranslatorInterface $translator,
string $emailVerificationUrlTemplate,
- EmailTemplateService $emailTemplateService,
- string $fallbackLocale,
- string $selfServiceUrl
+ private readonly EmailTemplateService $emailTemplateService,
+ private readonly string $fallbackLocale,
+ private readonly string $selfServiceUrl,
) {
Assertion::string(
$emailVerificationUrlTemplate,
- 'Email verification URL template "%s" expected to be string, type %s given'
+ 'Email verification URL template "%s" expected to be string, type %s given',
);
-
- $this->mailer = $mailer;
- $this->sender = $sender;
- $this->translator = $translator;
$this->emailVerificationUrlTemplate = $emailVerificationUrlTemplate;
- $this->emailTemplateService = $emailTemplateService;
- $this->fallbackLocale = $fallbackLocale;
- $this->selfServiceUrl = $selfServiceUrl;
}
/**
@@ -97,19 +58,19 @@ public function sendEmailVerificationEmail(
string $locale,
string $commonName,
string $email,
- string $verificationNonce
+ string $verificationNonce,
): void {
$subject = $this->translator->trans(
'ss.mail.email_verification_email.subject',
['%commonName%' => $commonName],
'messages',
- $locale
+ $locale,
);
$verificationUrl = str_replace(
'{nonce}',
urlencode($verificationNonce),
- $this->emailVerificationUrlTemplate
+ $this->emailVerificationUrlTemplate,
);
// In TemplatedEmail email is a reserved keyword, we also use it as a parameter that can be used in the mail
@@ -119,7 +80,7 @@ public function sendEmailVerificationEmail(
$emailTemplate->htmlContent = str_replace(
'{email}',
'{emailAddress}',
- $emailTemplate->htmlContent
+ $emailTemplate->htmlContent,
);
$parameters = [
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RecoveryTokenMailService.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RecoveryTokenMailService.php
index 73b104f00..cb5a8e77a 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RecoveryTokenMailService.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RecoveryTokenMailService.php
@@ -30,7 +30,7 @@
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mime\Address;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
use function str_replace;
/**
@@ -38,59 +38,19 @@
*/
class RecoveryTokenMailService
{
- /**
- * @var Mailer
- */
- private $mailer;
-
- /**
- * @var Sender
- */
- private $sender;
-
- /**
- * @var TranslatorInterface
- */
- private $translator;
-
- /**
- * @var EmailTemplateService
- */
- private $emailTemplateService;
-
- /**
- * @var string
- */
- private $fallbackLocale;
-
- /**
- * @var string
- */
- private $selfServiceUrl;
-
- /**
- * @var LoggerInterface
- */
- private $logger;
+ private readonly string $fallbackLocale;
public function __construct(
- Mailer $mailer,
- Sender $sender,
- TranslatorInterface $translator,
- EmailTemplateService $emailTemplateService,
+ private readonly Mailer $mailer,
+ private readonly Sender $sender,
+ private readonly TranslatorInterface $translator,
+ private readonly EmailTemplateService $emailTemplateService,
string $fallbackLocale,
- string $selfServiceUrl,
- LoggerInterface $logger
+ private readonly string $selfServiceUrl,
+ private readonly LoggerInterface $logger,
) {
Assertion::string($fallbackLocale, 'Fallback locale "%s" expected to be string, type %s given');
-
- $this->mailer = $mailer;
- $this->sender = $sender;
- $this->translator = $translator;
- $this->emailTemplateService = $emailTemplateService;
$this->fallbackLocale = $fallbackLocale;
- $this->selfServiceUrl = $selfServiceUrl;
- $this->logger = $logger;
}
public function sendRevoked(
@@ -99,10 +59,10 @@ public function sendRevoked(
Email $email,
RecoveryTokenType $recoveryTokenType,
RecoveryTokenId $tokenId,
- bool $revokedByRa
- ) {
+ bool $revokedByRa,
+ ): void {
$this->logger->notice(
- sprintf('Sending a recovery token revoked mail message for token type %s', $recoveryTokenType)
+ sprintf('Sending a recovery token revoked mail message for token type %s', $recoveryTokenType),
);
$subjectParameters = [
@@ -115,13 +75,13 @@ public function sendRevoked(
'ss.mail.recovery_token_revoked_email.subject',
$subjectParameters,
'messages',
- $locale->getLocale()
+ $locale->getLocale(),
);
$emailTemplate = $this->emailTemplateService->findByName(
'recovery_token_revoked',
$locale->getLocale(),
- $this->fallbackLocale
+ $this->fallbackLocale,
);
// In TemplatedEmail email is a reserved keyword, we also use it as a parameter that can be used in the mail
@@ -130,7 +90,7 @@ public function sendRevoked(
$emailTemplate->htmlContent = str_replace(
'{email}',
'{emailAddress}',
- $emailTemplate->htmlContent
+ $emailTemplate->htmlContent,
);
$parameters = [
@@ -155,7 +115,7 @@ public function sendRevoked(
$this->mailer->send($message);
}
- public function sendCreated(Locale $locale, CommonName $commonName, Email $email)
+ public function sendCreated(Locale $locale, CommonName $commonName, Email $email): void
{
$this->logger->notice('Sending a recovery token created mail message');
@@ -168,13 +128,13 @@ public function sendCreated(Locale $locale, CommonName $commonName, Email $email
'ss.mail.recovery_token_created_email.subject',
$subjectParameters,
'messages',
- $locale->getLocale()
+ $locale->getLocale(),
);
$emailTemplate = $this->emailTemplateService->findByName(
'recovery_token_created',
$locale->getLocale(),
- $this->fallbackLocale
+ $this->fallbackLocale,
);
// In TemplatedEmail email is a reserved keyword, we also use it as a parameter that can be used in the mail
@@ -183,7 +143,7 @@ public function sendCreated(Locale $locale, CommonName $commonName, Email $email
$emailTemplate->htmlContent = str_replace(
'{email}',
'{emailAddress}',
- $emailTemplate->htmlContent
+ $emailTemplate->htmlContent,
);
$parameters = [
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RegistrationMailService.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RegistrationMailService.php
index d6c0aa333..c9920b130 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RegistrationMailService.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RegistrationMailService.php
@@ -35,102 +35,37 @@
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\MailerInterface as Mailer;
use Symfony\Component\Mime\Address;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class RegistrationMailService
{
- /**
- * @var Mailer
- */
- private $mailer;
-
- /**
- * @var Sender
- */
- private $sender;
-
- /**
- * @var TranslatorInterface
- */
- private $translator;
-
- /**
- * @var EmailTemplateService
- */
- private $emailTemplateService;
-
- /**
- * @var string
- */
- private $fallbackLocale;
-
- /**
- * @var string
- */
- private $selfServiceUrl;
-
- /**
- * @var IdentityService
- */
- private $identityService;
-
- /**
- * @var SecondFactorService
- */
- private $secondFactorService;
-
- /**
- * @var RaLocationService
- */
- private $raLocationsService;
-
- /**
- * @var RaListingService
- */
- private $raListingService;
-
- /**
- * @var LoggerInterface
- */
- private $logger;
+ private readonly string $fallbackLocale;
/**
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
- Mailer $mailer,
- Sender $sender,
- TranslatorInterface $translator,
- EmailTemplateService $emailTemplateService,
+ private readonly Mailer $mailer,
+ private readonly Sender $sender,
+ private readonly TranslatorInterface $translator,
+ private readonly EmailTemplateService $emailTemplateService,
string $fallbackLocale,
- string $selfServiceUrl,
- InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
- IdentityService $identityService,
- SecondFactorService $secondFactorService,
- RaLocationService $raLocationService,
- RaListingService $raListingService,
- LoggerInterface $logger
+ private readonly string $selfServiceUrl,
+ public InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
+ private readonly IdentityService $identityService,
+ private readonly SecondFactorService $secondFactorService,
+ private readonly RaLocationService $raLocationsService,
+ private readonly RaListingService $raListingService,
+ private readonly LoggerInterface $logger,
) {
Assertion::string($fallbackLocale, 'Fallback locale "%s" expected to be string, type %s given');
-
- $this->mailer = $mailer;
- $this->sender = $sender;
- $this->translator = $translator;
- $this->emailTemplateService = $emailTemplateService;
$this->fallbackLocale = $fallbackLocale;
- $this->selfServiceUrl = $selfServiceUrl;
- $this->institutionConfigurationOptionsService = $institutionConfigurationOptionsService;
- $this->identityService = $identityService;
- $this->secondFactorService = $secondFactorService;
- $this->raLocationsService = $raLocationService;
- $this->raListingService = $raListingService;
- $this->logger = $logger;
}
- public function send(string $identityId, string $secondFactorId)
+ public function send(string $identityId, string $secondFactorId): void
{
$this->logger->notice(sprintf('Start processing of a registration email for %s', $identityId));
$identity = $this->identityService->find($identityId);
@@ -148,9 +83,9 @@ public function send(string $identityId, string $secondFactorId)
$identity->email->getEmail(),
$verifiedSecondFactor->registrationCode,
$this->getExpirationDateOfRegistration(
- DateTime::fromString($verifiedSecondFactor->registrationRequestedAt->format(DateTime::FORMAT))
+ DateTime::fromString($verifiedSecondFactor->registrationRequestedAt->format(DateTime::FORMAT)),
),
- $this->raLocationsService->listRaLocationsFor($institution)
+ $this->raLocationsService->listRaLocationsFor($institution),
);
return;
@@ -165,18 +100,16 @@ public function send(string $identityId, string $secondFactorId)
$identity->email->getEmail(),
$verifiedSecondFactor->registrationCode,
$this->getExpirationDateOfRegistration(
- DateTime::fromString($verifiedSecondFactor->registrationRequestedAt->format(DateTime::FORMAT))
+ DateTime::fromString($verifiedSecondFactor->registrationRequestedAt->format(DateTime::FORMAT)),
),
- $ras
+ $ras,
);
return;
}
- $rasWithoutRaas = array_filter($ras, function (RegistrationAuthorityCredentials $ra) {
- return !$ra->isRaa();
- });
+ $rasWithoutRaas = array_filter($ras, fn(RegistrationAuthorityCredentials $ra): bool => !$ra->isRaa());
$this->logger->notice(
- 'Sending a registration mail with ra contact information as there are no RAAs at this location'
+ 'Sending a registration mail with ra contact information as there are no RAAs at this location',
);
$this->sendRegistrationEmailWithRas(
$identity->preferredLocale->getLocale(),
@@ -184,9 +117,9 @@ public function send(string $identityId, string $secondFactorId)
$identity->email->getEmail(),
$verifiedSecondFactor->registrationCode,
$this->getExpirationDateOfRegistration(
- DateTime::fromString($verifiedSecondFactor->registrationRequestedAt->format(DateTime::FORMAT))
+ DateTime::fromString($verifiedSecondFactor->registrationRequestedAt->format(DateTime::FORMAT)),
),
- $rasWithoutRaas
+ $rasWithoutRaas,
);
}
@@ -196,19 +129,19 @@ private function sendRegistrationEmailWithRas(
string $email,
string $registrationCode,
DateTime $expirationDate,
- array $ras
- ) {
+ array $ras,
+ ): void {
$subject = $this->translator->trans(
'ss.mail.registration_email.subject',
['%commonName%' => $commonName],
'messages',
- $locale
+ $locale,
);
$emailTemplate = $this->emailTemplateService->findByName(
'registration_code_with_ras',
$locale,
- $this->fallbackLocale
+ $this->fallbackLocale,
);
// In TemplatedEmail email is a reserved keyword, we also use it as a parameter that can be used in the mail
@@ -217,7 +150,7 @@ private function sendRegistrationEmailWithRas(
$emailTemplate->htmlContent = str_replace(
'{email}',
'{emailAddress}',
- $emailTemplate->htmlContent
+ $emailTemplate->htmlContent,
);
$parameters = [
'templateString' => $emailTemplate->htmlContent,
@@ -225,7 +158,7 @@ private function sendRegistrationEmailWithRas(
'commonName' => $commonName,
'emailAddress' => $email,
'registrationCode' => $registrationCode,
- 'expirationDate' => $expirationDate,
+ 'expirationDate' => (string)$expirationDate,
'ras' => $ras,
'selfServiceUrl' => $this->selfServiceUrl,
];
@@ -246,19 +179,19 @@ private function sendRegistrationEmailWithRaLocations(
string $email,
string $registrationCode,
DateTime $expirationDate,
- array $raLocations
- ) {
+ array $raLocations,
+ ): void {
$subject = $this->translator->trans(
'ss.mail.registration_email.subject',
['%commonName%' => $commonName],
'messages',
- $locale
+ $locale,
);
$emailTemplate = $this->emailTemplateService->findByName(
'registration_code_with_ra_locations',
$locale,
- $this->fallbackLocale
+ $this->fallbackLocale,
);
// In TemplatedEmail email is a reserved keyword, we also use it as a parameter that can be used in the mail
// message, to prevent having to update all templates, and prevent a 500 error from the mailer, we perform a
@@ -266,7 +199,7 @@ private function sendRegistrationEmailWithRaLocations(
$emailTemplate->htmlContent = str_replace(
'{email}',
'{emailAddress}',
- $emailTemplate->htmlContent
+ $emailTemplate->htmlContent,
);
$parameters = [
@@ -275,7 +208,7 @@ private function sendRegistrationEmailWithRaLocations(
'commonName' => $commonName,
'emailAddress' => $email,
'registrationCode' => $registrationCode,
- 'expirationDate' => $expirationDate,
+ 'expirationDate' => (string)$expirationDate,
'raLocations' => $raLocations,
'selfServiceUrl' => $this->selfServiceUrl,
];
@@ -290,10 +223,10 @@ private function sendRegistrationEmailWithRaLocations(
$this->mailer->send($message);
}
- private function getExpirationDateOfRegistration(DateTime $date)
+ private function getExpirationDateOfRegistration(DateTime $date): DateTime
{
return $date->add(
- new DateInterval('P14D')
- )->endOfDay();
+ new DateInterval('P14D'),
+ );
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorRevocationMailService.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorRevocationMailService.php
index 669505f1c..3d6e0f53e 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorRevocationMailService.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorRevocationMailService.php
@@ -19,6 +19,7 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service;
use Assert\Assertion;
+use Assert\AssertionFailedException;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
use Surfnet\Stepup\Identity\Value\Locale;
@@ -31,70 +32,33 @@
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\MailerInterface as Mailer;
use Symfony\Component\Mime\Address;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
final class SecondFactorRevocationMailService
{
- /**
- * @var Mailer
- */
- private $mailer;
-
- /**
- * @var Sender
- */
- private $sender;
-
- /**
- * @var TranslatorInterface
- */
- private $translator;
-
- /**
- * @var \Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Service\EmailTemplateService
- */
- private $emailTemplateService;
-
- /**
- * @var string
- */
- private $fallbackLocale;
-
- /**
- * @var string
- */
- private $selfServiceUrl;
+ private readonly string $fallbackLocale;
- /**
- * @var \Surfnet\StepupMiddleware\MiddlewareBundle\Service\SecondFactorDisplayNameResolverService
- */
- private $displayNameResolver;
+ private readonly string $selfServiceUrl;
/**
- * @throws \Assert\AssertionFailedException
+ * @throws AssertionFailedException
*/
public function __construct(
- Mailer $mailer,
- Sender $sender,
- TranslatorInterface $translator,
- EmailTemplateService $emailTemplateService,
+ private readonly Mailer $mailer,
+ private readonly Sender $sender,
+ private readonly TranslatorInterface $translator,
+ private readonly EmailTemplateService $emailTemplateService,
string $fallbackLocale,
string $selfServiceUrl,
- SecondFactorDisplayNameResolverService $displayNameResolver
+ private readonly SecondFactorDisplayNameResolverService $displayNameResolver,
) {
Assertion::string($fallbackLocale, 'Fallback locale "%s" expected to be string, type %s given');
Assertion::string($selfServiceUrl, 'Self Service URL "%s" expected to be string, type %s given');
-
- $this->mailer = $mailer;
- $this->sender = $sender;
- $this->translator = $translator;
- $this->emailTemplateService = $emailTemplateService;
$this->fallbackLocale = $fallbackLocale;
$this->selfServiceUrl = $selfServiceUrl;
- $this->displayNameResolver = $displayNameResolver;
}
/**
@@ -105,21 +69,21 @@ public function sendVettedSecondFactorRevokedByRaEmail(
CommonName $commonName,
Email $email,
SecondFactorType $secondFactorType,
- SecondFactorIdentifier $secondFactorIdentifier
- ) {
+ SecondFactorIdentifier $secondFactorIdentifier,
+ ): void {
$subject = $this->translator->trans(
'mw.mail.second_factor_revoked.subject',
[
- '%tokenType%' => $this->displayNameResolver->resolveByType($secondFactorType)
+ '%tokenType%' => $this->displayNameResolver->resolveByType($secondFactorType),
],
'messages',
- $locale->getLocale()
+ $locale->getLocale(),
);
$emailTemplate = $this->emailTemplateService->findByName(
'second_factor_revoked',
$locale->getLocale(),
- $this->fallbackLocale
+ $this->fallbackLocale,
);
$parameters = [
@@ -150,21 +114,21 @@ public function sendVettedSecondFactorRevokedByRegistrantEmail(
CommonName $commonName,
Email $email,
SecondFactorType $secondFactorType,
- SecondFactorIdentifier $secondFactorIdentifier
- ) {
+ SecondFactorIdentifier $secondFactorIdentifier,
+ ): void {
$subject = $this->translator->trans(
'mw.mail.second_factor_revoked.subject',
[
- '%tokenType%' => $this->displayNameResolver->resolveByType($secondFactorType)
+ '%tokenType%' => $this->displayNameResolver->resolveByType($secondFactorType),
],
'messages',
- $locale->getLocale()
+ $locale->getLocale(),
);
$emailTemplate = $this->emailTemplateService->findByName(
'second_factor_revoked',
$locale->getLocale(),
- $this->fallbackLocale
+ $this->fallbackLocale,
);
$parameters = [
'isRevokedByRa' => false,
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorVettedMailService.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorVettedMailService.php
index d163b032d..71838fe31 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorVettedMailService.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorVettedMailService.php
@@ -19,6 +19,7 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service;
use Assert\Assertion;
+use Assert\AssertionFailedException;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
use Surfnet\Stepup\Identity\Value\Locale;
@@ -27,71 +28,37 @@
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\MailerInterface as Mailer;
use Symfony\Component\Mime\Address;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
final class SecondFactorVettedMailService
{
- /**
- * @var Mailer
- */
- private $mailer;
-
- /**
- * @var Sender
- */
- private $sender;
+ private readonly string $fallbackLocale;
/**
- * @var TranslatorInterface
- */
- private $translator;
-
- /**
- * @var \Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Service\EmailTemplateService
- */
- private $emailTemplateService;
-
- /**
- * @var string
- */
- private $fallbackLocale;
-
- /**
- * @var string
- */
- private $selfServiceUrl;
-
- /**
- * @throws \Assert\AssertionFailedException
+ * @throws AssertionFailedException
*/
public function __construct(
- Mailer $mailer,
- Sender $sender,
- TranslatorInterface $translator,
- EmailTemplateService $emailTemplateService,
+ private readonly Mailer $mailer,
+ private readonly Sender $sender,
+ private readonly TranslatorInterface $translator,
+ private readonly EmailTemplateService $emailTemplateService,
string $fallbackLocale,
- string $selfServiceUrl
+ private readonly string $selfServiceUrl,
) {
Assertion::string($fallbackLocale, 'Fallback locale "%s" expected to be string, type %s given');
-
- $this->mailer = $mailer;
- $this->sender = $sender;
- $this->translator = $translator;
- $this->emailTemplateService = $emailTemplateService;
$this->fallbackLocale = $fallbackLocale;
- $this->selfServiceUrl = $selfServiceUrl;
}
public function sendVettedEmail(
Locale $locale,
CommonName $commonName,
- Email $email
- ) {
+ Email $email,
+ ): void {
$subject = $this->translator->trans(
'ss.mail.vetted_email.subject',
['%commonName%' => $commonName->getCommonName(), '%email%' => $email->getEmail()],
'messages',
- $locale->getLocale()
+ $locale->getLocale(),
);
$emailTemplate = $this->emailTemplateService->findByName('vetted', $locale->getLocale(), $this->fallbackLocale);
@@ -102,7 +69,7 @@ public function sendVettedEmail(
$emailTemplate->htmlContent = str_replace(
'{email}',
'{emailAddress}',
- $emailTemplate->htmlContent
+ $emailTemplate->htmlContent,
);
$parameters = [
'templateString' => $emailTemplate->htmlContent,
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/VettingTypeHintService.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/VettingTypeHintService.php
index db6e69c94..1d225515f 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/VettingTypeHintService.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/VettingTypeHintService.php
@@ -28,29 +28,11 @@
class VettingTypeHintService
{
- /**
- * @var VettingTypeHintRepository
- */
- private $repository;
-
- /**
- * @var array
- */
- private $locales;
-
- /**
- * @var LoggerInterface
- */
- private $logger;
-
public function __construct(
- VettingTypeHintRepository $repository,
- array $locales,
- LoggerInterface $logger
+ private readonly VettingTypeHintRepository $repository,
+ private readonly array $locales,
+ private readonly LoggerInterface $logger,
) {
- $this->repository = $repository;
- $this->locales = $locales;
- $this->logger = $logger;
}
public function collectionFrom(array $hints): VettingTypeHintCollection
@@ -60,11 +42,10 @@ public function collectionFrom(array $hints): VettingTypeHintCollection
if ($this->unknownLocale($locale)) {
$this->logger->warning(
sprintf(
- 'Received unsupported locale %s while processing the vetting type hints. ' .
- 'Allowed locales are: %s.',
+ 'Received unsupported locale %s while processing the vetting type hints. Allowed locales are: %s.',
$locale,
- implode(', ', $this->locales)
- )
+ implode(', ', $this->locales),
+ ),
);
continue;
}
@@ -80,7 +61,7 @@ private function unknownLocale(string $locale): bool
public function findBy(Institution $institution): VettingTypeHintEntity
{
- $result = $this->repository->find((string) $institution);
+ $result = $this->repository->find((string)$institution);
if (!$result) {
throw new NotFoundException(sprintf('Vetting type hint not found for institution %s', $institution));
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/AuthorizingStage.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/AuthorizingStage.php
index 0c9db7427..8cf9c1612 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/AuthorizingStage.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/AuthorizingStage.php
@@ -19,7 +19,7 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline;
use Psr\Log\LoggerInterface;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\DeprovisionExecutable;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\ManagementExecutable;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\RaExecutable;
@@ -29,27 +29,13 @@
class AuthorizingStage implements Stage
{
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- /**
- * @var AuthorizationCheckerInterface
- */
- private $authorizationChecker;
-
- /**
- * @param LoggerInterface $logger
- * @param AuthorizationCheckerInterface $authorizationChecker
- */
- public function __construct(LoggerInterface $logger, AuthorizationCheckerInterface $authorizationChecker)
- {
- $this->logger = $logger;
- $this->authorizationChecker = $authorizationChecker;
+ public function __construct(
+ private readonly LoggerInterface $logger,
+ private readonly AuthorizationCheckerInterface $authorizationChecker,
+ ) {
}
- public function process(Command $command)
+ public function process(AbstractCommand $command): AbstractCommand
{
$this->logger->debug(sprintf('Processing authorization for command "%s"', $command));
@@ -70,18 +56,20 @@ public function process(Command $command)
$allowedRoles[] = 'ROLE_DEPROVISION';
}
- if (empty($allowedRoles)) {
+ if ($allowedRoles === []) {
$this->logger->debug(sprintf('No authorization required for command "%s"', $command));
return $command;
}
if (!$this->clientHasAtLeastOneRole($allowedRoles)) {
- $this->logger->error(sprintf(
- 'Client is not authorized to execute command "%s", it does not have (one of) the required role(s) "%s"',
- $command,
- implode(', ', $allowedRoles)
- ));
+ $this->logger->error(
+ sprintf(
+ 'Client is not authorized to execute command "%s", it does not have (one of) the required role(s) "%s"',
+ $command,
+ implode(', ', $allowedRoles),
+ ),
+ );
throw new ForbiddenException(sprintf('Processing of Command "%s" is forbidden.', $command));
}
@@ -92,13 +80,12 @@ public function process(Command $command)
}
/**
- * @param array $rolesToCheck
* @return bool
*/
- private function clientHasAtLeastOneRole(array $rolesToCheck)
+ private function clientHasAtLeastOneRole(array $rolesToCheck): bool
{
foreach ($rolesToCheck as $role) {
- if ($this->authorizationChecker->isGranted([$role])) {
+ if ($this->authorizationChecker->isGranted($role)) {
return true;
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/DispatchStage.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/DispatchStage.php
index 5420e512e..862326fc5 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/DispatchStage.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/DispatchStage.php
@@ -20,31 +20,17 @@
use Broadway\CommandHandling\CommandBus;
use Psr\Log\LoggerInterface;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
class DispatchStage implements Stage
{
- /**
- * @var CommandBus
- */
- private $commandBus;
-
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- /**
- * @param LoggerInterface $logger
- * @param CommandBus $commandBus
- */
- public function __construct(LoggerInterface $logger, CommandBus $commandBus)
- {
- $this->logger = $logger;
- $this->commandBus = $commandBus;
+ public function __construct(
+ private readonly LoggerInterface $logger,
+ private readonly CommandBus $commandBus,
+ ) {
}
- public function process(Command $command)
+ public function process(AbstractCommand $command): AbstractCommand
{
$this->logger->debug(sprintf('Dispatching command "%s" for handling', $command));
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/EventDispatchingStage.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/EventDispatchingStage.php
index 7e45e64b8..b770c6fcf 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/EventDispatchingStage.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/EventDispatchingStage.php
@@ -19,28 +19,18 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline;
use Psr\Log\LoggerInterface;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus;
class EventDispatchingStage implements Stage
{
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- /**
- * @var BufferedEventBus
- */
- private $bufferedEventBus;
-
- public function __construct(LoggerInterface $logger, BufferedEventBus $bufferedEventBus)
- {
- $this->logger = $logger;
- $this->bufferedEventBus = $bufferedEventBus;
+ public function __construct(
+ private readonly LoggerInterface $logger,
+ private readonly BufferedEventBus $bufferedEventBus,
+ ) {
}
- public function process(Command $command)
+ public function process(AbstractCommand $command): AbstractCommand
{
$this->logger->debug(sprintf('Dispatching Events for "%s"', $command));
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Exception/InvalidCommandException.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Exception/InvalidCommandException.php
index ebea66d3f..ba291b5bd 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Exception/InvalidCommandException.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Exception/InvalidCommandException.php
@@ -18,24 +18,26 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Exception;
+use RuntimeException;
use Symfony\Component\Validator\ConstraintViolationInterface;
use Symfony\Component\Validator\ConstraintViolationListInterface;
+use Throwable;
-class InvalidCommandException extends \RuntimeException implements ProcessingAbortedException
+class InvalidCommandException extends RuntimeException implements ProcessingAbortedException
{
/**
* @var string[]
*/
- private $errors;
+ private readonly array $errors;
- public static function createFromViolations(ConstraintViolationListInterface $violations)
+ public static function createFromViolations(ConstraintViolationListInterface $violations): self
{
return new self(self::mapViolationsToErrorStrings($violations));
}
- public function __construct(array $errors, $code = 0, \Exception $previous = null)
+ public function __construct(array $errors, int $code = 0, ?Throwable $previous = null)
{
- parent::__construct(sprintf('Command is invalid: %s', join('; ', $errors)), $code, $previous);
+ parent::__construct(sprintf('Command is invalid: %s', implode('; ', $errors)), $code, $previous);
$this->errors = $errors;
}
@@ -43,16 +45,15 @@ public function __construct(array $errors, $code = 0, \Exception $previous = nul
/**
* @return string[]
*/
- public function getErrors()
+ public function getErrors(): array
{
return $this->errors;
}
/**
- * @param ConstraintViolationListInterface $violations
* @return array
*/
- private static function mapViolationsToErrorStrings(ConstraintViolationListInterface $violations)
+ private static function mapViolationsToErrorStrings(ConstraintViolationListInterface $violations): array
{
$errors = [];
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Exception/ProcessingAbortedException.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Exception/ProcessingAbortedException.php
index 65f2170fc..e77666126 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Exception/ProcessingAbortedException.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Exception/ProcessingAbortedException.php
@@ -23,5 +23,5 @@ interface ProcessingAbortedException
/**
* @return string[]
*/
- public function getErrors();
+ public function getErrors(): array;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Pipeline.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Pipeline.php
index b08719555..9c81b2ca0 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Pipeline.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Pipeline.php
@@ -18,7 +18,7 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
/**
* Describes a linear structure in which commands are processed. For example, authorisation may be checked and
@@ -26,9 +26,5 @@
*/
interface Pipeline
{
- /**
- * @param Command $command
- * @return Command
- */
- public function process(Command $command);
+ public function process(AbstractCommand $command): AbstractCommand;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Stage.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Stage.php
index 4d7e35d12..2a55cc749 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Stage.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/Stage.php
@@ -18,7 +18,7 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
/**
* A stage is used in context of a pipeline and represents a stage in the processing of a command. Stages may block
@@ -26,9 +26,5 @@
*/
interface Stage
{
- /**
- * @param Command $command
- * @return Command
- */
- public function process(Command $command);
+ public function process(AbstractCommand $command): AbstractCommand;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/StagedPipeline.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/StagedPipeline.php
index ba61652ec..7930557f6 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/StagedPipeline.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/StagedPipeline.php
@@ -19,35 +19,29 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline;
use Psr\Log\LoggerInterface;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
class StagedPipeline implements Pipeline
{
/**
* @var Stage[]
*/
- private $stages = [];
+ private array $stages = [];
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- public function __construct(LoggerInterface $logger)
+ public function __construct(private readonly LoggerInterface $logger)
{
- $this->logger = $logger;
}
- public function process(Command $command)
+ public function process(AbstractCommand $command): AbstractCommand
{
$this->logger->debug(sprintf('Processing "%s"', $command));
foreach ($this->stages as $stage) {
- $this->logger->debug(sprintf('Invoking stage "%s" for "%s"', get_class($stage), $command));
+ $this->logger->debug(sprintf('Invoking stage "%s" for "%s"', $stage::class, $command));
$command = $stage->process($command);
- $this->logger->debug(sprintf('Stage "%s" finished processing "%s"', get_class($stage), $command));
+ $this->logger->debug(sprintf('Stage "%s" finished processing "%s"', $stage::class, $command));
}
$this->logger->debug(sprintf('Done processing "%s" in StagedPipeline', $command));
@@ -58,10 +52,8 @@ public function process(Command $command)
/**
* Adds a strage to the pipeling. Sorting of the stages based on priority has already been done in the
* \Surfnet\StepupMiddleware\CommandHandlingBundle\DependencyInjection\CompilerPass\AddPipelineStagesCompilerPass
- *
- * @param Stage $stage
*/
- public function addStage(Stage $stage)
+ public function addStage(Stage $stage): void
{
$this->stages[] = $stage;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/TransactionAwarePipeline.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/TransactionAwarePipeline.php
index 1465d16a5..b74b2d761 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/TransactionAwarePipeline.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/TransactionAwarePipeline.php
@@ -18,56 +18,29 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline;
-use Doctrine\DBAL\Driver\Connection;
+use Doctrine\DBAL\Connection;
+use Exception;
use Psr\Log\LoggerInterface;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
class TransactionAwarePipeline implements Pipeline
{
- /**
- * @var Pipeline
- */
- private $innerPipeline;
-
- /**
- * @var Connection
- */
- private $middlewareConnection;
-
- /**
- * @var Connection
- */
- private $gatewayConnection;
-
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- /**
- * @param LoggerInterface $logger
- * @param Pipeline $innerPipeline
- * @param Connection $middlewareConnection
- * @param Connection $gatewayConnection
- */
public function __construct(
- LoggerInterface $logger,
- Pipeline $innerPipeline,
- Connection $middlewareConnection,
- Connection $gatewayConnection
+ private readonly LoggerInterface $logger,
+ private readonly Pipeline $innerPipeline,
+ private readonly Connection $middlewareConnection,
+ private readonly Connection $gatewayConnection,
) {
- $this->logger = $logger;
- $this->innerPipeline = $innerPipeline;
- $this->middlewareConnection = $middlewareConnection;
- $this->gatewayConnection = $gatewayConnection;
}
- public function process(Command $command)
+ public function process(AbstractCommand $command): AbstractCommand
{
- $this->logger->debug(sprintf(
- 'Starting Transaction in TransactionAwarePipeline for processing command "%s"',
- $command
- ));
+ $this->logger->debug(
+ sprintf(
+ 'Starting Transaction in TransactionAwarePipeline for processing command "%s"',
+ $command,
+ ),
+ );
$this->middlewareConnection->beginTransaction();
$this->gatewayConnection->beginTransaction();
@@ -81,35 +54,37 @@ public function process(Command $command)
$this->middlewareConnection->commit();
$this->gatewayConnection->commit();
- } catch (\Exception $e) {
+ } catch (Exception $e) {
// log at highest level if we may have a split head in the db-cluster...
if (strpos($e->getMessage(), 'ER_UNKNOWN_COM_ERROR')) {
$this->logger->emergency(
sprintf(
'[!!!] Critical Database Exception while processing command "%s": "%s"',
$command,
- $e->getMessage()
+ $e->getMessage(),
),
- ['exception' => $e]
+ ['exception' => $e],
);
} else {
$this->logger->error(
sprintf(
'Exception occurred while processing command "%s": "%s", rolling back transaction',
$command,
- $e->getMessage()
+ $e->getMessage(),
),
- ['exception' => $e]
+ ['exception' => $e],
);
}
$this->middlewareConnection->rollBack();
$this->gatewayConnection->rollBack();
- $this->logger->debug(sprintf(
- 'Transaction for command "%s" rolled back, re-throwing exception',
- $command
- ));
+ $this->logger->debug(
+ sprintf(
+ 'Transaction for command "%s" rolled back, re-throwing exception',
+ $command,
+ ),
+ );
throw $e;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/ValidationStage.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/ValidationStage.php
index b39237f1c..ea17d1f4f 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/ValidationStage.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Pipeline/ValidationStage.php
@@ -19,33 +19,19 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline;
use Psr\Log\LoggerInterface;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Exception\InvalidCommandException;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class ValidationStage implements Stage
{
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- /**
- * @var ValidatorInterface
- */
- private $validator;
-
- /**
- * @param LoggerInterface $logger
- * @param ValidatorInterface $validator
- */
- public function __construct(LoggerInterface $logger, ValidatorInterface $validator)
- {
- $this->logger = $logger;
- $this->validator = $validator;
+ public function __construct(
+ private readonly LoggerInterface $logger,
+ private readonly ValidatorInterface $validator,
+ ) {
}
- public function process(Command $command)
+ public function process(AbstractCommand $command): AbstractCommand
{
$this->logger->debug(sprintf('Processing validation for "%s"', $command));
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/EmailVerificationEmailProcessor.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/EmailVerificationEmailProcessor.php
index 8b0b243be..ec16bed91 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/EmailVerificationEmailProcessor.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/EmailVerificationEmailProcessor.php
@@ -26,48 +26,43 @@
final class EmailVerificationEmailProcessor extends Processor
{
- /**
- * @var EmailVerificationMailService
- */
- private $emailVerificationMailService;
-
- public function __construct(EmailVerificationMailService $emailVerificationMailService)
- {
- $this->emailVerificationMailService = $emailVerificationMailService;
+ public function __construct(
+ private readonly EmailVerificationMailService $emailVerificationMailService,
+ ) {
}
- public function handlePhonePossessionProvenEvent(PhonePossessionProvenEvent $event)
+ public function handlePhonePossessionProvenEvent(PhonePossessionProvenEvent $event): void
{
- if ($event->emailVerificationRequired !== false) {
+ if ($event->emailVerificationRequired) {
$this->emailVerificationMailService->sendEmailVerificationEmail(
- (string) $event->preferredLocale,
- (string) $event->commonName,
- (string) $event->email,
- $event->emailVerificationNonce
+ (string)$event->preferredLocale,
+ (string)$event->commonName,
+ (string)$event->email,
+ $event->emailVerificationNonce,
);
}
}
- public function handleYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $event)
+ public function handleYubikeyPossessionProvenEvent(YubikeyPossessionProvenEvent $event): void
{
- if ($event->emailVerificationRequired !== false) {
+ if ($event->emailVerificationRequired) {
$this->emailVerificationMailService->sendEmailVerificationEmail(
- (string) $event->preferredLocale,
- (string) $event->commonName,
- (string) $event->email,
- $event->emailVerificationNonce
+ (string)$event->preferredLocale,
+ (string)$event->commonName,
+ (string)$event->email,
+ $event->emailVerificationNonce,
);
}
}
- public function handleGssfPossessionProvenEvent(GssfPossessionProvenEvent $event)
+ public function handleGssfPossessionProvenEvent(GssfPossessionProvenEvent $event): void
{
- if ($event->emailVerificationRequired !== false) {
+ if ($event->emailVerificationRequired) {
$this->emailVerificationMailService->sendEmailVerificationEmail(
- (string) $event->preferredLocale,
- (string) $event->commonName,
- (string) $event->email,
- $event->emailVerificationNonce
+ (string)$event->preferredLocale,
+ (string)$event->commonName,
+ (string)$event->email,
+ $event->emailVerificationNonce,
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/RecoveryTokenEmailProcessor.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/RecoveryTokenEmailProcessor.php
index f1f730d9f..6fbc27c32 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/RecoveryTokenEmailProcessor.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/RecoveryTokenEmailProcessor.php
@@ -23,35 +23,24 @@
use Surfnet\Stepup\Identity\Event\PhoneRecoveryTokenPossessionProvenEvent;
use Surfnet\Stepup\Identity\Event\RecoveryTokenRevokedEvent;
use Surfnet\Stepup\Identity\Event\SafeStoreSecretRecoveryTokenPossessionPromisedEvent;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\RecoveryTokenMailService;
final class RecoveryTokenEmailProcessor extends Processor
{
- /**
- * @var RecoveryTokenMailService
- */
- private $mailService;
-
- /**
- * @var IdentityService
- */
- private $identityService;
-
public function __construct(
- RecoveryTokenMailService $recoveryTokenMailService,
- IdentityService $identityService
+ private readonly RecoveryTokenMailService $mailService,
+ private readonly IdentityService $identityService,
) {
- $this->mailService = $recoveryTokenMailService;
- $this->identityService = $identityService;
}
public function handleCompliedWithRecoveryCodeRevocationEvent(
- CompliedWithRecoveryCodeRevocationEvent $event
- ) {
+ CompliedWithRecoveryCodeRevocationEvent $event,
+ ): void {
$identity = $this->identityService->find($event->identityId->getIdentityId());
- if ($identity === null) {
+ if (!$identity instanceof Identity) {
return;
}
@@ -61,15 +50,15 @@ public function handleCompliedWithRecoveryCodeRevocationEvent(
$identity->email,
$event->recoveryTokenType,
$event->recoveryTokenId,
- true
+ true,
);
}
- public function handleRecoveryTokenRevokedEvent(RecoveryTokenRevokedEvent $event)
+ public function handleRecoveryTokenRevokedEvent(RecoveryTokenRevokedEvent $event): void
{
$identity = $this->identityService->find($event->identityId->getIdentityId());
- if ($identity === null) {
+ if (!$identity instanceof Identity) {
return;
}
@@ -79,7 +68,7 @@ public function handleRecoveryTokenRevokedEvent(RecoveryTokenRevokedEvent $event
$identity->email,
$event->recoveryTokenType,
$event->recoveryTokenId,
- false
+ false,
);
}
@@ -87,28 +76,28 @@ public function handlePhoneRecoveryTokenPossessionProvenEvent(PhoneRecoveryToken
{
$identity = $this->identityService->find($event->identityId->getIdentityId());
- if ($identity === null) {
+ if (!$identity instanceof Identity) {
return;
}
$this->mailService->sendCreated(
$identity->preferredLocale,
$event->commonName,
- $event->email
+ $event->email,
);
}
public function handleSafeStoreSecretRecoveryTokenPossessionPromisedEvent(
- SafeStoreSecretRecoveryTokenPossessionPromisedEvent $event
+ SafeStoreSecretRecoveryTokenPossessionPromisedEvent $event,
): void {
$identity = $this->identityService->find($event->identityId->getIdentityId());
- if ($identity === null) {
+ if (!$identity instanceof Identity) {
return;
}
$this->mailService->sendCreated(
$identity->preferredLocale,
$event->commonName,
- $event->email
+ $event->email,
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/SecondFactorRevocationEmailProcessor.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/SecondFactorRevocationEmailProcessor.php
index b23b429c2..c415836ae 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/SecondFactorRevocationEmailProcessor.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/SecondFactorRevocationEmailProcessor.php
@@ -21,39 +21,24 @@
use Broadway\Processor\Processor;
use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
use Surfnet\Stepup\Identity\Event\SecondFactorRevokedEvent;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\SecondFactorRevocationMailService;
final class SecondFactorRevocationEmailProcessor extends Processor
{
- /**
- * @var SecondFactorRevocationMailService
- */
- private $mailService;
-
- /**
- * @var IdentityService
- */
- private $identityService;
-
- /**
- * @param SecondFactorRevocationMailService $secondFactorRevocationMailService
- * @param IdentityService $identityService
- */
public function __construct(
- SecondFactorRevocationMailService $secondFactorRevocationMailService,
- IdentityService $identityService
+ private readonly SecondFactorRevocationMailService $mailService,
+ private readonly IdentityService $identityService,
) {
- $this->mailService = $secondFactorRevocationMailService;
- $this->identityService = $identityService;
}
public function handleCompliedWithVettedSecondFactorRevocationEvent(
- CompliedWithVettedSecondFactorRevocationEvent $event
- ) {
+ CompliedWithVettedSecondFactorRevocationEvent $event,
+ ): void {
$identity = $this->identityService->find($event->identityId->getIdentityId());
- if ($identity === null) {
+ if (!$identity instanceof Identity) {
return;
}
@@ -62,15 +47,15 @@ public function handleCompliedWithVettedSecondFactorRevocationEvent(
$identity->commonName,
$identity->email,
$event->secondFactorType,
- $event->secondFactorIdentifier
+ $event->secondFactorIdentifier,
);
}
- public function handleVettedSecondFactorRevokedEvent(SecondFactorRevokedEvent $event)
+ public function handleVettedSecondFactorRevokedEvent(SecondFactorRevokedEvent $event): void
{
$identity = $this->identityService->find($event->identityId->getIdentityId());
- if ($identity === null) {
+ if (!$identity instanceof Identity) {
return;
}
@@ -79,7 +64,7 @@ public function handleVettedSecondFactorRevokedEvent(SecondFactorRevokedEvent $e
$identity->commonName,
$identity->email,
$event->secondFactorType,
- $event->secondFactorIdentifier
+ $event->secondFactorIdentifier,
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/SecondFactorVettedEmailProcessor.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/SecondFactorVettedEmailProcessor.php
index 3b7be414e..b02bcf55b 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/SecondFactorVettedEmailProcessor.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Processor/SecondFactorVettedEmailProcessor.php
@@ -19,29 +19,32 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Processor;
use Broadway\Processor\Processor;
-use Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession;
use Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\SecondFactorVettedMailService;
final class SecondFactorVettedEmailProcessor extends Processor
{
- /**
- * @var SecondFactorVettedMailService
- */
- private $secondFactorVettedMailService;
-
- public function __construct(SecondFactorVettedMailService $secondFactorVettedMailService)
+ public function __construct(private readonly SecondFactorVettedMailService $secondFactorVettedMailService)
{
- $this->secondFactorVettedMailService = $secondFactorVettedMailService;
}
- public function handleSecondFactorVettedEvent(SecondFactorVettedEvent $event)
+ public function handleSecondFactorVettedEvent(SecondFactorVettedEvent $event): void
{
- $this->secondFactorVettedMailService->sendVettedEmail($event->preferredLocale, $event->commonName, $event->email);
+ $this->secondFactorVettedMailService->sendVettedEmail(
+ $event->preferredLocale,
+ $event->commonName,
+ $event->email,
+ );
}
- public function handleSecondFactorVettedWithoutTokenProofOfPossession(SecondFactorVettedWithoutTokenProofOfPossession $event)
- {
- $this->secondFactorVettedMailService->sendVettedEmail($event->preferredLocale, $event->commonName, $event->email);
+ public function handleSecondFactorVettedWithoutTokenProofOfPossession(
+ SecondFactorVettedWithoutTokenProofOfPossession $event,
+ ): void {
+ $this->secondFactorVettedMailService->sendVettedEmail(
+ $event->preferredLocale,
+ $event->commonName,
+ $event->email,
+ );
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/command_handlers.yml b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/command_handlers.yml
index b12484be9..1e630ee48 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/command_handlers.yml
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/command_handlers.yml
@@ -1,64 +1,64 @@
services:
- surfnet_stepup_middleware_command_handling.command_handler.identity_command_handler:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\IdentityCommandHandler
- arguments:
- - "@surfnet_stepup.repository.identity"
- - "@surfnet_stepup_middleware_api.repository.identity"
- - "@identity.entity.configurable_settings"
- - "@surfnet_stepup_middleware_api.service.allowed_second_factor_list"
- - "@surfnet_stepup.service.second_factor_type"
- - '@Surfnet\Stepup\Helper\SecondFactorProvePossessionHelper'
- - "@surfnet_stepup_middleware_api.service.institution_configuration_options"
- - "@surfnet_stepup.service.loa_resolution"
- - '@Surfnet\Stepup\Helper\RecoveryTokenSecretHelper'
- - '@surfnet_stepup_middleware_command_handling.service.registration_mail'
- tags: [{ name: command_bus.command_handler }]
+ surfnet_stepup_middleware_command_handling.command_handler.identity_command_handler:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\IdentityCommandHandler
+ arguments:
+ - "@surfnet_stepup.repository.identity"
+ - "@surfnet_stepup_middleware_api.repository.identity"
+ - "@identity.entity.configurable_settings"
+ - "@surfnet_stepup_middleware_api.service.allowed_second_factor_list"
+ - "@surfnet_stepup.service.second_factor_type"
+ - '@Surfnet\Stepup\Helper\SecondFactorProvePossessionHelper'
+ - "@surfnet_stepup_middleware_api.service.institution_configuration_options"
+ - "@surfnet_stepup.service.loa_resolution"
+ - '@Surfnet\Stepup\Helper\RecoveryTokenSecretHelper'
+ - '@surfnet_stepup_middleware_command_handling.service.registration_mail'
+ tags: [ { name: command_bus.command_handler } ]
- surfnet_stepup_middleware_command_handling.command_handler.registration_authority_command_handler:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\RegistrationAuthorityCommandHandler
- arguments:
- - "@surfnet_stepup.repository.identity"
- - "@surfnet_stepup.repository.institution_configuration"
- - '@Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\VettingTypeHintService'
- tags: [{ name: command_bus.command_handler }]
+ surfnet_stepup_middleware_command_handling.command_handler.registration_authority_command_handler:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\RegistrationAuthorityCommandHandler
+ arguments:
+ - "@surfnet_stepup.repository.identity"
+ - "@surfnet_stepup.repository.institution_configuration"
+ - '@Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\VettingTypeHintService'
+ tags: [ { name: command_bus.command_handler } ]
- surfnet_stepup_middleware_command_handling.command_handler.configuration:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\CommandHandler\ConfigurationCommandHandler
- arguments:
- - "@surfnet_stepup.repository.configuration"
- tags: [{ name: command_bus.command_handler }]
+ surfnet_stepup_middleware_command_handling.command_handler.configuration:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\CommandHandler\ConfigurationCommandHandler
+ arguments:
+ - "@surfnet_stepup.repository.configuration"
+ tags: [ { name: command_bus.command_handler } ]
- surfnet_stepup_middleware_command_handling.command_handler.institution_configuration:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\CommandHandler\InstitutionConfigurationCommandHandler
- arguments:
- - "@surfnet_stepup.repository.institution_configuration"
- tags: [{ name: command_bus.command_handler }]
+ surfnet_stepup_middleware_command_handling.command_handler.institution_configuration:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\CommandHandler\InstitutionConfigurationCommandHandler
+ arguments:
+ - "@surfnet_stepup.repository.institution_configuration"
+ tags: [ { name: command_bus.command_handler } ]
- surfnet_stepup_middleware_command_handling.command_handler.whitelist:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\WhitelistCommandHandler
- arguments:
- - "@surfnet_stepup.repository.whitelist"
- tags: [{ name: command_bus.command_handler }]
+ surfnet_stepup_middleware_command_handling.command_handler.whitelist:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\WhitelistCommandHandler
+ arguments:
+ - "@surfnet_stepup.repository.whitelist"
+ tags: [ { name: command_bus.command_handler } ]
- surfnet_stepup_middleware_command_handling.command_handler.right_to_be_forgotten_command_handler:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\RightToBeForgottenCommandHandler
- arguments:
- - "@surfnet_stepup.repository.identity"
- - "@surfnet_stepup_middleware_api.repository.identity"
- - "@surfnet_stepup_middleware_command_handling.service.sensitive_data"
- - "@surfnet_stepup_middleware_api.repository.sraa"
- tags: [{ name: command_bus.command_handler }]
+ surfnet_stepup_middleware_command_handling.command_handler.right_to_be_forgotten_command_handler:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\RightToBeForgottenCommandHandler
+ arguments:
+ - "@surfnet_stepup.repository.identity"
+ - "@surfnet_stepup_middleware_api.repository.identity"
+ - "@surfnet_stepup_middleware_command_handling.service.sensitive_data"
+ - "@surfnet_stepup_middleware_api.repository.sraa"
+ tags: [ { name: command_bus.command_handler } ]
- surfnet_stepup_middleware_command_handling.command_handler.reminder_email:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\ReminderEmailCommandHandler
- arguments:
- - "@surfnet_stepup_middleware_middleware.verfied_second_factor_reminder"
- tags: [{ name: command_bus.command_handler }]
+ surfnet_stepup_middleware_command_handling.command_handler.reminder_email:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\ReminderEmailCommandHandler
+ arguments:
+ - "@surfnet_stepup_middleware_middleware.verfied_second_factor_reminder"
+ tags: [ { name: command_bus.command_handler } ]
- # Helper services for command handlers
- Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\VettingTypeHintService:
- arguments:
- - '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettingTypeHintRepository'
- - '%locales%'
- - '@logger'
+ # Helper services for command handlers
+ Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\VettingTypeHintService:
+ arguments:
+ - '@Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettingTypeHintRepository'
+ - '%locales%'
+ - '@logger'
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/event_sourcing.yml b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/event_sourcing.yml
index 9a009896d..520cd0786 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/event_sourcing.yml
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/event_sourcing.yml
@@ -1,91 +1,91 @@
services:
- # BC aliases
- Surfnet\StepupMiddleware\CommandHandlingBundle\EventSourcing\MetadataEnricher: "@surfnet_stepup_middleware_command_handling.metadata_enricher.actor"
-
- Surfnet\Stepup\Helper\UserDataFilterInterface:
- class: Surfnet\Stepup\Helper\UserDataFilter
-
- Surfnet\Stepup\Helper\UserDataFormatterInterface:
- class: Surfnet\Stepup\Helper\UserDataFormatter
- arguments:
- $applicationName: '%application_name%'
-
- surfnet_stepup.repository.identity:
- class: Surfnet\Stepup\Identity\EventSourcing\IdentityRepository
- arguments:
- - "@surfnet_stepup_middleware_command_handling.event_store.sensitive_data"
- - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
- - "@surfnet_stepup.aggregate_factory.public_constructor"
- - '@Surfnet\Stepup\Helper\UserDataFilterInterface'
- - "@logger"
- - ["@surfnet_stepup_middleware_command_handling.metadata_enricher.actor"]
-
- surfnet_stepup_middleware_command_handling.metadata_enricher.actor:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\EventSourcing\MetadataEnrichingEventStreamDecorator
-
- surfnet_stepup.repository.configuration:
- class: Surfnet\Stepup\Configuration\EventSourcing\ConfigurationRepository
- arguments:
- - "@surfnet_stepup.event_store.dbal"
- - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
- - "@surfnet_stepup.aggregate_factory.public_constructor"
-
- surfnet_stepup.repository.institution_configuration:
- class: Surfnet\Stepup\Configuration\EventSourcing\InstitutionConfigurationRepository
- arguments:
- - "@surfnet_stepup.event_store.dbal"
- - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
- - "@surfnet_stepup.aggregate_factory.public_constructor"
-
- surfnet_stepup.repository.whitelist:
- class: Surfnet\Stepup\Identity\EventSourcing\WhitelistRepository
- arguments:
- - "@surfnet_stepup.event_store.dbal"
- - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
- - "@surfnet_stepup.aggregate_factory.public_constructor"
-
- surfnet_stepup.aggregate_factory.public_constructor:
- public: false
- class: Broadway\EventSourcing\AggregateFactory\PublicConstructorAggregateFactory
-
- surfnet_stepup.event_store.in_memory:
- public: false
- class: Broadway\EventStore\InMemoryEventStore
-
- surfnet_stepup.event_store.dbal:
- public: false
- class: Broadway\EventStore\Dbal\DBALEventStore
- arguments:
- - "@doctrine.dbal.middleware_connection"
- - "@surfnet_stepup.event_store.simple_serializer"
- - "@surfnet_stepup.event_store.simple_serializer"
- - 'event_stream'
- - false
-
- surfnet_stepup.event_store.simple_serializer:
- public: false
- class: Broadway\Serializer\SimpleInterfaceSerializer
-
- surfnet_stepup_middleware_command_handling.event_bus.buffered:
- public: false
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus
- arguments:
- - "@doctrine.orm.entity_manager"
-
- # Sensitive data
- surfnet_stepup_middleware_command_handling.repository.sensitive_data_message:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Repository\SensitiveDataMessageRepository
- arguments:
- - "@doctrine.dbal.middleware_connection"
-
- surfnet_stepup_middleware_command_handling.event_store.sensitive_data:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\EventStore\SensitiveDataEventStoreDecorator
- arguments:
- - "@surfnet_stepup.event_store.dbal"
- - "@surfnet_stepup_middleware_command_handling.repository.sensitive_data_message"
-
- surfnet_stepup_middleware_command_handling.service.sensitive_data:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Service\SensitiveDataService
- arguments:
- - "@surfnet_stepup_middleware_command_handling.repository.sensitive_data_message"
+ # BC aliases
+ Surfnet\StepupMiddleware\CommandHandlingBundle\EventSourcing\MetadataEnricher: "@surfnet_stepup_middleware_command_handling.metadata_enricher.actor"
+
+ Surfnet\Stepup\Helper\UserDataFilterInterface:
+ class: Surfnet\Stepup\Helper\UserDataFilter
+
+ Surfnet\Stepup\Helper\UserDataFormatterInterface:
+ class: Surfnet\Stepup\Helper\UserDataFormatter
+ arguments:
+ $applicationName: '%application_name%'
+
+ surfnet_stepup.repository.identity:
+ class: Surfnet\Stepup\Identity\EventSourcing\IdentityRepository
+ arguments:
+ - "@surfnet_stepup_middleware_command_handling.event_store.sensitive_data"
+ - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
+ - "@surfnet_stepup.aggregate_factory.public_constructor"
+ - '@Surfnet\Stepup\Helper\UserDataFilterInterface'
+ - "@logger"
+ - [ "@surfnet_stepup_middleware_command_handling.metadata_enricher.actor" ]
+
+ surfnet_stepup_middleware_command_handling.metadata_enricher.actor:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\EventSourcing\MetadataEnrichingEventStreamDecorator
+
+ surfnet_stepup.repository.configuration:
+ class: Surfnet\Stepup\Configuration\EventSourcing\ConfigurationRepository
+ arguments:
+ - "@surfnet_stepup.event_store.dbal"
+ - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
+ - "@surfnet_stepup.aggregate_factory.public_constructor"
+
+ surfnet_stepup.repository.institution_configuration:
+ class: Surfnet\Stepup\Configuration\EventSourcing\InstitutionConfigurationRepository
+ arguments:
+ - "@surfnet_stepup.event_store.dbal"
+ - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
+ - "@surfnet_stepup.aggregate_factory.public_constructor"
+
+ surfnet_stepup.repository.whitelist:
+ class: Surfnet\Stepup\Identity\EventSourcing\WhitelistRepository
+ arguments:
+ - "@surfnet_stepup.event_store.dbal"
+ - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
+ - "@surfnet_stepup.aggregate_factory.public_constructor"
+
+ surfnet_stepup.aggregate_factory.public_constructor:
+ public: false
+ class: Broadway\EventSourcing\AggregateFactory\PublicConstructorAggregateFactory
+
+ surfnet_stepup.event_store.in_memory:
+ public: false
+ class: Broadway\EventStore\InMemoryEventStore
+
+ surfnet_stepup.event_store.dbal:
+ public: false
+ class: Broadway\EventStore\Dbal\DBALEventStore
+ arguments:
+ - "@doctrine.dbal.middleware_connection"
+ - "@surfnet_stepup.event_store.simple_serializer"
+ - "@surfnet_stepup.event_store.simple_serializer"
+ - 'event_stream'
+ - false
+
+ surfnet_stepup.event_store.simple_serializer:
+ public: false
+ class: Broadway\Serializer\SimpleInterfaceSerializer
+
+ surfnet_stepup_middleware_command_handling.event_bus.buffered:
+ public: false
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus
+ arguments:
+ - "@doctrine.orm.entity_manager"
+
+ # Sensitive data
+ surfnet_stepup_middleware_command_handling.repository.sensitive_data_message:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Repository\SensitiveDataMessageRepository
+ arguments:
+ - "@doctrine.dbal.middleware_connection"
+
+ surfnet_stepup_middleware_command_handling.event_store.sensitive_data:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\EventStore\SensitiveDataEventStoreDecorator
+ arguments:
+ - "@surfnet_stepup.event_store.dbal"
+ - "@surfnet_stepup_middleware_command_handling.repository.sensitive_data_message"
+
+ surfnet_stepup_middleware_command_handling.service.sensitive_data:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Service\SensitiveDataService
+ arguments:
+ - "@surfnet_stepup_middleware_command_handling.repository.sensitive_data_message"
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/pipeline.yml b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/pipeline.yml
index 682ae20ac..7ccdae563 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/pipeline.yml
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/pipeline.yml
@@ -1,64 +1,64 @@
services:
- pipeline:
- alias: surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline
- public: true
+ pipeline:
+ alias: surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline
+ public: true
- # BC aliases
- Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\TransactionAwarePipeline: "@surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline"
- Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\StagedPipeline: "@surfnet_stepup_middleware_command_handling.pipeline.staged_pipeline"
- Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\AuthorizingStage: "@surfnet_stepup_middleware_command_handling.pipeline.stage.authorizing"
- Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\ValidationStage: "@surfnet_stepup_middleware_command_handling.pipeline.stage.validation"
- Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\DispatchStage: "@surfnet_stepup_middleware_command_handling.pipeline.stage.dispatch"
- Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\EventDispatchingStage: "@surfnet_stepup_middleware_command_handling.pipeline.stage.event_dispatching"
- Broadway\CommandHandling\SimpleCommandBus: "@surfnet_stepup_middleware_command_handling.command_bus"
- Surfnet\StepupMiddleware\CommandHandlingBundle\EventListener\ProcessingAbortedExceptionListener: "@surfnet_stepup_middleware_command_handling.listener.invalid_command_exception_listener"
+ # BC aliases
+ Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\TransactionAwarePipeline: "@surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline"
+ Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\StagedPipeline: "@surfnet_stepup_middleware_command_handling.pipeline.staged_pipeline"
+ Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\AuthorizingStage: "@surfnet_stepup_middleware_command_handling.pipeline.stage.authorizing"
+ Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\ValidationStage: "@surfnet_stepup_middleware_command_handling.pipeline.stage.validation"
+ Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\DispatchStage: "@surfnet_stepup_middleware_command_handling.pipeline.stage.dispatch"
+ Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\EventDispatchingStage: "@surfnet_stepup_middleware_command_handling.pipeline.stage.event_dispatching"
+ Broadway\CommandHandling\SimpleCommandBus: "@surfnet_stepup_middleware_command_handling.command_bus"
+ Surfnet\StepupMiddleware\CommandHandlingBundle\EventListener\ProcessingAbortedExceptionListener: "@surfnet_stepup_middleware_command_handling.listener.invalid_command_exception_listener"
- surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\TransactionAwarePipeline
- public: true
- arguments:
- - "@logger"
- - "@surfnet_stepup_middleware_command_handling.pipeline.staged_pipeline"
- - "@doctrine.dbal.middleware_connection"
- - "@doctrine.dbal.gateway_connection"
+ surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\TransactionAwarePipeline
+ public: true
+ arguments:
+ - "@logger"
+ - "@surfnet_stepup_middleware_command_handling.pipeline.staged_pipeline"
+ - "@doctrine.dbal.middleware_connection"
+ - "@doctrine.dbal.gateway_connection"
- surfnet_stepup_middleware_command_handling.pipeline.staged_pipeline:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\StagedPipeline
- arguments:
- - "@logger"
+ surfnet_stepup_middleware_command_handling.pipeline.staged_pipeline:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\StagedPipeline
+ arguments:
+ - "@logger"
- surfnet_stepup_middleware_command_handling.pipeline.stage.authorizing:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\AuthorizingStage
- arguments:
- - "@logger"
- - "@security.authorization_checker"
- tags: [{ name: pipeline.stage, priority: 100 }]
+ surfnet_stepup_middleware_command_handling.pipeline.stage.authorizing:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\AuthorizingStage
+ arguments:
+ - "@logger"
+ - "@security.authorization_checker"
+ tags: [ { name: pipeline.stage, priority: 100 } ]
- surfnet_stepup_middleware_command_handling.pipeline.stage.validation:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\ValidationStage
- arguments:
- - "@logger"
- - "@validator"
- tags: [{ name: pipeline.stage, priority: 75 }]
+ surfnet_stepup_middleware_command_handling.pipeline.stage.validation:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\ValidationStage
+ arguments:
+ - "@logger"
+ - "@validator"
+ tags: [ { name: pipeline.stage, priority: 75 } ]
- surfnet_stepup_middleware_command_handling.pipeline.stage.dispatch:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\DispatchStage
- arguments:
- - "@logger"
- - "@surfnet_stepup_middleware_command_handling.command_bus"
- tags: [{ name: pipeline.stage, priority: 50 }]
+ surfnet_stepup_middleware_command_handling.pipeline.stage.dispatch:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\DispatchStage
+ arguments:
+ - "@logger"
+ - "@surfnet_stepup_middleware_command_handling.command_bus"
+ tags: [ { name: pipeline.stage, priority: 50 } ]
- surfnet_stepup_middleware_command_handling.pipeline.stage.event_dispatching:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\EventDispatchingStage
- arguments:
- - "@logger"
- - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
- tags: [{ name: pipeline.stage, priority: 25 }]
+ surfnet_stepup_middleware_command_handling.pipeline.stage.event_dispatching:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\EventDispatchingStage
+ arguments:
+ - "@logger"
+ - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
+ tags: [ { name: pipeline.stage, priority: 25 } ]
- surfnet_stepup_middleware_command_handling.command_bus:
- class: Broadway\CommandHandling\SimpleCommandBus
+ surfnet_stepup_middleware_command_handling.command_bus:
+ class: Broadway\CommandHandling\SimpleCommandBus
- surfnet_stepup_middleware_command_handling.listener.invalid_command_exception_listener:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\EventListener\ProcessingAbortedExceptionListener
- tags:
- - { name: kernel.event_listener, event: kernel.exception, priority: 10 }
+ surfnet_stepup_middleware_command_handling.listener.invalid_command_exception_listener:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\EventListener\ProcessingAbortedExceptionListener
+ tags:
+ - { name: kernel.event_listener, event: kernel.exception, priority: 10 }
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/processors.yml b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/processors.yml
index ad865cffc..bfa786669 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/processors.yml
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/config/processors.yml
@@ -1,104 +1,105 @@
services:
- surfnet_stepup_middleware_command_handling.processor.email_verification_email:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Processor\EmailVerificationEmailProcessor
- arguments:
- - "@surfnet_stepup_middleware_command_handling.service.email_verification_mail"
- tags: [{ name: event_bus.event_listener, disable_for_replay: true }]
+ surfnet_stepup_middleware_command_handling.processor.email_verification_email:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Processor\EmailVerificationEmailProcessor
+ arguments:
+ - "@surfnet_stepup_middleware_command_handling.service.email_verification_mail"
+ - "@logger"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: true } ]
- surfnet_stepup_middleware_command_handling.processor.second_factor_revocation_email:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Processor\SecondFactorRevocationEmailProcessor
- arguments:
- - "@surfnet_stepup_middleware_command_handling.service.second_factor_revocation_mail"
- - "@surfnet_stepup_middleware_api.service.identity"
- tags: [{ name: event_bus.event_listener, disable_for_replay: true }]
+ surfnet_stepup_middleware_command_handling.processor.second_factor_revocation_email:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Processor\SecondFactorRevocationEmailProcessor
+ arguments:
+ - "@surfnet_stepup_middleware_command_handling.service.second_factor_revocation_mail"
+ - "@surfnet_stepup_middleware_api.service.identity"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: true } ]
- surfnet_stepup_middleware_command_handling.processor.recovery_token_email:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Processor\RecoveryTokenEmailProcessor
- arguments:
- - "@surfnet_stepup_middleware_command_handling.service.recovery_token_mail"
- - "@surfnet_stepup_middleware_api.service.identity"
- tags: [{ name: event_bus.event_listener, disable_for_replay: true }]
+ surfnet_stepup_middleware_command_handling.processor.recovery_token_email:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Processor\RecoveryTokenEmailProcessor
+ arguments:
+ - "@surfnet_stepup_middleware_command_handling.service.recovery_token_mail"
+ - "@surfnet_stepup_middleware_api.service.identity"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: true } ]
- surfnet_stepup_middleware_command_handling.processor.second_factor_vetted_email:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Processor\SecondFactorVettedEmailProcessor
- arguments:
- - "@surfnet_stepup_middleware_command_handling.service.second_factor_vetted_mail"
- tags: [{ name: event_bus.event_listener, disable_for_replay: true }]
+ surfnet_stepup_middleware_command_handling.processor.second_factor_vetted_email:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Processor\SecondFactorVettedEmailProcessor
+ arguments:
+ - "@surfnet_stepup_middleware_command_handling.service.second_factor_vetted_mail"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: true } ]
- surfnet_stepup_middleware_command_handling.service.email_verification_mail:
- public: false
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\EmailVerificationMailService
- arguments:
- - "@mailer.mailer"
- - "@surfnet_stepup_middleware_command_handling.email_sender"
- - "@translator"
- - "" # Verification URL set in bundle extension
- - "@surfnet_stepup_middleware_management.service.email_template"
- - "" # Fallback locale
- - "" # Self service url is set in bundle extension
+ surfnet_stepup_middleware_command_handling.service.email_verification_mail:
+ public: false
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\EmailVerificationMailService
+ arguments:
+ - "@mailer.mailer"
+ - "@surfnet_stepup_middleware_command_handling.email_sender"
+ - "@translator"
+ - "" # Verification URL set in bundle extension
+ - "@surfnet_stepup_middleware_management.service.email_template"
+ - "" # Fallback locale
+ - "" # Self service url is set in bundle extension
- surfnet_stepup_middleware_command_handling.service.registration_mail:
- public: false
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\RegistrationMailService
- arguments:
- - "@mailer.mailer"
- - "@surfnet_stepup_middleware_command_handling.email_sender"
- - "@translator"
- - "@surfnet_stepup_middleware_management.service.email_template"
- - "" # Fallback locale
- - "" # Self service url is set in bundle extension
- - '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionConfigurationOptionsService'
- - '@Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService'
- - '@Surfnet\StepupMiddleware\ApiBundle\Identity\Service\SecondFactorService'
- - '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\RaLocationService'
- - '@Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaListingService'
- - '@logger'
+ surfnet_stepup_middleware_command_handling.service.registration_mail:
+ public: false
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\RegistrationMailService
+ arguments:
+ - "@mailer.mailer"
+ - "@surfnet_stepup_middleware_command_handling.email_sender"
+ - "@translator"
+ - "@surfnet_stepup_middleware_management.service.email_template"
+ - "" # Fallback locale
+ - "" # Self service url is set in bundle extension
+ - '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionConfigurationOptionsService'
+ - '@Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService'
+ - '@Surfnet\StepupMiddleware\ApiBundle\Identity\Service\SecondFactorService'
+ - '@Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\RaLocationService'
+ - '@Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaListingService'
+ - '@logger'
- surfnet_stepup_middleware_command_handling.service.second_factor_revocation_mail:
- public: false
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\SecondFactorRevocationMailService
- arguments:
- - "@mailer.mailer"
- - "@surfnet_stepup_middleware_command_handling.email_sender"
- - "@translator"
- - "@surfnet_stepup_middleware_management.service.email_template"
- - "" # Fallback locale
- - "" # Self service url is set in bundle extension
- - "@surfnet_stepup_middleware_middleware.second_factor_display_name_resolver"
+ surfnet_stepup_middleware_command_handling.service.second_factor_revocation_mail:
+ public: false
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\SecondFactorRevocationMailService
+ arguments:
+ - "@mailer.mailer"
+ - "@surfnet_stepup_middleware_command_handling.email_sender"
+ - "@translator"
+ - "@surfnet_stepup_middleware_management.service.email_template"
+ - "" # Fallback locale
+ - "" # Self service url is set in bundle extension
+ - "@surfnet_stepup_middleware_middleware.second_factor_display_name_resolver"
- surfnet_stepup_middleware_command_handling.service.recovery_token_mail:
- public: false
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\RecoveryTokenMailService
- arguments:
- - "@mailer.mailer"
- - "@surfnet_stepup_middleware_command_handling.email_sender"
- - "@translator"
- - "@surfnet_stepup_middleware_management.service.email_template"
- - "" # Fallback locale
- - "" # Self service url is set in bundle extension
- - "@logger"
+ surfnet_stepup_middleware_command_handling.service.recovery_token_mail:
+ public: false
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\RecoveryTokenMailService
+ arguments:
+ - "@mailer.mailer"
+ - "@surfnet_stepup_middleware_command_handling.email_sender"
+ - "@translator"
+ - "@surfnet_stepup_middleware_management.service.email_template"
+ - "" # Fallback locale
+ - "" # Self service url is set in bundle extension
+ - "@logger"
- surfnet_stepup_middleware_command_handling.service.second_factor_vetted_mail:
- public: false
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\SecondFactorVettedMailService
- arguments:
- - "@mailer.mailer"
- - "@surfnet_stepup_middleware_command_handling.email_sender"
- - "@translator"
- - "@surfnet_stepup_middleware_management.service.email_template"
- - "" # Fallback locale
- - "" # Self service url is set in bundle extension
+ surfnet_stepup_middleware_command_handling.service.second_factor_vetted_mail:
+ public: false
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\SecondFactorVettedMailService
+ arguments:
+ - "@mailer.mailer"
+ - "@surfnet_stepup_middleware_command_handling.email_sender"
+ - "@translator"
+ - "@surfnet_stepup_middleware_management.service.email_template"
+ - "" # Fallback locale
+ - "" # Self service url is set in bundle extension
- surfnet_stepup_middleware_command_handling.email_sender:
- public: false
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Value\Sender
- arguments:
- - "" # Name is set in bundle extension
- - "" # Email is set in bundle extension
+ surfnet_stepup_middleware_command_handling.email_sender:
+ public: false
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Value\Sender
+ arguments:
+ - "" # Name is set in bundle extension
+ - "" # Email is set in bundle extension
- surfnet_stepup_middleware_command_handling.processor.institution_configuration:
- class: Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Processor\InstitutionConfigurationProcessor
- arguments:
- - "@surfnet_stepup_middleware_api.repository.configured_institution"
- - "@service_container"
- tags: [{ name: event_bus.event_listener, disable_for_replay: true }]
+ surfnet_stepup_middleware_command_handling.processor.institution_configuration:
+ class: Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Processor\InstitutionConfigurationProcessor
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.configured_institution"
+ - "@pipeline"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: true } ]
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventSourcing/SensitiveDataMessage.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventSourcing/SensitiveDataMessage.php
index 0009673a3..988a78ef5 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventSourcing/SensitiveDataMessage.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventSourcing/SensitiveDataMessage.php
@@ -24,41 +24,17 @@
class SensitiveDataMessage
{
- /**
- * @var IdentityId
- */
- private $identityId;
-
- /**
- * @var int
- */
- private $playhead;
+ private readonly IdentityId $identityId;
- /**
- * @var SensitiveData
- */
- private $sensitiveData;
-
- /**
- * @param IdentityId $identityId
- * @param int $playhead The associated broadway domain message's playhead.
- * @param SensitiveData $sensitiveData
- */
- public function __construct(string $identityId, $playhead, SensitiveData $sensitiveData)
+ public function __construct(string $identityId, private readonly int $playhead, private SensitiveData $sensitiveData)
{
- if (!is_int($playhead)) {
- throw InvalidArgumentException::invalidType('int', 'playhead', $playhead);
- }
-
$this->identityId = new IdentityId($identityId);
- $this->playhead = $playhead;
- $this->sensitiveData = $sensitiveData;
}
/**
* Forgets all contained sensitive data.
*/
- public function forget()
+ public function forget(): void
{
$this->sensitiveData = $this->sensitiveData->forget();
}
@@ -66,7 +42,7 @@ public function forget()
/**
* @return IdentityId
*/
- public function getIdentityId()
+ public function getIdentityId(): IdentityId
{
return $this->identityId;
}
@@ -74,7 +50,7 @@ public function getIdentityId()
/**
* @return int
*/
- public function getPlayhead()
+ public function getPlayhead(): int
{
return $this->playhead;
}
@@ -82,7 +58,7 @@ public function getPlayhead()
/**
* @return SensitiveData
*/
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return $this->sensitiveData;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventSourcing/SensitiveDataMessageStream.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventSourcing/SensitiveDataMessageStream.php
index ae40ee5cd..d5a21794b 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventSourcing/SensitiveDataMessageStream.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventSourcing/SensitiveDataMessageStream.php
@@ -21,65 +21,61 @@
use ArrayIterator;
use Broadway\Domain\DomainEventStream;
use Broadway\Domain\DomainMessage;
+use Iterator;
use IteratorAggregate;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Exception\SensitiveDataApplicationException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable;
+/**
+ * @implements IteratorAggregate
+ */
class SensitiveDataMessageStream implements IteratorAggregate
{
- /**
- * @var array
- */
- private $messages;
-
/**
* @param SensitiveDataMessage[] $messages
*/
- public function __construct(array $messages)
+ public function __construct(private readonly array $messages)
{
- $this->messages = $messages;
}
- public function applyToDomainEventStream(DomainEventStream $domainEventStream)
+ public function applyToDomainEventStream(DomainEventStream $domainEventStream): void
{
$sensitiveDataMap = $this->createSensitiveDataMap($this->messages);
/** @var DomainMessage $domainMessage */
foreach ($domainEventStream as $domainMessage) {
- $sensitiveDataMessage = isset($sensitiveDataMap[$domainMessage->getPlayhead()])
- ? $sensitiveDataMap[$domainMessage->getPlayhead()]
- : null;
+ $sensitiveDataMessage = $sensitiveDataMap[$domainMessage->getPlayhead()] ?? null;
unset($sensitiveDataMap[$domainMessage->getPlayhead()]);
$this->setSensitiveData($domainMessage, $sensitiveDataMessage);
}
- if (count($sensitiveDataMap) > 0) {
- throw new SensitiveDataApplicationException(sprintf(
- '%d sensitive data messages are still to be matched to events',
- count($sensitiveDataMap)
- ));
+ if ($sensitiveDataMap !== []) {
+ throw new SensitiveDataApplicationException(
+ sprintf(
+ '%d sensitive data messages are still to be matched to events',
+ count($sensitiveDataMap),
+ ),
+ );
}
}
- public function forget()
+ public function forget(): void
{
foreach ($this->messages as $message) {
$message->forget();
}
}
- public function getIterator()
+ public function getIterator(): Iterator
{
return new ArrayIterator($this->messages);
}
- /**
- * @param DomainMessage $domainMessage
- * @param SensitiveDataMessage|null $sensitiveDataMessage
- */
- private function setSensitiveData(DomainMessage $domainMessage, SensitiveDataMessage $sensitiveDataMessage = null)
- {
+ private function setSensitiveData(
+ DomainMessage $domainMessage,
+ SensitiveDataMessage $sensitiveDataMessage = null,
+ ): void {
$event = $domainMessage->getPayload();
$eventIsForgettable = $event instanceof Forgettable;
@@ -88,27 +84,33 @@ private function setSensitiveData(DomainMessage $domainMessage, SensitiveDataMes
}
if ($eventIsForgettable && !$sensitiveDataMessage) {
- throw new SensitiveDataApplicationException(sprintf(
- 'Sensitive data is missing for event with UUID %s, playhead %d',
- $domainMessage->getId(),
- $domainMessage->getPlayhead()
- ));
+ throw new SensitiveDataApplicationException(
+ sprintf(
+ 'Sensitive data is missing for event with UUID %s, playhead %d',
+ $domainMessage->getId(),
+ $domainMessage->getPlayhead(),
+ ),
+ );
}
- if (!$eventIsForgettable && $sensitiveDataMessage) {
- throw new SensitiveDataApplicationException(sprintf(
- 'Encountered sensitive data for event which does not support sensitive data, UUID %s, playhead %d',
- $domainMessage->getId(),
- $domainMessage->getPlayhead()
- ));
+ if (!$eventIsForgettable) {
+ throw new SensitiveDataApplicationException(
+ sprintf(
+ 'Encountered sensitive data for event which does not support sensitive data, UUID %s, playhead %d',
+ $domainMessage->getId(),
+ $domainMessage->getPlayhead(),
+ ),
+ );
}
if ($domainMessage->getId() != $sensitiveDataMessage->getIdentityId()) {
- throw new SensitiveDataApplicationException(sprintf(
- 'Encountered sensitive data from stream %s for event from stream %s',
- $sensitiveDataMessage->getIdentityId(),
- $domainMessage->getId()
- ));
+ throw new SensitiveDataApplicationException(
+ sprintf(
+ 'Encountered sensitive data from stream %s for event from stream %s',
+ $sensitiveDataMessage->getIdentityId(),
+ $domainMessage->getId(),
+ ),
+ );
}
$event->setSensitiveData($sensitiveDataMessage->getSensitiveData());
@@ -118,7 +120,7 @@ private function setSensitiveData(DomainMessage $domainMessage, SensitiveDataMes
* @param SensitiveDataMessage[] $messages
* @return SensitiveDataMessage[] The same messages, but indexed by their playheads.
*/
- private function createSensitiveDataMap(array $messages)
+ private function createSensitiveDataMap(array $messages): array
{
$map = [];
foreach ($messages as $message) {
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventStore/SensitiveDataEventStoreDecorator.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventStore/SensitiveDataEventStoreDecorator.php
index b55d12abf..4e6a442fb 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventStore/SensitiveDataEventStoreDecorator.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/EventStore/SensitiveDataEventStoreDecorator.php
@@ -31,28 +31,12 @@
/**
* Event store decorator that loads and appends the sensitive data of events into a separate data store.
*/
-final class SensitiveDataEventStoreDecorator implements EventStoreInterface
+final readonly class SensitiveDataEventStoreDecorator implements EventStoreInterface
{
- /**
- * @var EventStoreInterface
- */
- private $decoratedEventStore;
-
- /**
- * @var SensitiveDataMessageRepository
- */
- private $sensitiveDataMessageRepository;
-
- /**
- * @param EventStoreInterface $decoratedEventStore
- * @param SensitiveDataMessageRepository $sensitiveDataMessageRepository
- */
public function __construct(
- EventStoreInterface $decoratedEventStore,
- SensitiveDataMessageRepository $sensitiveDataMessageRepository
+ private EventStoreInterface $decoratedEventStore,
+ private SensitiveDataMessageRepository $sensitiveDataMessageRepository,
) {
- $this->decoratedEventStore = $decoratedEventStore;
- $this->sensitiveDataMessageRepository = $sensitiveDataMessageRepository;
}
public function load($id): DomainEventStreamInterface
@@ -85,7 +69,7 @@ public function append($id, DomainEventStreamInterface $eventStream): void
$sensitiveDataMessages[] = new SensitiveDataMessage(
$id,
$message->getPlayhead(),
- $event->getSensitiveData()
+ $event->getSensitiveData(),
);
}
@@ -109,15 +93,12 @@ public function loadFromPlayhead($id, int $playhead): DomainEventStreamInterface
return $domainEventStream;
}
- /**
- * @param DomainEventStreamInterface $stream
- */
- public function assertIdentityAggregate(DomainEventStreamInterface $stream)
+ public function assertIdentityAggregate(DomainEventStreamInterface $stream): void
{
foreach ($stream as $message) {
if (!$message->getPayload() instanceof IdentityEvent) {
throw new InvalidArgumentException(
- 'The SensitiveDataEventStoreDecorator only works with Identities, please pass in an IdentityId $id'
+ 'The SensitiveDataEventStoreDecorator only works with Identities, please pass in an IdentityId $id',
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Forgettable.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Forgettable.php
index 108f647de..b0dd0c460 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Forgettable.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Forgettable.php
@@ -23,11 +23,10 @@ interface Forgettable
/**
* @return SensitiveData
*/
- public function getSensitiveData();
+ public function getSensitiveData(): SensitiveData;
/**
- * @param SensitiveData $sensitiveData
* @return void
*/
- public function setSensitiveData(SensitiveData $sensitiveData);
+ public function setSensitiveData(SensitiveData $sensitiveData): void;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Repository/SensitiveDataMessageRepository.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Repository/SensitiveDataMessageRepository.php
index adcc7948a..84e5c1ee5 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Repository/SensitiveDataMessageRepository.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Repository/SensitiveDataMessageRepository.php
@@ -29,46 +29,34 @@
class SensitiveDataMessageRepository
{
- /**
- * @var Connection
- */
- private $connection;
-
- public function __construct(Connection $connection)
+ public function __construct(private readonly Connection $connection)
{
- $this->connection = $connection;
}
/**
* Finds all sensitive data records for a given Identity, ordered by playhead.
- *
- * @param IdentityId $identityId
- * @return SensitiveDataMessageStream
*/
- public function findByIdentityId(IdentityId $identityId)
+ public function findByIdentityId(IdentityId $identityId): SensitiveDataMessageStream
{
$sql = 'SELECT identity_id, playhead, sensitive_data
FROM event_stream_sensitive_data
WHERE identity_id = :identity_id
ORDER BY playhead ASC';
- $rows = $this->connection->fetchAll($sql, ['identity_id' => (string) $identityId]);
- $messages = array_map(function (array $row) use ($identityId) {
- return new SensitiveDataMessage(
- $identityId,
- (int) $row['playhead'],
- SensitiveData::deserialize(JsonHelper::decode($row['sensitive_data']))
- );
- }, $rows);
+ $rows = $this->connection->fetchAllAssociative($sql, ['identity_id' => (string)$identityId]);
+ $messages = array_map(fn(array $row): SensitiveDataMessage => new SensitiveDataMessage(
+ $identityId,
+ (int)$row['playhead'],
+ SensitiveData::deserialize(JsonHelper::decode($row['sensitive_data'])),
+ ), $rows);
return new SensitiveDataMessageStream($messages);
}
/**
- * @param SensitiveDataMessageStream $sensitiveDataMessageStream
* @return void
*/
- public function append(SensitiveDataMessageStream $sensitiveDataMessageStream)
+ public function append(SensitiveDataMessageStream $sensitiveDataMessageStream): void
{
$this->connection->beginTransaction();
@@ -76,9 +64,9 @@ public function append(SensitiveDataMessageStream $sensitiveDataMessageStream)
foreach ($sensitiveDataMessageStream as $sensitiveDataMessage) {
/** @var SensitiveDataMessage $sensitiveDataMessage */
$this->connection->insert('event_stream_sensitive_data', [
- 'identity_id' => (string) $sensitiveDataMessage->getIdentityId(),
- 'playhead' => $sensitiveDataMessage->getPlayhead(),
- 'sensitive_data' => json_encode((object) $sensitiveDataMessage->getSensitiveData()->serialize()),
+ 'identity_id' => (string)$sensitiveDataMessage->getIdentityId(),
+ 'playhead' => $sensitiveDataMessage->getPlayhead(),
+ 'sensitive_data' => json_encode((object)$sensitiveDataMessage->getSensitiveData()->serialize()),
]);
}
$this->connection->commit();
@@ -89,10 +77,9 @@ public function append(SensitiveDataMessageStream $sensitiveDataMessageStream)
}
/**
- * @param SensitiveDataMessageStream $sensitiveDataMessageStream
* @return void
*/
- public function modify(SensitiveDataMessageStream $sensitiveDataMessageStream)
+ public function modify(SensitiveDataMessageStream $sensitiveDataMessageStream): void
{
$this->connection->beginTransaction();
@@ -101,11 +88,11 @@ public function modify(SensitiveDataMessageStream $sensitiveDataMessageStream)
/** @var SensitiveDataMessage $sensitiveDataMessage */
$this->connection->update(
'event_stream_sensitive_data',
- ['sensitive_data' => json_encode((object) $sensitiveDataMessage->getSensitiveData()->serialize())],
+ ['sensitive_data' => json_encode((object)$sensitiveDataMessage->getSensitiveData()->serialize())],
[
- 'identity_id' => (string) $sensitiveDataMessage->getIdentityId(),
- 'playhead' => $sensitiveDataMessage->getPlayhead(),
- ]
+ 'identity_id' => (string)$sensitiveDataMessage->getIdentityId(),
+ 'playhead' => $sensitiveDataMessage->getPlayhead(),
+ ],
);
}
$this->connection->commit();
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/RightToObtainDataInterface.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/RightToObtainDataInterface.php
index 6b10e9972..9e92f0c53 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/RightToObtainDataInterface.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/RightToObtainDataInterface.php
@@ -1,5 +1,21 @@
commonName = $commonName;
@@ -81,11 +55,7 @@ public function withCommonName(CommonName $commonName)
return $clone;
}
- /**
- * @param Email $email
- * @return SensitiveData
- */
- public function withEmail(Email $email)
+ public function withEmail(Email $email): static
{
$clone = clone $this;
$clone->email = $email;
@@ -93,15 +63,10 @@ public function withEmail(Email $email)
return $clone;
}
- /**
- * @param SecondFactorIdentifier $secondFactorIdentifier
- * @param SecondFactorType $secondFactorType
- * @return SensitiveData
- */
public function withSecondFactorIdentifier(
SecondFactorIdentifier $secondFactorIdentifier,
- SecondFactorType $secondFactorType
- ) {
+ SecondFactorType $secondFactorType,
+ ): static {
$clone = clone $this;
$clone->secondFactorType = $secondFactorType;
$clone->secondFactorIdentifier = $secondFactorIdentifier;
@@ -111,7 +76,7 @@ public function withSecondFactorIdentifier(
public function withRecoveryTokenSecret(
RecoveryTokenIdentifier $recoveryTokenIdentifier,
- RecoveryTokenType $type
+ RecoveryTokenType $type,
): SensitiveData {
$clone = clone $this;
$clone->recoveryTokenType = $type;
@@ -130,10 +95,8 @@ public function withVettingType(VettingType $vettingType): self
/**
* Returns an instance in which all sensitive data is forgotten.
- *
- * @return SensitiveData
*/
- public function forget()
+ public function forget(): self
{
$forgotten = new self();
$forgotten->secondFactorType = $this->secondFactorType;
@@ -141,50 +104,38 @@ public function forget()
return $forgotten;
}
- /**
- * @return CommonName
- */
- public function getCommonName()
+ public function getCommonName(): CommonName
{
return $this->commonName ?: CommonName::unknown();
}
- /**
- * @return Email
- */
- public function getEmail()
+ public function getEmail(): Email
{
return $this->email ?: Email::unknown();
}
- /**
- * @return SecondFactorIdentifier
- */
- public function getSecondFactorIdentifier()
+ public function getSecondFactorIdentifier(): SecondFactorIdentifier
{
return $this->secondFactorIdentifier ?: SecondFactorIdentifierFactory::unknownForType($this->secondFactorType);
}
public function getRecoveryTokenIdentifier(): ?RecoveryTokenIdentifier
{
- if ($this->recoveryTokenIdentifier) {
+ if ($this->recoveryTokenIdentifier instanceof RecoveryTokenIdentifier) {
return $this->recoveryTokenIdentifier;
}
- if ($this->recoveryTokenType) {
+ if ($this->recoveryTokenType instanceof RecoveryTokenType) {
return RecoveryTokenIdentifierFactory::unknownForType($this->recoveryTokenType);
}
return null;
}
- /**
- * @return VettingType
- */
- public function getVettingType()
+ public function getVettingType(): VettingType
{
return $this->vettingType ?: new UnknownVettingType();
}
- public static function deserialize(array $data)
+ public static function deserialize(array $data): SensitiveData
{
$self = new self;
@@ -211,7 +162,7 @@ public static function deserialize(array $data)
if (isset($data['recovery_token_identifier'])) {
$self->recoveryTokenIdentifier = RecoveryTokenIdentifierFactory::forType(
$self->recoveryTokenType,
- $data['recovery_token_identifier']
+ $data['recovery_token_identifier'],
);
}
@@ -224,15 +175,15 @@ public static function deserialize(array $data)
public function serialize(): array
{
- $vettingType = (!is_null($this->vettingType)) ? $this->vettingType->jsonSerialize() : null;
+ $vettingType = (is_null($this->vettingType)) ? null : $this->vettingType->jsonSerialize();
return array_filter([
- 'common_name' => $this->commonName,
- 'email' => $this->email,
- 'second_factor_type' => $this->secondFactorType,
+ 'common_name' => $this->commonName,
+ 'email' => $this->email,
+ 'second_factor_type' => $this->secondFactorType,
'second_factor_identifier' => $this->secondFactorIdentifier,
- 'recovery_token_type' => (string) $this->recoveryTokenType,
+ 'recovery_token_type' => (string)$this->recoveryTokenType,
'recovery_token_identifier' => $this->recoveryTokenIdentifier,
- 'vetting_type' => $vettingType
+ 'vetting_type' => $vettingType,
]);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Service/SensitiveDataService.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Service/SensitiveDataService.php
index 7d2652f41..a8be3e229 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Service/SensitiveDataService.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SensitiveData/Service/SensitiveDataService.php
@@ -23,17 +23,11 @@
class SensitiveDataService
{
- /**
- * @var \Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Repository\SensitiveDataMessageRepository
- */
- private $sensitiveDataMessageRepository;
-
- public function __construct(SensitiveDataMessageRepository $sensitiveDataMessageRepository)
+ public function __construct(private readonly SensitiveDataMessageRepository $sensitiveDataMessageRepository)
{
- $this->sensitiveDataMessageRepository = $sensitiveDataMessageRepository;
}
- public function forgetSensitiveData(IdentityId $identityId)
+ public function forgetSensitiveData(IdentityId $identityId): void
{
$sensitiveDataMessageStream = $this->sensitiveDataMessageRepository->findByIdentityId($identityId);
$sensitiveDataMessageStream->forget();
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SurfnetStepupMiddlewareCommandHandlingBundle.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SurfnetStepupMiddlewareCommandHandlingBundle.php
index 91e9afeaa..45fd35dfe 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SurfnetStepupMiddlewareCommandHandlingBundle.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/SurfnetStepupMiddlewareCommandHandlingBundle.php
@@ -26,7 +26,7 @@
class SurfnetStepupMiddlewareCommandHandlingBundle extends Bundle
{
- public function build(ContainerBuilder $container)
+ public function build(ContainerBuilder $container): void
{
parent::build($container);
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Command/AbstractCommandTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Command/AbstractCommandTest.php
index 4174885e6..ad28651f5 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Command/AbstractCommandTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Command/AbstractCommandTest.php
@@ -18,23 +18,26 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Command;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
class AbstractCommandTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group command
*/
- public function to_string_generates_command_identifiable_information()
+ public function to_string_generates_command_identifiable_information(): void
{
$command = new FixedUuidStubCommand();
$uuid = $command->UUID;
$this->assertEquals(
'Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Command\FixedUuidStubCommand[' . $uuid . ']',
- (string) $command,
- 'Command cast to string should give F\Q\C\N[UuidOfCommand]'
+ (string)$command,
+ 'Command cast to string should give F\Q\C\N[UuidOfCommand]',
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Command/FixedUuidStubCommand.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Command/FixedUuidStubCommand.php
index 93a8b5b53..ba6da8a52 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Command/FixedUuidStubCommand.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Command/FixedUuidStubCommand.php
@@ -24,7 +24,7 @@
class FixedUuidStubCommand extends AbstractCommand implements Command
{
/**
- * @var string generated using \Rhumsaa\Uuid\Uuid::uuid4()
+ * @var string generated using \Ramsey\Uuid\Uuid::uuid4()
*/
- public $UUID = '1e8a8dc6-852e-4df8-ba23-8c18061b7c38';
+ public string $UUID = '1e8a8dc6-852e-4df8-ba23-8c18061b7c38';
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/CommandHandlerTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/CommandHandlerTest.php
index 4c0fd0874..84a8125d3 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/CommandHandlerTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/CommandHandlerTest.php
@@ -19,15 +19,18 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests;
use Broadway\CommandHandling\Testing\CommandHandlerScenarioTestCase;
-use Rhumsaa\Uuid\Uuid;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Ramsey\Uuid\Uuid;
abstract class CommandHandlerTest extends CommandHandlerScenarioTestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @return string
*/
- protected static function uuid()
+ protected static function uuid(): string
{
- return (string) Uuid::uuid4();
+ return (string)Uuid::uuid4();
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/CommandHandler/ConfigurationCommandHandlerTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/CommandHandler/ConfigurationCommandHandlerTest.php
index bd59ee15e..3c900aeb1 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/CommandHandler/ConfigurationCommandHandlerTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/CommandHandler/ConfigurationCommandHandlerTest.php
@@ -22,6 +22,8 @@
use Broadway\EventHandling\EventBus as EventBusInterface;
use Broadway\EventSourcing\AggregateFactory\PublicConstructorAggregateFactory;
use Broadway\EventStore\EventStore as EventStoreInterface;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use RuntimeException;
use Surfnet\Stepup\Configuration\Configuration;
use Surfnet\Stepup\Configuration\Event\ConfigurationUpdatedEvent;
use Surfnet\Stepup\Configuration\Event\EmailTemplatesUpdatedEvent;
@@ -33,28 +35,30 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\UpdateConfigurationCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\CommandHandler\ConfigurationCommandHandler;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\CommandHandlerTest;
+use function is_string;
final class ConfigurationCommandHandlerTest extends CommandHandlerTest
{
+
/**
* Shorthand for fixed Configuration ID.
*/
- const CID = Configuration::CONFIGURATION_ID;
+ public const CID = Configuration::CONFIGURATION_ID;
/**
* @test
* @group command-handler
*/
- public function configuration_can_be_initialised()
+ public function configuration_can_be_initialised(): void
{
$configuration = [
- 'gateway' => [
+ 'gateway' => [
'identity_providers' => [],
'service_providers' => [],
],
- 'sraa' => [],
+ 'sraa' => [],
'email_templates' => [
- 'confirm_email' => ['en_GB' => ''],
+ 'confirm_email' => ['en_GB' => ''],
'registration_code' => ['en_GB' => ''],
],
];
@@ -70,29 +74,29 @@ public function configuration_can_be_initialised()
* @test
* @group command-handler
*/
- public function configuration_can_be_updated()
+ public function configuration_can_be_updated(): void
{
$configuration1 = [
- 'gateway' => [
+ 'gateway' => [
'identity_providers' => [],
'service_providers' => [],
],
- 'sraa' => [],
+ 'sraa' => [],
'email_templates' => [
- 'confirm_email' => ['en_GB' => ''],
+ 'confirm_email' => ['en_GB' => ''],
'registration_code' => ['en_GB' => ''],
],
];
$configuration2 = [
- 'gateway' => [
+ 'gateway' => [
'identity_providers' => [
[
"entity_id" => "https://entity.tld/id",
"loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- ]
+ ],
],
'service_providers' => [
[
@@ -103,69 +107,70 @@ public function configuration_can_be_updated()
"__default__" => "https://entity.tld/authentication/loa2",
],
"assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
- ]
+ "blacklisted_encryption_algorithms" => [],
+ ],
],
],
- 'sraa' => [
+ 'sraa' => [
'SURFnet bv' => [
[
'name_id' => 'ddfd',
- ]
+ ],
],
],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
];
$this->scenario
->withAggregateId(self::CID)
- ->given(array_merge(
- [$this->createNewConfigurationCreatedEvent()],
- $this->createConfigurationUpdatedEvents($configuration1, null)
- ))
+ ->given(
+ array_merge(
+ [$this->createNewConfigurationCreatedEvent()],
+ $this->createConfigurationUpdatedEvents($configuration1, null),
+ ),
+ )
->when($this->createUpdateCommand($configuration2))
->then($this->createConfigurationUpdatedEvents($configuration2, $configuration1));
}
- protected function createCommandHandler(EventStoreInterface $eventStore, EventBusInterface $eventBus): CommandHandler
- {
+ protected function createCommandHandler(
+ EventStoreInterface $eventStore,
+ EventBusInterface $eventBus,
+ ): CommandHandler {
$aggregateFactory = new PublicConstructorAggregateFactory();
return new ConfigurationCommandHandler(
- new ConfigurationRepository($eventStore, $eventBus, $aggregateFactory)
+ new ConfigurationRepository($eventStore, $eventBus, $aggregateFactory),
);
}
- /**
- * @param array $configuration
- * @return UpdateConfigurationCommand
- */
- private function createUpdateCommand(array $configuration)
+ private function createUpdateCommand(array $configuration): UpdateConfigurationCommand
{
- $command = new UpdateConfigurationCommand();
- $command->configuration = json_encode($configuration);
-
- return $command;
+ $encodedConfiguration = json_encode($configuration);
+ if (!is_string($encodedConfiguration)) {
+ throw new RuntimeException('The configuration could not be json_encoded');
+ }
+ $configuration = new UpdateConfigurationCommand();
+ $configuration->configuration = $encodedConfiguration;
+ return $configuration;
}
/**
* @return NewConfigurationCreatedEvent
*/
- private function createNewConfigurationCreatedEvent()
+ private function createNewConfigurationCreatedEvent(): NewConfigurationCreatedEvent
{
return new NewConfigurationCreatedEvent(self::CID);
}
/**
- * @param array $newConfiguration
- * @param array $oldConfiguration
* @return array
*/
- private function createConfigurationUpdatedEvents(array $newConfiguration, array $oldConfiguration = null)
+ private function createConfigurationUpdatedEvents(array $newConfiguration, array $oldConfiguration = null): array
{
return [
new ConfigurationUpdatedEvent(self::CID, $newConfiguration, $oldConfiguration),
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/CommandHandler/InstitutionConfigurationCommandHandlerTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/CommandHandler/InstitutionConfigurationCommandHandlerTest.php
index e2fa22ee4..24d519d96 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/CommandHandler/InstitutionConfigurationCommandHandlerTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/CommandHandler/InstitutionConfigurationCommandHandlerTest.php
@@ -19,10 +19,11 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Configuration\CommandHandler;
use Broadway\CommandHandling\CommandHandler;
-use Broadway\CommandHandling\CommandHandlerInterface;
use Broadway\EventHandling\EventBus as EventBusInterface;
use Broadway\EventSourcing\AggregateFactory\PublicConstructorAggregateFactory;
use Broadway\EventStore\EventStore as EventStoreInterface;
+use Broadway\Repository\AggregateNotFoundException;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Surfnet\Stepup\Configuration\Event\AllowedSecondFactorListUpdatedEvent;
use Surfnet\Stepup\Configuration\Event\InstitutionConfigurationRemovedEvent;
use Surfnet\Stepup\Configuration\Event\NewInstitutionConfigurationCreatedEvent;
@@ -41,6 +42,7 @@
use Surfnet\Stepup\Configuration\Value\AllowedSecondFactorList;
use Surfnet\Stepup\Configuration\Value\ContactInformation;
use Surfnet\Stepup\Configuration\Value\Institution;
+use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
use Surfnet\Stepup\Configuration\Value\Location;
@@ -52,8 +54,8 @@
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption;
use Surfnet\Stepup\Configuration\Value\SsoOn2faOption;
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption;
-use Surfnet\Stepup\Configuration\Value\InstitutionAuthorizationOption;
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
+use Surfnet\Stepup\Exception\DomainException;
use Surfnet\StepupBundle\Value\SecondFactorType;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\AddRaLocationCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\ChangeRaLocationCommand;
@@ -66,22 +68,23 @@
class InstitutionConfigurationCommandHandlerTest extends CommandHandlerTest
{
+
/**
* @test
* @group command-handler
*/
- public function an_institution_configuration_is_created_when_there_is_none_for_a_given_institution()
+ public function an_institution_configuration_is_created_when_there_is_none_for_a_given_institution(): void
{
- $command = new CreateInstitutionConfigurationCommand();
+ $command = new CreateInstitutionConfigurationCommand();
$command->institution = 'An institution';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $defaultUseRaLocationsOption = UseRaLocationsOption::getDefault();
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $defaultUseRaLocationsOption = UseRaLocationsOption::getDefault();
$defaultShowRaaContactInformationOption = ShowRaaContactInformationOption::getDefault();
- $defaultVerifyEmailOption = VerifyEmailOption::getDefault();
- $numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(0);
- $defaultAllowedSecondFactorList = AllowedSecondFactorList::blank();
+ $defaultVerifyEmailOption = VerifyEmailOption::getDefault();
+ $numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(0);
+ $defaultAllowedSecondFactorList = AllowedSecondFactorList::blank();
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -102,27 +105,27 @@ public function an_institution_configuration_is_created_when_there_is_none_for_a
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- $defaultAllowedSecondFactorList
+ $defaultAllowedSecondFactorList,
),
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaOption
+ $useRaOption,
),
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaaOption
+ $useRaaOption,
),
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $selectRaaOption
+ $selectRaaOption,
),
]);
}
@@ -131,19 +134,19 @@ public function an_institution_configuration_is_created_when_there_is_none_for_a
* @test
* @group command-handler
*/
- public function an_institution_configuration_cannot_be_created_when_there_already_is_one_for_a_given_institution()
+ public function an_institution_configuration_cannot_be_created_when_there_already_is_one_for_a_given_institution(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessage('Cannot rebuild InstitutionConfiguration as it has not been destroyed');
- $command = new CreateInstitutionConfigurationCommand();
- $command->institution = 'An institution';
+ $command = new CreateInstitutionConfigurationCommand();
+ $command->institution = 'An institution';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(false);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(false);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(0);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
@@ -164,22 +167,22 @@ public function an_institution_configuration_cannot_be_created_when_there_alread
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaOption
+ $useRaOption,
),
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaaOption
+ $useRaaOption,
),
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $selectRaaOption
+ $selectRaaOption,
),
])
->when($command);
@@ -189,15 +192,15 @@ public function an_institution_configuration_cannot_be_created_when_there_alread
* @test
* @group command-handler
*/
- public function institution_configuration_options_are_not_changed_if_their_given_value_is_not_different_from_their_current_value()
+ public function institution_configuration_options_are_not_changed_if_their_given_value_is_not_different_from_their_current_value(): void
{
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(false);
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(false);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(1);
- $defaultAllowedSecondFactorList = AllowedSecondFactorList::blank();
+ $defaultAllowedSecondFactorList = AllowedSecondFactorList::blank();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
$ssoOn2faOption = SsoOn2faOption::getDefault();
@@ -205,18 +208,18 @@ public function institution_configuration_options_are_not_changed_if_their_given
$useRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa());
$selectRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa());
- $command = new ReconfigureInstitutionConfigurationOptionsCommand();
- $command->institution = $institution->getInstitution();
- $command->useRaLocationsOption = $useRaLocationsOption->isEnabled();
+ $command = new ReconfigureInstitutionConfigurationOptionsCommand();
+ $command->institution = $institution->getInstitution();
+ $command->useRaLocationsOption = $useRaLocationsOption->isEnabled();
$command->showRaaContactInformationOption = $showRaaContactInformationOption->isEnabled();
- $command->verifyEmailOption = $verifyEmailOption->isEnabled();
+ $command->verifyEmailOption = $verifyEmailOption->isEnabled();
$command->selfVetOption = $selfVetOption->isEnabled();
- $command->allowedSecondFactors = $selfAssertedTokensOption->isEnabled();
+ $command->selfAssertedTokensOption = $selfAssertedTokensOption->isEnabled();
$command->numberOfTokensPerIdentityOption = $numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity();
$command->useRaOption = $useRaOption->jsonSerialize();
$command->useRaaOption = $useRaaOption->jsonSerialize();
$command->selectRaaOption = $selectRaaOption->jsonSerialize();
- $command->allowedSecondFactors = [];
+ $command->allowedSecondFactors = [];
$this->scenario
->withAggregateId($institutionConfigurationId)
@@ -230,27 +233,27 @@ public function institution_configuration_options_are_not_changed_if_their_given
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- $defaultAllowedSecondFactorList
+ $defaultAllowedSecondFactorList,
),
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaOption
+ $useRaOption,
),
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaaOption
+ $useRaaOption,
),
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $selectRaaOption
+ $selectRaaOption,
),
])
->when($command)
@@ -261,13 +264,13 @@ public function institution_configuration_options_are_not_changed_if_their_given
* @test
* @group command-handler
*/
- public function use_ra_locations_option_is_changed_if_its_given_value_is_different_from_the_current_value()
+ public function use_ra_locations_option_is_changed_if_its_given_value_is_different_from_the_current_value(): void
{
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(false);
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(false);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(0);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
@@ -277,22 +280,22 @@ public function use_ra_locations_option_is_changed_if_its_given_value_is_differe
$useRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa());
$selectRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa());
- $defaultAllowedSecondFactorList = AllowedSecondFactorList::blank();
+ $defaultAllowedSecondFactorList = AllowedSecondFactorList::blank();
$differentUseRaLocationsOptionValue = true;
- $command = new ReconfigureInstitutionConfigurationOptionsCommand();
- $command->institution = $institution->getInstitution();
- $command->useRaLocationsOption = $differentUseRaLocationsOptionValue;
+ $command = new ReconfigureInstitutionConfigurationOptionsCommand();
+ $command->institution = $institution->getInstitution();
+ $command->useRaLocationsOption = $differentUseRaLocationsOptionValue;
$command->showRaaContactInformationOption = $showRaaContactInformationOption->isEnabled();
- $command->verifyEmailOption = $verifyEmailOption->isEnabled();
+ $command->verifyEmailOption = $verifyEmailOption->isEnabled();
$command->selfVetOption = $selfVetOption->isEnabled();
- $command->allowedSecondFactors = $selfAssertedTokensOption->isEnabled();
+ $command->selfAssertedTokensOption = $selfAssertedTokensOption->isEnabled();
$command->numberOfTokensPerIdentityOption = $numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity();
$command->useRaOption = $useRaOption->jsonSerialize();
$command->useRaaOption = $useRaaOption->jsonSerialize();
$command->selectRaaOption = $selectRaaOption->jsonSerialize();
- $command->allowedSecondFactors = [];
+ $command->allowedSecondFactors = [];
$this->scenario
->withAggregateId($institutionConfigurationId)
@@ -306,27 +309,27 @@ public function use_ra_locations_option_is_changed_if_its_given_value_is_differe
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- $defaultAllowedSecondFactorList
+ $defaultAllowedSecondFactorList,
),
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaOption
+ $useRaOption,
),
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaaOption
+ $useRaaOption,
),
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $selectRaaOption
+ $selectRaaOption,
),
])
->when($command)
@@ -334,8 +337,8 @@ public function use_ra_locations_option_is_changed_if_its_given_value_is_differe
new UseRaLocationsOptionChangedEvent(
$institutionConfigurationId,
$institution,
- new UseRaLocationsOption($differentUseRaLocationsOptionValue)
- )
+ new UseRaLocationsOption($differentUseRaLocationsOptionValue),
+ ),
]);
}
@@ -343,13 +346,13 @@ public function use_ra_locations_option_is_changed_if_its_given_value_is_differe
* @test
* @group command-handler
*/
- public function show_raa_contact_information_option_is_changed_if_its_given_value_is_different_from_the_current_value()
+ public function show_raa_contact_information_option_is_changed_if_its_given_value_is_different_from_the_current_value(): void
{
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(0);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
@@ -358,19 +361,19 @@ public function show_raa_contact_information_option_is_changed_if_its_given_valu
$useRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::useRaa());
$selectRaaOption = InstitutionAuthorizationOption::getDefault(InstitutionRole::selectRaa());
- $defaultAllowedSecondFactorList = AllowedSecondFactorList::blank();
+ $defaultAllowedSecondFactorList = AllowedSecondFactorList::blank();
$differentShowRaaContactInformationOptionValue = false;
- $command = new ReconfigureInstitutionConfigurationOptionsCommand();
- $command->institution = $institution->getInstitution();
+ $command = new ReconfigureInstitutionConfigurationOptionsCommand();
+ $command->institution = $institution->getInstitution();
$command->showRaaContactInformationOption = $differentShowRaaContactInformationOptionValue;
- $command->useRaLocationsOption = $useRaLocationsOption->isEnabled();
- $command->verifyEmailOption = $verifyEmailOption->isEnabled();
+ $command->useRaLocationsOption = $useRaLocationsOption->isEnabled();
+ $command->verifyEmailOption = $verifyEmailOption->isEnabled();
$command->selfVetOption = $selfVetOption->isEnabled();
- $command->allowedSecondFactors = $selfAssertedTokensOption->isEnabled();
+ $command->selfAssertedTokensOption = $selfAssertedTokensOption->isEnabled();
$command->numberOfTokensPerIdentityOption = $numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity();
- $command->allowedSecondFactors = [];
+ $command->allowedSecondFactors = [];
$this->scenario
->withAggregateId($institutionConfigurationId)
@@ -384,27 +387,27 @@ public function show_raa_contact_information_option_is_changed_if_its_given_valu
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- $defaultAllowedSecondFactorList
+ $defaultAllowedSecondFactorList,
),
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaOption
+ $useRaOption,
),
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaaOption
+ $useRaaOption,
),
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $selectRaaOption
+ $selectRaaOption,
),
])
->when($command)
@@ -412,8 +415,8 @@ public function show_raa_contact_information_option_is_changed_if_its_given_valu
new ShowRaaContactInformationOptionChangedEvent(
$institutionConfigurationId,
$institution,
- new ShowRaaContactInformationOption($differentShowRaaContactInformationOptionValue)
- )
+ new ShowRaaContactInformationOption($differentShowRaaContactInformationOptionValue),
+ ),
]);
}
@@ -421,13 +424,13 @@ public function show_raa_contact_information_option_is_changed_if_its_given_valu
* @test
* @group command-handler
*/
- public function allowed_second_factor_list_is_changed_if_its_values_are_different_than_the_current_list()
+ public function allowed_second_factor_list_is_changed_if_its_values_are_different_than_the_current_list(): void
{
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = UseRaLocationsOption::getDefault();
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = UseRaLocationsOption::getDefault();
$showRaaContactInformationOption = ShowRaaContactInformationOption::getDefault();
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(0);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
@@ -442,16 +445,16 @@ public function allowed_second_factor_list_is_changed_if_its_values_are_differen
$secondFactorsToAllow = ['sms', 'yubikey'];
$updatedAllowedSecondFactorList = AllowedSecondFactorList::ofTypes([
new SecondFactorType($secondFactorsToAllow[0]),
- new SecondFactorType($secondFactorsToAllow[1])
+ new SecondFactorType($secondFactorsToAllow[1]),
]);
$command = new ReconfigureInstitutionConfigurationOptionsCommand();
$command->institution = $institution->getInstitution();
$command->useRaLocationsOption = $useRaLocationsOption->isEnabled();
$command->showRaaContactInformationOption = $showRaaContactInformationOption->isEnabled();
- $command->verifyEmailOption = $verifyEmailOption->isEnabled();
+ $command->verifyEmailOption = $verifyEmailOption->isEnabled();
$command->selfVetOption = $selfVetOption->isEnabled();
- $command->allowedSecondFactors = $selfAssertedTokensOption->isEnabled();
+ $command->selfAssertedTokensOption = $selfAssertedTokensOption->isEnabled();
$command->numberOfTokensPerIdentityOption = $numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity();
$command->allowedSecondFactors = $secondFactorsToAllow;
@@ -467,27 +470,27 @@ public function allowed_second_factor_list_is_changed_if_its_values_are_differen
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- $originalAllowedSecondFactorList
+ $originalAllowedSecondFactorList,
),
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaOption
+ $useRaOption,
),
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaaOption
+ $useRaaOption,
),
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $selectRaaOption
+ $selectRaaOption,
),
])
->when($command)
@@ -495,7 +498,7 @@ public function allowed_second_factor_list_is_changed_if_its_values_are_differen
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- $updatedAllowedSecondFactorList
+ $updatedAllowedSecondFactorList,
),
]);
}
@@ -504,19 +507,19 @@ public function allowed_second_factor_list_is_changed_if_its_values_are_differen
* @test
* @group command-handler
*/
- public function allowed_second_factor_list_is_not_changed_if_its_values_are_the_same_as_the_current_list()
+ public function allowed_second_factor_list_is_not_changed_if_its_values_are_the_same_as_the_current_list(): void
{
$secondFactorsToAllow = ['sms', 'yubikey'];
$allowedSecondFactorList = AllowedSecondFactorList::ofTypes([
new SecondFactorType($secondFactorsToAllow[0]),
- new SecondFactorType($secondFactorsToAllow[1])
+ new SecondFactorType($secondFactorsToAllow[1]),
]);
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = UseRaLocationsOption::getDefault();
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = UseRaLocationsOption::getDefault();
$showRaaContactInformationOption = ShowRaaContactInformationOption::getDefault();
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(0);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
@@ -531,9 +534,9 @@ public function allowed_second_factor_list_is_not_changed_if_its_values_are_the_
$command->institution = $institution->getInstitution();
$command->useRaLocationsOption = $useRaLocationsOption->isEnabled();
$command->showRaaContactInformationOption = $showRaaContactInformationOption->isEnabled();
- $command->verifyEmailOption = $verifyEmailOption->isEnabled();
+ $command->verifyEmailOption = $verifyEmailOption->isEnabled();
$command->selfVetOption = $selfVetOption->isEnabled();
- $command->allowedSecondFactors = $selfAssertedTokensOption->isEnabled();
+ $command->selfAssertedTokensOption = $selfAssertedTokensOption->isEnabled();
$command->numberOfTokensPerIdentityOption = $numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity();
$command->allowedSecondFactors = $secondFactorsToAllow;
@@ -549,28 +552,28 @@ public function allowed_second_factor_list_is_not_changed_if_its_values_are_the_
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaOption
+ $useRaOption,
),
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaaOption
+ $useRaaOption,
),
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $selectRaaOption
+ $selectRaaOption,
),
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- $originalAllowedSecondFactorList
- )
+ $originalAllowedSecondFactorList,
+ ),
])
->when($command)
->then([]);
@@ -580,21 +583,21 @@ public function allowed_second_factor_list_is_not_changed_if_its_values_are_the_
* @test
* @group command-handler
*/
- public function an_ra_location_can_be_added_to_an_existing_institution_configuration()
+ public function an_ra_location_can_be_added_to_an_existing_institution_configuration(): void
{
- $command = new AddRaLocationCommand();
- $command->raLocationId = self::uuid();
- $command->institution = 'An institution';
- $command->raLocationName = 'An RA location name';
- $command->location = 'A location';
+ $command = new AddRaLocationCommand();
+ $command->raLocationId = self::uuid();
+ $command->institution = 'An institution';
+ $command->raLocationName = 'An RA location name';
+ $command->location = 'A location';
$command->contactInformation = 'Some contact information';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(0);
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -611,7 +614,7 @@ public function an_ra_location_can_be_added_to_an_existing_institution_configura
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
])
->when($command)
@@ -622,8 +625,8 @@ public function an_ra_location_can_be_added_to_an_existing_institution_configura
new RaLocationId($command->raLocationId),
new RaLocationName($command->raLocationName),
new Location($command->location),
- new ContactInformation($command->contactInformation)
- )
+ new ContactInformation($command->contactInformation),
+ ),
]);
}
@@ -631,23 +634,23 @@ public function an_ra_location_can_be_added_to_an_existing_institution_configura
* @test
* @group command-handler
*/
- public function the_same_ra_location_cannot_be_added_twice()
+ public function the_same_ra_location_cannot_be_added_twice(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessage('already present');
- $command = new AddRaLocationCommand();
- $command->raLocationId = self::uuid();
- $command->institution = 'An institution';
- $command->raLocationName = 'An RA location name';
- $command->location = 'A location';
+ $command = new AddRaLocationCommand();
+ $command->raLocationId = self::uuid();
+ $command->institution = 'An institution';
+ $command->raLocationName = 'An RA location name';
+ $command->location = 'A location';
$command->contactInformation = 'Some contact information';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -665,7 +668,7 @@ public function the_same_ra_location_cannot_be_added_twice()
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new RaLocationAddedEvent(
$institutionConfigurationId,
@@ -673,8 +676,8 @@ public function the_same_ra_location_cannot_be_added_twice()
new RaLocationId($command->raLocationId),
new RaLocationName($command->raLocationName),
new Location($command->location),
- new ContactInformation($command->contactInformation)
- )
+ new ContactInformation($command->contactInformation),
+ ),
])
->when($command);
}
@@ -683,22 +686,22 @@ public function the_same_ra_location_cannot_be_added_twice()
* @test
* @group command-handler
*/
- public function an_ra_location_can_be_renamed()
+ public function an_ra_location_can_be_renamed(): void
{
$originalRaLocationName = new RaLocationName('An old RA location name');
- $command = new ChangeRaLocationCommand();
- $command->raLocationId = self::uuid();
- $command->institution = 'An institution';
- $command->raLocationName = 'An RA location name';
- $command->location = 'A location';
+ $command = new ChangeRaLocationCommand();
+ $command->raLocationId = self::uuid();
+ $command->institution = 'An institution';
+ $command->raLocationName = 'An RA location name';
+ $command->location = 'A location';
$command->contactInformation = 'Some contact information';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -716,7 +719,7 @@ public function an_ra_location_can_be_renamed()
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new RaLocationAddedEvent(
$institutionConfigurationId,
@@ -724,16 +727,16 @@ public function an_ra_location_can_be_renamed()
new RaLocationId($command->raLocationId),
$originalRaLocationName,
new Location($command->location),
- new ContactInformation($command->contactInformation)
- )
+ new ContactInformation($command->contactInformation),
+ ),
])
->when($command)
->then([
new RaLocationRenamedEvent(
$institutionConfigurationId,
new RaLocationId($command->raLocationId),
- new RaLocationName($command->raLocationName)
- )
+ new RaLocationName($command->raLocationName),
+ ),
]);
}
@@ -741,23 +744,23 @@ public function an_ra_location_can_be_renamed()
* @test
* @group command-handler
*/
- public function an_ra_location_cannot_be_changed_if_it_is_not_present_within_an_institution_configuration()
+ public function an_ra_location_cannot_be_changed_if_it_is_not_present_within_an_institution_configuration(): void
{
- $this->expectException('Surfnet\Stepup\Exception\DomainException');
+ $this->expectException(DomainException::class);
$this->expectExceptionMessage('not present');
- $command = new ChangeRaLocationCommand();
- $command->raLocationId = self::uuid();
- $command->institution = 'An institution';
- $command->raLocationName = 'An RA location name';
- $command->location = 'A location';
+ $command = new ChangeRaLocationCommand();
+ $command->raLocationId = self::uuid();
+ $command->institution = 'An institution';
+ $command->raLocationName = 'An RA location name';
+ $command->location = 'A location';
$command->contactInformation = 'Some contact information';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -775,8 +778,8 @@ public function an_ra_location_cannot_be_changed_if_it_is_not_present_within_an_
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
- )
+ $selfAssertedTokensOption,
+ ),
])
->when($command);
}
@@ -785,23 +788,23 @@ public function an_ra_location_cannot_be_changed_if_it_is_not_present_within_an_
* @test
* @group command-handler
*/
- public function an_ra_location_cannot_be_changed_if_its_institution_configuration_cannot_be_found()
+ public function an_ra_location_cannot_be_changed_if_its_institution_configuration_cannot_be_found(): void
{
- $this->expectException(\Broadway\Repository\AggregateNotFoundException::class);
+ $this->expectException(AggregateNotFoundException::class);
$this->expectExceptionMessage('not found');
- $command = new ChangeRaLocationCommand();
- $command->raLocationId = self::uuid();
- $command->institution = 'An institution';
- $command->raLocationName = 'An RA location name';
- $command->location = 'A location';
+ $command = new ChangeRaLocationCommand();
+ $command->raLocationId = self::uuid();
+ $command->institution = 'An institution';
+ $command->raLocationName = 'An RA location name';
+ $command->location = 'A location';
$command->contactInformation = 'Some contact information';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -819,8 +822,8 @@ public function an_ra_location_cannot_be_changed_if_its_institution_configuratio
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
- )
+ $selfAssertedTokensOption,
+ ),
])
->when($command);
}
@@ -830,22 +833,22 @@ public function an_ra_location_cannot_be_changed_if_its_institution_configuratio
* @group command-handler
* @group institution-configuration
*/
- public function an_ra_location_can_be_relocated()
+ public function an_ra_location_can_be_relocated(): void
{
- $originalLocation= new Location('An old location');
+ $originalLocation = new Location('An old location');
- $command = new ChangeRaLocationCommand();
- $command->raLocationId = self::uuid();
- $command->institution = 'An institution';
- $command->raLocationName = 'An RA location name';
- $command->location = 'A location';
+ $command = new ChangeRaLocationCommand();
+ $command->raLocationId = self::uuid();
+ $command->institution = 'An institution';
+ $command->raLocationName = 'An RA location name';
+ $command->location = 'A location';
$command->contactInformation = 'Some contact information';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -863,7 +866,7 @@ public function an_ra_location_can_be_relocated()
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new RaLocationAddedEvent(
$institutionConfigurationId,
@@ -871,16 +874,16 @@ public function an_ra_location_can_be_relocated()
new RaLocationId($command->raLocationId),
new RaLocationName($command->raLocationName),
$originalLocation,
- new ContactInformation($command->contactInformation)
- )
+ new ContactInformation($command->contactInformation),
+ ),
])
->when($command)
->then([
new RaLocationRelocatedEvent(
$institutionConfigurationId,
new RaLocationId($command->raLocationId),
- new Location($command->location)
- )
+ new Location($command->location),
+ ),
]);
}
@@ -889,22 +892,22 @@ public function an_ra_location_can_be_relocated()
* @group command-handler
* @group institution-configuration
*/
- public function an_ra_locations_contact_information_can_be_changed()
+ public function an_ra_locations_contact_information_can_be_changed(): void
{
- $originalContactInformation= new ContactInformation('Old contact information');
+ $originalContactInformation = new ContactInformation('Old contact information');
- $command = new ChangeRaLocationCommand();
- $command->raLocationId = self::uuid();
- $command->institution = 'An institution';
- $command->raLocationName = 'An RA location name';
- $command->location = 'A location';
+ $command = new ChangeRaLocationCommand();
+ $command->raLocationId = self::uuid();
+ $command->institution = 'An institution';
+ $command->raLocationName = 'An RA location name';
+ $command->location = 'A location';
$command->contactInformation = 'Some contact information';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -922,7 +925,7 @@ public function an_ra_locations_contact_information_can_be_changed()
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new RaLocationAddedEvent(
$institutionConfigurationId,
@@ -930,31 +933,31 @@ public function an_ra_locations_contact_information_can_be_changed()
new RaLocationId($command->raLocationId),
new RaLocationName($command->raLocationName),
new Location($command->location),
- $originalContactInformation
- )
+ $originalContactInformation,
+ ),
])
->when($command)
->then([
new RaLocationContactInformationChangedEvent(
$institutionConfigurationId,
new RaLocationId($command->raLocationId),
- new ContactInformation($command->contactInformation)
- )
+ new ContactInformation($command->contactInformation),
+ ),
]);
}
-
+
/**
* @test
* @group command-handler
* @group institution-configuration
*/
- public function the_self_vet_option_can_be_changed()
+ public function the_self_vet_option_can_be_changed(): void
{
- $institution = new Institution('Institution');
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = UseRaLocationsOption::getDefault();
+ $institution = new Institution('Institution');
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = UseRaLocationsOption::getDefault();
$showRaaContactInformationOption = ShowRaaContactInformationOption::getDefault();
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(0);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
@@ -969,9 +972,9 @@ public function the_self_vet_option_can_be_changed()
$command->institution = $institution->getInstitution();
$command->useRaLocationsOption = $useRaLocationsOption->isEnabled();
$command->showRaaContactInformationOption = $showRaaContactInformationOption->isEnabled();
- $command->verifyEmailOption = $verifyEmailOption->isEnabled();
+ $command->verifyEmailOption = $verifyEmailOption->isEnabled();
$command->selfVetOption = $newSelfVetOption->isEnabled();
- $command->allowedSecondFactors = $selfAssertedTokensOption->isEnabled();
+ $command->selfAssertedTokensOption = $selfAssertedTokensOption->isEnabled();
$command->numberOfTokensPerIdentityOption = $numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity();
$command->allowedSecondFactors = [];
@@ -987,36 +990,36 @@ public function the_self_vet_option_can_be_changed()
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
-
+
])
->when($command)
->then([
new UseRaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaOption
+ $useRaOption,
),
new UseRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $useRaaOption
+ $useRaaOption,
),
new SelectRaaOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $selectRaaOption
+ $selectRaaOption,
),
new AllowedSecondFactorListUpdatedEvent(
$institutionConfigurationId,
$institution,
- $defaultAllowedSecondFactorList
+ $defaultAllowedSecondFactorList,
),
new SelfVetOptionChangedEvent(
$institutionConfigurationId,
$institution,
- $newSelfVetOption
+ $newSelfVetOption,
),
]);
}
@@ -1026,20 +1029,20 @@ public function the_self_vet_option_can_be_changed()
* @group command-handler
* @group institution-configuration
*/
- public function an_ra_location_cannot_be_removed_if_its_institution_configuration_cannot_be_found()
+ public function an_ra_location_cannot_be_removed_if_its_institution_configuration_cannot_be_found(): void
{
- $this->expectException(\Broadway\Repository\AggregateNotFoundException::class);
+ $this->expectException(AggregateNotFoundException::class);
$this->expectExceptionMessage('not found');
- $command = new RemoveRaLocationCommand();
- $command->raLocationId = self::uuid();
- $command->institution = 'An institution';
+ $command = new RemoveRaLocationCommand();
+ $command->raLocationId = self::uuid();
+ $command->institution = 'An institution';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -1057,8 +1060,8 @@ public function an_ra_location_cannot_be_removed_if_its_institution_configuratio
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
- )
+ $selfAssertedTokensOption,
+ ),
])
->when($command);
}
@@ -1068,20 +1071,20 @@ public function an_ra_location_cannot_be_removed_if_its_institution_configuratio
* @group command-handler
* @group institution-configuration
*/
- public function an_ra_location_cannot_be_removed_if_it_is_not_present_within_an_institution_configuration()
+ public function an_ra_location_cannot_be_removed_if_it_is_not_present_within_an_institution_configuration(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessage('not present');
- $command = new RemoveRaLocationCommand();
- $command->raLocationId = self::uuid();
- $command->institution = 'An institution';
+ $command = new RemoveRaLocationCommand();
+ $command->raLocationId = self::uuid();
+ $command->institution = 'An institution';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -1099,8 +1102,8 @@ public function an_ra_location_cannot_be_removed_if_it_is_not_present_within_an_
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
- )
+ $selfAssertedTokensOption,
+ ),
])
->when($command);
}
@@ -1110,17 +1113,17 @@ public function an_ra_location_cannot_be_removed_if_it_is_not_present_within_an_
* @group command-handler
* @group institution-configuration
*/
- public function an_ra_location_can_be_removed()
+ public function an_ra_location_can_be_removed(): void
{
- $command = new RemoveRaLocationCommand();
- $command->raLocationId = self::uuid();
- $command->institution = 'An institution';
+ $command = new RemoveRaLocationCommand();
+ $command->raLocationId = self::uuid();
+ $command->institution = 'An institution';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::normalizedFrom($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -1138,7 +1141,7 @@ public function an_ra_location_can_be_removed()
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
+ $selfAssertedTokensOption,
),
new RaLocationAddedEvent(
$institutionConfigurationId,
@@ -1146,15 +1149,15 @@ public function an_ra_location_can_be_removed()
new RaLocationId($command->raLocationId),
new RaLocationName('A location name'),
new Location('A location'),
- new ContactInformation('Some contact information')
- )
+ new ContactInformation('Some contact information'),
+ ),
])
->when($command)
->then([
new RaLocationRemovedEvent(
$institutionConfigurationId,
- new RaLocationId($command->raLocationId)
- )
+ new RaLocationId($command->raLocationId),
+ ),
]);
}
@@ -1163,16 +1166,16 @@ public function an_ra_location_can_be_removed()
* @group command-handler
* @group institution-configuration
*/
- public function an_institution_configuration_with_unnormalized_institution_configuration_id_can_be_removed()
+ public function an_institution_configuration_with_unnormalized_institution_configuration_id_can_be_removed(): void
{
- $command = new RemoveInstitutionConfigurationByUnnormalizedIdCommand();
- $command->institution = 'Babelfish Inc.';
+ $command = new RemoveInstitutionConfigurationByUnnormalizedIdCommand();
+ $command->institution = 'Babelfish Inc.';
- $institution = new Institution($command->institution);
- $institutionConfigurationId = InstitutionConfigurationId::from($institution);
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution($command->institution);
+ $institutionConfigurationId = InstitutionConfigurationId::from($institution);
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(true);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$ssoOn2faOption = SsoOn2faOption::getDefault();
$selfVetOption = SelfVetOption::getDefault();
$selfAssertedTokensOption = SelfAssertedTokensOption::getDefault();
@@ -1191,18 +1194,18 @@ public function an_institution_configuration_with_unnormalized_institution_confi
$numberOfTokensPerIdentityOption,
$ssoOn2faOption,
$selfVetOption,
- $selfAssertedTokensOption
- )
- ]
+ $selfAssertedTokensOption,
+ ),
+ ],
)
->when($command)
->then(
[
new InstitutionConfigurationRemovedEvent(
$institutionConfigurationId,
- $institution
- )
- ]
+ $institution,
+ ),
+ ],
);
}
@@ -1214,12 +1217,14 @@ public function an_institution_configuration_with_unnormalized_institution_confi
*
* @return CommandHandler
*/
- protected function createCommandHandler(EventStoreInterface $eventStore, EventBusInterface $eventBus): CommandHandler
- {
+ protected function createCommandHandler(
+ EventStoreInterface $eventStore,
+ EventBusInterface $eventBus,
+ ): CommandHandler {
$aggregateFactory = new PublicConstructorAggregateFactory();
return new InstitutionConfigurationCommandHandler(
- new InstitutionConfigurationRepository($eventStore, $eventBus, $aggregateFactory)
+ new InstitutionConfigurationRepository($eventStore, $eventBus, $aggregateFactory),
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/Processor/InstitutionConfigurationProcessorTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/Processor/InstitutionConfigurationProcessorTest.php
index 5a67d02ea..f73c5211f 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/Processor/InstitutionConfigurationProcessorTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Configuration/Processor/InstitutionConfigurationProcessorTest.php
@@ -19,8 +19,9 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Configuration\Processor;
use Mockery;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase as TestCase;
-use Surfnet\Stepup\Configuration\Value\Institution as ConfigurationInstitution;
use Surfnet\Stepup\Identity\Collection\InstitutionCollection;
use Surfnet\Stepup\Identity\Event\IdentityCreatedEvent;
use Surfnet\Stepup\Identity\Event\InstitutionsAddedToWhitelistEvent;
@@ -40,11 +41,10 @@
class InstitutionConfigurationProcessorTest extends TestCase
{
- private $pipelineMock;
+ use MockeryPHPUnitIntegration;
+
+ private Pipeline&MockInterface $pipelineMock;
- /**
- * @return Mockery\MockInterface
- */
public function setUp(): void
{
$this->pipelineMock = Mockery::mock(Pipeline::class);
@@ -55,16 +55,16 @@ public function setUp(): void
* @group processor
* @group institution-configuration
*/
- public function a_create_institution_configuration_command_is_processed_when_an_identity_was_created_with_a_non_configured_institution()
+ public function a_create_institution_configuration_command_is_processed_when_an_identity_was_created_with_a_non_configured_institution(): void
{
- $expectedInstitution = 'institution';
+ $expectedInstitution = 'institution';
$identityCreatedEvent = new IdentityCreatedEvent(
new IdentityId('Id'),
new Institution($expectedInstitution),
new NameId('Name Id'),
new CommonName('Common name'),
new Email('test@email.test'),
- new Locale('Locale')
+ new Locale('Locale'),
);
$repositoryMock = Mockery::mock(ConfiguredInstitutionRepository::class);
@@ -79,7 +79,7 @@ public function a_create_institution_configuration_command_is_processed_when_an_
$institutionConfigurationProcessor = new InstitutionConfigurationProcessor(
$repositoryMock,
- $this->getContainerMock()
+ $this->pipelineMock,
);
$institutionConfigurationProcessor->handleIdentityCreatedEvent($identityCreatedEvent);
@@ -91,7 +91,7 @@ public function a_create_institution_configuration_command_is_processed_when_an_
* @group processor
* @group institution-configuration
*/
- public function no_create_institution_configuration_command_is_processed_when_an_identity_was_created_with_an_already_configured_institution()
+ public function no_create_institution_configuration_command_is_processed_when_an_identity_was_created_with_an_already_configured_institution(): void
{
$identityCreatedEvent = new IdentityCreatedEvent(
new IdentityId('Id'),
@@ -99,7 +99,7 @@ public function no_create_institution_configuration_command_is_processed_when_an
new NameId('Name Id'),
new CommonName('Common name'),
new Email('test@email.test'),
- new Locale('Locale')
+ new Locale('Locale'),
);
$repositoryMock = Mockery::mock(ConfiguredInstitutionRepository::class);
@@ -108,12 +108,11 @@ public function no_create_institution_configuration_command_is_processed_when_an
->andReturn(true);
$this->pipelineMock
- ->shouldReceive('process')
- ->never();
+ ->shouldNotHaveReceived('process');
$institutionConfigurationProcessor = new InstitutionConfigurationProcessor(
$repositoryMock,
- $this->getContainerMock()
+ $this->pipelineMock,
);
$institutionConfigurationProcessor->handleIdentityCreatedEvent($identityCreatedEvent);
@@ -125,9 +124,9 @@ public function no_create_institution_configuration_command_is_processed_when_an
* @group processor
* @group institution-configuration
*/
- public function create_institution_configuration_commands_are_processed_when_a_whitelist_was_created_containing_non_configured_institutions()
+ public function create_institution_configuration_commands_are_processed_when_a_whitelist_was_created_containing_non_configured_institutions(): void
{
- $firstInstitution = 'first institution';
+ $firstInstitution = 'first institution';
$secondInstitution = 'second institution';
$whitelistCreatedEvent = new WhitelistCreatedEvent(
@@ -135,8 +134,8 @@ public function create_institution_configuration_commands_are_processed_when_a_w
[
new Institution($firstInstitution),
new Institution($secondInstitution),
- ]
- )
+ ],
+ ),
);
$repositoryMock = Mockery::mock(ConfiguredInstitutionRepository::class);
@@ -154,7 +153,7 @@ public function create_institution_configuration_commands_are_processed_when_a_w
$institutionConfigurationProcessor = new InstitutionConfigurationProcessor(
$repositoryMock,
- $this->getContainerMock()
+ $this->pipelineMock,
);
$institutionConfigurationProcessor->handleWhitelistCreatedEvent($whitelistCreatedEvent);
@@ -166,18 +165,18 @@ public function create_institution_configuration_commands_are_processed_when_a_w
* @group processor
* @group institution-configuration
*/
- public function no_create_institution_configuration_command_is_processed_for_an_already_configured_institution_when_a_whitelist_was_created()
+ public function no_create_institution_configuration_command_is_processed_for_an_already_configured_institution_when_a_whitelist_was_created(): void
{
$alreadyPresentInstitution = 'already present';
- $newInstitution = 'new';
+ $newInstitution = 'new';
$whitelistCreatedEvent = new WhitelistCreatedEvent(
new InstitutionCollection(
[
new Institution($alreadyPresentInstitution),
new Institution($newInstitution),
- ]
- )
+ ],
+ ),
);
$repositoryMock = Mockery::mock(ConfiguredInstitutionRepository::class);
@@ -199,7 +198,7 @@ public function no_create_institution_configuration_command_is_processed_for_an_
$institutionConfigurationProcessor = new InstitutionConfigurationProcessor(
$repositoryMock,
- $this->getContainerMock()
+ $this->pipelineMock,
);
$institutionConfigurationProcessor->handleWhitelistCreatedEvent($whitelistCreatedEvent);
@@ -211,9 +210,9 @@ public function no_create_institution_configuration_command_is_processed_for_an_
* @group processor
* @group institution-configuration
*/
- public function create_institution_configuration_commands_are_created_when_a_whitelist_was_replaced_containing_non_configured_institutions()
+ public function create_institution_configuration_commands_are_created_when_a_whitelist_was_replaced_containing_non_configured_institutions(): void
{
- $firstInstitution = 'first institution';
+ $firstInstitution = 'first institution';
$secondInstitution = 'second institution';
$whitelistReplacedEvent = new WhitelistReplacedEvent(
@@ -221,8 +220,8 @@ public function create_institution_configuration_commands_are_created_when_a_whi
[
new Institution($firstInstitution),
new Institution($secondInstitution),
- ]
- )
+ ],
+ ),
);
$repositoryMock = Mockery::mock(ConfiguredInstitutionRepository::class);
@@ -242,7 +241,7 @@ public function create_institution_configuration_commands_are_created_when_a_whi
$institutionConfigurationProcessor = new InstitutionConfigurationProcessor(
$repositoryMock,
- $this->getContainerMock()
+ $this->pipelineMock,
);
$institutionConfigurationProcessor->handleWhitelistReplacedEvent($whitelistReplacedEvent);
@@ -254,18 +253,18 @@ public function create_institution_configuration_commands_are_created_when_a_whi
* @group processor
* @group institution-configuration
*/
- public function no_create_institution_configuration_command_is_processed_for_an_already_configured_institution_when_a_whitelist_was_replaced()
+ public function no_create_institution_configuration_command_is_processed_for_an_already_configured_institution_when_a_whitelist_was_replaced(): void
{
$alreadyPresentInstitution = 'already present';
- $newInstitution = 'new';
+ $newInstitution = 'new';
$whitelistCreatedEvent = new WhitelistReplacedEvent(
new InstitutionCollection(
[
new Institution($alreadyPresentInstitution),
new Institution($newInstitution),
- ]
- )
+ ],
+ ),
);
$repositoryMock = Mockery::mock(ConfiguredInstitutionRepository::class);
@@ -287,7 +286,7 @@ public function no_create_institution_configuration_command_is_processed_for_an_
$institutionConfigurationProcessor = new InstitutionConfigurationProcessor(
$repositoryMock,
- $this->getContainerMock()
+ $this->pipelineMock,
);
$institutionConfigurationProcessor->handleWhitelistReplacedEvent($whitelistCreatedEvent);
@@ -299,9 +298,9 @@ public function no_create_institution_configuration_command_is_processed_for_an_
* @group processor
* @group institution-configuration
*/
- public function create_institution_configuration_commands_are_created_when_non_configured_institutions_are_added_to_the_whitelist()
+ public function create_institution_configuration_commands_are_created_when_non_configured_institutions_are_added_to_the_whitelist(): void
{
- $firstInstitution = 'first institution';
+ $firstInstitution = 'first institution';
$secondInstitution = 'second institution';
$institutionsAddedToWhitelistEvent = new InstitutionsAddedToWhitelistEvent(
@@ -309,8 +308,8 @@ public function create_institution_configuration_commands_are_created_when_non_c
[
new Institution($firstInstitution),
new Institution($secondInstitution),
- ]
- )
+ ],
+ ),
);
$repositoryMock = Mockery::mock(ConfiguredInstitutionRepository::class);
@@ -330,7 +329,7 @@ public function create_institution_configuration_commands_are_created_when_non_c
$institutionConfigurationProcessor = new InstitutionConfigurationProcessor(
$repositoryMock,
- $this->getContainerMock()
+ $this->pipelineMock,
);
$institutionConfigurationProcessor->handleInstitutionsAddedToWhitelistEvent($institutionsAddedToWhitelistEvent);
@@ -342,18 +341,18 @@ public function create_institution_configuration_commands_are_created_when_non_c
* @group processor
* @group institution-configuration
*/
- public function no_create_institution_configuration_command_is_created_for_an_already_configured_institution_when_institutions_are_added_to_a_whitelist()
+ public function no_create_institution_configuration_command_is_created_for_an_already_configured_institution_when_institutions_are_added_to_a_whitelist(): void
{
$alreadyPresentInstitution = 'already present';
- $newInstitution = 'new';
+ $newInstitution = 'new';
$whitelistCreatedEvent = new InstitutionsAddedToWhitelistEvent(
new InstitutionCollection(
[
new Institution($alreadyPresentInstitution),
new Institution($newInstitution),
- ]
- )
+ ],
+ ),
);
$repositoryMock = Mockery::mock(ConfiguredInstitutionRepository::class);
@@ -375,24 +374,10 @@ public function no_create_institution_configuration_command_is_created_for_an_al
$institutionConfigurationProcessor = new InstitutionConfigurationProcessor(
$repositoryMock,
- $this->getContainerMock()
+ $this->pipelineMock,
);
$institutionConfigurationProcessor->handleInstitutionsAddedToWhitelistEvent($whitelistCreatedEvent);
$this->assertInstanceOf(InstitutionConfigurationProcessor::class, $institutionConfigurationProcessor);
}
-
- /**
- * @return ContainerInterface
- */
- private function getContainerMock()
- {
- $containerMock = Mockery::mock(ContainerInterface::class);
- $containerMock
- ->shouldReceive('get')
- ->with('pipeline')
- ->andReturn($this->pipelineMock);
-
- return $containerMock;
- }
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/DateTimeHelper.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/DateTimeHelper.php
index 3089d4085..42f43d134 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/DateTimeHelper.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/DateTimeHelper.php
@@ -28,9 +28,9 @@ class DateTimeHelper
*
* @param DateTime|null $now
*/
- public static function setCurrentTime(DateTime $now = null)
+ public static function setCurrentTime(DateTime $now = null): void
{
- $nowProperty = new ReflectionProperty('Surfnet\Stepup\DateTime\DateTime', 'now');
+ $nowProperty = new ReflectionProperty(DateTime::class, 'now');
$nowProperty->setAccessible(true);
$nowProperty->setValue($now);
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/DateTimeHelperTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/DateTimeHelperTest.php
index cb0b24f47..888f4b9b9 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/DateTimeHelperTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/DateTimeHelperTest.php
@@ -19,6 +19,7 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests;
use DateTime as CoreDateTime;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
use Surfnet\Stepup\DateTime\DateTime;
@@ -27,11 +28,13 @@
*/
class DateTimeHelperTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group testing
*/
- public function it_mocks_now()
+ public function it_mocks_now(): void
{
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@12345')));
@@ -42,7 +45,7 @@ public function it_mocks_now()
* @test
* @group testing
*/
- public function it_can_be_disabled_in_the_same_process()
+ public function it_can_be_disabled_in_the_same_process(): void
{
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@12345')));
$this->assertEquals(new DateTime(new CoreDateTime('@12345')), DateTime::now());
@@ -57,7 +60,7 @@ public function it_can_be_disabled_in_the_same_process()
* @test
* @group testing
*/
- public function it_works_with_separate_processes()
+ public function it_works_with_separate_processes(): void
{
// The stub value has been removed.
// Deliberately assigned temporary variable due to microsecond precision in PHP 7.1
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/EventHandling/BufferedEventBusTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/EventHandling/BufferedEventBusTest.php
index 19608e97f..b6ef9e995 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/EventHandling/BufferedEventBusTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/EventHandling/BufferedEventBusTest.php
@@ -22,23 +22,28 @@
use Broadway\Domain\DomainEventStream;
use Broadway\Domain\DomainMessage;
use Broadway\Domain\Metadata;
+use Broadway\EventHandling\EventListener;
use Doctrine\ORM\EntityManagerInterface;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
use Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus;
class BufferedEventBusTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group event-handling
*/
- public function it_buffers_events()
+ public function it_buffers_events(): void
{
$event = $this->createDummyDomainMessage(null);
- $listener = m::mock(\Broadway\EventHandling\EventListener::class)
- ->shouldReceive('handle')->never()
- ->getMock();
+ /** @var EventListener&MockInterface $listener */
+ $listener = m::mock(EventListener::class);
+ $listener->shouldNotHaveReceived('handle');
$bus = new BufferedEventBus($this->getDummyEntityManager());
$bus->subscribe($listener);
@@ -53,12 +58,12 @@ public function it_buffers_events()
* @test
* @group event-handling
*/
- public function it_flushes_events()
+ public function it_flushes_events(): void
{
$event = $this->createDummyDomainMessage(null);
- $listener = m::mock(\Broadway\EventHandling\EventListener::class)
- ->shouldReceive('handle')->once()->with($event)
- ->getMock();
+ /** @var EventListener&MockInterface $listener */
+ $listener = m::mock(EventListener::class);
+ $listener->shouldReceive('handle')->once()->with($event);
$bus = new BufferedEventBus($this->getDummyEntityManager());
$bus->subscribe($listener);
@@ -75,12 +80,12 @@ public function it_flushes_events()
* @test
* @group event-handling
*/
- public function flushing_succesfully_empties_the_buffer_to_prevent_flushing_the_same_event_twice()
+ public function flushing_succesfully_empties_the_buffer_to_prevent_flushing_the_same_event_twice(): void
{
- $event = $this->createDummyDomainMessage(null);
- $listener = m::mock(\Broadway\EventHandling\EventListener::class)
- ->shouldReceive('handle')->once()->with($event)
- ->getMock();
+ $event = $this->createDummyDomainMessage(null);
+ /** @var EventListener&MockInterface $listener */
+ $listener = m::mock(EventListener::class);
+ $listener->shouldReceive('handle')->once()->with($event);
$bus = new BufferedEventBus($this->getDummyEntityManager());
$bus->subscribe($listener);
@@ -96,7 +101,7 @@ public function flushing_succesfully_empties_the_buffer_to_prevent_flushing_the_
* @test
* @group event-handling
*/
- public function an_event_caused_by_an_event_in_the_current_buffer_being_flushed_is_buffered_and_flushed_after_events_in_the_current_buffer()
+ public function an_event_caused_by_an_event_in_the_current_buffer_being_flushed_is_buffered_and_flushed_after_events_in_the_current_buffer(): void
{
$bus = new BufferedEventBus($this->getDummyEntityManager());
@@ -106,7 +111,7 @@ public function an_event_caused_by_an_event_in_the_current_buffer_being_flushed_
$listener = new RecordEventsAndPublishToBusOnFirstCallEventListener(
$bus,
- new DomainEventStream([$eventCausedByFirstEvent])
+ new DomainEventStream([$eventCausedByFirstEvent]),
);
$bus->subscribe($listener);
@@ -119,18 +124,13 @@ public function an_event_caused_by_an_event_in_the_current_buffer_being_flushed_
$this->assertEquals($expectedEventSequence, $actualEventSequence);
}
- /**
- * @param mixed $payload
- * @return DomainMessage
- */
- private function createDummyDomainMessage($payload)
+ private function createDummyDomainMessage(?string $payload): DomainMessage
{
return new DomainMessage('1', 0, new Metadata(), $payload, DateTime::fromString('1970-01-01H00:00:00.000'));
}
- private function getDummyEntityManager()
+ private function getDummyEntityManager(): EntityManagerInterface&MockInterface
{
return m::mock(EntityManagerInterface::class)->shouldIgnoreMissing(true);
}
}
-
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/EventHandling/RecordEventsAndPublishToBusOnFirstCallEventListener.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/EventHandling/RecordEventsAndPublishToBusOnFirstCallEventListener.php
index 075c13374..5d3740246 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/EventHandling/RecordEventsAndPublishToBusOnFirstCallEventListener.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/EventHandling/RecordEventsAndPublishToBusOnFirstCallEventListener.php
@@ -21,38 +21,23 @@
use Broadway\Domain\DomainEventStream;
use Broadway\Domain\DomainMessage;
use Broadway\EventHandling\EventListener as EventListenerInterface;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus;
class RecordEventsAndPublishToBusOnFirstCallEventListener implements EventListenerInterface
{
- /**
- * @var bool
- */
- private $firstEventHandled = false;
-
- /**
- * @var BufferedEventBus
- */
- private $eventBus;
-
- /**
- * @var DomainEventStream
- */
- private $toPublish;
+ use MockeryPHPUnitIntegration;
+ private bool $firstEventHandled = false;
/**
* @var DomainMessage[]
*/
- private $recordedEvents = [];
+ private array $recordedEvents = [];
- /**
- * @param BufferedEventBus $eventBus
- * @param DomainEventStream $toPublish
- */
- public function __construct(BufferedEventBus $eventBus, DomainEventStream $toPublish)
- {
- $this->eventBus = $eventBus;
- $this->toPublish = $toPublish;
+ public function __construct(
+ private readonly BufferedEventBus $eventBus,
+ private readonly DomainEventStream $toPublish,
+ ) {
}
/**
@@ -71,7 +56,7 @@ public function handle(DomainMessage $domainMessage): void
/**
* @return DomainMessage[]
*/
- public function getRecordedEvents()
+ public function getRecordedEvents(): array
{
return $this->recordedEvents;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerMoveTokenTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerMoveTokenTest.php
index fb5d83d82..14ed8ae17 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerMoveTokenTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerMoveTokenTest.php
@@ -23,6 +23,7 @@
use Broadway\EventSourcing\AggregateFactory\PublicConstructorAggregateFactory;
use Broadway\EventStore\EventStore as EventStoreInterface;
use Mockery as m;
+use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Surfnet\Stepup\Configuration\Value\AllowedSecondFactorList;
use Surfnet\Stepup\DateTime\DateTime;
@@ -69,27 +70,15 @@
*/
class IdentityCommandHandlerMoveTokenTest extends CommandHandlerTest
{
- private static $window = 3600;
+ private static int $window = 3600;
- /**
- * @var AllowedSecondFactorListService|m\MockInterface
- */
- private $allowedSecondFactorListServiceMock;
+ private AllowedSecondFactorListService&MockInterface $allowedSecondFactorListServiceMock;
- /**
- * @var LoaResolutionService
- */
- private $loaResolutionService;
+ private LoaResolutionService&MockInterface $loaResolutionService;
- /**
- * @var m\Mock|InstitutionConfigurationOptionsService
- */
- private $configService;
+ private InstitutionConfigurationOptionsService&MockInterface $configService;
- /**
- * @var IdentityProjectionRepository|m\MockInterface
- */
- private $identityProjectionRepository;
+ private IdentityProjectionRepository&MockInterface $identityProjectionRepository;
public function setUp(): void
@@ -100,8 +89,10 @@ public function setUp(): void
parent::setUp();
}
- protected function createCommandHandler(EventStoreInterface $eventStore, EventBusInterface $eventBus): CommandHandler
- {
+ protected function createCommandHandler(
+ EventStoreInterface $eventStore,
+ EventBusInterface $eventBus,
+ ): CommandHandler {
$aggregateFactory = new PublicConstructorAggregateFactory();
$this->identityProjectionRepository = m::mock(IdentityProjectionRepository::class);
$secondFactorTypeService = m::mock(SecondFactorTypeService::class);
@@ -118,7 +109,7 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
$eventBus,
$aggregateFactory,
m::mock(UserDataFilterInterface::class),
- $logger
+ $logger,
),
$this->identityProjectionRepository,
ConfigurableSettings::create(self::$window, ['nl_NL', 'en_GB']),
@@ -128,7 +119,7 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
$this->configService,
$this->loaResolutionService,
m::mock(RecoveryTokenSecretHelper::class),
- $registrationMailService
+ $registrationMailService,
);
}
@@ -136,7 +127,7 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
* @group command-handler
* @runInSeparateProcess
*/
- public function test_a_second_factor_can_be_moved()
+ public function test_a_second_factor_can_be_moved(): void
{
$this->setUpInstitutionConfiguration(2, ['yubikey']);
@@ -173,7 +164,7 @@ public function test_a_second_factor_can_be_moved()
$targetRegistrantNameId,
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->withAggregateId($sourceRegistrantId)
@@ -184,7 +175,7 @@ public function test_a_second_factor_can_be_moved()
$sourceRegistrantNameId,
$sourceRegistrantCommonName,
$sourceRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$sourceRegistrantId,
@@ -194,8 +185,8 @@ public function test_a_second_factor_can_be_moved()
$sourceRegistrantEmail,
new Locale('en_GB'),
$sourceRegistrantSecFacId,
- $sourceYubikeySecFacId
- )
+ $sourceYubikeySecFacId,
+ ),
])
->when($command)
->then([
@@ -211,7 +202,7 @@ public function test_a_second_factor_can_be_moved()
new UnknownVettingType(),
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorMigratedToEvent(
$sourceRegistrantId,
@@ -220,12 +211,12 @@ public function test_a_second_factor_can_be_moved()
$sourceRegistrantSecFacId,
$targetRegistrantSecFacId,
new SecondFactorType('yubikey'),
- $sourceYubikeySecFacId
+ $sourceYubikeySecFacId,
),
]);
}
- public function test_can_not_be_moved_if_already_moved()
+ public function test_can_not_be_moved_if_already_moved(): void
{
$this->expectExceptionMessage("The second factor was registered as a vetted second factor");
$this->expectException(DomainException::class);
@@ -265,7 +256,7 @@ public function test_can_not_be_moved_if_already_moved()
$targetRegistrantNameId,
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorMigratedEvent(
$targetRegistrantId,
@@ -279,7 +270,7 @@ public function test_can_not_be_moved_if_already_moved()
new UnknownVettingType(),
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorMigratedToEvent(
$sourceRegistrantId,
@@ -288,7 +279,7 @@ public function test_can_not_be_moved_if_already_moved()
$sourceRegistrantSecFacId,
$targetRegistrantSecFacId,
new SecondFactorType('yubikey'),
- $sourceYubikeySecFacId
+ $sourceYubikeySecFacId,
),
])
->withAggregateId($sourceRegistrantId)
@@ -299,7 +290,7 @@ public function test_can_not_be_moved_if_already_moved()
$sourceRegistrantNameId,
$sourceRegistrantCommonName,
$sourceRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$sourceRegistrantId,
@@ -309,14 +300,14 @@ public function test_can_not_be_moved_if_already_moved()
$sourceRegistrantEmail,
new Locale('en_GB'),
$sourceRegistrantSecFacId,
- $sourceYubikeySecFacId
+ $sourceYubikeySecFacId,
),
])
->when($command)
->then([]);
}
- public function test_can_not_be_moved_if_already_present_as_bootstrapped_thus_vetted_token()
+ public function test_can_not_be_moved_if_already_present_as_bootstrapped_thus_vetted_token(): void
{
$this->expectExceptionMessage("The second factor was registered as a vetted second factor");
$this->expectException(DomainException::class);
@@ -357,7 +348,7 @@ public function test_can_not_be_moved_if_already_present_as_bootstrapped_thus_ve
$targetRegistrantNameId,
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$targetRegistrantId,
@@ -367,7 +358,7 @@ public function test_can_not_be_moved_if_already_present_as_bootstrapped_thus_ve
$targetRegistrantEmail,
new Locale('en_GB'),
$targetRegistrantSecFacId,
- $targetYubikeySecFacId
+ $targetYubikeySecFacId,
),
])
->withAggregateId($sourceRegistrantId)
@@ -378,7 +369,7 @@ public function test_can_not_be_moved_if_already_present_as_bootstrapped_thus_ve
$sourceRegistrantNameId,
$sourceRegistrantCommonName,
$sourceRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$sourceRegistrantId,
@@ -388,7 +379,7 @@ public function test_can_not_be_moved_if_already_present_as_bootstrapped_thus_ve
$sourceRegistrantEmail,
new Locale('en_GB'),
$sourceRegistrantSecFacId,
- $sourceYubikeySecFacId
+ $sourceYubikeySecFacId,
),
])
->when($command)
@@ -396,7 +387,7 @@ public function test_can_not_be_moved_if_already_present_as_bootstrapped_thus_ve
}
- public function test_can_not_be_moved_if_already_present_as_vetted_token()
+ public function test_can_not_be_moved_if_already_present_as_vetted_token(): void
{
$this->expectExceptionMessage("The second factor was registered as a vetted second factor");
$this->expectException(DomainException::class);
@@ -437,7 +428,7 @@ public function test_can_not_be_moved_if_already_present_as_vetted_token()
$targetRegistrantNameId,
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$targetRegistrantId,
@@ -446,13 +437,13 @@ public function test_can_not_be_moved_if_already_present_as_vetted_token()
$targetYubikeySecFacId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$targetRegistrantId,
@@ -464,7 +455,7 @@ public function test_can_not_be_moved_if_already_present_as_vetted_token()
'REGCODE',
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorVettedEvent(
$targetRegistrantId,
@@ -476,7 +467,7 @@ public function test_can_not_be_moved_if_already_present_as_vetted_token()
$targetRegistrantCommonName,
$targetRegistrantEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('NH9392'))
+ new OnPremiseVettingType(new DocumentNumber('NH9392')),
),
])
->withAggregateId($sourceRegistrantId)
@@ -487,7 +478,7 @@ public function test_can_not_be_moved_if_already_present_as_vetted_token()
$sourceRegistrantNameId,
$sourceRegistrantCommonName,
$sourceRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$sourceRegistrantId,
@@ -497,14 +488,14 @@ public function test_can_not_be_moved_if_already_present_as_vetted_token()
$sourceRegistrantEmail,
new Locale('en_GB'),
$sourceRegistrantSecFacId,
- $sourceYubikeySecFacId
+ $sourceYubikeySecFacId,
),
])
->when($command)
->then([]);
}
- public function test_can_not_be_moved_if_already_present_as_verified_token()
+ public function test_can_not_be_moved_if_already_present_as_verified_token(): void
{
$this->expectExceptionMessage("The second factor was already registered as a verified second factor");
$this->expectException(DomainException::class);
@@ -545,7 +536,7 @@ public function test_can_not_be_moved_if_already_present_as_verified_token()
$targetRegistrantNameId,
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$targetRegistrantId,
@@ -554,13 +545,13 @@ public function test_can_not_be_moved_if_already_present_as_verified_token()
$targetYubikeySecFacId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$targetRegistrantId,
@@ -572,7 +563,7 @@ public function test_can_not_be_moved_if_already_present_as_verified_token()
'REGCODE',
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->withAggregateId($sourceRegistrantId)
@@ -583,7 +574,7 @@ public function test_can_not_be_moved_if_already_present_as_verified_token()
$sourceRegistrantNameId,
$sourceRegistrantCommonName,
$sourceRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$sourceRegistrantId,
@@ -593,14 +584,14 @@ public function test_can_not_be_moved_if_already_present_as_verified_token()
$sourceRegistrantEmail,
new Locale('en_GB'),
$sourceRegistrantSecFacId,
- $sourceYubikeySecFacId
+ $sourceYubikeySecFacId,
),
])
->when($command)
->then([]);
}
- public function test_can_not_be_moved_if_already_present_as_unverified_token()
+ public function test_can_not_be_moved_if_already_present_as_unverified_token(): void
{
$this->expectExceptionMessage("The second factor was already registered as a unverified second factor");
$this->expectException(DomainException::class);
@@ -641,7 +632,7 @@ public function test_can_not_be_moved_if_already_present_as_unverified_token()
$targetRegistrantNameId,
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$targetRegistrantId,
@@ -650,13 +641,13 @@ public function test_can_not_be_moved_if_already_present_as_unverified_token()
$targetYubikeySecFacId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->withAggregateId($sourceRegistrantId)
@@ -667,7 +658,7 @@ public function test_can_not_be_moved_if_already_present_as_unverified_token()
$sourceRegistrantNameId,
$sourceRegistrantCommonName,
$sourceRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$sourceRegistrantId,
@@ -677,14 +668,14 @@ public function test_can_not_be_moved_if_already_present_as_unverified_token()
$sourceRegistrantEmail,
new Locale('en_GB'),
$sourceRegistrantSecFacId,
- $sourceYubikeySecFacId
+ $sourceYubikeySecFacId,
),
])
->when($command)
->then([]);
}
- public function test_can_not_be_moved_to_same_institution()
+ public function test_can_not_be_moved_to_same_institution(): void
{
$this->expectExceptionMessage("Cannot move the second factor to the same institution");
$this->expectException(DomainException::class);
@@ -723,7 +714,7 @@ public function test_can_not_be_moved_to_same_institution()
$targetRegistrantNameId,
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->withAggregateId($sourceRegistrantId)
@@ -734,7 +725,7 @@ public function test_can_not_be_moved_to_same_institution()
$sourceRegistrantNameId,
$sourceRegistrantCommonName,
$sourceRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$sourceRegistrantId,
@@ -744,14 +735,14 @@ public function test_can_not_be_moved_to_same_institution()
$sourceRegistrantEmail,
new Locale('en_GB'),
$sourceRegistrantSecFacId,
- $sourceYubikeySecFacId
- )
+ $sourceYubikeySecFacId,
+ ),
])
->when($command)
->then([]);
}
- public function test_can_not_be_moved_if_token_type_not_allowed_for_institution()
+ public function test_can_not_be_moved_if_token_type_not_allowed_for_institution(): void
{
$this->expectExceptionMessage('Institution "institution2.com" does not support second factor "yubikey"');
$this->expectException(SecondFactorNotAllowedException::class);
@@ -791,7 +782,7 @@ public function test_can_not_be_moved_if_token_type_not_allowed_for_institution(
$targetRegistrantNameId,
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->withAggregateId($sourceRegistrantId)
@@ -802,7 +793,7 @@ public function test_can_not_be_moved_if_token_type_not_allowed_for_institution(
$sourceRegistrantNameId,
$sourceRegistrantCommonName,
$sourceRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$sourceRegistrantId,
@@ -812,24 +803,24 @@ public function test_can_not_be_moved_if_token_type_not_allowed_for_institution(
$sourceRegistrantEmail,
new Locale('en_GB'),
$sourceRegistrantSecFacId,
- $sourceYubikeySecFacId
- )
+ $sourceYubikeySecFacId,
+ ),
])
->when($command)
->then([
new SecondFactorMigratedToEvent(
$targetRegistrantId,
- $sourceRegistrantNameId,
- $targetRegistrantNameId,
+ $sourceRegistrantInstitution,
$targetRegistrantInstitution,
$sourceRegistrantSecFacId,
$targetRegistrantSecFacId,
- new SecondFactorType('yubikey')
+ new SecondFactorType('yubikey'),
+ $sourceYubikeySecFacId,
),
]);
}
- public function test_the_max_number_of_tokens_can_not_be_exceeded()
+ public function test_the_max_number_of_tokens_can_not_be_exceeded(): void
{
$this->expectExceptionMessage("User may not have more than 1 token(s)");
$this->expectException(DomainException::class);
@@ -870,7 +861,7 @@ public function test_the_max_number_of_tokens_can_not_be_exceeded()
$targetRegistrantNameId,
$targetRegistrantCommonName,
$targetRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$targetRegistrantId,
@@ -880,8 +871,8 @@ public function test_the_max_number_of_tokens_can_not_be_exceeded()
$targetRegistrantEmail,
new Locale('en_GB'),
$targetRegistrantSecFacId,
- $targetYubikeySecFacId
- )
+ $targetYubikeySecFacId,
+ ),
])
->withAggregateId($sourceRegistrantId)
->given([
@@ -891,7 +882,7 @@ public function test_the_max_number_of_tokens_can_not_be_exceeded()
$sourceRegistrantNameId,
$sourceRegistrantCommonName,
$sourceRegistrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$sourceRegistrantId,
@@ -901,21 +892,23 @@ public function test_the_max_number_of_tokens_can_not_be_exceeded()
$sourceRegistrantEmail,
new Locale('en_GB'),
$sourceRegistrantSecFacId,
- $sourceYubikeySecFacId
- )
+ $sourceYubikeySecFacId,
+ ),
])
->when($command)
->then([]);
}
- private function setUpInstitutionConfiguration(int $allowedMaxNumberOfTokens, array $allowedTokenTypes)
+ private function setUpInstitutionConfiguration(int $allowedMaxNumberOfTokens, array $allowedTokenTypes): void
{
$secondFactorTypes = [];
foreach ($allowedTokenTypes as $type) {
$secondFactorTypes[] = new SecondFactorType($type);
}
$this->configService->shouldReceive('getMaxNumberOfTokensFor')->andReturn($allowedMaxNumberOfTokens);
- $this->allowedSecondFactorListServiceMock->shouldReceive('getAllowedSecondFactorListFor')->andReturn(AllowedSecondFactorList::ofTypes($secondFactorTypes));
+ $this->allowedSecondFactorListServiceMock->shouldReceive('getAllowedSecondFactorListFor')->andReturn(
+ AllowedSecondFactorList::ofTypes($secondFactorTypes),
+ );
$this->configService->shouldIgnoreMissing();
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerSelfAssertedTokensTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerSelfAssertedTokensTest.php
index 396a7d3dc..37099b9c0 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerSelfAssertedTokensTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerSelfAssertedTokensTest.php
@@ -23,6 +23,7 @@
use Broadway\EventSourcing\AggregateFactory\PublicConstructorAggregateFactory;
use Broadway\EventStore\EventStore as EventStoreInterface;
use Mockery as m;
+use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Surfnet\Stepup\Configuration\Value\AllowedSecondFactorList;
use Surfnet\Stepup\Configuration\Value\SelfAssertedTokensOption;
@@ -62,7 +63,6 @@
use Surfnet\Stepup\Identity\Value\SafeStore;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
use Surfnet\Stepup\Identity\Value\SelfAssertedRegistrationVettingType;
-use Surfnet\Stepup\Identity\Value\SelfVetVettingType;
use Surfnet\Stepup\Identity\Value\StepupProvider;
use Surfnet\Stepup\Identity\Value\TimeFrame;
use Surfnet\Stepup\Identity\Value\UnhashedSecret;
@@ -86,77 +86,38 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\RegistrationMailService;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\CommandHandlerTest;
-
/**
* @runTestsInSeparateProcesses
*/
class IdentityCommandHandlerSelfAssertedTokensTest extends CommandHandlerTest
{
- private static $window = 3600;
+ private static int $window = 3600;
- /**
- * @var AllowedSecondFactorListService|m\MockInterface
- */
- private $allowedSecondFactorListServiceMock;
+ private AllowedSecondFactorListService&MockInterface $allowedSecondFactorListServiceMock;
- /**
- * @var m\MockInterface|IdentityProjectionRepository
- */
- private $identityProjectionRepository;
+ private IdentityProjectionRepository&MockInterface $identityProjectionRepository;
- /**
- * @var SecondFactorTypeService|m\MockInterface
- */
- private $secondFactorTypeService;
+ private SecondFactorTypeService&MockInterface $secondFactorTypeService;
- /**
- * @var SecondFactorProvePossessionHelper|m\MockInterface
- */
- private $secondFactorProvePossessionHelper;
+ private SecondFactorProvePossessionHelper&MockInterface $secondFactorProvePossessionHelper;
- /**
- * @var InstitutionConfigurationOptionsService $configService
- */
- private $configService;
+ private InstitutionConfigurationOptionsService&MockInterface $configService;
- /**
- * @var LoaResolutionService
- */
- private $loaResolutionService;
+ private LoaResolutionService&MockInterface $loaResolutionService;
- /**
- * @var IdentityId
- */
- private $id;
+ private IdentityId $id;
- /**
- * @var Institution
- */
- private $institution;
+ private Institution $institution;
- /**
- * @var Email
- */
- private $email;
+ private Email $email;
- /**
- * @var CommonName
- */
- private $commonName;
+ private CommonName $commonName;
- /**
- * @var Locale
- */
- private $preferredLocale;
- /**
- * @var RecoveryTokenSecretHelper|m\MockInterface
- */
- private $recoveryTokenSecretHelper;
+ private Locale $preferredLocale;
- /**
- * @var NameId
- */
- private $nameId;
+ private RecoveryTokenSecretHelper&MockInterface $recoveryTokenSecretHelper;
+
+ private ?NameId $nameId = null;
public function setUp(): void
{
@@ -176,7 +137,7 @@ public function setUp(): void
* @group command-handler
* @runInSeparateProcess
*/
- public function test_a_sms_recovery_code_possession_can_be_proven()
+ public function test_a_sms_recovery_code_possession_can_be_proven(): void
{
$recoveryTokenId = new RecoveryTokenId(self::uuid());
$phoneNumber = new PhoneNumber('+31 (0) 612345678');
@@ -202,8 +163,8 @@ public function test_a_sms_recovery_code_possession_can_be_proven()
$phoneNumber,
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
]);
}
@@ -211,7 +172,7 @@ public function test_a_sms_recovery_code_possession_can_be_proven()
* @group command-handler
* @runInSeparateProcess
*/
- public function test_a_safe_store_secret_recovery_code_possession_can_be_proven()
+ public function test_a_safe_store_secret_recovery_code_possession_can_be_proven(): void
{
$recoveryTokenId = new RecoveryTokenId(self::uuid());
$secret = m::mock(HashedSecret::class);
@@ -227,11 +188,13 @@ public function test_a_safe_store_secret_recovery_code_possession_can_be_proven(
$this->recoveryTokenSecretHelper
->shouldReceive('hash')
- ->with(m::on(function ($unhashedSecret) {
- $isUnhashedSecret = $unhashedSecret instanceof UnhashedSecret;
- $hasExpectedSecret = $unhashedSecret->getSecret() === 'super-safe-secret';
- return $isUnhashedSecret && $hasExpectedSecret;
- }))
+ ->with(
+ m::on(function ($unhashedSecret): bool {
+ $isUnhashedSecret = $unhashedSecret instanceof UnhashedSecret;
+ $hasExpectedSecret = $unhashedSecret->getSecret() === 'super-safe-secret';
+ return $isUnhashedSecret && $hasExpectedSecret;
+ }),
+ )
->andReturn($secret);
$this->scenario
@@ -246,8 +209,8 @@ public function test_a_safe_store_secret_recovery_code_possession_can_be_proven(
new SafeStore($secret),
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
]);
}
@@ -255,7 +218,7 @@ public function test_a_safe_store_secret_recovery_code_possession_can_be_proven(
* @group command-handler
* @runInSeparateProcess
*/
- public function test_a_safe_store_secret_and_phone_recovery_code_possession_can_be_proven()
+ public function test_a_safe_store_secret_and_phone_recovery_code_possession_can_be_proven(): void
{
$recoveryTokenId = new RecoveryTokenId(self::uuid());
@@ -274,11 +237,13 @@ public function test_a_safe_store_secret_and_phone_recovery_code_possession_can_
$secret = new HashedSecret('secret-for-safe-keeping');
$this->recoveryTokenSecretHelper
->shouldReceive('hash')
- ->with(m::on(function ($unhashedSecret) {
- $isUnhashedSecret = $unhashedSecret instanceof UnhashedSecret;
- $hasExpectedSecret = $unhashedSecret->getSecret() === 'secret-for-safe-keeping';
- return $isUnhashedSecret && $hasExpectedSecret;
- }))
+ ->with(
+ m::on(function ($unhashedSecret): bool {
+ $isUnhashedSecret = $unhashedSecret instanceof UnhashedSecret;
+ $hasExpectedSecret = $unhashedSecret->getSecret() === 'secret-for-safe-keeping';
+ return $isUnhashedSecret && $hasExpectedSecret;
+ }),
+ )
->andReturn($secret);
$confMock = m::mock(InstitutionConfigurationOptions::class);
@@ -297,8 +262,8 @@ public function test_a_safe_store_secret_and_phone_recovery_code_possession_can_
new SafeStore($secret),
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
])
->when($command2)
->then([
@@ -309,8 +274,8 @@ public function test_a_safe_store_secret_and_phone_recovery_code_possession_can_
$phoneNumber,
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
]);
}
@@ -318,7 +283,7 @@ public function test_a_safe_store_secret_and_phone_recovery_code_possession_can_
* @group command-handler
* @runInSeparateProcess
*/
- public function test_a_sms_recovery_code_possession_can_not_be_proven_twice()
+ public function test_a_sms_recovery_code_possession_can_not_be_proven_twice(): void
{
$recoveryTokenId = new RecoveryTokenId(self::uuid());
$phoneNumber = new PhoneNumber('+31 (0) 612345678');
@@ -346,8 +311,8 @@ public function test_a_sms_recovery_code_possession_can_not_be_proven_twice()
$phoneNumber,
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
])
->when($command);
}
@@ -356,7 +321,7 @@ public function test_a_sms_recovery_code_possession_can_not_be_proven_twice()
* @group command-handler
* @runInSeparateProcess
*/
- public function test_only_one_safe_store_secret_allowed()
+ public function test_only_one_safe_store_secret_allowed(): void
{
$recoveryTokenId = new RecoveryTokenId(self::uuid());
@@ -372,11 +337,13 @@ public function test_only_one_safe_store_secret_allowed()
$secret = new HashedSecret('secret-for-safe-keeping');
$this->recoveryTokenSecretHelper
->shouldReceive('hash')
- ->with(m::on(function ($unhashedSecret) {
- $isUnhashedSecret = $unhashedSecret instanceof UnhashedSecret;
- $hasExpectedSecret = $unhashedSecret->getSecret() === 'secret-for-safe-keeping';
- return $isUnhashedSecret && $hasExpectedSecret;
- }))
+ ->with(
+ m::on(function ($unhashedSecret): bool {
+ $isUnhashedSecret = $unhashedSecret instanceof UnhashedSecret;
+ $hasExpectedSecret = $unhashedSecret->getSecret() === 'secret-for-safe-keeping';
+ return $isUnhashedSecret && $hasExpectedSecret;
+ }),
+ )
->andReturn($secret);
$this->expectException(DomainException::class);
@@ -394,8 +361,8 @@ public function test_only_one_safe_store_secret_allowed()
new SafeStore($secret),
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
])
->when($command);
}
@@ -404,7 +371,7 @@ public function test_only_one_safe_store_secret_allowed()
* @group command-handler
* @runInSeparateProcess
*/
- public function test_a_sms_recovery_token_possession_requires_institution_configuration_feature_enabled()
+ public function test_a_sms_recovery_token_possession_requires_institution_configuration_feature_enabled(): void
{
$identityCreatedEvent = $this->buildIdentityCreatedEvent();
$recoveryTokenId = new RecoveryTokenId(self::uuid());
@@ -419,7 +386,9 @@ public function test_a_sms_recovery_token_possession_requires_institution_config
$this->configService->shouldReceive('findInstitutionConfigurationOptionsFor')->andReturn($confMock);
$this->expectException(RuntimeException::class);
- $this->expectExceptionMessage('Registration of self-asserted tokens is not allowed for this institution "a corp.".');
+ $this->expectExceptionMessage(
+ 'Registration of self-asserted tokens is not allowed for this institution "a corp.".',
+ );
$this->scenario
->withAggregateId($this->id)
@@ -432,8 +401,8 @@ public function test_a_sms_recovery_token_possession_requires_institution_config
$phoneNumber,
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
])
->when($command);
}
@@ -442,7 +411,7 @@ public function test_a_sms_recovery_token_possession_requires_institution_config
* @group command-handler
* @runInSeparateProcess
*/
- public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked_by_ra()
+ public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked_by_ra(): void
{
$recoveryTokenId = new RecoveryTokenId(self::uuid());
$secret = m::mock(HashedSecret::class);
@@ -471,7 +440,7 @@ public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked
$authorityNameId,
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$authorityId,
@@ -481,8 +450,8 @@ public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked
$authorityEmail,
new Locale('en_GB'),
new SecondFactorId(self::uuid()),
- new YubikeyPublicId('00000012')
- )
+ new YubikeyPublicId('00000012'),
+ ),
])
->withAggregateId($this->id)
->given([
@@ -494,8 +463,8 @@ public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked
new SafeStore($secret),
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
])
->when($command)
->then([
@@ -504,8 +473,8 @@ public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked
$this->institution,
$recoveryTokenId,
RecoveryTokenType::safeStore(),
- $authorityId
- )
+ $authorityId,
+ ),
]);
}
@@ -513,7 +482,7 @@ public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked
* @group command-handler
* @runInSeparateProcess
*/
- public function test_a_token_can_be_registered_self_asserted()
+ public function test_a_token_can_be_registered_self_asserted(): void
{
$recoveryTokenId = new RecoveryTokenId(self::uuid());
$secret = m::mock(HashedSecret::class);
@@ -535,7 +504,6 @@ public function test_a_token_can_be_registered_self_asserted()
$expectedVettingType = new SelfAssertedRegistrationVettingType($recoveryTokenId);
$this->scenario
-
->withAggregateId($this->id)
->given([
$this->buildIdentityCreatedEvent(),
@@ -546,13 +514,13 @@ public function test_a_token_can_be_registered_self_asserted()
$yubikeyPublicId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$this->id,
@@ -564,7 +532,7 @@ public function test_a_token_can_be_registered_self_asserted()
'REGCODE',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SafeStoreSecretRecoveryTokenPossessionPromisedEvent(
$this->id,
@@ -573,8 +541,8 @@ public function test_a_token_can_be_registered_self_asserted()
new SafeStore($secret),
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
])
->when($command)
->then([
@@ -588,8 +556,8 @@ public function test_a_token_can_be_registered_self_asserted()
$this->commonName,
$this->email,
$this->preferredLocale,
- $expectedVettingType
- )
+ $expectedVettingType,
+ ),
]);
}
@@ -597,7 +565,7 @@ public function test_a_token_can_be_registered_self_asserted()
* @group command-handler
* @runInSeparateProcess
*/
- public function test_self_asserted_token_registration_requires_possession_of_recovery_token()
+ public function test_self_asserted_token_registration_requires_possession_of_recovery_token(): void
{
$madeUpRecoveryTokenId = new RecoveryTokenId(self::uuid());
@@ -618,7 +586,6 @@ public function test_self_asserted_token_registration_requires_possession_of_rec
$this->expectException(DomainException::class);
$this->expectExceptionMessage('A recovery token is required to perform a self-asserted token registration');
$this->scenario
-
->withAggregateId($this->id)
->given([
$this->buildIdentityCreatedEvent(),
@@ -629,13 +596,13 @@ public function test_self_asserted_token_registration_requires_possession_of_rec
$yubikeyPublicId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$this->id,
@@ -647,18 +614,17 @@ public function test_self_asserted_token_registration_requires_possession_of_rec
'REGCODE',
$this->commonName,
$this->email,
- new Locale('en_GB')
- )
+ new Locale('en_GB'),
+ ),
])
- ->when($command);
-
+ ->when($command);
}
/**
* @group command-handler
* @runInSeparateProcess
*/
- public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked()
+ public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked(): void
{
$recoveryTokenId = new RecoveryTokenId(self::uuid());
$secret = m::mock(HashedSecret::class);
@@ -682,8 +648,8 @@ public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked
new SafeStore($secret),
$this->commonName,
$this->email,
- $this->preferredLocale
- )
+ $this->preferredLocale,
+ ),
])
->when($command)
->then([
@@ -691,8 +657,8 @@ public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked
$this->id,
$this->institution,
$recoveryTokenId,
- RecoveryTokenType::safeStore()
- )
+ RecoveryTokenType::safeStore(),
+ ),
]);
}
@@ -700,7 +666,7 @@ public function test_a_safe_store_secret_recovery_code_possession_can_be_revoked
* @group command-handler
* @runInSeparateProcess
*/
- public function test_a_sat_token_can_be_used_to_self_vet_a_token()
+ public function test_a_sat_token_can_be_used_to_self_vet_a_token(): void
{
$recoveryTokenId = new RecoveryTokenId(self::uuid());
$secret = m::mock(HashedSecret::class);
@@ -716,8 +682,8 @@ public function test_a_sat_token_can_be_used_to_self_vet_a_token()
$loa = new Loa(1.5, 'loa-self-asserted');
$this->loaResolutionService->shouldReceive('getLoa')->with('loa-self-asserted')->andReturn($loa);
- $phoneSfId = new SecondFactorId($this->uuid());
- $phoneIdentifier = new PhoneNumber('+31 (0) 612345678');
+ $phoneSfId = new SecondFactorId($this->uuid());
+ $phoneIdentifier = new PhoneNumber('+31 (0) 612345678');
$command = new SelfVetSecondFactorCommand();
$command->secondFactorId = '+31 (0) 612345678';
@@ -739,13 +705,13 @@ public function test_a_sat_token_can_be_used_to_self_vet_a_token()
$yubikeyPublicId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$this->id,
@@ -757,7 +723,7 @@ public function test_a_sat_token_can_be_used_to_self_vet_a_token()
'REGCODE',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SafeStoreSecretRecoveryTokenPossessionPromisedEvent(
$this->id,
@@ -766,7 +732,7 @@ public function test_a_sat_token_can_be_used_to_self_vet_a_token()
new SafeStore($secret),
$this->commonName,
$this->email,
- $this->preferredLocale
+ $this->preferredLocale,
),
new SecondFactorVettedWithoutTokenProofOfPossession(
$this->id,
@@ -778,7 +744,7 @@ public function test_a_sat_token_can_be_used_to_self_vet_a_token()
$this->commonName,
$this->email,
$this->preferredLocale,
- $vettingType
+ $vettingType,
),
// The next token is self-vetted using the other SAT token
new PhonePossessionProvenEvent(
@@ -788,13 +754,13 @@ public function test_a_sat_token_can_be_used_to_self_vet_a_token()
$phoneIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$this->id,
@@ -806,7 +772,7 @@ public function test_a_sat_token_can_be_used_to_self_vet_a_token()
'REGCODE',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command)
@@ -822,7 +788,7 @@ public function test_a_sat_token_can_be_used_to_self_vet_a_token()
$this->commonName,
$this->email,
new Locale('en_GB'),
- new SelfAssertedRegistrationVettingType($recoveryTokenId)
+ new SelfAssertedRegistrationVettingType($recoveryTokenId),
),
]);
}
@@ -831,7 +797,7 @@ public function test_a_sat_token_can_be_used_to_self_vet_a_token()
* @group command-handler
* @runInSeparateProcess
*/
- public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted()
+ public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted(): void
{
$recoveryTokenId = new RecoveryTokenId(self::uuid());
$secret = m::mock(HashedSecret::class);
@@ -870,14 +836,16 @@ public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted()
new SecondFactorType('tiqr'),
new SecondFactorType('yubikey'),
new SecondFactorType('sms'),
- ]
- )
+ ],
+ ),
);
$this->configService->shouldReceive('getMaxNumberOfTokensFor')->andReturn(5);
$this->expectException(DomainException::class);
- $this->expectExceptionMessage('Not all tokens are self-asserted, it is not allowed to self-vet using the self-asserted token');
+ $this->expectExceptionMessage(
+ 'Not all tokens are self-asserted, it is not allowed to self-vet using the self-asserted token',
+ );
$this->scenario
->withAggregateId($this->id)
@@ -890,13 +858,13 @@ public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted()
$yubikeyPublicId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$this->id,
@@ -908,7 +876,7 @@ public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted()
'REGCODE',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SafeStoreSecretRecoveryTokenPossessionPromisedEvent(
$this->id,
@@ -917,7 +885,7 @@ public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted()
new SafeStore($secret),
$this->commonName,
$this->email,
- $this->preferredLocale
+ $this->preferredLocale,
),
new SecondFactorVettedWithoutTokenProofOfPossession(
$this->id,
@@ -929,7 +897,7 @@ public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted()
$this->commonName,
$this->email,
$this->preferredLocale,
- $vettingType
+ $vettingType,
),
// The next token is ra-vetted
new PhonePossessionProvenEvent(
@@ -939,13 +907,13 @@ public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted()
$phoneIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$this->id,
@@ -957,7 +925,7 @@ public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted()
'REGCODE',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorVettedEvent(
$this->id,
@@ -969,7 +937,7 @@ public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted()
$this->commonName,
$this->email,
$this->preferredLocale,
- new OnPremiseVettingType(new DocumentNumber('123123'))
+ new OnPremiseVettingType(new DocumentNumber('123123')),
),
// The third token is an attempt to self-vet a token
new GssfPossessionProvenEvent(
@@ -980,13 +948,13 @@ public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted()
$gsspIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$this->id,
@@ -998,14 +966,16 @@ public function test_sat_not_allowed_when_one_vetted_token_is_identity_vetted()
'REGCODE',
$this->commonName,
$this->email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command);
}
- protected function createCommandHandler(EventStoreInterface $eventStore, EventBusInterface $eventBus): CommandHandler
- {
+ protected function createCommandHandler(
+ EventStoreInterface $eventStore,
+ EventBusInterface $eventBus,
+ ): CommandHandler {
$aggregateFactory = new PublicConstructorAggregateFactory();
$this->identityProjectionRepository = m::mock(IdentityProjectionRepository::class);
@@ -1024,7 +994,7 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
$eventBus,
$aggregateFactory,
m::mock(UserDataFilterInterface::class),
- $logger
+ $logger,
),
$this->identityProjectionRepository,
ConfigurableSettings::create(self::$window, ['nl_NL', 'en_GB']),
@@ -1034,11 +1004,11 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
$this->configService,
$this->loaResolutionService,
$this->recoveryTokenSecretHelper,
- $registrationMailService
+ $registrationMailService,
);
}
- private function buildIdentityCreatedEvent()
+ private function buildIdentityCreatedEvent(): IdentityCreatedEvent
{
$this->nameId = new NameId(md5(__METHOD__));
@@ -1048,7 +1018,7 @@ private function buildIdentityCreatedEvent()
$this->nameId,
$this->commonName,
$this->email,
- $this->preferredLocale
+ $this->preferredLocale,
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerTest.php
index 06f8b08b7..96aec0d76 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityCommandHandlerTest.php
@@ -23,12 +23,13 @@
use Broadway\EventSourcing\AggregateFactory\PublicConstructorAggregateFactory;
use Broadway\EventStore\EventStore as EventStoreInterface;
use DateTime as CoreDateTime;
-use Hamcrest\Matchers;
+use Mockery\Matcher\IsEqual;
use Mockery as m;
-use Mockery\Mock;
+use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Surfnet\Stepup\Configuration\Value\AllowedSecondFactorList;
use Surfnet\Stepup\DateTime\DateTime;
+use Surfnet\Stepup\Exception\DomainException;
use Surfnet\Stepup\Helper\RecoveryTokenSecretHelper;
use Surfnet\Stepup\Helper\SecondFactorProvePossessionHelper;
use Surfnet\Stepup\Helper\UserDataFilterInterface;
@@ -40,8 +41,8 @@
use Surfnet\Stepup\Identity\Event\IdentityRenamedEvent;
use Surfnet\Stepup\Identity\Event\LocalePreferenceExpressedEvent;
use Surfnet\Stepup\Identity\Event\PhonePossessionProvenEvent;
-use Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession;
use Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession;
use Surfnet\Stepup\Identity\Event\U2fDevicePossessionProvenEvent;
use Surfnet\Stepup\Identity\Event\YubikeyPossessionProvenEvent;
use Surfnet\Stepup\Identity\Event\YubikeySecondFactorBootstrappedEvent;
@@ -62,8 +63,9 @@
use Surfnet\Stepup\Identity\Value\StepupProvider;
use Surfnet\Stepup\Identity\Value\TimeFrame;
use Surfnet\Stepup\Identity\Value\U2fKeyHandle;
-use Surfnet\Stepup\Identity\Value\VettingType;
use Surfnet\Stepup\Identity\Value\YubikeyPublicId;
+use Surfnet\Stepup\Token\TokenGenerator;
+use Surfnet\StepupBundle\Security\OtpGenerator;
use Surfnet\StepupBundle\Service\LoaResolutionService;
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
use Surfnet\StepupBundle\Value\Loa;
@@ -72,6 +74,7 @@
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionConfigurationOptionsService;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository as IdentityProjectionRepository;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\SecondFactorNotAllowedException;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\UnsupportedLocaleException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\BootstrapIdentityWithYubikeySecondFactorCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\CreateIdentityCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ExpressLocalePreferenceCommand;
@@ -96,42 +99,21 @@
*/
class IdentityCommandHandlerTest extends CommandHandlerTest
{
- private static $window = 3600;
+ private static int $window = 3600;
- /**
- * @var AllowedSecondFactorListService|m\MockInterface
- */
- private $allowedSecondFactorListServiceMock;
+ private AllowedSecondFactorListService&MockInterface $allowedSecondFactorListServiceMock;
- /**
- * @var m\MockInterface|IdentityProjectionRepository
- */
- private $identityProjectionRepository;
+ private IdentityProjectionRepository&MockInterface $identityProjectionRepository;
- /**
- * @var SecondFactorTypeService
- */
- private $secondFactorTypeService;
+ private SecondFactorTypeService&MockInterface $secondFactorTypeService;
- /**
- * @var SecondFactorProvePossessionHelper|m\MockInterface
- */
- private $secondFactorProvePossessionHelper;
+ private SecondFactorProvePossessionHelper&MockInterface $secondFactorProvePossessionHelper;
- /**
- * @var InstitutionConfigurationOptionsService $configService
- */
- private $configService;
+ private InstitutionConfigurationOptionsService&MockInterface $configService;
- /**
- * @var LoaResolutionService
- */
- private $loaResolutionService;
- /**
- * @var RegistrationMailService|Mock
- */
- private $registrationMailService;
+ private LoaResolutionService&MockInterface $loaResolutionService;
+ private RegistrationMailService&MockInterface $registrationMailService;
public function setUp(): void
{
@@ -141,8 +123,10 @@ public function setUp(): void
parent::setUp();
}
- protected function createCommandHandler(EventStoreInterface $eventStore, EventBusInterface $eventBus): CommandHandler
- {
+ protected function createCommandHandler(
+ EventStoreInterface $eventStore,
+ EventBusInterface $eventBus,
+ ): CommandHandler {
$aggregateFactory = new PublicConstructorAggregateFactory();
$this->identityProjectionRepository = m::mock(IdentityProjectionRepository::class);
@@ -160,7 +144,7 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
$eventBus,
$aggregateFactory,
m::mock(UserDataFilterInterface::class),
- $logger
+ $logger,
),
$this->identityProjectionRepository,
ConfigurableSettings::create(self::$window, ['nl_NL', 'en_GB']),
@@ -170,7 +154,7 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
$this->configService,
$this->loaResolutionService,
m::mock(RecoveryTokenSecretHelper::class),
- $this->registrationMailService
+ $this->registrationMailService,
);
}
@@ -179,16 +163,16 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
* @group command-handler
* @runInSeparateProcess
*/
- public function an_identity_can_be_bootstrapped_with_a_yubikey_second_factor()
+ public function an_identity_can_be_bootstrapped_with_a_yubikey_second_factor(): void
{
- $command = new BootstrapIdentityWithYubikeySecondFactorCommand();
- $command->identityId = 'ID-ID';
- $command->nameId = 'N-ID';
- $command->institution = 'Institution';
- $command->commonName = 'Enrique';
- $command->email = 'foo@domain.invalid';
+ $command = new BootstrapIdentityWithYubikeySecondFactorCommand();
+ $command->identityId = 'ID-ID';
+ $command->nameId = 'N-ID';
+ $command->institution = 'Institution';
+ $command->commonName = 'Enrique';
+ $command->email = 'foo@domain.invalid';
$command->preferredLocale = 'nl_NL';
- $command->secondFactorId = 'SF-ID';
+ $command->secondFactorId = 'SF-ID';
$command->yubikeyPublicId = '93193884';
$this->identityProjectionRepository->shouldReceive('hasIdentityWithNameIdAndInstitution')->andReturn(false);
@@ -209,7 +193,7 @@ public function an_identity_can_be_bootstrapped_with_a_yubikey_second_factor()
new NameId('N-ID'),
new CommonName($command->commonName),
new Email($command->email),
- new Locale('nl_NL')
+ new Locale('nl_NL'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -219,8 +203,8 @@ public function an_identity_can_be_bootstrapped_with_a_yubikey_second_factor()
new Email($command->email),
new Locale('nl_NL'),
new SecondFactorId('SF-ID'),
- new YubikeyPublicId('93193884')
- )
+ new YubikeyPublicId('93193884'),
+ ),
]);
}
@@ -229,16 +213,16 @@ public function an_identity_can_be_bootstrapped_with_a_yubikey_second_factor()
* @group command-handler
* @runInSeparateProcess
*/
- public function an_identity_cannot_be_bootstrapped_twice()
+ public function an_identity_cannot_be_bootstrapped_twice(): void
{
- $command = new BootstrapIdentityWithYubikeySecondFactorCommand();
- $command->identityId = 'ID-ID';
- $command->nameId = 'N-ID';
- $command->institution = 'Institution';
- $command->commonName = 'Enrique';
- $command->email = 'foo@domain.invalid';
+ $command = new BootstrapIdentityWithYubikeySecondFactorCommand();
+ $command->identityId = 'ID-ID';
+ $command->nameId = 'N-ID';
+ $command->institution = 'Institution';
+ $command->commonName = 'Enrique';
+ $command->email = 'foo@domain.invalid';
$command->preferredLocale = 'nl_NL';
- $command->secondFactorId = 'SF-ID';
+ $command->secondFactorId = 'SF-ID';
$command->yubikeyPublicId = '93193884';
$this->identityProjectionRepository->shouldReceive('hasIdentityWithNameIdAndInstitution')->andReturn(true);
@@ -257,28 +241,26 @@ public function an_identity_cannot_be_bootstrapped_twice()
* @group command-handler
* @runInSeparateProcess
*/
- public function a_yubikey_possession_can_be_proven()
+ public function a_yubikey_possession_can_be_proven(): void
{
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@12345')));
- m::mock('alias:Surfnet\StepupBundle\Security\OtpGenerator')
- ->shouldReceive('generate')->once()->andReturn('regcode');
- m::mock('alias:Surfnet\Stepup\Token\TokenGenerator')
+ m::mock('alias:'.TokenGenerator::class)
->shouldReceive('generateNonce')->once()->andReturn('nonce');
- $id = new IdentityId(self::uuid());
- $institution = new Institution('A Corp.');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secFacId = new SecondFactorId(self::uuid());
- $pubId = new YubikeyPublicId('00028278');
+ $id = new IdentityId(self::uuid());
+ $institution = new Institution('A Corp.');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secFacId = new SecondFactorId(self::uuid());
+ $pubId = new YubikeyPublicId('00028278');
- $command = new ProveYubikeyPossessionCommand();
- $command->identityId = (string) $id;
- $command->secondFactorId = (string) $secFacId;
- $command->yubikeyPublicId = (string) $pubId;
+ $command = new ProveYubikeyPossessionCommand();
+ $command->identityId = (string)$id;
+ $command->secondFactorId = (string)$secFacId;
+ $command->yubikeyPublicId = (string)$pubId;
$this->configService->shouldReceive('getMaxNumberOfTokensFor')->andReturn(2);
@@ -288,14 +270,16 @@ public function a_yubikey_possession_can_be_proven()
$this->scenario
->withAggregateId($id)
- ->given([new IdentityCreatedEvent(
- $id,
- $institution,
- $nameId,
- $commonName,
- $email,
- $preferredLocale
- )])
+ ->given([
+ new IdentityCreatedEvent(
+ $id,
+ $institution,
+ $nameId,
+ $commonName,
+ $email,
+ $preferredLocale,
+ ),
+ ])
->when($command)
->then([
new YubikeyPossessionProvenEvent(
@@ -305,14 +289,14 @@ public function a_yubikey_possession_can_be_proven()
$pubId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$commonName,
$email,
- $preferredLocale
- )
+ $preferredLocale,
+ ),
]);
}
@@ -321,28 +305,23 @@ public function a_yubikey_possession_can_be_proven()
* @group command-handler
* @runInSeparateProcess
*/
- public function a_yubikey_possession_cannot_be_proven_if_the_second_factor_is_not_allowed_by_the_institution()
+ public function a_yubikey_possession_cannot_be_proven_if_the_second_factor_is_not_allowed_by_the_institution(): void
{
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@12345')));
- m::mock('alias:Surfnet\StepupBundle\Security\OtpGenerator')
- ->shouldReceive('generate')->once()->andReturn('regcode');
- m::mock('alias:Surfnet\Stepup\Token\TokenGenerator')
- ->shouldReceive('generateNonce')->once()->andReturn('nonce');
-
- $id = new IdentityId(self::uuid());
- $institution = new Institution('A Corp.');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secFacId = new SecondFactorId(self::uuid());
- $pubId = new YubikeyPublicId('00028278');
+ $id = new IdentityId(self::uuid());
+ $institution = new Institution('A Corp.');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secFacId = new SecondFactorId(self::uuid());
+ $pubId = new YubikeyPublicId('00028278');
- $command = new ProveYubikeyPossessionCommand();
- $command->identityId = (string) $id;
- $command->secondFactorId = (string) $secFacId;
- $command->yubikeyPublicId = (string) $pubId;
+ $command = new ProveYubikeyPossessionCommand();
+ $command->identityId = (string)$id;
+ $command->secondFactorId = (string)$secFacId;
+ $command->yubikeyPublicId = (string)$pubId;
$this->configService->shouldReceive('getMaxNumberOfTokensFor')->andReturn(2);
@@ -355,14 +334,16 @@ public function a_yubikey_possession_cannot_be_proven_if_the_second_factor_is_no
$this->scenario
->withAggregateId($id)
- ->given([new IdentityCreatedEvent(
- $id,
- $institution,
- $nameId,
- $commonName,
- $email,
- $preferredLocale
- )])
+ ->given([
+ new IdentityCreatedEvent(
+ $id,
+ $institution,
+ $nameId,
+ $commonName,
+ $email,
+ $preferredLocale,
+ ),
+ ])
->when($command);
}
@@ -370,19 +351,19 @@ public function a_yubikey_possession_cannot_be_proven_if_the_second_factor_is_no
* @test
* @group command-handler
*/
- public function yubikey_possession_cannot_be_proven_twice()
+ public function yubikey_possession_cannot_be_proven_twice(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessage('more than 1 token(s)');
- $id = new IdentityId(self::uuid());
- $institution = new Institution('A Corp.');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secFacId1 = new SecondFactorId(self::uuid());
- $pubId1 = new YubikeyPublicId('00028278');
+ $id = new IdentityId(self::uuid());
+ $institution = new Institution('A Corp.');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secFacId1 = new SecondFactorId(self::uuid());
+ $pubId1 = new YubikeyPublicId('00028278');
$this->allowedSecondFactorListServiceMock
->shouldReceive('getAllowedSecondFactorListFor')
@@ -390,10 +371,10 @@ public function yubikey_possession_cannot_be_proven_twice()
$this->configService->shouldReceive('getMaxNumberOfTokensFor')->andReturn(1);
- $command = new ProveYubikeyPossessionCommand();
- $command->identityId = (string) $id;
- $command->secondFactorId = (string) $secFacId1;
- $command->yubikeyPublicId = (string) $pubId1;
+ $command = new ProveYubikeyPossessionCommand();
+ $command->identityId = (string)$id;
+ $command->secondFactorId = (string)$secFacId1;
+ $command->yubikeyPublicId = (string)$pubId1;
$this->scenario
->withAggregateId($id)
@@ -404,7 +385,7 @@ public function yubikey_possession_cannot_be_proven_twice()
$nameId,
$commonName,
$email,
- $preferredLocale
+ $preferredLocale,
),
new YubikeyPossessionProvenEvent(
$id,
@@ -413,14 +394,14 @@ public function yubikey_possession_cannot_be_proven_twice()
$pubId1,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$commonName,
$email,
- $preferredLocale
- )
+ $preferredLocale,
+ ),
])
->when($command);
}
@@ -430,23 +411,21 @@ public function yubikey_possession_cannot_be_proven_twice()
* @group command-handler
* @runInSeparateProcess
*/
- public function a_phone_possession_can_be_proven()
+ public function a_phone_possession_can_be_proven(): void
{
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@12345')));
- m::mock('alias:Surfnet\StepupBundle\Security\OtpGenerator')
- ->shouldReceive('generate')->once()->andReturn('regcode');
- m::mock('alias:Surfnet\Stepup\Token\TokenGenerator')
+ m::mock('alias:'.TokenGenerator::class)
->shouldReceive('generateNonce')->once()->andReturn('nonce');
- $id = new IdentityId(self::uuid());
- $institution = new Institution('A Corp.');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secFacId = new SecondFactorId(self::uuid());
- $phoneNumber = new PhoneNumber('+31 (0) 612345678');
+ $id = new IdentityId(self::uuid());
+ $institution = new Institution('A Corp.');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secFacId = new SecondFactorId(self::uuid());
+ $phoneNumber = new PhoneNumber('+31 (0) 612345678');
$this->allowedSecondFactorListServiceMock
->shouldReceive('getAllowedSecondFactorListFor')
@@ -454,21 +433,23 @@ public function a_phone_possession_can_be_proven()
$this->configService->shouldReceive('getMaxNumberOfTokensFor')->andReturn(2);
- $command = new ProvePhonePossessionCommand();
- $command->identityId = (string) $id;
- $command->secondFactorId = (string) $secFacId;
- $command->phoneNumber = (string) $phoneNumber;
+ $command = new ProvePhonePossessionCommand();
+ $command->identityId = (string)$id;
+ $command->secondFactorId = (string)$secFacId;
+ $command->phoneNumber = (string)$phoneNumber;
$this->scenario
->withAggregateId($id)
- ->given([new IdentityCreatedEvent(
- $id,
- $institution,
- $nameId,
- $commonName,
- $email,
- $preferredLocale
- )])
+ ->given([
+ new IdentityCreatedEvent(
+ $id,
+ $institution,
+ $nameId,
+ $commonName,
+ $email,
+ $preferredLocale,
+ ),
+ ])
->when($command)
->then([
new PhonePossessionProvenEvent(
@@ -478,14 +459,14 @@ public function a_phone_possession_can_be_proven()
$phoneNumber,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$commonName,
$email,
- $preferredLocale
- )
+ $preferredLocale,
+ ),
]);
}
@@ -494,23 +475,18 @@ public function a_phone_possession_can_be_proven()
* @group command-handler
* @runInSeparateProcess
*/
- public function a_phone_possession_cannot_be_proven_if_the_second_factor_is_not_allowed_by_the_institution()
+ public function a_phone_possession_cannot_be_proven_if_the_second_factor_is_not_allowed_by_the_institution(): void
{
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@12345')));
- m::mock('alias:Surfnet\StepupBundle\Security\OtpGenerator')
- ->shouldReceive('generate')->once()->andReturn('regcode');
- m::mock('alias:Surfnet\Stepup\Token\TokenGenerator')
- ->shouldReceive('generateNonce')->once()->andReturn('nonce');
-
- $id = new IdentityId(self::uuid());
- $institution = new Institution('A Corp.');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secFacId = new SecondFactorId(self::uuid());
- $phoneNumber = new PhoneNumber('+31 (0) 612345678');
+ $id = new IdentityId(self::uuid());
+ $institution = new Institution('A Corp.');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secFacId = new SecondFactorId(self::uuid());
+ $phoneNumber = new PhoneNumber('+31 (0) 612345678');
$this->allowedSecondFactorListServiceMock
->shouldReceive('getAllowedSecondFactorListFor')
@@ -519,21 +495,23 @@ public function a_phone_possession_cannot_be_proven_if_the_second_factor_is_not_
$this->expectException(SecondFactorNotAllowedException::class);
$this->expectExceptionMessage('does not support second factor');
- $command = new ProvePhonePossessionCommand();
- $command->identityId = (string) $id;
- $command->secondFactorId = (string) $secFacId;
- $command->phoneNumber = (string) $phoneNumber;
+ $command = new ProvePhonePossessionCommand();
+ $command->identityId = (string)$id;
+ $command->secondFactorId = (string)$secFacId;
+ $command->phoneNumber = (string)$phoneNumber;
$this->scenario
->withAggregateId($id)
- ->given([new IdentityCreatedEvent(
- $id,
- $institution,
- $nameId,
- $commonName,
- $email,
- $preferredLocale
- )])
+ ->given([
+ new IdentityCreatedEvent(
+ $id,
+ $institution,
+ $nameId,
+ $commonName,
+ $email,
+ $preferredLocale,
+ ),
+ ])
->when($command)
->then([]);
}
@@ -543,26 +521,23 @@ public function a_phone_possession_cannot_be_proven_if_the_second_factor_is_not_
* @group command-handler
* @runInSeparateProcess
*/
- public function a_gssf_possession_can_be_proven()
+ public function a_gssf_possession_can_be_proven(): void
{
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@12345')));
- m::mock('alias:Surfnet\StepupBundle\Security\OtpGenerator')
- ->shouldReceive('generate')->once()->andReturn('regcode');
-
$nonce = 'nonce';
- m::mock('alias:Surfnet\Stepup\Token\TokenGenerator')
+ m::mock('alias:'.TokenGenerator::class)
->shouldReceive('generateNonce')->once()->andReturn($nonce);
- $identityId = new IdentityId(self::uuid());
- $institution = new Institution('Surfnet');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secondFactorId = new SecondFactorId(self::uuid());
- $stepupProvider = new StepupProvider('tiqr');
- $gssfId = new GssfId('_' . md5('Surfnet'));
+ $identityId = new IdentityId(self::uuid());
+ $institution = new Institution('Surfnet');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secondFactorId = new SecondFactorId(self::uuid());
+ $stepupProvider = new StepupProvider('tiqr');
+ $gssfId = new GssfId('_' . md5('Surfnet'));
$this->allowedSecondFactorListServiceMock
->shouldReceive('getAllowedSecondFactorListFor')
@@ -572,28 +547,30 @@ public function a_gssf_possession_can_be_proven()
new SecondFactorType('biometric'),
new SecondFactorType('tiqr'),
new SecondFactorType('anotherGssp'),
- ]
- )
+ ],
+ ),
);
$this->configService->shouldReceive('getMaxNumberOfTokensFor')->andReturn(2);
- $command = new ProveGssfPossessionCommand();
- $command->identityId = (string) $identityId;
- $command->secondFactorId = (string) $secondFactorId;
- $command->stepupProvider = (string) $stepupProvider;
- $command->gssfId = (string) $gssfId;
+ $command = new ProveGssfPossessionCommand();
+ $command->identityId = (string)$identityId;
+ $command->secondFactorId = (string)$secondFactorId;
+ $command->stepupProvider = (string)$stepupProvider;
+ $command->gssfId = (string)$gssfId;
$this->scenario
->withAggregateId($identityId)
- ->given([new IdentityCreatedEvent(
- $identityId,
- $institution,
- $nameId,
- $commonName,
- $email,
- $preferredLocale
- )])
+ ->given([
+ new IdentityCreatedEvent(
+ $identityId,
+ $institution,
+ $nameId,
+ $commonName,
+ $email,
+ $preferredLocale,
+ ),
+ ])
->when($command)
->then([
new GssfPossessionProvenEvent(
@@ -604,14 +581,14 @@ public function a_gssf_possession_can_be_proven()
$gssfId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
$nonce,
$commonName,
$email,
- $preferredLocale
- )
+ $preferredLocale,
+ ),
]);
}
@@ -621,26 +598,19 @@ public function a_gssf_possession_can_be_proven()
* @group command-handler
* @runInSeparateProcess
*/
- public function a_gssf_possession_can_not_be_proven_if_the_second_factor_is_not_allowed_by_the_institution()
+ public function a_gssf_possession_can_not_be_proven_if_the_second_factor_is_not_allowed_by_the_institution(): void
{
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@12345')));
- m::mock('alias:Surfnet\StepupBundle\Security\OtpGenerator')
- ->shouldReceive('generate')->once()->andReturn('regcode');
-
- $nonce = 'nonce';
- m::mock('alias:Surfnet\Stepup\Token\TokenGenerator')
- ->shouldReceive('generateNonce')->once()->andReturn($nonce);
-
- $identityId = new IdentityId(self::uuid());
- $institution = new Institution('Surfnet');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secondFactorId = new SecondFactorId(self::uuid());
- $stepupProvider = new StepupProvider('tiqr');
- $gssfId = new GssfId('_' . md5('Surfnet'));
+ $identityId = new IdentityId(self::uuid());
+ $institution = new Institution('Surfnet');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secondFactorId = new SecondFactorId(self::uuid());
+ $stepupProvider = new StepupProvider('tiqr');
+ $gssfId = new GssfId('_' . md5('Surfnet'));
$this->allowedSecondFactorListServiceMock
->shouldReceive('getAllowedSecondFactorListFor')
@@ -649,22 +619,24 @@ public function a_gssf_possession_can_not_be_proven_if_the_second_factor_is_not_
$this->expectException(SecondFactorNotAllowedException::class);
$this->expectExceptionMessage('does not support second factor');
- $command = new ProveGssfPossessionCommand();
- $command->identityId = (string) $identityId;
- $command->secondFactorId = (string) $secondFactorId;
- $command->stepupProvider = (string) $stepupProvider;
- $command->gssfId = (string) $gssfId;
+ $command = new ProveGssfPossessionCommand();
+ $command->identityId = (string)$identityId;
+ $command->secondFactorId = (string)$secondFactorId;
+ $command->stepupProvider = (string)$stepupProvider;
+ $command->gssfId = (string)$gssfId;
$this->scenario
->withAggregateId($identityId)
- ->given([new IdentityCreatedEvent(
- $identityId,
- $institution,
- $nameId,
- $commonName,
- $email,
- $preferredLocale
- )])
+ ->given([
+ new IdentityCreatedEvent(
+ $identityId,
+ $institution,
+ $nameId,
+ $commonName,
+ $email,
+ $preferredLocale,
+ ),
+ ])
->when($command)
->then([]);
}
@@ -674,23 +646,21 @@ public function a_gssf_possession_can_not_be_proven_if_the_second_factor_is_not_
* @group command-handler
* @runInSeparateProcess
*/
- public function a_u2f_device_possession_can_be_proven()
+ public function a_u2f_device_possession_can_be_proven(): void
{
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@12345')));
- m::mock('alias:Surfnet\StepupBundle\Security\OtpGenerator')
- ->shouldReceive('generate')->once()->andReturn('regcode');
- m::mock('alias:Surfnet\Stepup\Token\TokenGenerator')
+ m::mock('alias:'.TokenGenerator::class)
->shouldReceive('generateNonce')->once()->andReturn('nonce');
- $id = new IdentityId(self::uuid());
- $institution = new Institution('A Corp.');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secFacId = new SecondFactorId(self::uuid());
- $keyHandle = new U2fKeyHandle('DMUV_wX');
+ $id = new IdentityId(self::uuid());
+ $institution = new Institution('A Corp.');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secFacId = new SecondFactorId(self::uuid());
+ $keyHandle = new U2fKeyHandle('DMUV_wX');
$this->allowedSecondFactorListServiceMock
->shouldReceive('getAllowedSecondFactorListFor')
@@ -698,21 +668,23 @@ public function a_u2f_device_possession_can_be_proven()
$this->configService->shouldReceive('getMaxNumberOfTokensFor')->andReturn(2);
- $command = new ProveU2fDevicePossessionCommand();
- $command->identityId = (string) $id;
- $command->secondFactorId = (string) $secFacId;
- $command->keyHandle = $keyHandle->getValue();
+ $command = new ProveU2fDevicePossessionCommand();
+ $command->identityId = (string)$id;
+ $command->secondFactorId = (string)$secFacId;
+ $command->keyHandle = $keyHandle->getValue();
$this->scenario
->withAggregateId($id)
- ->given([new IdentityCreatedEvent(
- $id,
- $institution,
- $nameId,
- $commonName,
- $email,
- $preferredLocale
- )])
+ ->given([
+ new IdentityCreatedEvent(
+ $id,
+ $institution,
+ $nameId,
+ $commonName,
+ $email,
+ $preferredLocale,
+ ),
+ ])
->when($command)
->then([
new U2fDevicePossessionProvenEvent(
@@ -722,14 +694,14 @@ public function a_u2f_device_possession_can_be_proven()
$keyHandle,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$commonName,
$email,
- $preferredLocale
- )
+ $preferredLocale,
+ ),
]);
}
@@ -738,23 +710,18 @@ public function a_u2f_device_possession_can_be_proven()
* @group command-handler
* @runInSeparateProcess
*/
- public function a_u2f_device_possession_cannot_be_proven_if_the_second_factor_is_not_allowed_by_the_institution()
+ public function a_u2f_device_possession_cannot_be_proven_if_the_second_factor_is_not_allowed_by_the_institution(): void
{
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@12345')));
- m::mock('alias:Surfnet\StepupBundle\Security\OtpGenerator')
- ->shouldReceive('generate')->once()->andReturn('regcode');
- m::mock('alias:Surfnet\Stepup\Token\TokenGenerator')
- ->shouldReceive('generateNonce')->once()->andReturn('nonce');
-
- $id = new IdentityId(self::uuid());
- $institution = new Institution('A Corp.');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secFacId = new SecondFactorId(self::uuid());
- $keyHandle = new U2fKeyHandle('DMUV_wX');
+ $id = new IdentityId(self::uuid());
+ $institution = new Institution('A Corp.');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secFacId = new SecondFactorId(self::uuid());
+ $keyHandle = new U2fKeyHandle('DMUV_wX');
$this->allowedSecondFactorListServiceMock
->shouldReceive('getAllowedSecondFactorListFor')
@@ -763,21 +730,23 @@ public function a_u2f_device_possession_cannot_be_proven_if_the_second_factor_is
$this->expectException(SecondFactorNotAllowedException::class);
$this->expectExceptionMessage('does not support second factor');
- $command = new ProveU2fDevicePossessionCommand();
- $command->identityId = (string) $id;
- $command->secondFactorId = (string) $secFacId;
- $command->keyHandle = $keyHandle->getValue();
+ $command = new ProveU2fDevicePossessionCommand();
+ $command->identityId = (string)$id;
+ $command->secondFactorId = (string)$secFacId;
+ $command->keyHandle = $keyHandle->getValue();
$this->scenario
->withAggregateId($id)
- ->given([new IdentityCreatedEvent(
- $id,
- $institution,
- $nameId,
- $commonName,
- $email,
- $preferredLocale
- )])
+ ->given([
+ new IdentityCreatedEvent(
+ $id,
+ $institution,
+ $nameId,
+ $commonName,
+ $email,
+ $preferredLocale,
+ ),
+ ])
->when($command)
->then([]);
}
@@ -786,24 +755,24 @@ public function a_u2f_device_possession_cannot_be_proven_if_the_second_factor_is
* @test
* @group command-handler
*/
- public function phone_possession_cannot_be_proven_twice()
+ public function phone_possession_cannot_be_proven_twice(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessage('more than 1 token(s)');
- $id = new IdentityId(self::uuid());
- $institution = new Institution('A Corp.');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secFacId1 = new SecondFactorId(self::uuid());
- $phoneNumber1 = new PhoneNumber('+31 (0) 612345678');
+ $id = new IdentityId(self::uuid());
+ $institution = new Institution('A Corp.');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secFacId1 = new SecondFactorId(self::uuid());
+ $phoneNumber1 = new PhoneNumber('+31 (0) 612345678');
- $command = new ProvePhonePossessionCommand();
- $command->identityId = (string) $id;
- $command->secondFactorId = (string) $secFacId1;
- $command->phoneNumber = (string) $phoneNumber1;
+ $command = new ProvePhonePossessionCommand();
+ $command->identityId = (string)$id;
+ $command->secondFactorId = (string)$secFacId1;
+ $command->phoneNumber = (string)$phoneNumber1;
$this->allowedSecondFactorListServiceMock
->shouldReceive('getAllowedSecondFactorListFor')
@@ -820,7 +789,7 @@ public function phone_possession_cannot_be_proven_twice()
$nameId,
$commonName,
$email,
- $preferredLocale
+ $preferredLocale,
),
new PhonePossessionProvenEvent(
$id,
@@ -829,14 +798,14 @@ public function phone_possession_cannot_be_proven_twice()
$phoneNumber1,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$commonName,
$email,
- $preferredLocale
- )
+ $preferredLocale,
+ ),
])
->when($command);
}
@@ -845,20 +814,20 @@ public function phone_possession_cannot_be_proven_twice()
* @test
* @group command-handler
*/
- public function cannot_prove_possession_of_arbitrary_second_factor_type_twice()
+ public function cannot_prove_possession_of_arbitrary_second_factor_type_twice(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessage('more than 1 token(s)');
- $id = new IdentityId(self::uuid());
- $institution = new Institution('A Corp.');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secFacId1 = new SecondFactorId(self::uuid());
- $publicId = new YubikeyPublicId('00028278');
- $phoneNumber = new PhoneNumber('+31 (0) 676543210');
+ $id = new IdentityId(self::uuid());
+ $institution = new Institution('A Corp.');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secFacId1 = new SecondFactorId(self::uuid());
+ $publicId = new YubikeyPublicId('00028278');
+ $phoneNumber = new PhoneNumber('+31 (0) 676543210');
$this->allowedSecondFactorListServiceMock
->shouldReceive('getAllowedSecondFactorListFor')
@@ -867,9 +836,9 @@ public function cannot_prove_possession_of_arbitrary_second_factor_type_twice()
$this->configService->shouldReceive('getMaxNumberOfTokensFor')->andReturn(1);
$command = new ProvePhonePossessionCommand();
- $command->identityId = (string) $id;
- $command->secondFactorId = (string) $secFacId1;
- $command->phoneNumber = (string) $phoneNumber;
+ $command->identityId = (string)$id;
+ $command->secondFactorId = (string)$secFacId1;
+ $command->phoneNumber = (string)$phoneNumber;
$this->scenario
->withAggregateId($id)
@@ -880,7 +849,7 @@ public function cannot_prove_possession_of_arbitrary_second_factor_type_twice()
$nameId,
$commonName,
$email,
- $preferredLocale
+ $preferredLocale,
),
new YubikeyPossessionProvenEvent(
$id,
@@ -889,14 +858,14 @@ public function cannot_prove_possession_of_arbitrary_second_factor_type_twice()
$publicId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$commonName,
$email,
- $preferredLocale
- )
+ $preferredLocale,
+ ),
])
->when($command);
}
@@ -906,24 +875,24 @@ public function cannot_prove_possession_of_arbitrary_second_factor_type_twice()
* @group command-handler
* @runInSeparateProcess
*/
- public function an_unverified_second_factors_email_can_be_verified()
+ public function an_unverified_second_factors_email_can_be_verified(): void
{
DateTimeHelper::setCurrentTime(new DateTime(new CoreDateTime('@12345')));
m::mock('alias:Surfnet\StepupBundle\Security\OtpGenerator')
->shouldReceive('generate')->once()->andReturn('regcode');
- $id = new IdentityId(self::uuid());
- $institution = new Institution('A Corp.');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secondFactorId = new SecondFactorId(self::uuid());
+ $id = new IdentityId(self::uuid());
+ $institution = new Institution('A Corp.');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secondFactorId = new SecondFactorId(self::uuid());
$secondFactorIdentifier = new YubikeyPublicId('00028278');
- $command = new VerifyEmailCommand();
- $command->identityId = (string) $id;
+ $command = new VerifyEmailCommand();
+ $command->identityId = (string)$id;
$command->verificationNonce = 'nonce';
$this->scenario
@@ -935,7 +904,7 @@ public function an_unverified_second_factors_email_can_be_verified()
$nameId,
$commonName,
$email,
- $preferredLocale
+ $preferredLocale,
),
new YubikeyPossessionProvenEvent(
$id,
@@ -944,14 +913,14 @@ public function an_unverified_second_factors_email_can_be_verified()
$secondFactorIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$commonName,
$email,
- $preferredLocale
- )
+ $preferredLocale,
+ ),
])
->when($command)
->then([
@@ -965,8 +934,8 @@ public function an_unverified_second_factors_email_can_be_verified()
'regcode',
$commonName,
$email,
- $preferredLocale
- )
+ $preferredLocale,
+ ),
]);
}
@@ -974,22 +943,24 @@ public function an_unverified_second_factors_email_can_be_verified()
* @test
* @group command-handler
*/
- public function a_verified_second_factors_email_cannot_be_verified()
+ public function a_verified_second_factors_email_cannot_be_verified(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
- $this->expectExceptionMessage('Cannot verify second factor, no unverified second factor can be verified using the given nonce');
-
- $id = new IdentityId(self::uuid());
- $institution = new Institution('A Corp.');
- $nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
- $secondFactorId = new SecondFactorId(self::uuid());
+ $this->expectException(DomainException::class);
+ $this->expectExceptionMessage(
+ 'Cannot verify second factor, no unverified second factor can be verified using the given nonce',
+ );
+
+ $id = new IdentityId(self::uuid());
+ $institution = new Institution('A Corp.');
+ $nameId = new NameId(md5(__METHOD__));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
+ $secondFactorId = new SecondFactorId(self::uuid());
$secondFactorIdentifier = new YubikeyPublicId('00028278');
$command = new VerifyEmailCommand();
- $command->identityId = (string) $id;
+ $command->identityId = (string)$id;
$command->verificationNonce = 'nonce';
$this->scenario
@@ -1001,7 +972,7 @@ public function a_verified_second_factors_email_cannot_be_verified()
$nameId,
$commonName,
$email,
- $preferredLocale
+ $preferredLocale,
),
new YubikeyPossessionProvenEvent(
$id,
@@ -1010,13 +981,13 @@ public function a_verified_second_factors_email_cannot_be_verified()
$secondFactorIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$commonName,
$email,
- $preferredLocale
+ $preferredLocale,
),
new EmailVerifiedEvent(
$id,
@@ -1028,8 +999,8 @@ public function a_verified_second_factors_email_cannot_be_verified()
'regcode',
$commonName,
$email,
- $preferredLocale
- )
+ $preferredLocale,
+ ),
])
->when($command);
}
@@ -1038,9 +1009,9 @@ public function a_verified_second_factors_email_cannot_be_verified()
* @test
* @group command-handler
*/
- public function cannot_verify_an_email_after_the_verification_window_has_closed()
+ public function cannot_verify_an_email_after_the_verification_window_has_closed(): void
{
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
$this->expectExceptionMessage('Cannot verify second factor, the verification window is closed.');
$id = new IdentityId(self::uuid());
@@ -1048,12 +1019,12 @@ public function cannot_verify_an_email_after_the_verification_window_has_closed(
$publicId = new YubikeyPublicId('00028278');
$institution = new Institution('A Corp.');
$nameId = new NameId(md5(__METHOD__));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $preferredLocale = new Locale('en_GB');
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $preferredLocale = new Locale('en_GB');
$command = new VerifyEmailCommand();
- $command->identityId = (string) $id;
+ $command->identityId = (string)$id;
$command->verificationNonce = 'nonce';
$this->scenario
@@ -1065,7 +1036,7 @@ public function cannot_verify_an_email_after_the_verification_window_has_closed(
$nameId,
$commonName,
$email,
- $preferredLocale
+ $preferredLocale,
),
new YubikeyPossessionProvenEvent(
$id,
@@ -1074,14 +1045,14 @@ public function cannot_verify_an_email_after_the_verification_window_has_closed(
$publicId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- new DateTime(new CoreDateTime('-2 days'))
+ TimeFrame::ofSeconds(self::$window),
+ new DateTime(new CoreDateTime('-2 days')),
),
'nonce',
$commonName,
$email,
- $preferredLocale
- )
+ $preferredLocale,
+ ),
])
->when($command);
}
@@ -1090,7 +1061,7 @@ public function cannot_verify_an_email_after_the_verification_window_has_closed(
* @test
* @group command-handler
*/
- public function it_can_create_a_new_identity()
+ public function it_can_create_a_new_identity(): void
{
$createCommand = new CreateIdentityCommand();
$createCommand->UUID = '1';
@@ -1101,12 +1072,12 @@ public function it_can_create_a_new_identity()
$createCommand->email = 'a@domain.invalid';
$createCommand->commonName = 'foobar';
- $identityId = new IdentityId($createCommand->id);
- $identityInstitution = new Institution($createCommand->institution);
- $identityNameId = new NameId($createCommand->nameId);
- $identityEmail = new Email($createCommand->email);
- $identityCommonName = new CommonName($createCommand->commonName);
- $identityPreferredLocale = new Locale($createCommand->preferredLocale);
+ $identityId = new IdentityId($createCommand->id);
+ $identityInstitution = new Institution($createCommand->institution);
+ $identityNameId = new NameId($createCommand->nameId);
+ $identityEmail = new Email($createCommand->email);
+ $identityCommonName = new CommonName($createCommand->commonName);
+ $identityPreferredLocale = new Locale($createCommand->preferredLocale);
$createdEvent = new IdentityCreatedEvent(
$identityId,
@@ -1114,7 +1085,7 @@ public function it_can_create_a_new_identity()
$identityNameId,
$identityCommonName,
$identityEmail,
- $identityPreferredLocale
+ $identityPreferredLocale,
);
$this->scenario
@@ -1129,12 +1100,12 @@ public function it_can_create_a_new_identity()
* @test
* @group command-handler
*/
- public function an_identity_can_be_updated()
+ public function an_identity_can_be_updated(): void
{
- $id = new IdentityId('42');
- $institution = new Institution('A Corp.');
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
+ $id = new IdentityId('42');
+ $institution = new Institution('A Corp.');
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
$createdEvent = new IdentityCreatedEvent(
$id,
@@ -1142,12 +1113,12 @@ public function an_identity_can_be_updated()
new NameId('3'),
$commonName,
$email,
- new Locale('de_DE')
+ new Locale('de_DE'),
);
- $updateCommand = new UpdateIdentityCommand();
- $updateCommand->id = $id->getIdentityId();
- $updateCommand->email = 'new-email@domain.invalid';
+ $updateCommand = new UpdateIdentityCommand();
+ $updateCommand->id = $id->getIdentityId();
+ $updateCommand->email = 'new-email@domain.invalid';
$updateCommand->commonName = 'Henk Hendriksen';
$this->scenario
@@ -1156,7 +1127,7 @@ public function an_identity_can_be_updated()
->when($updateCommand)
->then([
new IdentityRenamedEvent($id, $institution, new CommonName($updateCommand->commonName)),
- new IdentityEmailChangedEvent($id, $institution, new Email($updateCommand->email))
+ new IdentityEmailChangedEvent($id, $institution, new Email($updateCommand->email)),
]);
}
@@ -1164,12 +1135,12 @@ public function an_identity_can_be_updated()
* @test
* @group command-handler
*/
- public function an_identity_can_be_updated_twice_only_emitting_events_when_changed()
+ public function an_identity_can_be_updated_twice_only_emitting_events_when_changed(): void
{
- $id = new IdentityId('42');
- $institution = new Institution('A Corp.');
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
+ $id = new IdentityId('42');
+ $institution = new Institution('A Corp.');
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
$createdEvent = new IdentityCreatedEvent(
$id,
@@ -1177,12 +1148,12 @@ public function an_identity_can_be_updated_twice_only_emitting_events_when_chang
new NameId('3'),
$commonName,
$email,
- new Locale('de_DE')
+ new Locale('de_DE'),
);
- $updateCommand = new UpdateIdentityCommand();
- $updateCommand->id = $id->getIdentityId();
- $updateCommand->email = 'new-email@domain.invalid';
+ $updateCommand = new UpdateIdentityCommand();
+ $updateCommand->id = $id->getIdentityId();
+ $updateCommand->email = 'new-email@domain.invalid';
$updateCommand->commonName = 'Henk Hendriksen';
$this->scenario
@@ -1192,7 +1163,7 @@ public function an_identity_can_be_updated_twice_only_emitting_events_when_chang
->when($updateCommand)
->then([
new IdentityRenamedEvent($id, $institution, new CommonName($updateCommand->commonName)),
- new IdentityEmailChangedEvent($id, $institution, new Email($updateCommand->email))
+ new IdentityEmailChangedEvent($id, $institution, new Email($updateCommand->email)),
]);
}
@@ -1200,38 +1171,38 @@ public function an_identity_can_be_updated_twice_only_emitting_events_when_chang
* @test
* @group command-handler
*/
- public function a_second_factor_can_be_vetted()
+ public function a_second_factor_can_be_vetted(): void
{
- $command = new VetSecondFactorCommand();
- $command->authorityId = 'AID';
- $command->identityId = 'IID';
- $command->secondFactorId = 'ISFID';
- $command->registrationCode = 'REGCODE';
- $command->secondFactorType = 'yubikey';
+ $command = new VetSecondFactorCommand();
+ $command->authorityId = 'AID';
+ $command->identityId = 'IID';
+ $command->secondFactorId = 'ISFID';
+ $command->registrationCode = 'REGCODE';
+ $command->secondFactorType = 'yubikey';
$command->secondFactorIdentifier = '00028278';
- $command->documentNumber = 'NH9392';
- $command->identityVerified = true;
+ $command->documentNumber = 'NH9392';
+ $command->identityVerified = true;
$command->provePossessionSkipped = false;
- $authorityId = new IdentityId($command->authorityId);
- $authorityNameId = new NameId($this->uuid());
- $authorityInstitution = new Institution('Wazoo');
- $authorityEmail = new Email('info@domain.invalid');
- $authorityCommonName = new CommonName('Henk Westbroek');
+ $authorityId = new IdentityId($command->authorityId);
+ $authorityNameId = new NameId($this->uuid());
+ $authorityInstitution = new Institution('Wazoo');
+ $authorityEmail = new Email('info@domain.invalid');
+ $authorityCommonName = new CommonName('Henk Westbroek');
- $registrantId = new IdentityId($command->identityId);
- $registrantInstitution = new Institution('A Corp.');
- $registrantNameId = new NameId('3');
- $registrantEmail = new Email('reg@domain.invalid');
- $registrantCommonName = new CommonName('Reginald Waterloo');
- $registrantSecFacId = new SecondFactorId('ISFID');
- $registrantSecFacIdentifier = new YubikeyPublicId('00028278');
+ $registrantId = new IdentityId($command->identityId);
+ $registrantInstitution = new Institution('A Corp.');
+ $registrantNameId = new NameId('3');
+ $registrantEmail = new Email('reg@domain.invalid');
+ $registrantCommonName = new CommonName('Reginald Waterloo');
+ $registrantSecFacId = new SecondFactorId('ISFID');
+ $registrantSecFacIdentifier = new YubikeyPublicId('00028278');
$this->secondFactorTypeService->shouldReceive('hasEqualOrLowerLoaComparedTo')->andReturn(true);
$secondFactorType = new SecondFactorType($command->secondFactorType);
$this->secondFactorProvePossessionHelper->shouldReceive('canSkipProvePossession')
- ->with(Matchers::equalTo($secondFactorType))
+ ->with(new IsEqual($secondFactorType))
->andReturn(false);
$this->scenario
@@ -1243,7 +1214,7 @@ public function a_second_factor_can_be_vetted()
$authorityNameId,
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$authorityId,
@@ -1253,8 +1224,8 @@ public function a_second_factor_can_be_vetted()
$authorityEmail,
new Locale('en_GB'),
new SecondFactorId($this->uuid()),
- new YubikeyPublicId('00000012')
- )
+ new YubikeyPublicId('00000012'),
+ ),
])
->withAggregateId($registrantId)
->given([
@@ -1264,7 +1235,7 @@ public function a_second_factor_can_be_vetted()
$registrantNameId,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$registrantId,
@@ -1273,13 +1244,13 @@ public function a_second_factor_can_be_vetted()
$registrantSecFacIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -1291,7 +1262,7 @@ public function a_second_factor_can_be_vetted()
'REGCODE',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command)
@@ -1306,7 +1277,7 @@ public function a_second_factor_can_be_vetted()
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('NH9392'))
+ new OnPremiseVettingType(new DocumentNumber('NH9392')),
),
]);
}
@@ -1315,36 +1286,37 @@ public function a_second_factor_can_be_vetted()
* @test
* @group command-handler
*/
- public function a_second_factor_cannot_be_vetted_without_a_secure_enough_vetted_second_factor()
+ public function a_second_factor_cannot_be_vetted_without_a_secure_enough_vetted_second_factor(): void
{
$this->expectExceptionMessage("Authority does not have the required LoA");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
-
- $command = new VetSecondFactorCommand();
- $command->authorityId = 'AID';
- $command->identityId = 'IID';
- $command->secondFactorId = 'ISFID';
- $command->registrationCode = 'REGCODE';
- $command->secondFactorType = 'yubikey';
+ $this->expectException(DomainException::class);
+
+ $command = new VetSecondFactorCommand();
+ $command->authorityId = 'AID';
+ $command->identityId = 'IID';
+ $command->secondFactorId = 'ISFID';
+ $command->registrationCode = 'REGCODE';
+ $command->secondFactorType = 'yubikey';
$command->secondFactorIdentifier = '00028278';
- $command->documentNumber = 'NH9392';
- $command->identityVerified = true;
-
- $authorityId = new IdentityId($command->authorityId);
- $authorityInstitution = new Institution('Wazoo');
- $authorityNameId = new NameId($this->uuid());
- $authorityEmail = new Email('info@domain.invalid');
- $authorityCommonName = new CommonName('Henk Westbroek');
- $authorityPhoneSfId = new SecondFactorId($this->uuid());
- $authorityPhoneNo = new PhoneNumber('+31 (0) 612345678');
-
- $registrantId = new IdentityId($command->identityId);
- $registrantInstitution = new Institution('A Corp.');
- $registrantNameId = new NameId('3');
- $registrantEmail = new Email('reg@domain.invalid');
- $registrantCommonName = new CommonName('Reginald Waterloo');
- $registrantSecFacId = new SecondFactorId('ISFID');
- $registrantPubId = new YubikeyPublicId('00028278');
+ $command->documentNumber = 'NH9392';
+ $command->identityVerified = true;
+ $command->provePossessionSkipped = false;
+
+ $authorityId = new IdentityId($command->authorityId);
+ $authorityInstitution = new Institution('Wazoo');
+ $authorityNameId = new NameId($this->uuid());
+ $authorityEmail = new Email('info@domain.invalid');
+ $authorityCommonName = new CommonName('Henk Westbroek');
+ $authorityPhoneSfId = new SecondFactorId($this->uuid());
+ $authorityPhoneNo = new PhoneNumber('+31 (0) 612345678');
+
+ $registrantId = new IdentityId($command->identityId);
+ $registrantInstitution = new Institution('A Corp.');
+ $registrantNameId = new NameId('3');
+ $registrantEmail = new Email('reg@domain.invalid');
+ $registrantCommonName = new CommonName('Reginald Waterloo');
+ $registrantSecFacId = new SecondFactorId('ISFID');
+ $registrantPubId = new YubikeyPublicId('00028278');
$this->secondFactorTypeService->shouldReceive('hasEqualOrLowerLoaComparedTo')->andReturn(false);
@@ -1357,7 +1329,7 @@ public function a_second_factor_cannot_be_vetted_without_a_secure_enough_vetted_
$authorityNameId,
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new PhonePossessionProvenEvent(
$authorityId,
@@ -1366,13 +1338,13 @@ public function a_second_factor_cannot_be_vetted_without_a_secure_enough_vetted_
$authorityPhoneNo,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$authorityId,
@@ -1384,7 +1356,7 @@ public function a_second_factor_cannot_be_vetted_without_a_secure_enough_vetted_
'regcode',
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorVettedEvent(
$authorityId,
@@ -1396,8 +1368,8 @@ public function a_second_factor_cannot_be_vetted_without_a_secure_enough_vetted_
$authorityCommonName,
$authorityEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('NG-RB-81'))
- )
+ new OnPremiseVettingType(new DocumentNumber('NG-RB-81')),
+ ),
])
->withAggregateId($registrantId)
->given([
@@ -1407,7 +1379,7 @@ public function a_second_factor_cannot_be_vetted_without_a_secure_enough_vetted_
$registrantNameId,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$registrantId,
@@ -1416,13 +1388,13 @@ public function a_second_factor_cannot_be_vetted_without_a_secure_enough_vetted_
$registrantPubId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -1434,7 +1406,7 @@ public function a_second_factor_cannot_be_vetted_without_a_secure_enough_vetted_
'REGCODE',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command)
@@ -1449,7 +1421,7 @@ public function a_second_factor_cannot_be_vetted_without_a_secure_enough_vetted_
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('NH9392'))
+ new OnPremiseVettingType(new DocumentNumber('NH9392')),
),
]);
}
@@ -1459,38 +1431,38 @@ public function a_second_factor_cannot_be_vetted_without_a_secure_enough_vetted_
* @test
* @group command-handler
*/
- public function a_second_factor_can_be_vetted_without_a_physical_proven_possession()
+ public function a_second_factor_can_be_vetted_without_a_physical_proven_possession(): void
{
- $command = new VetSecondFactorCommand();
- $command->authorityId = 'AID';
- $command->identityId = 'IID';
- $command->secondFactorId = 'ISFID';
- $command->registrationCode = 'REGCODE';
- $command->secondFactorType = 'yubikey';
+ $command = new VetSecondFactorCommand();
+ $command->authorityId = 'AID';
+ $command->identityId = 'IID';
+ $command->secondFactorId = 'ISFID';
+ $command->registrationCode = 'REGCODE';
+ $command->secondFactorType = 'yubikey';
$command->secondFactorIdentifier = '00028278';
- $command->documentNumber = 'NH9392';
- $command->identityVerified = true;
+ $command->documentNumber = 'NH9392';
+ $command->identityVerified = true;
$command->provePossessionSkipped = true;
- $authorityId = new IdentityId($command->authorityId);
- $authorityNameId = new NameId($this->uuid());
- $authorityInstitution = new Institution('Wazoo');
- $authorityEmail = new Email('info@domain.invalid');
- $authorityCommonName = new CommonName('Henk Westbroek');
+ $authorityId = new IdentityId($command->authorityId);
+ $authorityNameId = new NameId($this->uuid());
+ $authorityInstitution = new Institution('Wazoo');
+ $authorityEmail = new Email('info@domain.invalid');
+ $authorityCommonName = new CommonName('Henk Westbroek');
- $registrantId = new IdentityId($command->identityId);
- $registrantInstitution = new Institution('A Corp.');
- $registrantNameId = new NameId('3');
- $registrantEmail = new Email('reg@domain.invalid');
- $registrantCommonName = new CommonName('Reginald Waterloo');
- $registrantSecFacId = new SecondFactorId('ISFID');
- $registrantSecFacIdentifier = new YubikeyPublicId('00028278');
+ $registrantId = new IdentityId($command->identityId);
+ $registrantInstitution = new Institution('A Corp.');
+ $registrantNameId = new NameId('3');
+ $registrantEmail = new Email('reg@domain.invalid');
+ $registrantCommonName = new CommonName('Reginald Waterloo');
+ $registrantSecFacId = new SecondFactorId('ISFID');
+ $registrantSecFacIdentifier = new YubikeyPublicId('00028278');
$this->secondFactorTypeService->shouldReceive('hasEqualOrLowerLoaComparedTo')->andReturn(true);
$secondFactorType = new SecondFactorType($command->secondFactorType);
$this->secondFactorProvePossessionHelper->shouldReceive('canSkipProvePossession')
- ->with(Matchers::equalTo($secondFactorType))
+ ->with(new IsEqual($secondFactorType))
->andReturn(true);
$this->scenario
@@ -1502,7 +1474,7 @@ public function a_second_factor_can_be_vetted_without_a_physical_proven_possessi
$authorityNameId,
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$authorityId,
@@ -1512,8 +1484,8 @@ public function a_second_factor_can_be_vetted_without_a_physical_proven_possessi
$authorityEmail,
new Locale('en_GB'),
new SecondFactorId($this->uuid()),
- new YubikeyPublicId('00000012')
- )
+ new YubikeyPublicId('00000012'),
+ ),
])
->withAggregateId($registrantId)
->given([
@@ -1523,7 +1495,7 @@ public function a_second_factor_can_be_vetted_without_a_physical_proven_possessi
$registrantNameId,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$registrantId,
@@ -1532,13 +1504,13 @@ public function a_second_factor_can_be_vetted_without_a_physical_proven_possessi
$registrantSecFacIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -1550,7 +1522,7 @@ public function a_second_factor_can_be_vetted_without_a_physical_proven_possessi
'REGCODE',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command)
@@ -1565,7 +1537,7 @@ public function a_second_factor_can_be_vetted_without_a_physical_proven_possessi
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('NH9392'))
+ new OnPremiseVettingType(new DocumentNumber('NH9392')),
),
]);
}
@@ -1574,43 +1546,45 @@ public function a_second_factor_can_be_vetted_without_a_physical_proven_possessi
* @test
* @group command-handler
*/
- public function a_second_factor_cannot_be_vetted_without_physical_prove_of_possession_when_not_configured()
+ public function a_second_factor_cannot_be_vetted_without_physical_prove_of_possession_when_not_configured(): void
{
- $this->expectExceptionMessage("The possession of registrants second factor with ID 'ISFID' of type 'yubikey' has to be physically proven");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
-
- $command = new VetSecondFactorCommand();
- $command->authorityId = 'AID';
- $command->identityId = 'IID';
- $command->secondFactorId = 'ISFID';
- $command->registrationCode = 'REGCODE';
- $command->secondFactorType = 'yubikey';
+ $this->expectExceptionMessage(
+ "The possession of registrants second factor with ID 'ISFID' of type 'yubikey' has to be physically proven",
+ );
+ $this->expectException(DomainException::class);
+
+ $command = new VetSecondFactorCommand();
+ $command->authorityId = 'AID';
+ $command->identityId = 'IID';
+ $command->secondFactorId = 'ISFID';
+ $command->registrationCode = 'REGCODE';
+ $command->secondFactorType = 'yubikey';
$command->secondFactorIdentifier = '00028278';
- $command->documentNumber = 'NH9392';
- $command->identityVerified = true;
+ $command->documentNumber = 'NH9392';
+ $command->identityVerified = true;
$command->provePossessionSkipped = true;
- $authorityId = new IdentityId($command->authorityId);
- $authorityInstitution = new Institution('Wazoo');
- $authorityNameId = new NameId($this->uuid());
- $authorityEmail = new Email('info@domain.invalid');
- $authorityCommonName = new CommonName('Henk Westbroek');
- $authorityPhoneSfId = new SecondFactorId($this->uuid());
- $authorityPhoneNo = new PhoneNumber('+31 (0) 612345678');
-
- $registrantId = new IdentityId($command->identityId);
- $registrantInstitution = new Institution('A Corp.');
- $registrantNameId = new NameId('3');
- $registrantEmail = new Email('reg@domain.invalid');
- $registrantCommonName = new CommonName('Reginald Waterloo');
- $registrantSecFacId = new SecondFactorId('ISFID');
- $registrantPubId = new YubikeyPublicId('00028278');
+ $authorityId = new IdentityId($command->authorityId);
+ $authorityInstitution = new Institution('Wazoo');
+ $authorityNameId = new NameId($this->uuid());
+ $authorityEmail = new Email('info@domain.invalid');
+ $authorityCommonName = new CommonName('Henk Westbroek');
+ $authorityPhoneSfId = new SecondFactorId($this->uuid());
+ $authorityPhoneNo = new PhoneNumber('+31 (0) 612345678');
+
+ $registrantId = new IdentityId($command->identityId);
+ $registrantInstitution = new Institution('A Corp.');
+ $registrantNameId = new NameId('3');
+ $registrantEmail = new Email('reg@domain.invalid');
+ $registrantCommonName = new CommonName('Reginald Waterloo');
+ $registrantSecFacId = new SecondFactorId('ISFID');
+ $registrantPubId = new YubikeyPublicId('00028278');
$this->secondFactorTypeService->shouldReceive('hasEqualOrLowerLoaComparedTo')->andReturn(true);
$secondFactorType = new SecondFactorType($command->secondFactorType);
$this->secondFactorProvePossessionHelper->shouldReceive('canSkipProvePossession')
- ->with(Matchers::equalTo($secondFactorType))
+ ->with(new IsEqual($secondFactorType))
->andReturn(false);
$this->scenario
@@ -1622,7 +1596,7 @@ public function a_second_factor_cannot_be_vetted_without_physical_prove_of_posse
$authorityNameId,
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new PhonePossessionProvenEvent(
$authorityId,
@@ -1631,13 +1605,13 @@ public function a_second_factor_cannot_be_vetted_without_physical_prove_of_posse
$authorityPhoneNo,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$authorityId,
@@ -1649,7 +1623,7 @@ public function a_second_factor_cannot_be_vetted_without_physical_prove_of_posse
'regcode',
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorVettedEvent(
$authorityId,
@@ -1661,8 +1635,8 @@ public function a_second_factor_cannot_be_vetted_without_physical_prove_of_posse
$authorityCommonName,
$authorityEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('NG-RB-81'))
- )
+ new OnPremiseVettingType(new DocumentNumber('NG-RB-81')),
+ ),
])
->withAggregateId($registrantId)
->given([
@@ -1672,7 +1646,7 @@ public function a_second_factor_cannot_be_vetted_without_physical_prove_of_posse
$registrantNameId,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$registrantId,
@@ -1681,13 +1655,13 @@ public function a_second_factor_cannot_be_vetted_without_physical_prove_of_posse
$registrantPubId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -1699,7 +1673,7 @@ public function a_second_factor_cannot_be_vetted_without_physical_prove_of_posse
'REGCODE',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command)
@@ -1714,7 +1688,7 @@ public function a_second_factor_cannot_be_vetted_without_physical_prove_of_posse
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('123456'))
+ new OnPremiseVettingType(new DocumentNumber('123456')),
),
]);
}
@@ -1724,13 +1698,13 @@ public function a_second_factor_cannot_be_vetted_without_physical_prove_of_posse
* @group command-handler
* @runInSeparateProcess
*/
- public function an_identity_can_express_its_locale_preference()
+ public function an_identity_can_express_its_locale_preference(): void
{
- $command = new ExpressLocalePreferenceCommand();
- $command->identityId = $this->uuid();
+ $command = new ExpressLocalePreferenceCommand();
+ $command->identityId = $this->uuid();
$command->preferredLocale = 'nl_NL';
- $identityId = new IdentityId($command->identityId);
+ $identityId = new IdentityId($command->identityId);
$institution = new Institution('Institution');
$this->scenario
@@ -1742,7 +1716,7 @@ public function an_identity_can_express_its_locale_preference()
new NameId('N-ID'),
new CommonName('Matti Vanhanen'),
new Email('m.vanhanen@domain.invalid'),
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command)
@@ -1756,13 +1730,13 @@ public function an_identity_can_express_its_locale_preference()
* @group command-handler
* @runInSeparateProcess
*/
- public function an_identity_can_send_registration_mail()
+ public function an_identity_can_send_registration_mail(): void
{
$command = new SendSecondFactorRegistrationEmailCommand();
$command->identityId = self::uuid();
$command->secondFactorId = 'second-factor-id';
- $identityId = new IdentityId($command->identityId);
+ $identityId = new IdentityId($command->identityId);
$institution = new Institution('Institution');
$this->registrationMailService
@@ -1778,7 +1752,7 @@ public function an_identity_can_send_registration_mail()
new NameId('N-ID'),
new CommonName('Matti Vanhanen'),
new Email('m.vanhanen@domain.invalid'),
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command)
@@ -1790,16 +1764,16 @@ public function an_identity_can_send_registration_mail()
* @group command-handler
* @runInSeparateProcess
*/
- public function an_identity_cannot_express_a_preference_for_an_unsupported_locale()
+ public function an_identity_cannot_express_a_preference_for_an_unsupported_locale(): void
{
$this->expectExceptionMessage("Given locale \"fi_FI\" is not a supported locale");
- $this->expectException(\Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\UnsupportedLocaleException::class);
+ $this->expectException(UnsupportedLocaleException::class);
- $command = new ExpressLocalePreferenceCommand();
- $command->identityId = $this->uuid();
+ $command = new ExpressLocalePreferenceCommand();
+ $command->identityId = $this->uuid();
$command->preferredLocale = 'fi_FI';
- $identityId = new IdentityId($command->identityId);
+ $identityId = new IdentityId($command->identityId);
$institution = new Institution('Institution');
$this->scenario
@@ -1811,7 +1785,7 @@ public function an_identity_cannot_express_a_preference_for_an_unsupported_local
new NameId('N-ID'),
new CommonName('Matti Vanhanen'),
new Email('m.vanhanen@domain.invalid'),
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command);
@@ -1822,13 +1796,13 @@ public function an_identity_cannot_express_a_preference_for_an_unsupported_local
* @group command-handler
* @runInSeparateProcess
*/
- public function an_identity_can_express_its_locale_preference_more_than_one_time()
+ public function an_identity_can_express_its_locale_preference_more_than_one_time(): void
{
- $command = new ExpressLocalePreferenceCommand();
- $command->identityId = $this->uuid();
+ $command = new ExpressLocalePreferenceCommand();
+ $command->identityId = $this->uuid();
$command->preferredLocale = 'nl_NL';
- $identityId = new IdentityId($command->identityId);
+ $identityId = new IdentityId($command->identityId);
$institution = new Institution('Institution');
$this->scenario
@@ -1840,7 +1814,7 @@ public function an_identity_can_express_its_locale_preference_more_than_one_time
new NameId('N-ID'),
new CommonName('Matti Vanhanen'),
new Email('m.vanhanen@domain.invalid'),
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command)
@@ -1856,7 +1830,7 @@ public function an_identity_can_express_its_locale_preference_more_than_one_time
* @group command-handler
* @runInSeparateProcess
*/
- public function a_second_factor_can_be_self_vetted()
+ public function a_second_factor_can_be_self_vetted(): void
{
$command = new SelfVetSecondFactorCommand();
$command->secondFactorId = '+31 (0) 612345678';
@@ -1865,8 +1839,8 @@ public function a_second_factor_can_be_self_vetted()
$command->authoringSecondFactorLoa = "loa-3";
$command->secondFactorType = 'sms';
- $authorityPhoneSfId = new SecondFactorId($this->uuid());
- $authorityPhoneNo = new PhoneNumber('+31 (0) 612345678');
+ $authorityPhoneSfId = new SecondFactorId($this->uuid());
+ $authorityPhoneNo = new PhoneNumber('+31 (0) 612345678');
$registrantId = new IdentityId($command->identityId);
$registrantInstitution = new Institution('Institution');
@@ -1890,7 +1864,7 @@ public function a_second_factor_can_be_self_vetted()
$registrantNameId,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$registrantId,
@@ -1899,13 +1873,13 @@ public function a_second_factor_can_be_self_vetted()
$registrantSecPubId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -1917,7 +1891,7 @@ public function a_second_factor_can_be_self_vetted()
$command->registrationCode,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorVettedEvent(
$registrantId,
@@ -1929,7 +1903,7 @@ public function a_second_factor_can_be_self_vetted()
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('123456'))
+ new OnPremiseVettingType(new DocumentNumber('123456')),
),
// The next token is vetted using the other token
new PhonePossessionProvenEvent(
@@ -1939,13 +1913,13 @@ public function a_second_factor_can_be_self_vetted()
$authorityPhoneNo,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -1957,7 +1931,7 @@ public function a_second_factor_can_be_self_vetted()
'REGCODE',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command)
@@ -1973,7 +1947,7 @@ public function a_second_factor_can_be_self_vetted()
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new SelfVetVettingType($loa)
+ new SelfVetVettingType($loa),
),
]);
}
@@ -1985,7 +1959,7 @@ public function a_second_factor_can_be_self_vetted()
*
* @todo remove this test once we drop BC support for SelfService 3.5
*/
- public function a_second_factor_can_be_self_vetted_using_old_authoringSecondFactorIdentifier_command_property()
+ public function a_second_factor_can_be_self_vetted_using_old_authoringSecondFactorIdentifier_command_property(): void
{
$command = new SelfVetSecondFactorCommand();
$command->secondFactorId = '+31 (0) 612345678';
@@ -1994,8 +1968,8 @@ public function a_second_factor_can_be_self_vetted_using_old_authoringSecondFact
$command->authoringSecondFactorIdentifier = "loa-3";
$command->secondFactorType = 'sms';
- $authorityPhoneSfId = new SecondFactorId($this->uuid());
- $authorityPhoneNo = new PhoneNumber('+31 (0) 612345678');
+ $authorityPhoneSfId = new SecondFactorId($this->uuid());
+ $authorityPhoneNo = new PhoneNumber('+31 (0) 612345678');
$registrantId = new IdentityId($command->identityId);
$registrantInstitution = new Institution('Institution');
@@ -2019,7 +1993,7 @@ public function a_second_factor_can_be_self_vetted_using_old_authoringSecondFact
$registrantNameId,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$registrantId,
@@ -2028,13 +2002,13 @@ public function a_second_factor_can_be_self_vetted_using_old_authoringSecondFact
$registrantSecPubId,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -2046,7 +2020,7 @@ public function a_second_factor_can_be_self_vetted_using_old_authoringSecondFact
$command->registrationCode,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorVettedEvent(
$registrantId,
@@ -2058,7 +2032,7 @@ public function a_second_factor_can_be_self_vetted_using_old_authoringSecondFact
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('123456'))
+ new OnPremiseVettingType(new DocumentNumber('123456')),
),
// The next token is vetted using the other token
new PhonePossessionProvenEvent(
@@ -2068,13 +2042,13 @@ public function a_second_factor_can_be_self_vetted_using_old_authoringSecondFact
$authorityPhoneNo,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -2086,7 +2060,7 @@ public function a_second_factor_can_be_self_vetted_using_old_authoringSecondFact
'REGCODE',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command)
@@ -2102,7 +2076,7 @@ public function a_second_factor_can_be_self_vetted_using_old_authoringSecondFact
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new SelfVetVettingType($loa)
+ new SelfVetVettingType($loa),
),
]);
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityIdEnforcingEventStoreDecorator.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityIdEnforcingEventStoreDecorator.php
index 2e68ce726..847d00104 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityIdEnforcingEventStoreDecorator.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/IdentityIdEnforcingEventStoreDecorator.php
@@ -20,19 +20,17 @@
use Broadway\Domain\DomainEventStream as DomainEventStreamInterface;
use Broadway\EventStore\EventStore as EventStoreInterface;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Surfnet\Stepup\Identity\Event\IdentityEvent;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\InvalidArgumentException;
final class IdentityIdEnforcingEventStoreDecorator implements EventStoreInterface
{
- /**
- * @var EventStoreInterface
- */
- private $decoratedEventStore;
+ use MockeryPHPUnitIntegration;
- public function __construct(EventStoreInterface $decoratedEventStore)
- {
- $this->decoratedEventStore = $decoratedEventStore;
+ public function __construct(
+ private EventStoreInterface $decoratedEventStore,
+ ) {
}
public function load($id): DomainEventStreamInterface
@@ -65,15 +63,12 @@ public function loadFromPlayhead($id, int $playhead): DomainEventStreamInterface
return $eventStream;
}
- /**
- * @param DomainEventStreamInterface $stream
- */
- public function assertIdentityAggregate(DomainEventStreamInterface $stream)
+ public function assertIdentityAggregate(DomainEventStreamInterface $stream): void
{
foreach ($stream as $message) {
if (!$message->getPayload() instanceof IdentityEvent) {
throw new InvalidArgumentException(
- 'The SensitiveDataEventStoreDecorator only works with Identities, please pass in an IdentityId $id'
+ 'The SensitiveDataEventStoreDecorator only works with Identities, please pass in an IdentityId $id',
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/RegistrationAuthorityCommandHandlerTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/RegistrationAuthorityCommandHandlerTest.php
index f05b51bea..c990989d0 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/RegistrationAuthorityCommandHandlerTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/RegistrationAuthorityCommandHandlerTest.php
@@ -22,12 +22,13 @@
use Broadway\CommandHandling\CommandHandlerInterface;
use Broadway\EventHandling\EventBus as EventBusInterface;
use Broadway\EventSourcing\AggregateFactory\PublicConstructorAggregateFactory;
-use Broadway\EventSourcing\EventStreamDecorator;
use Broadway\EventStore\EventStore as EventStoreInterface;
use Mockery as m;
+use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Surfnet\Stepup\Configuration\EventSourcing\InstitutionConfigurationRepository;
use Surfnet\Stepup\Configuration\InstitutionConfiguration;
+use Surfnet\Stepup\Exception\DomainException;
use Surfnet\Stepup\Helper\UserDataFilterInterface;
use Surfnet\Stepup\Identity\Event\AppointedAsRaaForInstitutionEvent;
use Surfnet\Stepup\Identity\Event\AppointedAsRaForInstitutionEvent;
@@ -50,6 +51,7 @@
use Surfnet\Stepup\Identity\Value\RegistrationAuthorityRole;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
use Surfnet\Stepup\Identity\Value\YubikeyPublicId;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\RuntimeException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\AccreditIdentityCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\AmendRegistrationAuthorityInformationCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\AppointRoleCommand;
@@ -61,26 +63,22 @@
class RegistrationAuthorityCommandHandlerTest extends CommandHandlerTest
{
- /**
- * @var InstitutionConfigurationRepository
- */
- private $institutionConfigurationRepositoryMock;
+ private MockInterface&InstitutionConfigurationRepository $institutionConfigurationRepositoryMock;
- /**
- * @var InstitutionConfiguration
- */
- private $institutionConfiguration;
+ private MockInterface&InstitutionConfiguration $institutionConfiguration;
/**
* Create a command handler for the given scenario test case.
*
* @param EventStoreInterface $eventStore
- * @param EventBusInterface $eventBus
+ * @param EventBusInterface $eventBus
*
* @return CommandHandler
*/
- protected function createCommandHandler(EventStoreInterface $eventStore, EventBusInterface $eventBus): CommandHandler
- {
+ protected function createCommandHandler(
+ EventStoreInterface $eventStore,
+ EventBusInterface $eventBus,
+ ): CommandHandler {
$aggregateFactory = new PublicConstructorAggregateFactory();
$this->institutionConfigurationRepositoryMock = m::mock(InstitutionConfigurationRepository::class);
@@ -99,10 +97,10 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
$eventBus,
$aggregateFactory,
m::mock(UserDataFilterInterface::class),
- $logger
+ $logger,
),
$this->institutionConfigurationRepositoryMock,
- m::mock(VettingTypeHintService::class)
+ m::mock(VettingTypeHintService::class),
);
}
@@ -111,25 +109,25 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_cannot_be_accredited_for_another_institution_than_configured()
+ public function an_identity_cannot_be_accredited_for_another_institution_than_configured(): void
{
$this->expectExceptionMessage("An Identity may only be accredited by configured institutions");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
- $command = new AccreditIdentityCommand();
- $command->identityId = static::uuid();
- $command->institution = 'Babelfish Inc.';
- $command->role = 'ra';
- $command->location = 'Somewhere behind you';
+ $command = new AccreditIdentityCommand();
+ $command->identityId = static::uuid();
+ $command->institution = 'Babelfish Inc.';
+ $command->role = 'ra';
+ $command->location = 'Somewhere behind you';
$command->contactInformation = 'Call me Maybe';
- $command->raInstitution = 'RA institution';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution('A Different Institution than the Command holds');
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $command->raInstitution = 'RA institution';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution('A Different Institution than the Command holds');
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->institutionConfiguration
@@ -145,7 +143,7 @@ public function an_identity_cannot_be_accredited_for_another_institution_than_co
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -155,8 +153,8 @@ public function an_identity_cannot_be_accredited_for_another_institution_than_co
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
- )
+ $secondFactorPublicId,
+ ),
])
->when($command);
}
@@ -166,23 +164,25 @@ public function an_identity_cannot_be_accredited_for_another_institution_than_co
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_cannot_be_accredited_when_it_does_not_have_a_vetted_second_factor()
+ public function an_identity_cannot_be_accredited_when_it_does_not_have_a_vetted_second_factor(): void
{
- $this->expectExceptionMessage("An Identity must have at least one vetted second factor before it can be accredited");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
- $command = new AccreditIdentityCommand();
- $command->identityId = static::uuid();
- $command->institution = 'Babelfish Inc.';
- $command->role = 'ra';
- $command->location = 'Somewhere behind you';
+ $this->expectExceptionMessage(
+ "An Identity must have at least one vetted second factor before it can be accredited",
+ );
+ $this->expectException(DomainException::class);
+ $command = new AccreditIdentityCommand();
+ $command->identityId = static::uuid();
+ $command->institution = 'Babelfish Inc.';
+ $command->role = 'ra';
+ $command->location = 'Somewhere behind you';
$command->contactInformation = 'Call me Maybe';
- $command->raInstitution = 'RA institution';
+ $command->raInstitution = 'RA institution';
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution($command->institution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution($command->institution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
$this->institutionConfiguration
->shouldReceive('isInstitutionAllowedToAccreditRoles')
@@ -197,7 +197,7 @@ public function an_identity_cannot_be_accredited_when_it_does_not_have_a_vetted_
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command);
@@ -209,24 +209,24 @@ public function an_identity_cannot_be_accredited_when_it_does_not_have_a_vetted_
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_cannot_be_accredited_when_it_already_has_been_accredited()
+ public function an_identity_cannot_be_accredited_when_it_already_has_been_accredited(): void
{
$this->expectExceptionMessage("Cannot accredit Identity as it has already been accredited for institution");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
- $command = new AccreditIdentityCommand();
- $command->identityId = static::uuid();
- $command->institution = 'Babelfish Inc.';
- $command->role = 'ra';
- $command->location = 'Somewhere behind you';
+ $this->expectException(DomainException::class);
+ $command = new AccreditIdentityCommand();
+ $command->identityId = static::uuid();
+ $command->institution = 'Babelfish Inc.';
+ $command->role = 'ra';
+ $command->location = 'Somewhere behind you';
$command->contactInformation = 'Call me Maybe';
- $command->raInstitution = 'Babelfish Inc.';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution($command->institution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $command->raInstitution = 'Babelfish Inc.';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution($command->institution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->institutionConfiguration
@@ -243,7 +243,7 @@ public function an_identity_cannot_be_accredited_when_it_already_has_been_accred
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -253,7 +253,7 @@ public function an_identity_cannot_be_accredited_when_it_already_has_been_accred
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
+ $secondFactorPublicId,
),
new IdentityAccreditedAsRaEvent(
$identityId,
@@ -261,9 +261,9 @@ public function an_identity_cannot_be_accredited_when_it_already_has_been_accred
$institution,
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA),
new Location('Somewhere behind you'),
- new ContactInformation('Call me maybe')
- )
- ]
+ new ContactInformation('Call me maybe'),
+ ),
+ ],
)
->when($command);
}
@@ -273,24 +273,24 @@ public function an_identity_cannot_be_accredited_when_it_already_has_been_accred
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_cannot_be_accredited_with_an_invalid_role()
+ public function an_identity_cannot_be_accredited_with_an_invalid_role(): void
{
- $this->expectException(\Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\RuntimeException::class);
+ $this->expectException(RuntimeException::class);
- $command = new AccreditIdentityCommand();
- $command->identityId = static::uuid();
- $command->institution = 'Babelfish Inc.';
- $command->role = 'A role that does not exist';
- $command->location = 'Somewhere behind you';
+ $command = new AccreditIdentityCommand();
+ $command->identityId = static::uuid();
+ $command->institution = 'Babelfish Inc.';
+ $command->role = 'A role that does not exist';
+ $command->location = 'Somewhere behind you';
$command->contactInformation = 'Call me Maybe';
- $command->raInstitution = 'RA institution';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution($command->institution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $command->raInstitution = 'RA institution';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution($command->institution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->scenario
@@ -303,7 +303,7 @@ public function an_identity_cannot_be_accredited_with_an_invalid_role()
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -313,9 +313,9 @@ public function an_identity_cannot_be_accredited_with_an_invalid_role()
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
- )
- ]
+ $secondFactorPublicId,
+ ),
+ ],
)
->when($command);
}
@@ -325,24 +325,24 @@ public function an_identity_cannot_be_accredited_with_an_invalid_role()
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_can_be_accredited_with_ra_role()
+ public function an_identity_can_be_accredited_with_ra_role(): void
{
- $command = new AccreditIdentityCommand();
- $command->identityId = static::uuid();
- $command->institution = 'RA institution';
- $command->role = 'ra';
- $command->location = 'Somewhere behind you';
+ $command = new AccreditIdentityCommand();
+ $command->identityId = static::uuid();
+ $command->institution = 'RA institution';
+ $command->role = 'ra';
+ $command->location = 'Somewhere behind you';
$command->contactInformation = 'Call me Maybe';
- $command->raInstitution = 'RA institution';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution($command->institution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $command->raInstitution = 'RA institution';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution($command->institution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
- $raInstitution = new Institution($command->raInstitution);
+ $raInstitution = new Institution($command->raInstitution);
$this->institutionConfiguration
->shouldReceive('isInstitutionAllowedToAccreditRoles')
@@ -358,7 +358,7 @@ public function an_identity_can_be_accredited_with_ra_role()
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -368,9 +368,9 @@ public function an_identity_can_be_accredited_with_ra_role()
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
- )
- ]
+ $secondFactorPublicId,
+ ),
+ ],
)
->when($command)
->then([
@@ -381,8 +381,8 @@ public function an_identity_can_be_accredited_with_ra_role()
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA),
new Location($command->location),
new ContactInformation($command->contactInformation),
- $raInstitution
- )
+ $raInstitution,
+ ),
]);
}
@@ -391,23 +391,23 @@ public function an_identity_can_be_accredited_with_ra_role()
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_can_be_accredited_with_raa_role()
+ public function an_identity_can_be_accredited_with_raa_role(): void
{
- $command = new AccreditIdentityCommand();
- $command->identityId = static::uuid();
- $command->institution = 'Babelfish Inc.';
- $command->role = 'raa';
- $command->location = 'Somewhere behind you';
+ $command = new AccreditIdentityCommand();
+ $command->identityId = static::uuid();
+ $command->institution = 'Babelfish Inc.';
+ $command->role = 'raa';
+ $command->location = 'Somewhere behind you';
$command->contactInformation = 'Call me Maybe';
- $command->raInstitution = 'RA institution';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution('Babelfish Inc.');
- $raInstitution = new Institution($command->raInstitution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $command->raInstitution = 'RA institution';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution('Babelfish Inc.');
+ $raInstitution = new Institution($command->raInstitution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->institutionConfiguration
@@ -424,7 +424,7 @@ public function an_identity_can_be_accredited_with_raa_role()
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -434,9 +434,9 @@ public function an_identity_can_be_accredited_with_raa_role()
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
- )
- ]
+ $secondFactorPublicId,
+ ),
+ ],
)
->when($command)
->then(
@@ -448,9 +448,9 @@ public function an_identity_can_be_accredited_with_raa_role()
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA),
new Location($command->location),
new ContactInformation($command->contactInformation),
- $raInstitution
- )
- ]
+ $raInstitution,
+ ),
+ ],
);
}
@@ -459,20 +459,20 @@ public function an_identity_can_be_accredited_with_raa_role()
* @group command-handler
* @group ra-command-handler
*/
- public function a_registration_authoritys_information_can_be_amended()
+ public function a_registration_authoritys_information_can_be_amended(): void
{
- $command = new AmendRegistrationAuthorityInformationCommand();
- $command->identityId = static::uuid();
- $command->location = 'New York';
+ $command = new AmendRegistrationAuthorityInformationCommand();
+ $command->identityId = static::uuid();
+ $command->location = 'New York';
$command->contactInformation = '131 West 3rd Street, NY';
- $command->raInstitution = 'Ra institution';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution($command->raInstitution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $command->raInstitution = 'Ra institution';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution($command->raInstitution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->scenario
@@ -485,7 +485,7 @@ public function a_registration_authoritys_information_can_be_amended()
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -495,7 +495,7 @@ public function a_registration_authoritys_information_can_be_amended()
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
+ $secondFactorPublicId,
),
new IdentityAccreditedAsRaaForInstitutionEvent(
$identityId,
@@ -504,9 +504,9 @@ public function a_registration_authoritys_information_can_be_amended()
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA),
new Location('Somewhere behind you'),
new ContactInformation('Call me Maybe'),
- $institution
+ $institution,
),
- ]
+ ],
)
->when($command)
->then(
@@ -517,9 +517,9 @@ public function a_registration_authoritys_information_can_be_amended()
$nameId,
new Location($command->location),
new ContactInformation($command->contactInformation),
- $institution
- )
- ]
+ $institution,
+ ),
+ ],
);
}
@@ -528,23 +528,25 @@ public function a_registration_authoritys_information_can_be_amended()
* @group command-handler
* @group ra-command-handler
*/
- public function an_identitys_registration_authority_information_cannot_be_amended()
+ public function an_identitys_registration_authority_information_cannot_be_amended(): void
{
- $this->expectExceptionMessage("Cannot amend registration authority information: identity is not a registration authority");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectExceptionMessage(
+ "Cannot amend registration authority information: identity is not a registration authority",
+ );
+ $this->expectException(DomainException::class);
- $command = new AmendRegistrationAuthorityInformationCommand();
- $command->identityId = static::uuid();
- $command->location = 'New York';
+ $command = new AmendRegistrationAuthorityInformationCommand();
+ $command->identityId = static::uuid();
+ $command->location = 'New York';
$command->contactInformation = '131 West 3rd Street, NY';
- $command->raInstitution = 'Ra institution';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution('Blue Note');
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $command->raInstitution = 'Ra institution';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution('Blue Note');
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->scenario
@@ -557,7 +559,7 @@ public function an_identitys_registration_authority_information_cannot_be_amende
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -567,9 +569,9 @@ public function an_identitys_registration_authority_information_cannot_be_amende
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
+ $secondFactorPublicId,
),
- ]
+ ],
)
->when($command);
}
@@ -579,24 +581,26 @@ public function an_identitys_registration_authority_information_cannot_be_amende
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_without_vetted_second_factor_may_not_be_accredited_as_ra()
+ public function an_identity_without_vetted_second_factor_may_not_be_accredited_as_ra(): void
{
- $this->expectExceptionMessage("An Identity must have at least one vetted second factor before it can be accredited");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
-
- $command = new AccreditIdentityCommand();
- $command->identityId = static::uuid();
- $command->institution = 'Babelfish Inc.';
- $command->role = 'ra';
- $command->location = 'somewhere';
+ $this->expectExceptionMessage(
+ "An Identity must have at least one vetted second factor before it can be accredited",
+ );
+ $this->expectException(DomainException::class);
+
+ $command = new AccreditIdentityCommand();
+ $command->identityId = static::uuid();
+ $command->institution = 'Babelfish Inc.';
+ $command->role = 'ra';
+ $command->location = 'somewhere';
$command->contactInformation = 'Call me maybe';
- $command->raInstitution = 'RA institution';
+ $command->raInstitution = 'RA institution';
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution($command->institution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution($command->institution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
$this->institutionConfiguration
->shouldReceive('isInstitutionAllowedToAccreditRoles')
@@ -611,7 +615,7 @@ public function an_identity_without_vetted_second_factor_may_not_be_accredited_a
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command);
@@ -622,24 +626,24 @@ public function an_identity_without_vetted_second_factor_may_not_be_accredited_a
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_with_a_vetted_second_factor_can_be_accredited_as_ra()
+ public function an_identity_with_a_vetted_second_factor_can_be_accredited_as_ra(): void
{
- $command = new AccreditIdentityCommand();
- $command->identityId = static::uuid();
- $command->institution = 'Babelfish Inc.';
- $command->role = 'ra';
- $command->location = 'somewhere';
+ $command = new AccreditIdentityCommand();
+ $command->identityId = static::uuid();
+ $command->institution = 'Babelfish Inc.';
+ $command->role = 'ra';
+ $command->location = 'somewhere';
$command->contactInformation = 'Call me maybe';
- $command->raInstitution = 'RA institution';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution($command->institution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $command->raInstitution = 'RA institution';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution($command->institution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
- $raInstitution = new Institution($command->raInstitution);
+ $raInstitution = new Institution($command->raInstitution);
$this->institutionConfiguration
->shouldReceive('isInstitutionAllowedToAccreditRoles')
@@ -655,7 +659,7 @@ public function an_identity_with_a_vetted_second_factor_can_be_accredited_as_ra(
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -665,9 +669,9 @@ public function an_identity_with_a_vetted_second_factor_can_be_accredited_as_ra(
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
+ $secondFactorPublicId,
),
- ]
+ ],
)
->when($command)
->then([
@@ -678,8 +682,8 @@ public function an_identity_with_a_vetted_second_factor_can_be_accredited_as_ra(
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA),
new Location($command->location),
new ContactInformation($command->contactInformation),
- $raInstitution
- )
+ $raInstitution,
+ ),
]);
}
@@ -688,25 +692,25 @@ public function an_identity_with_a_vetted_second_factor_can_be_accredited_as_ra(
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_cannot_be_accredited_twice()
+ public function an_identity_cannot_be_accredited_twice(): void
{
$this->expectExceptionMessage("Cannot accredit Identity as it has already been accredited for institution");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
- $command = new AccreditIdentityCommand();
- $command->identityId = static::uuid();
- $command->institution = 'Babelfish Inc.';
- $command->role = 'ra';
- $command->location = 'somewhere';
+ $command = new AccreditIdentityCommand();
+ $command->identityId = static::uuid();
+ $command->institution = 'Babelfish Inc.';
+ $command->role = 'ra';
+ $command->location = 'somewhere';
$command->contactInformation = 'Call me maybe';
- $command->raInstitution = 'Babelfish Inc.';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution($command->institution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $command->raInstitution = 'Babelfish Inc.';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution($command->institution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->institutionConfiguration
@@ -722,7 +726,7 @@ public function an_identity_cannot_be_accredited_twice()
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -732,7 +736,7 @@ public function an_identity_cannot_be_accredited_twice()
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
+ $secondFactorPublicId,
),
new IdentityAccreditedAsRaForInstitutionEvent(
$identityId,
@@ -741,8 +745,8 @@ public function an_identity_cannot_be_accredited_twice()
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA),
new Location($command->location),
new ContactInformation($command->contactInformation),
- $institution
- )
+ $institution,
+ ),
])
->when($command);
}
@@ -752,25 +756,25 @@ public function an_identity_cannot_be_accredited_twice()
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_cannot_be_accredited_as_sraa()
+ public function an_identity_cannot_be_accredited_as_sraa(): void
{
- $this->expectException(\Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\RuntimeException::class);
+ $this->expectException(RuntimeException::class);
- $command = new AccreditIdentityCommand();
- $command->identityId = static::uuid();
- $command->institution = 'Babelfish Inc.';
- $command->role = 'sraa';
- $command->location = 'somewhere';
+ $command = new AccreditIdentityCommand();
+ $command->identityId = static::uuid();
+ $command->institution = 'Babelfish Inc.';
+ $command->role = 'sraa';
+ $command->location = 'somewhere';
$command->contactInformation = 'Call me maybe';
- $command->raInstitution = 'Babelfish Inc.';
+ $command->raInstitution = 'Babelfish Inc.';
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution($command->institution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution($command->institution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->scenario
@@ -782,7 +786,7 @@ public function an_identity_cannot_be_accredited_as_sraa()
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -792,7 +796,7 @@ public function an_identity_cannot_be_accredited_as_sraa()
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
+ $secondFactorPublicId,
),
])
->when($command);
@@ -803,19 +807,19 @@ public function an_identity_cannot_be_accredited_as_sraa()
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_that_is_accredited_as_raa_can_be_appointed_as_ra()
+ public function an_identity_that_is_accredited_as_raa_can_be_appointed_as_ra(): void
{
- $command = new AppointRoleCommand();
- $command->identityId = static::uuid();
- $command->role = 'ra';
- $command->raInstitution = 'Babelfish Inc.';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution($command->raInstitution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $command = new AppointRoleCommand();
+ $command->identityId = static::uuid();
+ $command->role = 'ra';
+ $command->raInstitution = 'Babelfish Inc.';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution($command->raInstitution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->institutionConfiguration
@@ -831,7 +835,7 @@ public function an_identity_that_is_accredited_as_raa_can_be_appointed_as_ra()
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -841,7 +845,7 @@ public function an_identity_that_is_accredited_as_raa_can_be_appointed_as_ra()
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
+ $secondFactorPublicId,
),
new IdentityAccreditedAsRaForInstitutionEvent(
$identityId,
@@ -850,8 +854,8 @@ public function an_identity_that_is_accredited_as_raa_can_be_appointed_as_ra()
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA),
new Location('somewhere'),
new ContactInformation('Call me maybe'),
- $institution
- )
+ $institution,
+ ),
])
->when($command)
->then([
@@ -859,8 +863,8 @@ public function an_identity_that_is_accredited_as_raa_can_be_appointed_as_ra()
$identityId,
$institution,
$nameId,
- $institution
- )
+ $institution,
+ ),
]);
}
@@ -869,20 +873,20 @@ public function an_identity_that_is_accredited_as_raa_can_be_appointed_as_ra()
* @group command-handler
* @group ra-command-handler
*/
- public function an_identity_that_is_accredited_as_ra_can_be_appointed_as_raa()
+ public function an_identity_that_is_accredited_as_ra_can_be_appointed_as_raa(): void
{
- $command = new AppointRoleCommand();
- $command->identityId = static::uuid();
- $command->role = 'raa';
- $command->raInstitution = 'Ra institution';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution('Babelfish Inc.');
- $raInstitution = new Institution($command->raInstitution);
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $command = new AppointRoleCommand();
+ $command->identityId = static::uuid();
+ $command->role = 'raa';
+ $command->raInstitution = 'Ra institution';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution('Babelfish Inc.');
+ $raInstitution = new Institution($command->raInstitution);
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->institutionConfiguration
@@ -898,7 +902,7 @@ public function an_identity_that_is_accredited_as_ra_can_be_appointed_as_raa()
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -908,7 +912,7 @@ public function an_identity_that_is_accredited_as_ra_can_be_appointed_as_raa()
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
+ $secondFactorPublicId,
),
new IdentityAccreditedAsRaaForInstitutionEvent(
$identityId,
@@ -917,8 +921,8 @@ public function an_identity_that_is_accredited_as_ra_can_be_appointed_as_raa()
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA),
new Location('somewhere'),
new ContactInformation('Call me maybe'),
- $raInstitution
- )
+ $raInstitution,
+ ),
])
->when($command)
->then([
@@ -926,8 +930,8 @@ public function an_identity_that_is_accredited_as_ra_can_be_appointed_as_raa()
$identityId,
$institution,
$nameId,
- $raInstitution
- )
+ $raInstitution,
+ ),
]);
}
@@ -936,22 +940,24 @@ public function an_identity_that_is_accredited_as_ra_can_be_appointed_as_raa()
* @group command-handler
* @group ra-command-handler
*/
- public function an_unaccredited_identity_cannot_be_appointed_a_registration_authority_role()
+ public function an_unaccredited_identity_cannot_be_appointed_a_registration_authority_role(): void
{
- $this->expectExceptionMessage("Cannot appoint as different RegistrationAuthorityRole: identity is not a registration authority");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
-
- $command = new AppointRoleCommand();
- $command->identityId = static::uuid();
- $command->role = 'raa';
- $command->raInstitution = 'RA institution';
-
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution('Babelfish Inc.');
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $this->expectExceptionMessage(
+ "Cannot appoint as different RegistrationAuthorityRole: identity is not a registration authority",
+ );
+ $this->expectException(DomainException::class);
+
+ $command = new AppointRoleCommand();
+ $command->identityId = static::uuid();
+ $command->role = 'raa';
+ $command->raInstitution = 'RA institution';
+
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution('Babelfish Inc.');
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->institutionConfiguration
@@ -967,7 +973,7 @@ public function an_unaccredited_identity_cannot_be_appointed_a_registration_auth
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -977,8 +983,8 @@ public function an_unaccredited_identity_cannot_be_appointed_a_registration_auth
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
- )
+ $secondFactorPublicId,
+ ),
])
->when($command);
}
@@ -988,21 +994,23 @@ public function an_unaccredited_identity_cannot_be_appointed_a_registration_auth
* @group command-handler
* @group ra-command-handler
*/
- public function an_unaccredited_identity_cannot_have_its_registration_authority_retracted()
+ public function an_unaccredited_identity_cannot_have_its_registration_authority_retracted(): void
{
- $this->expectExceptionMessage("Cannot Retract Registration Authority as the Identity is not a registration authority");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectExceptionMessage(
+ "Cannot Retract Registration Authority as the Identity is not a registration authority",
+ );
+ $this->expectException(DomainException::class);
- $command = new RetractRegistrationAuthorityCommand();
- $command->identityId = static::uuid();
+ $command = new RetractRegistrationAuthorityCommand();
+ $command->identityId = static::uuid();
$command->raInstitution = 'RA institution';
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution('Babelfish Inc.');
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution('Babelfish Inc.');
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->scenario
@@ -1014,7 +1022,7 @@ public function an_unaccredited_identity_cannot_have_its_registration_authority_
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -1024,24 +1032,24 @@ public function an_unaccredited_identity_cannot_have_its_registration_authority_
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
- )
+ $secondFactorPublicId,
+ ),
])
->when($command);
}
- public function an_accredited_identity_can_retract_its_registration_authority()
+ public function an_accredited_identity_can_retract_its_registration_authority(): void
{
- $command = new RetractRegistrationAuthorityCommand();
+ $command = new RetractRegistrationAuthorityCommand();
$command->identityId = static::uuid();
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution('Babelfish Inc.');
- $raInstitution = new Institution('Ra institution');
- $nameId = new NameId(md5('someNameId'));
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId(static::uuid());
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution('Babelfish Inc.');
+ $raInstitution = new Institution('Ra institution');
+ $nameId = new NameId(md5('someNameId'));
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId(static::uuid());
$secondFactorPublicId = new YubikeyPublicId('8329283834');
$this->scenario
@@ -1053,7 +1061,7 @@ public function an_accredited_identity_can_retract_its_registration_authority()
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -1063,7 +1071,7 @@ public function an_accredited_identity_can_retract_its_registration_authority()
$email,
new Locale('en_GB'),
$secondFactorId,
- $secondFactorPublicId
+ $secondFactorPublicId,
),
new IdentityAccreditedAsRaaForInstitutionEvent(
$identityId,
@@ -1072,8 +1080,8 @@ public function an_accredited_identity_can_retract_its_registration_authority()
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA),
new Location('somewhere'),
new ContactInformation('Call me maybe'),
- $raInstitution
- )
+ $raInstitution,
+ ),
])
->when($command)
->then([
@@ -1083,8 +1091,8 @@ public function an_accredited_identity_can_retract_its_registration_authority()
$nameId,
$commonName,
$email,
- $raInstitution
- )
+ $raInstitution,
+ ),
]);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/RightToBeForgottenCommandHandlerTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/RightToBeForgottenCommandHandlerTest.php
index 65c557641..039117b0e 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/RightToBeForgottenCommandHandlerTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/RightToBeForgottenCommandHandlerTest.php
@@ -22,10 +22,11 @@
use Broadway\EventHandling\EventBus as EventBusInterface;
use Broadway\EventSourcing\AggregateFactory\PublicConstructorAggregateFactory;
use Broadway\EventStore\EventStore as EventStoreInterface;
-use Hamcrest\Matchers;
+use Mockery\Matcher\IsEqual;
use Mockery as m;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
+use Surfnet\Stepup\Exception\DomainException;
use Surfnet\Stepup\Helper\UserDataFilterInterface;
use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaEvent;
use Surfnet\Stepup\Identity\Event\IdentityAccreditedAsRaForInstitutionEvent;
@@ -44,30 +45,39 @@
use Surfnet\Stepup\Identity\Value\RegistrationAuthorityRole;
use Surfnet\Stepup\Identity\Value\SecondFactorId;
use Surfnet\Stepup\Identity\Value\YubikeyPublicId;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
+use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SraaRepository;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\RuntimeException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ForgetIdentityCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\CommandHandler\RightToBeForgottenCommandHandler;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Service\SensitiveDataService;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\CommandHandlerTest;
+
/**
* @runTestsInSeparateProcesses
*/
class RightToBeForgottenCommandHandlerTest extends CommandHandlerTest
{
/** @var MockInterface */
- private $apiIdentityRepository;
+ private MockInterface $apiIdentityRepository;
/** @var MockInterface */
- private $sensitiveDataService;
+ private MockInterface $sensitiveDataService;
/** @var MockInterface */
- private $sraaRepository;
+ private MockInterface $sraaRepository;
- protected function createCommandHandler(EventStoreInterface $eventStore, EventBusInterface $eventBus): CommandHandler
- {
+ protected function createCommandHandler(
+ EventStoreInterface $eventStore,
+ EventBusInterface $eventBus,
+ ): CommandHandler {
$aggregateFactory = new PublicConstructorAggregateFactory();
- $this->apiIdentityRepository = m::mock('Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository');
- $this->sensitiveDataService = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Service\SensitiveDataService');
- $this->sraaRepository = m::mock('Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\SraaRepository');
+ $this->apiIdentityRepository = m::mock(
+ \Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository::class,
+ );
+ $this->sensitiveDataService = m::mock(SensitiveDataService::class);
+ $this->sraaRepository = m::mock(SraaRepository::class);
$logger = m::mock(LoggerInterface::class);
$logger->shouldIgnoreMissing();
@@ -78,11 +88,11 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
$eventBus,
$aggregateFactory,
m::mock(UserDataFilterInterface::class),
- $logger
+ $logger,
),
$this->apiIdentityRepository,
$this->sensitiveDataService,
- $this->sraaRepository
+ $this->sraaRepository,
);
}
@@ -91,27 +101,27 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
* @group command-handler
* @group sensitive-data
*/
- public function an_identity_can_be_forgotten()
+ public function an_identity_can_be_forgotten(): void
{
- $identityId = new IdentityId('A');
+ $identityId = new IdentityId('A');
$institution = new Institution('Helsingin Yliopisto');
- $nameId = new NameId('urn:eeva-kuopio');
- $commonName = new CommonName('Eeva Kuopio');
- $email = new Email('e.kuopio@hy.fi');
- $locale = new Locale('fi_FI');;
+ $nameId = new NameId('urn:eeva-kuopio');
+ $commonName = new CommonName('Eeva Kuopio');
+ $email = new Email('e.kuopio@hy.fi');
+ $locale = new Locale('fi_FI');
$this->apiIdentityRepository
->shouldReceive('findOneByNameIdAndInstitution')
->once()
- ->with(Matchers::equalTo($nameId), Matchers::equalTo($institution))
- ->andReturn((object) ['id' => $identityId->getIdentityId()]);
+ ->with(new IsEqual($nameId), new IsEqual($institution))
+ ->andReturn($this->createIdentity($identityId->getIdentityId()));
$this->sensitiveDataService
->shouldReceive('forgetSensitiveData')
->once()
- ->with(Matchers::equalTo($identityId));
+ ->with(new IsEqual($identityId));
- $this->sraaRepository->shouldReceive('contains')->once()->with(Matchers::equalTo($nameId))->andReturn(false);
+ $this->sraaRepository->shouldReceive('contains')->once()->with(new IsEqual($nameId))->andReturn(false);
$command = new ForgetIdentityCommand();
$command->nameId = $nameId->getNameId();
@@ -126,7 +136,7 @@ public function an_identity_can_be_forgotten()
$nameId,
$commonName,
$email,
- $locale
+ $locale,
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -136,8 +146,8 @@ public function an_identity_can_be_forgotten()
$email,
$locale,
new SecondFactorId('SF-ID'),
- new YubikeyPublicId('01900473')
- )
+ new YubikeyPublicId('01900473'),
+ ),
])
->when($command)
->then([
@@ -150,30 +160,25 @@ public function an_identity_can_be_forgotten()
* @group command-handler
* @group sensitive-data
*/
- public function an_identity_may_not_be_forgotten_twice()
+ public function an_identity_may_not_be_forgotten_twice(): void
{
$this->expectExceptionMessage("Operation on this Identity is not allowed: it has been forgotten");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
- $identityId = new IdentityId('A');
+ $identityId = new IdentityId('A');
$institution = new Institution('Helsingin Yliopisto');
- $nameId = new NameId('urn:eeva-kuopio');
- $commonName = new CommonName('Eeva Kuopio');
- $email = new Email('e.kuopio@hy.fi');
- $locale = new Locale('fi_FI');;
+ $nameId = new NameId('urn:eeva-kuopio');
+ $commonName = new CommonName('Eeva Kuopio');
+ $email = new Email('e.kuopio@hy.fi');
+ $locale = new Locale('fi_FI');
$this->apiIdentityRepository
->shouldReceive('findOneByNameIdAndInstitution')
->once()
- ->with(Matchers::equalTo($nameId), Matchers::equalTo($institution))
- ->andReturn((object) ['id' => $identityId->getIdentityId()]);
-
- $this->sensitiveDataService
- ->shouldReceive('forgetSensitiveData')
- ->once()
- ->with(Matchers::equalTo($identityId));
+ ->with(new IsEqual($nameId), new IsEqual($institution))
+ ->andReturn($this->createIdentity($identityId->getIdentityId()));
- $this->sraaRepository->shouldReceive('contains')->once()->with(Matchers::equalTo($nameId))->andReturn(false);
+ $this->sraaRepository->shouldReceive('contains')->once()->with(new IsEqual($nameId))->andReturn(false);
$command = new ForgetIdentityCommand();
$command->nameId = $nameId->getNameId();
@@ -188,7 +193,7 @@ public function an_identity_may_not_be_forgotten_twice()
$nameId,
$commonName,
$email,
- $locale
+ $locale,
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -198,7 +203,7 @@ public function an_identity_may_not_be_forgotten_twice()
$email,
$locale,
new SecondFactorId('SF-ID'),
- new YubikeyPublicId('01900473')
+ new YubikeyPublicId('01900473'),
),
new IdentityForgottenEvent($identityId, $institution),
])
@@ -210,30 +215,25 @@ public function an_identity_may_not_be_forgotten_twice()
* @group command-handler
* @group sensitive-data
*/
- public function an_ra_cannot_be_forgotten()
+ public function an_ra_cannot_be_forgotten(): void
{
$this->expectExceptionMessage("Cannot forget an identity that is currently accredited as an RA(A)");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
- $identityId = new IdentityId('A');
+ $identityId = new IdentityId('A');
$institution = new Institution('Helsingin Yliopisto');
- $nameId = new NameId('urn:eeva-kuopio');
- $commonName = new CommonName('Eeva Kuopio');
- $email = new Email('e.kuopio@hy.fi');
- $locale = new Locale('fi_FI');;
+ $nameId = new NameId('urn:eeva-kuopio');
+ $commonName = new CommonName('Eeva Kuopio');
+ $email = new Email('e.kuopio@hy.fi');
+ $locale = new Locale('fi_FI');
$this->apiIdentityRepository
->shouldReceive('findOneByNameIdAndInstitution')
->once()
- ->with(Matchers::equalTo($nameId), Matchers::equalTo($institution))
- ->andReturn((object) ['id' => $identityId->getIdentityId()]);
-
- $this->sensitiveDataService
- ->shouldReceive('forgetSensitiveData')
- ->once()
- ->with(Matchers::equalTo($identityId));
+ ->with(new IsEqual($nameId), new IsEqual($institution))
+ ->andReturn($this->createIdentity($identityId->getIdentityId()));
- $this->sraaRepository->shouldReceive('contains')->once()->with(Matchers::equalTo($nameId))->andReturn(false);
+ $this->sraaRepository->shouldReceive('contains')->once()->with(new IsEqual($nameId))->andReturn(false);
$command = new ForgetIdentityCommand();
$command->nameId = $nameId->getNameId();
@@ -248,7 +248,7 @@ public function an_ra_cannot_be_forgotten()
$nameId,
$commonName,
$email,
- $locale
+ $locale,
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -258,7 +258,7 @@ public function an_ra_cannot_be_forgotten()
$email,
$locale,
new SecondFactorId('SF-ID'),
- new YubikeyPublicId('01900473')
+ new YubikeyPublicId('01900473'),
),
new IdentityAccreditedAsRaEvent(
$identityId,
@@ -267,7 +267,6 @@ public function an_ra_cannot_be_forgotten()
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RA),
new Location('0x0392ff832'),
new ContactInformation('/dev/null'),
- $institution
),
])
->when($command);
@@ -278,30 +277,25 @@ public function an_ra_cannot_be_forgotten()
* @group command-handler
* @group sensitive-data
*/
- public function an_raa_cannot_be_forgotten()
+ public function an_raa_cannot_be_forgotten(): void
{
$this->expectExceptionMessage("Cannot forget an identity that is currently accredited as an RA(A)");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
- $identityId = new IdentityId('A');
+ $identityId = new IdentityId('A');
$institution = new Institution('Helsingin Yliopisto');
- $nameId = new NameId('urn:eeva-kuopio');
- $commonName = new CommonName('Eeva Kuopio');
- $email = new Email('e.kuopio@hy.fi');
- $locale = new Locale('fi_FI');;
+ $nameId = new NameId('urn:eeva-kuopio');
+ $commonName = new CommonName('Eeva Kuopio');
+ $email = new Email('e.kuopio@hy.fi');
+ $locale = new Locale('fi_FI');
$this->apiIdentityRepository
->shouldReceive('findOneByNameIdAndInstitution')
->once()
- ->with(Matchers::equalTo($nameId), Matchers::equalTo($institution))
- ->andReturn((object) ['id' => $identityId->getIdentityId()]);
-
- $this->sensitiveDataService
- ->shouldReceive('forgetSensitiveData')
- ->once()
- ->with(Matchers::equalTo($identityId));
+ ->with(new IsEqual($nameId), new IsEqual($institution))
+ ->andReturn($this->createIdentity($identityId->getIdentityId()));
- $this->sraaRepository->shouldReceive('contains')->once()->with(Matchers::equalTo($nameId))->andReturn(false);
+ $this->sraaRepository->shouldReceive('contains')->once()->with(new IsEqual($nameId))->andReturn(false);
$command = new ForgetIdentityCommand();
$command->nameId = $nameId->getNameId();
@@ -316,7 +310,7 @@ public function an_raa_cannot_be_forgotten()
$nameId,
$commonName,
$email,
- $locale
+ $locale,
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -326,7 +320,7 @@ public function an_raa_cannot_be_forgotten()
$email,
$locale,
new SecondFactorId('SF-ID'),
- new YubikeyPublicId('01900473')
+ new YubikeyPublicId('01900473'),
),
new IdentityAccreditedAsRaForInstitutionEvent(
$identityId,
@@ -335,7 +329,7 @@ public function an_raa_cannot_be_forgotten()
new RegistrationAuthorityRole(RegistrationAuthorityRole::ROLE_RAA),
new Location('0x0392ff832'),
new ContactInformation('/dev/null'),
- $institution
+ $institution,
),
])
->when($command);
@@ -346,30 +340,19 @@ public function an_raa_cannot_be_forgotten()
* @group command-handler
* @group sensitive-data
*/
- public function an_sraa_cannae_be_forgotten()
+ public function an_sraa_cannot_be_forgotten(): void
{
$this->expectExceptionMessage("Cannot forget an identity that is currently accredited as an SRAA");
- $this->expectException(\Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\RuntimeException::class);
+ $this->expectException(RuntimeException::class);
- $identityId = new IdentityId('A');
+ $identityId = new IdentityId('A');
$institution = new Institution('Helsingin Yliopisto');
- $nameId = new NameId('urn:eeva-kuopio');
- $commonName = new CommonName('Eeva Kuopio');
- $email = new Email('e.kuopio@hy.fi');
- $locale = new Locale('fi_FI');;
+ $nameId = new NameId('urn:eeva-kuopio');
+ $commonName = new CommonName('Eeva Kuopio');
+ $email = new Email('e.kuopio@hy.fi');
+ $locale = new Locale('fi_FI');
- $this->apiIdentityRepository
- ->shouldReceive('findOneByNameIdAndInstitution')
- ->once()
- ->with(Matchers::equalTo($nameId), Matchers::equalTo($institution))
- ->andReturn((object) ['id' => $identityId->getIdentityId()]);
-
- $this->sensitiveDataService
- ->shouldReceive('forgetSensitiveData')
- ->once()
- ->with(Matchers::equalTo($identityId));
-
- $this->sraaRepository->shouldReceive('contains')->once()->with(Matchers::equalTo($nameId))->andReturn(true);
+ $this->sraaRepository->shouldReceive('contains')->once()->with(new IsEqual($nameId))->andReturn(true);
$command = new ForgetIdentityCommand();
$command->nameId = $nameId->getNameId();
@@ -384,7 +367,7 @@ public function an_sraa_cannae_be_forgotten()
$nameId,
$commonName,
$email,
- $locale
+ $locale,
),
new YubikeySecondFactorBootstrappedEvent(
$identityId,
@@ -394,9 +377,16 @@ public function an_sraa_cannae_be_forgotten()
$email,
$locale,
new SecondFactorId('SF-ID'),
- new YubikeyPublicId('01900473')
- )
+ new YubikeyPublicId('01900473'),
+ ),
])
->when($command);
}
+
+ private function createIdentity(string $identityId): Identity
+ {
+ $identity = new Identity();
+ $identity->id = $identityId;
+ return $identity;
+ }
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/SecondFactorRevocationTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/SecondFactorRevocationTest.php
index f7613f750..80253a852 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/SecondFactorRevocationTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/SecondFactorRevocationTest.php
@@ -34,8 +34,8 @@
use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
use Surfnet\Stepup\Identity\Event\EmailVerifiedEvent;
use Surfnet\Stepup\Identity\Event\IdentityCreatedEvent;
-use Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession;
use Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent;
+use Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession;
use Surfnet\Stepup\Identity\Event\U2fDevicePossessionProvenEvent;
use Surfnet\Stepup\Identity\Event\UnverifiedSecondFactorRevokedEvent;
use Surfnet\Stepup\Identity\Event\VerifiedSecondFactorRevokedEvent;
@@ -74,10 +74,12 @@
*/
class SecondFactorRevocationTest extends CommandHandlerTest
{
- private static $window = 3600;
+ private static int $window = 3600;
- protected function createCommandHandler(EventStoreInterface $eventStore, EventBusInterface $eventBus): CommandHandler
- {
+ protected function createCommandHandler(
+ EventStoreInterface $eventStore,
+ EventBusInterface $eventBus,
+ ): CommandHandler {
$aggregateFactory = new PublicConstructorAggregateFactory();
$logger = m::mock(LoggerInterface::class);
$logger->shouldIgnoreMissing();
@@ -88,7 +90,7 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
$eventBus,
$aggregateFactory,
m::mock(UserDataFilterInterface::class),
- $logger
+ $logger,
),
m::mock(IdentityProjectionRepository::class),
ConfigurableSettings::create(self::$window, []),
@@ -98,7 +100,7 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
m::mock(InstitutionConfigurationOptionsService::class)->shouldIgnoreMissing(),
m::mock(LoaResolutionService::class),
m::mock(RecoveryTokenSecretHelper::class),
- m::mock(RegistrationMailService::class)
+ m::mock(RegistrationMailService::class),
);
}
@@ -106,17 +108,17 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
* @test
* @group command-handler
*/
- public function an_identity_can_revoke_its_own_unverified_second_factor()
+ public function an_identity_can_revoke_its_own_unverified_second_factor(): void
{
- $command = new RevokeOwnSecondFactorCommand();
- $command->identityId = '42';
+ $command = new RevokeOwnSecondFactorCommand();
+ $command->identityId = '42';
$command->secondFactorId = self::uuid();
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution('A Corp.');
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId($command->secondFactorId);
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution('A Corp.');
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId($command->secondFactorId);
$secondFactorIdentifier = new YubikeyPublicId('00890782');
$this->scenario
@@ -128,7 +130,7 @@ public function an_identity_can_revoke_its_own_unverified_second_factor()
new NameId('3'),
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$identityId,
@@ -137,14 +139,14 @@ public function an_identity_can_revoke_its_own_unverified_second_factor()
$secondFactorIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$commonName,
$email,
- new Locale('en_GB')
- )
+ new Locale('en_GB'),
+ ),
])
->when($command)
->then([
@@ -153,8 +155,8 @@ public function an_identity_can_revoke_its_own_unverified_second_factor()
$institution,
$secondFactorId,
new SecondFactorType('yubikey'),
- $secondFactorIdentifier
- )
+ $secondFactorIdentifier,
+ ),
]);
}
@@ -162,17 +164,17 @@ public function an_identity_can_revoke_its_own_unverified_second_factor()
* @test
* @group command-handler
*/
- public function an_identity_can_revoke_its_own_verified_second_factor()
+ public function an_identity_can_revoke_its_own_verified_second_factor(): void
{
- $command = new RevokeOwnSecondFactorCommand();
- $command->identityId = '42';
+ $command = new RevokeOwnSecondFactorCommand();
+ $command->identityId = '42';
$command->secondFactorId = self::uuid();
- $identityId = new IdentityId($command->identityId);
- $institution = new Institution('A Corp.');
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId($command->secondFactorId);
+ $identityId = new IdentityId($command->identityId);
+ $institution = new Institution('A Corp.');
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId($command->secondFactorId);
$secondFactorIdentifier = new YubikeyPublicId('00890782');
$this->scenario
@@ -184,7 +186,7 @@ public function an_identity_can_revoke_its_own_verified_second_factor()
new NameId('3'),
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$identityId,
@@ -193,13 +195,13 @@ public function an_identity_can_revoke_its_own_verified_second_factor()
$secondFactorIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$identityId,
@@ -211,8 +213,8 @@ public function an_identity_can_revoke_its_own_verified_second_factor()
'SOMEREGISTRATIONCODE',
$commonName,
$email,
- new Locale('en_GB')
- )
+ new Locale('en_GB'),
+ ),
])
->when($command)
->then([
@@ -221,8 +223,8 @@ public function an_identity_can_revoke_its_own_verified_second_factor()
$institution,
$secondFactorId,
new SecondFactorType('yubikey'),
- $secondFactorIdentifier
- )
+ $secondFactorIdentifier,
+ ),
]);
}
@@ -230,19 +232,19 @@ public function an_identity_can_revoke_its_own_verified_second_factor()
* @test
* @group command-handler
*/
- public function an_identity_can_revoke_its_own_vetted_second_factor()
+ public function an_identity_can_revoke_its_own_vetted_second_factor(): void
{
- $command = new RevokeOwnSecondFactorCommand();
- $command->identityId = '42';
+ $command = new RevokeOwnSecondFactorCommand();
+ $command->identityId = '42';
$command->secondFactorId = self::uuid();
- $identityId = new IdentityId($command->identityId);
- $nameId = new NameId('3');
- $institution = new Institution('A Corp.');
- $email = new Email('info@domain.invalid');
- $commonName = new CommonName('Henk Westbroek');
- $secondFactorId = new SecondFactorId($command->secondFactorId);
- $secondFactorType = new SecondFactorType('yubikey');
+ $identityId = new IdentityId($command->identityId);
+ $nameId = new NameId('3');
+ $institution = new Institution('A Corp.');
+ $email = new Email('info@domain.invalid');
+ $commonName = new CommonName('Henk Westbroek');
+ $secondFactorId = new SecondFactorId($command->secondFactorId);
+ $secondFactorType = new SecondFactorType('yubikey');
$secondFactorIdentifier = new YubikeyPublicId('00890782');
$this->scenario
@@ -254,7 +256,7 @@ public function an_identity_can_revoke_its_own_vetted_second_factor()
$nameId,
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$identityId,
@@ -263,13 +265,13 @@ public function an_identity_can_revoke_its_own_vetted_second_factor()
$secondFactorIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$identityId,
@@ -281,7 +283,7 @@ public function an_identity_can_revoke_its_own_vetted_second_factor()
'SOMEREGISTRATIONCODE',
$commonName,
$email,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorVettedEvent(
$identityId,
@@ -293,8 +295,8 @@ public function an_identity_can_revoke_its_own_vetted_second_factor()
$commonName,
$email,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('DOCUMENT_42'))
- )
+ new OnPremiseVettingType(new DocumentNumber('DOCUMENT_42')),
+ ),
])
->when($command)
->then([
@@ -303,11 +305,11 @@ public function an_identity_can_revoke_its_own_vetted_second_factor()
$institution,
$secondFactorId,
$secondFactorType,
- $secondFactorIdentifier
+ $secondFactorIdentifier,
),
new VettedSecondFactorsAllRevokedEvent(
$identityId,
- $institution
+ $institution,
),
]);
}
@@ -316,26 +318,26 @@ public function an_identity_can_revoke_its_own_vetted_second_factor()
* @test
* @group command-handler
*/
- public function a_registration_authority_can_revoke_an_unverified_second_factor()
+ public function a_registration_authority_can_revoke_an_unverified_second_factor(): void
{
- $command = new RevokeRegistrantsSecondFactorCommand();
- $command->authorityId = static::uuid();
- $command->identityId = static::uuid();
+ $command = new RevokeRegistrantsSecondFactorCommand();
+ $command->authorityId = static::uuid();
+ $command->identityId = static::uuid();
$command->secondFactorId = static::uuid();
- $authorityId = new IdentityId($command->authorityId);
- $authorityNameId = new NameId(static::uuid());
- $authorityInstitution = new Institution('SURFnet');
- $authorityEmail = new Email('info@domain.invalid');
- $authorityCommonName = new CommonName('Henk Westbroek');
+ $authorityId = new IdentityId($command->authorityId);
+ $authorityNameId = new NameId(static::uuid());
+ $authorityInstitution = new Institution('SURFnet');
+ $authorityEmail = new Email('info@domain.invalid');
+ $authorityCommonName = new CommonName('Henk Westbroek');
- $registrantId = new IdentityId($command->identityId);
- $registrantInstitution = new Institution('SURFnet');
- $registrantNameId = new NameId('3');
- $registrantSecondFactorId = new SecondFactorId($command->secondFactorId);
+ $registrantId = new IdentityId($command->identityId);
+ $registrantInstitution = new Institution('SURFnet');
+ $registrantNameId = new NameId('3');
+ $registrantSecondFactorId = new SecondFactorId($command->secondFactorId);
$registrantSecondFactorIdentifier = new YubikeyPublicId('00890782');
- $registrantEmail = new Email('matti@domain.invalid');
- $registrantCommonName = new CommonName('Matti Vanhanen');
+ $registrantEmail = new Email('matti@domain.invalid');
+ $registrantCommonName = new CommonName('Matti Vanhanen');
$this->scenario
->withAggregateId($authorityId)
@@ -346,7 +348,7 @@ public function a_registration_authority_can_revoke_an_unverified_second_factor(
$authorityNameId,
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$authorityId,
@@ -356,8 +358,8 @@ public function a_registration_authority_can_revoke_an_unverified_second_factor(
$authorityEmail,
new Locale('en_GB'),
new SecondFactorId(static::uuid()),
- new YubikeyPublicId('12345678')
- )
+ new YubikeyPublicId('12345678'),
+ ),
])
->withAggregateId($registrantId)
->given([
@@ -367,7 +369,7 @@ public function a_registration_authority_can_revoke_an_unverified_second_factor(
$registrantNameId,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$registrantId,
@@ -376,13 +378,13 @@ public function a_registration_authority_can_revoke_an_unverified_second_factor(
$registrantSecondFactorIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
])
->when($command)
@@ -393,7 +395,7 @@ public function a_registration_authority_can_revoke_an_unverified_second_factor(
$registrantSecondFactorId,
new SecondFactorType('yubikey'),
$registrantSecondFactorIdentifier,
- $authorityId
+ $authorityId,
),
]);
}
@@ -402,27 +404,27 @@ public function a_registration_authority_can_revoke_an_unverified_second_factor(
* @test
* @group command-handler
*/
- public function a_registration_authority_can_revoke_a_verified_second_factor()
+ public function a_registration_authority_can_revoke_a_verified_second_factor(): void
{
- $command = new RevokeRegistrantsSecondFactorCommand();
- $command->authorityId = static::uuid();
- $command->identityId = static::uuid();
+ $command = new RevokeRegistrantsSecondFactorCommand();
+ $command->authorityId = static::uuid();
+ $command->identityId = static::uuid();
$command->secondFactorId = static::uuid();
- $authorityId = new IdentityId($command->authorityId);
- $authorityNameId = new NameId(static::uuid());
- $authorityInstitution = new Institution('Wazoo');
- $authorityEmail = new Email('info@domain.invalid');
- $authorityCommonName = new CommonName('Henk Westbroek');
-
- $registrantId = new IdentityId($command->identityId);
- $registrantInstitution = new Institution('A Corp.');
- $registrantNameId = new NameId('3');
- $registrantSecondFactorId = new SecondFactorId($command->secondFactorId);
- $registrantSecondFactorType = new SecondFactorType('yubikey');
+ $authorityId = new IdentityId($command->authorityId);
+ $authorityNameId = new NameId(static::uuid());
+ $authorityInstitution = new Institution('Wazoo');
+ $authorityEmail = new Email('info@domain.invalid');
+ $authorityCommonName = new CommonName('Henk Westbroek');
+
+ $registrantId = new IdentityId($command->identityId);
+ $registrantInstitution = new Institution('A Corp.');
+ $registrantNameId = new NameId('3');
+ $registrantSecondFactorId = new SecondFactorId($command->secondFactorId);
+ $registrantSecondFactorType = new SecondFactorType('yubikey');
$registrantSecondFactorIdentifier = new YubikeyPublicId('00890782');
- $registrantEmail = new Email('matti@domain.invalid');
- $registrantCommonName = new CommonName('Matti Vanhanen');
+ $registrantEmail = new Email('matti@domain.invalid');
+ $registrantCommonName = new CommonName('Matti Vanhanen');
$this->scenario
->withAggregateId($authorityId)
@@ -433,7 +435,7 @@ public function a_registration_authority_can_revoke_a_verified_second_factor()
$authorityNameId,
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$authorityId,
@@ -443,8 +445,8 @@ public function a_registration_authority_can_revoke_a_verified_second_factor()
$authorityEmail,
new Locale('en_GB'),
new SecondFactorId(static::uuid()),
- new YubikeyPublicId('12345678')
- )
+ new YubikeyPublicId('12345678'),
+ ),
])
->withAggregateId($registrantId)
->given([
@@ -454,7 +456,7 @@ public function a_registration_authority_can_revoke_a_verified_second_factor()
$registrantNameId,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$registrantId,
@@ -463,13 +465,13 @@ public function a_registration_authority_can_revoke_a_verified_second_factor()
$registrantSecondFactorIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -481,8 +483,8 @@ public function a_registration_authority_can_revoke_a_verified_second_factor()
'REGISTRATION_CODE',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
- )
+ new Locale('en_GB'),
+ ),
])
->when($command)
->then([
@@ -492,7 +494,7 @@ public function a_registration_authority_can_revoke_a_verified_second_factor()
$registrantSecondFactorId,
$registrantSecondFactorType,
$registrantSecondFactorIdentifier,
- $authorityId
+ $authorityId,
),
]);
}
@@ -501,27 +503,27 @@ public function a_registration_authority_can_revoke_a_verified_second_factor()
* @test
* @group command-handler
*/
- public function a_registration_authority_can_revoke_a_vetted_second_factor()
+ public function a_registration_authority_can_revoke_a_vetted_second_factor(): void
{
- $command = new RevokeRegistrantsSecondFactorCommand();
- $command->authorityId = static::uuid();
- $command->identityId = static::uuid();
+ $command = new RevokeRegistrantsSecondFactorCommand();
+ $command->authorityId = static::uuid();
+ $command->identityId = static::uuid();
$command->secondFactorId = static::uuid();
- $authorityId = new IdentityId($command->authorityId);
- $authorityNameId = new NameId(static::uuid());
- $authorityInstitution = new Institution('Wazoo');
- $authorityEmail = new Email('info@domain.invalid');
- $authorityCommonName = new CommonName('Henk Westbroek');
-
- $registrantId = new IdentityId($command->identityId);
- $registrantInstitution = new Institution('A Corp.');
- $registrantNameId = new NameId('3');
- $registrantSecondFactorId = new SecondFactorId($command->secondFactorId);
- $registrantSecondFactorType = new SecondFactorType('yubikey');
+ $authorityId = new IdentityId($command->authorityId);
+ $authorityNameId = new NameId(static::uuid());
+ $authorityInstitution = new Institution('Wazoo');
+ $authorityEmail = new Email('info@domain.invalid');
+ $authorityCommonName = new CommonName('Henk Westbroek');
+
+ $registrantId = new IdentityId($command->identityId);
+ $registrantInstitution = new Institution('A Corp.');
+ $registrantNameId = new NameId('3');
+ $registrantSecondFactorId = new SecondFactorId($command->secondFactorId);
+ $registrantSecondFactorType = new SecondFactorType('yubikey');
$registrantSecondFactorIdentifier = new YubikeyPublicId('00890782');
- $registrantEmail = new Email('matti@domain.invalid');
- $registrantCommonName = new CommonName('Matti Vanhanen');
+ $registrantEmail = new Email('matti@domain.invalid');
+ $registrantCommonName = new CommonName('Matti Vanhanen');
$this->scenario
->withAggregateId($authorityId)
@@ -532,7 +534,7 @@ public function a_registration_authority_can_revoke_a_vetted_second_factor()
$authorityNameId,
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$authorityId,
@@ -542,8 +544,8 @@ public function a_registration_authority_can_revoke_a_vetted_second_factor()
$authorityEmail,
new Locale('en_GB'),
new SecondFactorId(static::uuid()),
- new YubikeyPublicId('12345678')
- )
+ new YubikeyPublicId('12345678'),
+ ),
])
->withAggregateId($registrantId)
->given([
@@ -553,7 +555,7 @@ public function a_registration_authority_can_revoke_a_vetted_second_factor()
$registrantNameId,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$registrantId,
@@ -562,13 +564,13 @@ public function a_registration_authority_can_revoke_a_vetted_second_factor()
$registrantSecondFactorIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -580,7 +582,7 @@ public function a_registration_authority_can_revoke_a_vetted_second_factor()
'REGISTRATION_CODE',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorVettedEvent(
$registrantId,
@@ -592,8 +594,8 @@ public function a_registration_authority_can_revoke_a_vetted_second_factor()
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('DOCUMENT_NUMBER'))
- )
+ new OnPremiseVettingType(new DocumentNumber('DOCUMENT_NUMBER')),
+ ),
])
->when($command)
->then([
@@ -603,42 +605,41 @@ public function a_registration_authority_can_revoke_a_vetted_second_factor()
$registrantSecondFactorId,
new SecondFactorType('yubikey'),
$registrantSecondFactorIdentifier,
- $authorityId
+ $authorityId,
),
new VettedSecondFactorsAllRevokedEvent(
$registrantId,
- $registrantInstitution
+ $registrantInstitution,
),
]);
}
-
/**
* @test
* @group command-handler
*/
- public function a_registration_authority_can_revoke_a_possession_proved_skipped_vetted_second_factor()
+ public function a_registration_authority_can_revoke_a_possession_proved_skipped_vetted_second_factor(): void
{
- $command = new RevokeRegistrantsSecondFactorCommand();
- $command->authorityId = static::uuid();
- $command->identityId = static::uuid();
+ $command = new RevokeRegistrantsSecondFactorCommand();
+ $command->authorityId = static::uuid();
+ $command->identityId = static::uuid();
$command->secondFactorId = static::uuid();
- $authorityId = new IdentityId($command->authorityId);
- $authorityNameId = new NameId(static::uuid());
- $authorityInstitution = new Institution('Wazoo');
- $authorityEmail = new Email('info@domain.invalid');
- $authorityCommonName = new CommonName('Henk Westbroek');
-
- $registrantId = new IdentityId($command->identityId);
- $registrantInstitution = new Institution('A Corp.');
- $registrantNameId = new NameId('3');
- $registrantSecondFactorId = new SecondFactorId($command->secondFactorId);
- $registrantSecondFactorType = new SecondFactorType('yubikey');
+ $authorityId = new IdentityId($command->authorityId);
+ $authorityNameId = new NameId(static::uuid());
+ $authorityInstitution = new Institution('Wazoo');
+ $authorityEmail = new Email('info@domain.invalid');
+ $authorityCommonName = new CommonName('Henk Westbroek');
+
+ $registrantId = new IdentityId($command->identityId);
+ $registrantInstitution = new Institution('A Corp.');
+ $registrantNameId = new NameId('3');
+ $registrantSecondFactorId = new SecondFactorId($command->secondFactorId);
+ $registrantSecondFactorType = new SecondFactorType('yubikey');
$registrantSecondFactorIdentifier = new YubikeyPublicId('00890782');
- $registrantEmail = new Email('matti@domain.invalid');
- $registrantCommonName = new CommonName('Matti Vanhanen');
+ $registrantEmail = new Email('matti@domain.invalid');
+ $registrantCommonName = new CommonName('Matti Vanhanen');
$this->scenario
->withAggregateId($authorityId)
@@ -649,7 +650,7 @@ public function a_registration_authority_can_revoke_a_possession_proved_skipped_
$authorityNameId,
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$authorityId,
@@ -659,8 +660,8 @@ public function a_registration_authority_can_revoke_a_possession_proved_skipped_
$authorityEmail,
new Locale('en_GB'),
new SecondFactorId(static::uuid()),
- new YubikeyPublicId('12345678')
- )
+ new YubikeyPublicId('12345678'),
+ ),
])
->withAggregateId($registrantId)
->given([
@@ -670,7 +671,7 @@ public function a_registration_authority_can_revoke_a_possession_proved_skipped_
$registrantNameId,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeyPossessionProvenEvent(
$registrantId,
@@ -679,13 +680,13 @@ public function a_registration_authority_can_revoke_a_possession_proved_skipped_
$registrantSecondFactorIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -697,7 +698,7 @@ public function a_registration_authority_can_revoke_a_possession_proved_skipped_
'REGISTRATION_CODE',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorVettedWithoutTokenProofOfPossession(
$registrantId,
@@ -709,8 +710,8 @@ public function a_registration_authority_can_revoke_a_possession_proved_skipped_
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('DOCUMENT_NUMBER'))
- )
+ new OnPremiseVettingType(new DocumentNumber('DOCUMENT_NUMBER')),
+ ),
])
->when($command)
->then([
@@ -720,11 +721,11 @@ public function a_registration_authority_can_revoke_a_possession_proved_skipped_
$registrantSecondFactorId,
new SecondFactorType('yubikey'),
$registrantSecondFactorIdentifier,
- $authorityId
+ $authorityId,
),
new VettedSecondFactorsAllRevokedEvent(
$registrantId,
- $registrantInstitution
+ $registrantInstitution,
),
]);
}
@@ -734,31 +735,31 @@ public function a_registration_authority_can_revoke_a_possession_proved_skipped_
* @test
* @group command-handler
*/
- public function a_registration_authority_can_revoke_one_of_multiple_vetted_second_factors()
+ public function a_registration_authority_can_revoke_one_of_multiple_vetted_second_factors(): void
{
- $command = new RevokeRegistrantsSecondFactorCommand();
- $command->authorityId = static::uuid();
- $command->identityId = static::uuid();
- $command->secondFactorId = static::uuid();
+ $command = new RevokeRegistrantsSecondFactorCommand();
+ $command->authorityId = static::uuid();
+ $command->identityId = static::uuid();
+ $command->secondFactorId = static::uuid();
$secondFactorId2 = static::uuid();
- $authorityId = new IdentityId($command->authorityId);
- $authorityNameId = new NameId(static::uuid());
- $authorityInstitution = new Institution('Wazoo');
- $authorityEmail = new Email('info@domain.invalid');
- $authorityCommonName = new CommonName('Henk Westbroek');
-
- $registrantId = new IdentityId($command->identityId);
- $registrantInstitution = new Institution('A Corp.');
- $registrantNameId = new NameId('3');
- $registrantSecondFactorId = new SecondFactorId($command->secondFactorId);
- $registrantSecondFactorType = new SecondFactorType('yubikey');
+ $authorityId = new IdentityId($command->authorityId);
+ $authorityNameId = new NameId(static::uuid());
+ $authorityInstitution = new Institution('Wazoo');
+ $authorityEmail = new Email('info@domain.invalid');
+ $authorityCommonName = new CommonName('Henk Westbroek');
+
+ $registrantId = new IdentityId($command->identityId);
+ $registrantInstitution = new Institution('A Corp.');
+ $registrantNameId = new NameId('3');
+ $registrantSecondFactorId = new SecondFactorId($command->secondFactorId);
+ $registrantSecondFactorType = new SecondFactorType('yubikey');
$registrantSecondFactorIdentifier = new YubikeyPublicId('00890782');
- $registrantEmail = new Email('matti@domain.invalid');
- $registrantCommonName = new CommonName('Matti Vanhanen');
+ $registrantEmail = new Email('matti@domain.invalid');
+ $registrantCommonName = new CommonName('Matti Vanhanen');
- $registrantSecondFactorId2 = new SecondFactorId($secondFactorId2);
- $registrantSecondFactorType2 = new SecondFactorType('u2f');
+ $registrantSecondFactorId2 = new SecondFactorId($secondFactorId2);
+ $registrantSecondFactorType2 = new SecondFactorType('u2f');
$registrantSecondFactorIdentifier2 = new U2fKeyHandle('00890783');
$this->scenario
@@ -770,7 +771,7 @@ public function a_registration_authority_can_revoke_one_of_multiple_vetted_secon
$authorityNameId,
$authorityCommonName,
$authorityEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new YubikeySecondFactorBootstrappedEvent(
$authorityId,
@@ -780,8 +781,8 @@ public function a_registration_authority_can_revoke_one_of_multiple_vetted_secon
$authorityEmail,
new Locale('en_GB'),
new SecondFactorId(static::uuid()),
- new YubikeyPublicId('12345678')
- )
+ new YubikeyPublicId('12345678'),
+ ),
])
->withAggregateId($registrantId)
->given([
@@ -791,7 +792,7 @@ public function a_registration_authority_can_revoke_one_of_multiple_vetted_secon
$registrantNameId,
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
// First second factor
new YubikeyPossessionProvenEvent(
@@ -801,13 +802,13 @@ public function a_registration_authority_can_revoke_one_of_multiple_vetted_secon
$registrantSecondFactorIdentifier,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -819,7 +820,7 @@ public function a_registration_authority_can_revoke_one_of_multiple_vetted_secon
'REGISTRATION_CODE',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorVettedEvent(
$registrantId,
@@ -831,7 +832,7 @@ public function a_registration_authority_can_revoke_one_of_multiple_vetted_secon
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('DOCUMENT_NUMBER'))
+ new OnPremiseVettingType(new DocumentNumber('DOCUMENT_NUMBER')),
),
// Second second factor
new U2fDevicePossessionProvenEvent(
@@ -841,13 +842,13 @@ public function a_registration_authority_can_revoke_one_of_multiple_vetted_secon
$registrantSecondFactorIdentifier2,
true,
EmailVerificationWindow::createFromTimeFrameStartingAt(
- TimeFrame::ofSeconds(static::$window),
- DateTime::now()
+ TimeFrame::ofSeconds(self::$window),
+ DateTime::now(),
),
'nonce',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new EmailVerifiedEvent(
$registrantId,
@@ -859,7 +860,7 @@ public function a_registration_authority_can_revoke_one_of_multiple_vetted_secon
'REGISTRATION_CODE',
$registrantCommonName,
$registrantEmail,
- new Locale('en_GB')
+ new Locale('en_GB'),
),
new SecondFactorVettedEvent(
$registrantId,
@@ -871,7 +872,7 @@ public function a_registration_authority_can_revoke_one_of_multiple_vetted_secon
$registrantCommonName,
$registrantEmail,
new Locale('en_GB'),
- new OnPremiseVettingType(new DocumentNumber('DOCUMENT_NUMBER'))
+ new OnPremiseVettingType(new DocumentNumber('DOCUMENT_NUMBER')),
),
])
->when($command)
@@ -882,7 +883,7 @@ public function a_registration_authority_can_revoke_one_of_multiple_vetted_secon
$registrantSecondFactorId,
new SecondFactorType('yubikey'),
$registrantSecondFactorIdentifier,
- $authorityId
+ $authorityId,
),
]);
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/WhitelistCommandHandlerTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/WhitelistCommandHandlerTest.php
index 70a8e0fcf..c407c752b 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/WhitelistCommandHandlerTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Identity/CommandHandler/WhitelistCommandHandlerTest.php
@@ -22,6 +22,7 @@
use Broadway\EventHandling\EventBus as EventBusInterface;
use Broadway\EventSourcing\AggregateFactory\PublicConstructorAggregateFactory;
use Broadway\EventStore\EventStore as EventStoreInterface;
+use Surfnet\Stepup\Exception\DomainException;
use Surfnet\Stepup\Identity\Collection\InstitutionCollection;
use Surfnet\Stepup\Identity\Event\InstitutionsAddedToWhitelistEvent;
use Surfnet\Stepup\Identity\Event\InstitutionsRemovedFromWhitelistEvent;
@@ -41,10 +42,12 @@ class WhitelistCommandHandlerTest extends CommandHandlerTest
/**
* Shorthand for fixed Whitelist ID.
*/
- const WID = Whitelist::WHITELIST_AGGREGATE_ID;
+ public const WID = Whitelist::WHITELIST_AGGREGATE_ID;
- protected function createCommandHandler(EventStoreInterface $eventStore, EventBusInterface $eventBus): CommandHandler
- {
+ protected function createCommandHandler(
+ EventStoreInterface $eventStore,
+ EventBusInterface $eventBus,
+ ): CommandHandler {
$aggregateFactory = new PublicConstructorAggregateFactory();
return new WhitelistCommandHandler(new WhitelistRepository($eventStore, $eventBus, $aggregateFactory));
@@ -55,17 +58,17 @@ protected function createCommandHandler(EventStoreInterface $eventStore, EventBu
* @group command-handler
* @group whitelist
*/
- public function when_the_whitelist_does_not_exist_yet_it_is_created()
+ public function when_the_whitelist_does_not_exist_yet_it_is_created(): void
{
- $command = new ReplaceWhitelistCommand();
+ $command = new ReplaceWhitelistCommand();
$command->institutions = ['Replace A', 'Replace B', 'Replace C'];
- $institutions = $this->mapStringValuesToInstitutions($command->institutions);
+ $institutions = $this->mapStringValuesToInstitutions($command->institutions);
$this->scenario
->when($command)
->then([
new WhitelistCreatedEvent(new InstitutionCollection()),
- new WhitelistReplacedEvent(new InstitutionCollection($institutions))
+ new WhitelistReplacedEvent(new InstitutionCollection($institutions)),
]);
}
@@ -74,7 +77,7 @@ public function when_the_whitelist_does_not_exist_yet_it_is_created()
* @group command-handler
* @group whitelist
*/
- public function the_whitelist_can_be_fully_replaced()
+ public function the_whitelist_can_be_fully_replaced(): void
{
$initialInstitutions = $this->mapStringValuesToInstitutions(['Initial One', 'Initial Two']);
@@ -87,8 +90,8 @@ public function the_whitelist_can_be_fully_replaced()
->when($command)
->then([
new WhitelistReplacedEvent(
- new InstitutionCollection($this->mapStringValuesToInstitutions($command->institutions))
- )
+ new InstitutionCollection($this->mapStringValuesToInstitutions($command->institutions)),
+ ),
]);
}
@@ -98,11 +101,11 @@ public function the_whitelist_can_be_fully_replaced()
* @group command-handler
* @group whitelist
*/
- public function an_institution_not_yet_on_the_whitelist_can_be_added_to_the_whitelist()
+ public function an_institution_not_yet_on_the_whitelist_can_be_added_to_the_whitelist(): void
{
$initialInstitutions = $this->mapStringValuesToInstitutions(['Initial One', 'Initial Two']);
- $command = new AddToWhitelistCommand();
+ $command = new AddToWhitelistCommand();
$command->institutionsToBeAdded = ['Added Institution'];
$this->scenario
@@ -111,8 +114,8 @@ public function an_institution_not_yet_on_the_whitelist_can_be_added_to_the_whit
->when($command)
->then([
new InstitutionsAddedToWhitelistEvent(
- new InstitutionCollection($this->mapStringValuesToInstitutions($command->institutionsToBeAdded))
- )
+ new InstitutionCollection($this->mapStringValuesToInstitutions($command->institutionsToBeAdded)),
+ ),
]);
}
@@ -121,14 +124,14 @@ public function an_institution_not_yet_on_the_whitelist_can_be_added_to_the_whit
* @group command-handler
* @group whitelist
*/
- public function an_institution_on_the_whitelist_may_not_be_added_again()
+ public function an_institution_on_the_whitelist_may_not_be_added_again(): void
{
$this->expectExceptionMessage("Cannot add institution \"already exists\" as it is already whitelisted");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
$initialInstitutions = $this->mapStringValuesToInstitutions(['Initial One', 'Already Exists']);
- $command = new AddToWhitelistCommand();
+ $command = new AddToWhitelistCommand();
$command->institutionsToBeAdded = ['Already Exists'];
$this->scenario
@@ -142,11 +145,11 @@ public function an_institution_on_the_whitelist_may_not_be_added_again()
* @group command-handler
* @group whitelist
*/
- public function an_institution_on_the_whitelist_can_be_removed_from_the_whitelist()
+ public function an_institution_on_the_whitelist_can_be_removed_from_the_whitelist(): void
{
$initialInstitutions = $this->mapStringValuesToInstitutions(['Initial One', 'On the whitelist']);
- $command = new RemoveFromWhitelistCommand();
+ $command = new RemoveFromWhitelistCommand();
$command->institutionsToBeRemoved = ['On the whitelist'];
$this->scenario
@@ -155,8 +158,8 @@ public function an_institution_on_the_whitelist_can_be_removed_from_the_whitelis
->when($command)
->then([
new InstitutionsRemovedFromWhitelistEvent(
- new InstitutionCollection($this->mapStringValuesToInstitutions($command->institutionsToBeRemoved))
- )
+ new InstitutionCollection($this->mapStringValuesToInstitutions($command->institutionsToBeRemoved)),
+ ),
]);
}
@@ -165,10 +168,10 @@ public function an_institution_on_the_whitelist_can_be_removed_from_the_whitelis
* @group command-handler
* @group whitelist
*/
- public function an_institution_that_is_not_on_the_whitelist_cannot_be_removed()
+ public function an_institution_that_is_not_on_the_whitelist_cannot_be_removed(): void
{
$this->expectExceptionMessage("Cannot remove institution \"not on the whitelist\" as it is not whitelisted");
- $this->expectException(\Surfnet\Stepup\Exception\DomainException::class);
+ $this->expectException(DomainException::class);
$initialInstitutions = $this->mapStringValuesToInstitutions(['Initial One', 'Initial Two']);
$command = new RemoveFromWhitelistCommand();
@@ -182,13 +185,10 @@ public function an_institution_that_is_not_on_the_whitelist_cannot_be_removed()
/**
* Helper function to quickly map String[] to Institution[]
- * @param array $institutions
* @return array
*/
- private function mapStringValuesToInstitutions(array $institutions)
+ private function mapStringValuesToInstitutions(array $institutions): array
{
- return array_map(function ($institution) {
- return new Institution($institution);
- }, $institutions);
+ return array_map(fn($institution): Institution => new Institution($institution), $institutions);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/HasInstitutionMatcher.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/HasInstitutionMatcher.php
index 2a6453aa4..7e4d28679 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/HasInstitutionMatcher.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/HasInstitutionMatcher.php
@@ -23,18 +23,12 @@
final class HasInstitutionMatcher extends MatcherAbstract
{
- public function __construct($expected)
+ public function __construct(string $expected)
{
- if (!is_string($expected)) {
- throw new RuntimeException(
- sprintf('In order to use the %s, a string should be given.', self::class)
- );
- }
-
parent::__construct($expected);
}
- public function match(&$actual)
+ public function match(mixed &$actual): bool
{
if (!is_object($actual)) {
return false;
@@ -50,8 +44,8 @@ public function match(&$actual)
return false;
}
- public function __toString()
+ public function __toString(): string
{
- return sprintf('', $this->_expected);
+ return sprintf('', $this->_expected);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/HasInstitutionMatcherTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/HasInstitutionMatcherTest.php
index b4c2c0769..b19a6bcb4 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/HasInstitutionMatcherTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/HasInstitutionMatcherTest.php
@@ -18,27 +18,18 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Mockery;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Mockery\Exception\RuntimeException;
use PHPUnit\Framework\TestCase as TestCase;
+use stdClass;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Mockery\TestObjects\ObjectWithInstitutionAccessor;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Mockery\TestObjects\ObjectWithInstitutionProperty;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Mockery\TestObjects\ObjectWithoutInstitutionPropertyAndAccessor;
+use TypeError;
class HasInstitutionMatcherTest extends TestCase
{
- /**
- * @test
- * @group mockery
- * @group institution
- *
- * @dataProvider nonStringProvider
- */
- public function has_institution_matcher_only_matches_against_strings($nonString)
- {
- $this->expectException(RuntimeException::class);
-
- $hasInstitutionMatcher = new HasInstitutionMatcher($nonString);
- }
+ use MockeryPHPUnitIntegration;
/**
* @test
@@ -47,8 +38,9 @@ public function has_institution_matcher_only_matches_against_strings($nonString)
*
* @dataProvider nonObjectProvider
*/
- public function has_institution_matcher_only_matches_objects_against_a_given_institution($nonObject)
- {
+ public function has_institution_matcher_only_matches_objects_against_a_given_institution(
+ bool|int|float|string|array|null $nonObject,
+ ): void {
$institution = 'surfnet.nl';
$hasInstitutionMatcher = new HasInstitutionMatcher($institution);
@@ -62,7 +54,7 @@ public function has_institution_matcher_only_matches_objects_against_a_given_ins
* @group mockery
* @group institution
*/
- public function has_institution_matcher_does_not_match_when_object_has_no_institution_property_and_no_institution_accessor()
+ public function has_institution_matcher_does_not_match_when_object_has_no_institution_property_and_no_institution_accessor(): void
{
$institution = 'surfnet.nl';
@@ -79,9 +71,9 @@ public function has_institution_matcher_does_not_match_when_object_has_no_instit
* @group mockery
* @group institution
*/
- public function has_institution_matcher_does_not_match_when_objects_accessed_institution_differs_from_given_institution()
+ public function has_institution_matcher_does_not_match_when_objects_accessed_institution_differs_from_given_institution(): void
{
- $institution = 'surfnet.nl';
+ $institution = 'surfnet.nl';
$differentInstitution = 'not-surfnet.nl';
$nonMatchingObject = new ObjectWithInstitutionAccessor($institution);
@@ -97,9 +89,9 @@ public function has_institution_matcher_does_not_match_when_objects_accessed_ins
* @group mockery
* @group institution
*/
- public function has_institution_matcher_matches_when_objects_accessed_institution_is_the_same_as_given_institution()
+ public function has_institution_matcher_matches_when_objects_accessed_institution_is_the_same_as_given_institution(): void
{
- $institution = 'surfnet.nl';
+ $institution = 'surfnet.nl';
$nonMatchingObject = new ObjectWithInstitutionAccessor($institution);
@@ -114,9 +106,9 @@ public function has_institution_matcher_matches_when_objects_accessed_institutio
* @group mockery
* @group institution
*/
- public function has_institution_matcher_does_not_match_when_objects_institution_property_differs_from_given_institution()
+ public function has_institution_matcher_does_not_match_when_objects_institution_property_differs_from_given_institution(): void
{
- $institution = 'surfnet.nl';
+ $institution = 'surfnet.nl';
$differentInstitution = 'not-surfnet.nl';
$nonMatchingObject = new ObjectWithInstitutionProperty($institution);
@@ -132,7 +124,7 @@ public function has_institution_matcher_does_not_match_when_objects_institution_
* @group mockery
* @group institution
*/
- public function has_institution_matcher_matches_when_objects_institution_property_is_the_same_as_given_institution()
+ public function has_institution_matcher_matches_when_objects_institution_property_is_the_same_as_given_institution(): void
{
$institution = 'surfnet.nl';
@@ -144,27 +136,27 @@ public function has_institution_matcher_matches_when_objects_institution_propert
$this->assertTrue($match);
}
- public function nonStringProvider()
+ public function nonStringProvider(): array
{
return [
- 'null' => [null],
- 'array' => [[]],
- 'boolean' => [true],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \stdClass()],
+ 'null' => [null],
+ 'array' => [[]],
+ 'boolean' => [true],
+ 'integer' => [1],
+ 'float' => [1.2],
+ 'object' => [new stdClass()],
];
}
- public function nonObjectProvider()
+ public function nonObjectProvider(): array
{
return [
- 'null' => [null],
- 'array' => [[]],
- 'boolean' => [true],
- 'integer' => [1],
- 'float' => [1.2],
- 'string' => ['string'],
+ 'null' => [null],
+ 'array' => [[]],
+ 'boolean' => [true],
+ 'integer' => [1],
+ 'float' => [1.2],
+ 'string' => ['string'],
];
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/TestObjects/ObjectWithInstitutionAccessor.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/TestObjects/ObjectWithInstitutionAccessor.php
index 5eba39b90..f6dea7f94 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/TestObjects/ObjectWithInstitutionAccessor.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/TestObjects/ObjectWithInstitutionAccessor.php
@@ -20,14 +20,11 @@
final class ObjectWithInstitutionAccessor
{
- private $institution;
-
- public function __construct($institution)
+ public function __construct(private string $institution)
{
- $this->institution = $institution;
}
- public function getInstitution()
+ public function getInstitution(): string
{
return $this->institution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/TestObjects/ObjectWithInstitutionProperty.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/TestObjects/ObjectWithInstitutionProperty.php
index 877603f79..a2ec7b381 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/TestObjects/ObjectWithInstitutionProperty.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Mockery/TestObjects/ObjectWithInstitutionProperty.php
@@ -20,10 +20,7 @@
final class ObjectWithInstitutionProperty
{
- public $institution;
-
- public function __construct($institution)
+ public function __construct(public string $institution)
{
- $this->institution = $institution;
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/AuthorizingStageTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/AuthorizingStageTest.php
index b96570df0..287e52dee 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/AuthorizingStageTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/AuthorizingStageTest.php
@@ -19,27 +19,31 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Pipeline;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase as UnitTest;
use Psr\Log\NullLogger;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\ManagementExecutable;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\RaExecutable;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\SelfServiceExecutable;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\ForbiddenException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\AuthorizingStage;
+use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
class AuthorizingStageTest extends UnitTest
{
- /**
- * @var \Mockery\MockInterface mock of Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
- */
- private $authorizationChecker;
+ use MockeryPHPUnitIntegration;
- /**
- * @var NullLogger
- */
- private $logger;
+ private MockInterface&AuthorizationCheckerInterface $authorizationChecker;
+
+ private NullLogger $logger;
public function setUp(): void
{
$this->logger = new NullLogger();
$this->authorizationChecker = m::mock(
- 'Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
+ AuthorizationCheckerInterface::class,
);
}
@@ -47,10 +51,10 @@ public function setUp(): void
* @test
* @group pipeline
*/
- public function when_a_command_has_no_marker_interface_authorization_is_granted_by_default()
+ public function when_a_command_has_no_marker_interface_authorization_is_granted_by_default(): void
{
- $command = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command');
- $this->authorizationChecker->shouldReceive('isGranted')->never();
+ $command = m::mock(AbstractCommand::class);
+ $this->authorizationChecker->shouldNotHaveReceived('isGranted');
$authorizingStage = new AuthorizingStage($this->logger, $this->authorizationChecker);
@@ -63,17 +67,17 @@ public function when_a_command_has_no_marker_interface_authorization_is_granted_
* @test
* @group pipeline
* @dataProvider interfaceToRoleMappingProvider
- *
- * @param string $interface
- * @param string $role
*/
- public function a_command_with_a_marker_interface_triggers_a_check_for_the_correct_role($interface, $role)
- {
- $command = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command, ' . $interface);
+ public function a_command_with_a_marker_interface_triggers_a_check_for_the_correct_role(
+ string $interface,
+ string $role,
+ ): void {
+ /** @var MockInterface&AbstractCommand $command */
+ $command = m::mock(AbstractCommand::class . ', ' . $interface);
$this->authorizationChecker
->shouldReceive('isGranted')
->once()
- ->with([$role])
+ ->with($role)
->andReturn(true);
$authorizingStage = new AuthorizingStage($this->logger, $this->authorizationChecker);
@@ -87,28 +91,32 @@ public function a_command_with_a_marker_interface_triggers_a_check_for_the_corre
* @test
* @group pipeline
*/
- public function when_a_command_implements_multiple_marker_interfaces_at_least_one_corresponding_role_is_required()
+ public function when_a_command_implements_multiple_marker_interfaces_at_least_one_corresponding_role_is_required(): void
{
+ /** @var AbstractCommand&SelfServiceExecutable&RaExecutable&ManagementExecutable&MockInterface $command */
$command = m::mock(
- 'Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command, '
- . 'Surfnet\StepupMiddleware\CommandHandlingBundle\Command\SelfServiceExecutable, '
- . 'Surfnet\StepupMiddleware\CommandHandlingBundle\Command\RaExecutable, '
- . 'Surfnet\StepupMiddleware\CommandHandlingBundle\Command\ManagementExecutable'
+ sprintf(
+ "%s, %s, %s, %s",
+ AbstractCommand::class,
+ SelfServiceExecutable::class,
+ RaExecutable::class,
+ ManagementExecutable::class
+ )
);
$this->authorizationChecker
->shouldReceive('isGranted')
- ->with(['ROLE_SS'])
+ ->with('ROLE_SS')
->andReturn(false);
$this->authorizationChecker
->shouldReceive('isGranted')
- ->with(['ROLE_RA'])
+ ->with('ROLE_RA')
->andReturn(true);
$this->authorizationChecker
->shouldReceive('isGranted')
- ->with(['ROLE_MANAGEMENT'])
+ ->with('ROLE_MANAGEMENT')
->andReturn(false);
$authorizingStage = new AuthorizingStage($this->logger, $this->authorizationChecker);
@@ -122,43 +130,47 @@ public function when_a_command_implements_multiple_marker_interfaces_at_least_on
* @test
* @group pipeline
*/
- public function when_the_client_does_not_have_the_required_role_an_forbidden_exception_is_thrown()
+ public function when_the_client_does_not_have_the_required_role_an_forbidden_exception_is_thrown(): void
{
- $this->expectException(\Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\ForbiddenException::class);
+ $this->expectException(ForbiddenException::class);
+ /** @var AbstractCommand&SelfServiceExecutable&MockInterface $command */
$command = m::mock(
- 'Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command, '
- . 'Surfnet\StepupMiddleware\CommandHandlingBundle\Command\SelfServiceExecutable'
+ sprintf(
+ "%s, %s",
+ AbstractCommand::class,
+ SelfServiceExecutable::class,
+ )
);
$this->authorizationChecker
->shouldReceive('isGranted')
->once()
- ->with(['ROLE_SS'])
+ ->with('ROLE_SS')
->andReturn(false);
$authorizingStage = new AuthorizingStage($this->logger, $this->authorizationChecker);
$authorizingStage->process($command);
- $this->assertInstanceOf($authorizingStage, AuthorizingStage::class);
+ $this->assertInstanceOf(AuthorizingStage::class, $authorizingStage);
}
- public function interfaceToRoleMappingProvider()
+ public function interfaceToRoleMappingProvider(): array
{
- return [
+ return [
'SelfServiceExecutable => ROLE_SS' => [
- 'Surfnet\StepupMiddleware\CommandHandlingBundle\Command\SelfServiceExecutable',
- 'ROLE_SS'
+ SelfServiceExecutable::class,
+ 'ROLE_SS',
],
'RaExecutable => ROLE_RA' => [
- 'Surfnet\StepupMiddleware\CommandHandlingBundle\Command\RaExecutable',
- 'ROLE_RA'
+ RaExecutable::class,
+ 'ROLE_RA',
],
'ManagementExecutable => ROLE_MANAGEMENT' => [
- 'Surfnet\StepupMiddleware\CommandHandlingBundle\Command\ManagementExecutable',
- 'ROLE_MANAGEMENT'
- ]
+ ManagementExecutable::class,
+ 'ROLE_MANAGEMENT',
+ ],
];
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/DispatchStageTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/DispatchStageTest.php
index 9f3366964..9d75430f7 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/DispatchStageTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/DispatchStageTest.php
@@ -20,19 +20,26 @@
use Broadway\CommandHandling\CommandBus;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\DispatchStage;
class DispatchStageTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group pipeline
*/
- public function it_dispatches_commands()
+ public function it_dispatches_commands(): void
{
- $command = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command');
+ $command = m::mock(AbstractCommand::class);
+ /** @var CommandBus&MockInterface $commandBus */
$commandBus = m::mock(CommandBus::class)->makePartial()
->shouldReceive('dispatch')->once()->with($command)->andReturnNull()
->getMock();
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/EventDispatchingStageTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/EventDispatchingStageTest.php
index 6f6928be8..c6fa4d44e 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/EventDispatchingStageTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/EventDispatchingStageTest.php
@@ -19,21 +19,28 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Pipeline;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase as UnitTest;
use Psr\Log\NullLogger;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\EventDispatchingStage;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Command\FixedUuidStubCommand;
class EventDispatchingStageTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group pipeline
*/
- public function buffered_event_bus_flush_is_called_during_process()
+ public function buffered_event_bus_flush_is_called_during_process(): void
{
- $command = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command');
- $eventBus = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus')
+ $command = m::mock(AbstractCommand::class);
+ /** @var BufferedEventBus&MockInterface $eventBus */
+ $eventBus = m::mock(BufferedEventBus::class)
->shouldReceive('flush')->once()
->getMock();
@@ -47,12 +54,12 @@ public function buffered_event_bus_flush_is_called_during_process()
* @test
* @group pipeline
*/
- public function it_returns_the_same_command_as_it_processes_unmodified()
+ public function it_returns_the_same_command_as_it_processes_unmodified(): void
{
$command = new FixedUuidStubCommand();
$uuid = $command->UUID;
-
- $eventBus = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus')
+ /** @var BufferedEventBus&MockInterface $eventBus */
+ $eventBus = m::mock(BufferedEventBus::class)
->shouldReceive('flush')->once()
->getMock();
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/StagedPipelineTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/StagedPipelineTest.php
index ab22e271a..d3b791345 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/StagedPipelineTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/StagedPipelineTest.php
@@ -19,20 +19,27 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Pipeline;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Stage;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\StagedPipeline;
class StagedPipelineTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group pipeline
*/
- public function it_passes_a_command_through_a_single_stage()
+ public function it_passes_a_command_through_a_single_stage(): void
{
- $command = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command');
- $stage = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Stage')
+ $command = m::mock(AbstractCommand::class);
+ /** @var Stage&MockInterface $stage */
+ $stage = m::mock(Stage::class)
->shouldReceive('process')->once()->with($command)->andReturn($command)
->getMock();
@@ -46,13 +53,15 @@ public function it_passes_a_command_through_a_single_stage()
* @test
* @group pipeline
*/
- public function it_passes_a_command_through_multiple_stages()
+ public function it_passes_a_command_through_multiple_stages(): void
{
- $command = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command');
- $stage1 = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Stage')
+ $command = m::mock(AbstractCommand::class);
+ /** @var Stage&MockInterface $stage1 */
+ $stage1 = m::mock(Stage::class)
->shouldReceive('process')->once()->with($command)->andReturn($command)
->getMock();
- $stage2 = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Stage')
+ /** @var Stage&MockInterface $stage2 */
+ $stage2 = m::mock(Stage::class)
->shouldReceive('process')->once()->with($command)->andReturn($command)
->getMock();
@@ -67,14 +76,16 @@ public function it_passes_a_command_through_multiple_stages()
* @test
* @group pipeline
*/
- public function it_passes_the_command_returned_from_an_earlier_stage_on_to_the_next()
+ public function it_passes_the_command_returned_from_an_earlier_stage_on_to_the_next(): void
{
- $command1 = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command');
- $command2 = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command');
- $stage1 = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Stage')
+ $command1 = m::mock(AbstractCommand::class);
+ $command2 = m::mock(AbstractCommand::class);
+ /** @var Stage&MockInterface $stage1 */
+ $stage1 = m::mock(Stage::class)
->shouldReceive('process')->once()->with($command1)->andReturn($command2)
->getMock();
- $stage2 = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Stage')
+ /** @var Stage&MockInterface $stage2 */
+ $stage2 = m::mock(Stage::class)
->shouldReceive('process')->once()->with($command2)->andReturn($command2)
->getMock();
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/ValidationStageTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/ValidationStageTest.php
index 1fd8c2dd8..c8e24da65 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/ValidationStageTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Pipeline/ValidationStageTest.php
@@ -18,24 +18,34 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Pipeline;
+use ArrayIterator;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Exception\InvalidCommandException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\ValidationStage;
+use Symfony\Component\Validator\ConstraintViolationListInterface;
+use Symfony\Component\Validator\Validator\ValidatorInterface;
class ValidationStageTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group pipeline
*/
- public function it_validates_commands()
+ public function it_validates_commands(): void
{
- $command = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command');
- $violations = m::mock('Symfony\Component\Validator\ConstraintViolationListInterface')
+ $command = m::mock(AbstractCommand::class);
+ $violations = m::mock(ConstraintViolationListInterface::class)
->shouldReceive('count')->with()->andReturn(0)
->getMock();
- $validator = m::mock('Symfony\Component\Validator\Validator\ValidatorInterface')
+ /** @var ValidatorInterface&MockInterface $validator */
+ $validator = m::mock(ValidatorInterface::class)
->shouldReceive('validate')->once()->with($command)->andReturn($violations)
->getMock();
@@ -48,16 +58,17 @@ public function it_validates_commands()
* @test
* @group pipeline
*/
- public function it_throws_an_exception_when_validation_fails()
+ public function it_throws_an_exception_when_validation_fails(): void
{
- $this->expectException(\Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Exception\InvalidCommandException::class);
+ $this->expectException(InvalidCommandException::class);
- $command = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command');
- $violations = m::mock('Symfony\Component\Validator\ConstraintViolationListInterface')
- ->shouldReceive('count')->with()->andReturn(1)
- ->shouldReceive('getIterator')->with()->andReturn(new \ArrayIterator())
- ->getMock();
- $validator = m::mock('Symfony\Component\Validator\Validator\ValidatorInterface')
+ $command = m::mock(AbstractCommand::class);
+ $violations = m::mock(ConstraintViolationListInterface::class);
+ $violations->allows()->count()->andReturn(1);
+ $violations->allows()->getIterator()->andReturn(new ArrayIterator())->getMock();
+
+ /** @var ValidatorInterface&MockInterface $validator */
+ $validator = m::mock(ValidatorInterface::class)
->shouldReceive('validate')->once()->with($command)->andReturn($violations)
->getMock();
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Processor/RecoveryTokenEmailProcessorTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Processor/RecoveryTokenEmailProcessorTest.php
index fefcbeae8..add7b0c48 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Processor/RecoveryTokenEmailProcessorTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Processor/RecoveryTokenEmailProcessorTest.php
@@ -19,6 +19,7 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Processor;
use Mockery;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
use Surfnet\Stepup\Identity\Event\CompliedWithRecoveryCodeRevocationEvent;
use Surfnet\Stepup\Identity\Event\PhoneRecoveryTokenPossessionProvenEvent;
@@ -33,30 +34,21 @@
use Surfnet\Stepup\Identity\Value\RecoveryTokenId;
use Surfnet\Stepup\Identity\Value\RecoveryTokenType;
use Surfnet\Stepup\Identity\Value\SafeStore;
-use Surfnet\Stepup\Identity\Value\Secret;
use Surfnet\Stepup\Identity\Value\UnhashedSecret;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Service\RecoveryTokenMailService;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Processor\RecoveryTokenEmailProcessor;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Identity\Processor\InstitutionConfigurationProcessor;
class RecoveryTokenEmailProcessorTest extends TestCase
{
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
- /**
- * @var RecoveryTokenEmailProcessor
- */
- private $processor;
- /**
- * @var Mockery\MockInterface|RecoveryTokenMailService
- */
- private $mailService;
- /**
- * @var Mockery\MockInterface|IdentityService
- */
- private $identityService;
+ private RecoveryTokenEmailProcessor $processor;
+
+ private RecoveryTokenMailService&MockInterface $mailService;
+
+ private IdentityService&MockInterface $identityService;
public function setUp(): void
{
@@ -64,14 +56,14 @@ public function setUp(): void
$this->identityService = Mockery::mock(IdentityService::class);
$this->processor = new RecoveryTokenEmailProcessor(
$this->mailService,
- $this->identityService
+ $this->identityService,
);
}
/**
* @group processor
*/
- public function test_mails_when_complied_with_recovery_token_revocation()
+ public function test_mails_when_complied_with_recovery_token_revocation(): void
{
$identity = $this->returnABogusIdentity();
$this->identityService
@@ -83,7 +75,7 @@ public function test_mails_when_complied_with_recovery_token_revocation()
new Institution('Harderwijk University'),
new RecoveryTokenId('r-t-id'),
new RecoveryTokenType('safe-store'),
- new IdentityId('ra-id')
+ new IdentityId('ra-id'),
);
$this->mailService
@@ -95,7 +87,7 @@ public function test_mails_when_complied_with_recovery_token_revocation()
$identity->email,
$event->recoveryTokenType,
$event->recoveryTokenId,
- true
+ true,
);
$this->processor->handleCompliedWithRecoveryCodeRevocationEvent($event);
}
@@ -103,7 +95,7 @@ public function test_mails_when_complied_with_recovery_token_revocation()
/**
* @group processor
*/
- public function test_does_not_mail_when_identity_not_found_complied_with_recovery_token_revocation()
+ public function test_does_not_mail_when_identity_not_found_complied_with_recovery_token_revocation(): void
{
$this->identityService
->shouldReceive('find')
@@ -114,7 +106,7 @@ public function test_does_not_mail_when_identity_not_found_complied_with_recover
new Institution('Harderwijk University'),
new RecoveryTokenId('r-t-id'),
new RecoveryTokenType('safe-store'),
- new IdentityId('ra-id')
+ new IdentityId('ra-id'),
);
$this->mailService
@@ -125,7 +117,7 @@ public function test_does_not_mail_when_identity_not_found_complied_with_recover
/**
* @group processor
*/
- public function test_it_mails_when_recovery_token_revoked_by_identity()
+ public function test_it_mails_when_recovery_token_revoked_by_identity(): void
{
$identity = $this->returnABogusIdentity();
$this->identityService
@@ -136,7 +128,7 @@ public function test_it_mails_when_recovery_token_revoked_by_identity()
new IdentityId('my-id'),
new Institution('Harderwijk University'),
new RecoveryTokenId('r-t-id'),
- new RecoveryTokenType('safe-store')
+ new RecoveryTokenType('safe-store'),
);
$this->mailService
@@ -148,7 +140,7 @@ public function test_it_mails_when_recovery_token_revoked_by_identity()
$identity->email,
$event->recoveryTokenType,
$event->recoveryTokenId,
- false
+ false,
);
$this->processor->handleRecoveryTokenRevokedEvent($event);
}
@@ -156,7 +148,7 @@ public function test_it_mails_when_recovery_token_revoked_by_identity()
/**
* @group processor
*/
- public function test_does_not_mail_when_identity_not_found_recovery_token_revocation()
+ public function test_does_not_mail_when_identity_not_found_recovery_token_revocation(): void
{
$this->identityService
->shouldReceive('find')
@@ -166,7 +158,7 @@ public function test_does_not_mail_when_identity_not_found_recovery_token_revoca
new IdentityId('my-not-found-id'),
new Institution('Harderwijk University'),
new RecoveryTokenId('r-t-id'),
- new RecoveryTokenType('safe-store')
+ new RecoveryTokenType('safe-store'),
);
$this->mailService
@@ -177,7 +169,7 @@ public function test_does_not_mail_when_identity_not_found_recovery_token_revoca
/**
* @group processor
*/
- public function test_it_mails_when_sms_token_created()
+ public function test_it_mails_when_sms_token_created(): void
{
$identity = $this->returnABogusIdentity();
$this->identityService
@@ -191,7 +183,7 @@ public function test_it_mails_when_sms_token_created()
new PhoneNumber('+42 (0) 612345678'),
$identity->commonName,
$identity->email,
- $identity->preferredLocale
+ $identity->preferredLocale,
);
$this->mailService
@@ -200,7 +192,7 @@ public function test_it_mails_when_sms_token_created()
->with(
$identity->preferredLocale,
$identity->commonName,
- $identity->email
+ $identity->email,
);
$this->processor->handlePhoneRecoveryTokenPossessionProvenEvent($event);
}
@@ -208,7 +200,7 @@ public function test_it_mails_when_sms_token_created()
/**
* @group processor
*/
- public function test_does_not_mail_when_identity_not_found_sms_creation()
+ public function test_does_not_mail_when_identity_not_found_sms_creation(): void
{
$this->identityService
->shouldReceive('find')
@@ -221,7 +213,7 @@ public function test_does_not_mail_when_identity_not_found_sms_creation()
new PhoneNumber('+42 (0) 38473929281'),
new CommonName('Jan de Wandelaar'),
new Email('j.walker@example.com'),
- new Locale('nl_NL')
+ new Locale('nl_NL'),
);
$this->mailService
@@ -232,7 +224,7 @@ public function test_does_not_mail_when_identity_not_found_sms_creation()
/**
* @group processor
*/
- public function test_it_mails_when_safe_store_token_created()
+ public function test_it_mails_when_safe_store_token_created(): void
{
$identity = $this->returnABogusIdentity();
$this->identityService
@@ -246,7 +238,7 @@ public function test_it_mails_when_safe_store_token_created()
new SafeStore(new UnhashedSecret('super-secret')),
$identity->commonName,
$identity->email,
- $identity->preferredLocale
+ $identity->preferredLocale,
);
$this->mailService
@@ -255,7 +247,7 @@ public function test_it_mails_when_safe_store_token_created()
->with(
$identity->preferredLocale,
$identity->commonName,
- $identity->email
+ $identity->email,
);
$this->processor->handleSafeStoreSecretRecoveryTokenPossessionPromisedEvent($event);
}
@@ -263,7 +255,7 @@ public function test_it_mails_when_safe_store_token_created()
/**
* @group processor
*/
- public function test_does_not_mail_when_identity_not_found_safe_store_creation()
+ public function test_does_not_mail_when_identity_not_found_safe_store_creation(): void
{
$this->identityService
->shouldReceive('find')
@@ -276,7 +268,7 @@ public function test_does_not_mail_when_identity_not_found_safe_store_creation()
new SafeStore(new UnhashedSecret('super-secret')),
new CommonName('Jan de Wandelaar'),
new Email('j.walker@example.com'),
- new Locale('nl_NL')
+ new Locale('nl_NL'),
);
$this->mailService
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/EventSourcing/ForgettableEventStub.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/EventSourcing/ForgettableEventStub.php
index 334c7e0c0..8ba62a886 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/EventSourcing/ForgettableEventStub.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/EventSourcing/ForgettableEventStub.php
@@ -26,12 +26,12 @@ final class ForgettableEventStub implements Forgettable
/**
* @var SensitiveData
*/
- public $sensitiveData;
+ public SensitiveData $sensitiveData;
/**
* @return SensitiveData
*/
- public function getSensitiveData()
+ public function getSensitiveData(): SensitiveData
{
return $this->sensitiveData;
}
@@ -40,7 +40,7 @@ public function getSensitiveData()
* @param SensitiveData $sensitiveData
* @return void
*/
- public function setSensitiveData(SensitiveData $sensitiveData)
+ public function setSensitiveData(SensitiveData $sensitiveData): void
{
$this->sensitiveData = $sensitiveData;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/EventSourcing/SensitiveDataMessageStreamTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/EventSourcing/SensitiveDataMessageStreamTest.php
index 627578ec6..490cd8f8e 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/EventSourcing/SensitiveDataMessageStreamTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/EventSourcing/SensitiveDataMessageStreamTest.php
@@ -23,24 +23,29 @@
use Broadway\Domain\DomainMessage;
use Broadway\Domain\Metadata;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase as TestCase;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\Email;
use Surfnet\Stepup\Identity\Value\IdentityId;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\EventSourcing\SensitiveDataMessage;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\EventSourcing\SensitiveDataMessageStream;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Exception\SensitiveDataApplicationException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
final class SensitiveDataMessageStreamTest extends TestCase
{
- const EVENT_STREAM_A = 'A';
- const EVENT_STREAM_B = 'B';
+ use MockeryPHPUnitIntegration;
+
+ public const EVENT_STREAM_A = 'A';
+ public const EVENT_STREAM_B = 'B';
/**
* @test
* @group sensitive-data
*/
- public function it_can_work_with_zero_sensitive_data_messages_and_zero_events()
+ public function it_can_work_with_zero_sensitive_data_messages_and_zero_events(): void
{
$this->apply([], []);
@@ -51,13 +56,13 @@ public function it_can_work_with_zero_sensitive_data_messages_and_zero_events()
* @test
* @group sensitive-data
*/
- public function it_can_apply_one_sensitive_data_message_to_one_matching_event()
+ public function it_can_apply_one_sensitive_data_message_to_one_matching_event(): void
{
$sensitiveDataMessages = [
new SensitiveDataMessage(
new IdentityId(self::EVENT_STREAM_A),
0,
- (new SensitiveData)->withCommonName(new CommonName('Willie Willoughby'))
+ (new SensitiveData)->withCommonName(new CommonName('Willie Willoughby')),
),
];
$domainMessages = [
@@ -66,7 +71,7 @@ public function it_can_apply_one_sensitive_data_message_to_one_matching_event()
0,
new Metadata(),
new ForgettableEventStub(),
- DateTime::now()
+ DateTime::now(),
),
];
@@ -78,18 +83,18 @@ public function it_can_apply_one_sensitive_data_message_to_one_matching_event()
* @test
* @group sensitive-data
*/
- public function it_can_apply_two_sensitive_data_message_to_two_matching_events()
+ public function it_can_apply_two_sensitive_data_message_to_two_matching_events(): void
{
$sensitiveDataMessages = [
new SensitiveDataMessage(
new IdentityId(self::EVENT_STREAM_A),
0,
- (new SensitiveData)->withCommonName(new CommonName('Willie Willoughby'))
+ (new SensitiveData)->withCommonName(new CommonName('Willie Willoughby')),
),
new SensitiveDataMessage(
new IdentityId(self::EVENT_STREAM_A),
1,
- (new SensitiveData)->withEmail(new Email('willie@willougby.invalid'))
+ (new SensitiveData)->withEmail(new Email('willie@willougby.invalid')),
),
];
$domainMessages = [
@@ -98,14 +103,14 @@ public function it_can_apply_two_sensitive_data_message_to_two_matching_events()
0,
new Metadata(),
new ForgettableEventStub(),
- DateTime::now()
+ DateTime::now(),
),
new DomainMessage(
self::EVENT_STREAM_A,
1,
new Metadata(),
new ForgettableEventStub(),
- DateTime::now()
+ DateTime::now(),
),
];
@@ -118,13 +123,13 @@ public function it_can_apply_two_sensitive_data_message_to_two_matching_events()
* @test
* @group sensitive-data
*/
- public function it_can_apply_one_sensitive_data_message_to_one_regular_event_and_one_matching_forgettable_event()
+ public function it_can_apply_one_sensitive_data_message_to_one_regular_event_and_one_matching_forgettable_event(): void
{
$sensitiveDataMessages = [
new SensitiveDataMessage(
new IdentityId(self::EVENT_STREAM_A),
1,
- (new SensitiveData)->withEmail(new Email('willie@willougby.invalid'))->forget()
+ (new SensitiveData)->withEmail(new Email('willie@willougby.invalid'))->forget(),
),
];
$domainMessages = [
@@ -133,14 +138,14 @@ public function it_can_apply_one_sensitive_data_message_to_one_regular_event_and
0,
new Metadata(),
new RegularEventStub(),
- DateTime::now()
+ DateTime::now(),
),
new DomainMessage(
self::EVENT_STREAM_A,
1,
new Metadata(),
new ForgettableEventStub(),
- DateTime::now()
+ DateTime::now(),
),
];
@@ -152,10 +157,10 @@ public function it_can_apply_one_sensitive_data_message_to_one_regular_event_and
* @test
* @group sensitive-data
*/
- public function it_fails_when_sensitive_data_is_missing_for_an_event()
+ public function it_fails_when_sensitive_data_is_missing_for_an_event(): void
{
$this->expectExceptionMessage("Sensitive data is missing for event with UUID A, playhead 0");
- $this->expectException(\Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Exception\SensitiveDataApplicationException::class);
+ $this->expectException(SensitiveDataApplicationException::class);
$sensitiveDataMessages = [];
$domainMessages = [
@@ -164,7 +169,7 @@ public function it_fails_when_sensitive_data_is_missing_for_an_event()
0,
new Metadata(),
new ForgettableEventStub(),
- DateTime::now()
+ DateTime::now(),
),
];
@@ -175,15 +180,15 @@ public function it_fails_when_sensitive_data_is_missing_for_an_event()
* @test
* @group sensitive-data
*/
- public function it_fails_when_not_all_sensitive_data_could_be_matched_to_an_event()
+ public function it_fails_when_not_all_sensitive_data_could_be_matched_to_an_event(): void
{
$this->expectExceptionMessage("1 sensitive data messages are still to be matched to events");
- $this->expectException(\Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Exception\SensitiveDataApplicationException::class);
+ $this->expectException(SensitiveDataApplicationException::class);
$sensitiveDataMessages = [
new SensitiveDataMessage(
new IdentityId(self::EVENT_STREAM_A),
1,
- (new SensitiveData)->withEmail(new Email('willie@willougby.invalid'))->forget()
+ (new SensitiveData)->withEmail(new Email('willie@willougby.invalid'))->forget(),
),
];
$domainMessages = [
@@ -192,7 +197,7 @@ public function it_fails_when_not_all_sensitive_data_could_be_matched_to_an_even
0,
new Metadata(),
new RegularEventStub(),
- DateTime::now()
+ DateTime::now(),
),
];
@@ -203,16 +208,18 @@ public function it_fails_when_not_all_sensitive_data_could_be_matched_to_an_even
* @test
* @group sensitive-data
*/
- public function it_fails_when_sensitive_data_matches_a_regular_event()
+ public function it_fails_when_sensitive_data_matches_a_regular_event(): void
{
- $this->expectExceptionMessage("Encountered sensitive data for event which does not support sensitive data, UUID A, playhead 0");
- $this->expectException(\Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Exception\SensitiveDataApplicationException::class);
+ $this->expectExceptionMessage(
+ "Encountered sensitive data for event which does not support sensitive data, UUID A, playhead 0",
+ );
+ $this->expectException(SensitiveDataApplicationException::class);
$sensitiveDataMessages = [
new SensitiveDataMessage(
new IdentityId(self::EVENT_STREAM_A),
0,
- (new SensitiveData)->withEmail(new Email('willie@willougby.invalid'))->forget()
+ (new SensitiveData)->withEmail(new Email('willie@willougby.invalid'))->forget(),
),
];
$domainMessages = [
@@ -221,7 +228,7 @@ public function it_fails_when_sensitive_data_matches_a_regular_event()
0,
new Metadata(),
new RegularEventStub(),
- DateTime::now()
+ DateTime::now(),
),
];
@@ -232,16 +239,16 @@ public function it_fails_when_sensitive_data_matches_a_regular_event()
* @test
* @group sensitive-data
*/
- public function it_fails_when_stream_ids_dont_match()
+ public function it_fails_when_stream_ids_dont_match(): void
{
$this->expectExceptionMessage("Encountered sensitive data from stream A for event from stream B");
- $this->expectException(\Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Exception\SensitiveDataApplicationException::class);
+ $this->expectException(SensitiveDataApplicationException::class);
$sensitiveDataMessages = [
new SensitiveDataMessage(
new IdentityId(self::EVENT_STREAM_A),
0,
- (new SensitiveData)->withEmail(new Email('willie@willougby.invalid'))->forget()
+ (new SensitiveData)->withEmail(new Email('willie@willougby.invalid'))->forget(),
),
];
$domainMessages = [
@@ -250,7 +257,7 @@ public function it_fails_when_stream_ids_dont_match()
0,
new Metadata(),
new ForgettableEventStub(),
- DateTime::now()
+ DateTime::now(),
),
];
@@ -261,26 +268,28 @@ public function it_fails_when_stream_ids_dont_match()
* @test
* @group sensitive-data
*/
- public function it_can_forget_all_sensitive_data()
+ public function it_can_forget_all_sensitive_data(): void
{
- $sensitiveDataMessageStream = new SensitiveDataMessageStream([
- m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\EventSourcing\SensitiveDataMessage')
- ->shouldReceive('forget')->once()
- ->getMock(),
- ]);
+ /** @var MockInterface&SensitiveDataMessage $command */
+ $command = m::mock(SensitiveDataMessage::class)
+ ->shouldReceive('forget')->once()
+ ->getMock();
+ $sensitiveDataMessageStream = new SensitiveDataMessageStream([$command]);
$sensitiveDataMessageStream->forget();
$this->assertInstanceOf(SensitiveDataMessageStream::class, $sensitiveDataMessageStream);
}
- private function apply(array $sensitiveDataMessages, array $domainMessages)
+ private function apply(array $sensitiveDataMessages, array $domainMessages): void
{
(new SensitiveDataMessageStream($sensitiveDataMessages))
->applyToDomainEventStream(new DomainEventStream($domainMessages));
}
- private function assertSensitiveDataEquals(SensitiveDataMessage $sensitiveDataMessage, DomainMessage $domainMessage)
- {
+ private function assertSensitiveDataEquals(
+ SensitiveDataMessage $sensitiveDataMessage,
+ DomainMessage $domainMessage,
+ ): void {
$this->assertEquals($sensitiveDataMessage->getSensitiveData(), $domainMessage->getPayload()->sensitiveData);
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/SensitiveDataTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/SensitiveDataTest.php
index 69da5eb85..8fe429397 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/SensitiveDataTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/SensitiveDataTest.php
@@ -18,6 +18,7 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\SensitiveData;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
use Surfnet\Stepup\Identity\Value\CommonName;
use Surfnet\Stepup\Identity\Value\DocumentNumber;
@@ -28,19 +29,22 @@
use Surfnet\Stepup\Identity\Value\YubikeyPublicId;
use Surfnet\StepupBundle\Value\SecondFactorType;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
+use function is_string;
class SensitiveDataTest extends TestCase
{
- public function sensitiveDataToSerialise()
+ use MockeryPHPUnitIntegration;
+
+ public function sensitiveDataToSerialise(): array
{
return [
'None' => [
(new SensitiveData()),
- []
+ [],
],
'None, forgotten' => [
(new SensitiveData())->forget(),
- []
+ [],
],
'CommonName' => [
(new SensitiveData())->withCommonName(new CommonName('Willie')),
@@ -103,21 +107,22 @@ public function sensitiveDataToSerialise()
* @test
* @group sensitive-data
* @dataProvider sensitiveDataToSerialise
- *
- * @param SensitiveData $sensitiveData
- * @param array $getterExpectations
*/
public function it_serialises_and_deserialises(
SensitiveData $sensitiveData,
- array $getterExpectations
- ) {
- $sensitiveData = SensitiveData::deserialize(json_decode(json_encode($sensitiveData->serialize()), true));
+ array $getterExpectations,
+ ): void {
+ $serializedData = json_encode($sensitiveData->serialize());
+ if (!is_string($serializedData)) {
+ $this->fail('Unable to json_encode the serialized sensitive data');
+ }
+ $sensitiveData = SensitiveData::deserialize(json_decode($serializedData, true));
foreach ($getterExpectations as $data => $expectedValue) {
$this->assertEquals(
$expectedValue,
$sensitiveData->{"get$data"}(),
- "get$data() returned an unexpected value"
+ "get$data() returned an unexpected value",
);
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/Service/SensitiveDataServiceTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/Service/SensitiveDataServiceTest.php
index e637573d7..96af9303a 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/Service/SensitiveDataServiceTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/SensitiveData/Service/SensitiveDataServiceTest.php
@@ -19,24 +19,31 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\SensitiveData\Service;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
use Surfnet\Stepup\Identity\Value\IdentityId;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\EventSourcing\SensitiveDataMessageStream;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Repository\SensitiveDataMessageRepository;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Service\SensitiveDataService;
final class SensitiveDataServiceTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group sensitive-data
*/
- public function it_can_forget_sensitive_data_in_a_stream()
+ public function it_can_forget_sensitive_data_in_a_stream(): void
{
$identityId = new IdentityId('A');
- $sensitiveDataMessageStream = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\EventSourcing\SensitiveDataMessageStream');
+ $sensitiveDataMessageStream = m::mock(SensitiveDataMessageStream::class);
$sensitiveDataMessageStream->shouldReceive('forget')->once();
- $sensitiveDataMessageRepository = m::mock('Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Repository\SensitiveDataMessageRepository');
- $sensitiveDataMessageRepository->shouldReceive('findByIdentityId')->with($identityId)->once()->andReturn($sensitiveDataMessageStream);
+ $sensitiveDataMessageRepository = m::mock(SensitiveDataMessageRepository::class);
+ $sensitiveDataMessageRepository->shouldReceive('findByIdentityId')->with($identityId)->once()->andReturn(
+ $sensitiveDataMessageStream,
+ );
$sensitiveDataMessageRepository->shouldReceive('modify')->with($sensitiveDataMessageStream);
$service = new SensitiveDataService($sensitiveDataMessageRepository);
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Twig/BackwardsCompatibleExtensionTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Twig/BackwardsCompatibleExtensionTest.php
new file mode 100644
index 000000000..02d080689
--- /dev/null
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Twig/BackwardsCompatibleExtensionTest.php
@@ -0,0 +1,61 @@
+ $template]), ['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0]);
+ $twig->addExtension( new BackwardsCompatibleExtension(new IntlExtension()));
+
+ $output = $twig->render('template', ['date' => $date, 'locale' => $locale]);
+ $this->assertEquals($expected, $output);
+
+ $output = $twig->render('template', ['date' => $dateString, 'locale' => $locale]);
+ $this->assertEquals($expected, $output);
+ }
+
+ public function templateProvider(): array
+ {
+ return [
+ 'date en' => ["{{ date | localizeddate('full', 'none', locale) }}", 'Thursday, 5 December 2024', 'en_GB'],
+ 'date nl' => ["{{ date | localizeddate('full', 'none', locale) }}", 'donderdag 5 december 2024', 'nl_NL'],
+ 'date and time nl' => ["{{ date | localizeddate('full', 'medium', locale) }}", 'Thursday, 5 December 2024 at 13:12:10', 'en_GB'],
+ 'date and time en' => ["{{ date | localizeddate('full', 'medium', locale) }}", 'donderdag 5 december 2024 om 13:12:10', 'nl_NL'],
+ 'time nl' => ["{{ date | localizeddate('none', 'medium', locale) }}", '13:12:10', 'en_GB'],
+ 'time en' => ["{{ date | localizeddate('none', 'medium', locale) }}", '13:12:10', 'nl_NL'],
+ ];
+ }
+}
\ No newline at end of file
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Value/InstitutionTest.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Value/InstitutionTest.php
index 7f7fe08b0..9a0595132 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Value/InstitutionTest.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Tests/Value/InstitutionTest.php
@@ -18,20 +18,23 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Tests\Value;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\InvalidArgumentException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Value\Institution;
class InstitutionTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @dataProvider nonStringOrNonEmptyStringProvider
- *
- * @param mixed $invalidValue
*/
- public function an_institution_cannot_be_created_with_anything_but_a_nonempty_string($invalidValue)
- {
- $this->expectException(\Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\InvalidArgumentException::class);
+ public function an_institution_cannot_be_created_with_anything_but_a_nonempty_string(
+ string $invalidValue,
+ ): void {
+ $this->expectException(InvalidArgumentException::class);
new Institution($invalidValue);
}
@@ -39,27 +42,23 @@ public function an_institution_cannot_be_created_with_anything_but_a_nonempty_st
/**
* @test
*/
- public function two_institutions_with_the_same_value_are_equal()
+ public function two_institutions_with_the_same_value_are_equal(): void
{
- $institution = new Institution('a');
- $theSame = new Institution('a');
+ $institution = new Institution('a');
+ $theSame = new Institution('a');
$theSameWithSpaces = new Institution(' a ');
- $different = new Institution('A');
+ $different = new Institution('A');
$this->assertTrue($institution->equals($theSame));
$this->assertTrue($institution->equals($theSameWithSpaces));
$this->assertFalse($institution->equals($different));
}
- public function nonStringOrNonEmptyStringProvider()
+ public function nonStringOrNonEmptyStringProvider(): array
{
return [
'empty string' => [''],
'blank string' => [' '],
- 'array' => [[]],
- 'integer' => [1],
- 'float' => [1.2],
- 'object' => [new \StdClass()],
];
}
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Twig/BackwardsCompatibleExtension.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Twig/BackwardsCompatibleExtension.php
new file mode 100644
index 000000000..8c254acf9
--- /dev/null
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Twig/BackwardsCompatibleExtension.php
@@ -0,0 +1,59 @@
+intlExtension = $intlExtension;
+ }
+
+ public function getFilters(): array
+ {
+ return [
+ new TwigFilter('localizeddate', [$this, 'localizedDate'], ['needs_environment' => true]),
+ ];
+ }
+
+ // localizeddate('full', 'none', locale)
+ public function localizedDate(
+ Environment $env,
+ DateTimeInterface|string|null $date,
+ ?string $dateFormat = 'medium',
+ ?string $timeFormat = 'medium',
+ string $locale = null
+ ): string {
+ return $this->intlExtension->formatDateTime($env, $date, $dateFormat, $timeFormat, locale: $locale);
+ }
+}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Value/Institution.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Value/Institution.php
index ee4efada1..4b7838dc7 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Value/Institution.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Value/Institution.php
@@ -18,21 +18,19 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Value;
+use Stringable;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\InvalidArgumentException;
-final class Institution
+final class Institution implements Stringable
{
- /**
- * @var string
- */
- private $institution;
+ private readonly string $institution;
/**
* @param string $institution may not be an empty string
*/
- public function __construct($institution)
+ public function __construct(string $institution)
{
- if (!is_string($institution) || strlen(trim($institution)) === 0) {
+ if (trim($institution) === '') {
throw InvalidArgumentException::invalidType('non-empty string', 'institution', $institution);
}
@@ -42,21 +40,20 @@ public function __construct($institution)
/**
* @return string
*/
- public function getInstitution()
+ public function getInstitution(): string
{
return $this->institution;
}
/**
- * @param Institution $otherInstitution
* @return bool
*/
- public function equals(Institution $otherInstitution)
+ public function equals(Institution $otherInstitution): bool
{
return $this->institution === $otherInstitution->institution;
}
- public function __toString()
+ public function __toString(): string
{
return $this->institution;
}
diff --git a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Value/Sender.php b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Value/Sender.php
index 1e5e35486..02f4f1753 100644
--- a/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Value/Sender.php
+++ b/src/Surfnet/StepupMiddleware/CommandHandlingBundle/Value/Sender.php
@@ -18,37 +18,20 @@
namespace Surfnet\StepupMiddleware\CommandHandlingBundle\Value;
+use Stringable;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\InvalidArgumentException;
-class Sender
+class Sender implements Stringable
{
- /**
- * @var string
- */
- private $name;
+ private readonly string $email;
- /**
- * @var string
- */
- private $email;
-
- public function __construct(string $name, string $email)
+ public function __construct(private readonly string $name, string $email)
{
- if (!is_string($name)) {
- throw InvalidArgumentException::invalidType('string', 'name', $name);
- }
-
- if (!is_string($email)) {
- throw InvalidArgumentException::invalidType('string', 'email', $name);
- }
-
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new InvalidArgumentException(
- sprintf("Invalid argument type: expected e-mail address for 'email', got '%s'", $email)
+ sprintf("Invalid argument type: expected e-mail address for 'email', got '%s'", $email),
);
}
-
- $this->name = $name;
$this->email = $email;
}
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/DependencyInjection/Configuration.php b/src/Surfnet/StepupMiddleware/GatewayBundle/DependencyInjection/Configuration.php
index b1a9bd7d3..c923ebf4c 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/DependencyInjection/Configuration.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/DependencyInjection/Configuration.php
@@ -23,11 +23,8 @@
class Configuration implements ConfigurationInterface
{
- public function getConfigTreeBuilder()
+ public function getConfigTreeBuilder(): TreeBuilder
{
- $treeBuilder = new TreeBuilder();
- $treeBuilder->root('surfnet_stepup_gateway_gateway');
-
- return $treeBuilder;
+ return new TreeBuilder('surfnet_stepup_gateway_gateway');
}
}
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/DependencyInjection/SurfnetStepupMiddlewareGatewayExtension.php b/src/Surfnet/StepupMiddleware/GatewayBundle/DependencyInjection/SurfnetStepupMiddlewareGatewayExtension.php
index 82e1c1e1c..c4691aaed 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/DependencyInjection/SurfnetStepupMiddlewareGatewayExtension.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/DependencyInjection/SurfnetStepupMiddlewareGatewayExtension.php
@@ -25,7 +25,7 @@
class SurfnetStepupMiddlewareGatewayExtension extends Extension
{
- public function load(array $configs, ContainerBuilder $container)
+ public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$this->processConfiguration($configuration, $configs);
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/InstitutionConfiguration.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/InstitutionConfiguration.php
index 1b12b0eba..1af95c2af 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/InstitutionConfiguration.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/InstitutionConfiguration.php
@@ -20,30 +20,22 @@
namespace Surfnet\StepupMiddleware\GatewayBundle\Entity;
+use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping as ORM;
+use Surfnet\StepupMiddleware\GatewayBundle\Repository\InstitutionConfigurationRepository;
-/**
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\GatewayBundle\Repository\InstitutionConfigurationRepository")
- */
+#[ORM\Entity(repositoryClass: InstitutionConfigurationRepository::class)]
class InstitutionConfiguration
{
- /**
- * @var string
- * @ORM\Id
- * @ORM\Column(length=200)
- */
- public $institution;
-
- /**
- * @ORM\Column(type="boolean")
- *
- * @var bool is the SSO on 2FA feature enabled?
- */
- public $ssoOn2faEnabled;
-
- public function __construct(string $institution, bool $ssoOn2faEnabled)
- {
- $this->institution = $institution;
- $this->ssoOn2faEnabled = $ssoOn2faEnabled;
+ public function __construct(
+ #[ORM\Id]
+ #[ORM\Column(length: 255)]
+ public string $institution,
+ /**
+ * @var bool is the SSO on 2FA feature enabled?
+ */
+ #[ORM\Column(type: 'boolean')]
+ public bool $ssoOn2faEnabled
+ ) {
}
}
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SamlEntity.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SamlEntity.php
index 3ab5e21a8..e31509a93 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SamlEntity.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SamlEntity.php
@@ -19,83 +19,54 @@
namespace Surfnet\StepupMiddleware\GatewayBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
+use Surfnet\StepupMiddleware\GatewayBundle\Exception\RuntimeException;
+use function is_string;
-/**
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\GatewayBundle\Entity\SamlEntityRepository")
- * @ORM\Table(
- * uniqueConstraints={
- * @ORM\UniqueConstraint(name="unq_saml_entity_entity_id_type", columns={"entity_id", "type"})
- * }
- * )
- */
+#[ORM\Table]
+#[ORM\UniqueConstraint(name: 'unq_saml_entity_entity_id_type', columns: ['entity_id', 'type'])]
+#[ORM\Entity(repositoryClass: SamlEntityRepository::class)]
class SamlEntity
{
/**
* Constants denoting the type of SamlEntity. Also used in the gateway to make that distinction
*/
- const TYPE_IDP = 'idp';
- const TYPE_SP = 'sp';
-
- /**
- * @var string
- *
- * @ORM\Id
- * @ORM\Column(length=36)
- */
- public $id;
-
- /**
- * @ORM\Column
- *
- * @var string
- */
- public $entityId;
+ public const TYPE_IDP = 'idp';
+ public const TYPE_SP = 'sp';
/**
- * @ORM\Column
- *
* @var string
*/
- public $type;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ public string $id;
- /**
- * @ORM\Column(type="text")
- *
- * @var string the configuration as json string
- */
- public $configuration;
-
- /**
- * @param string $entityId
- * @param string $type
- * @param string $configuration
- */
- private function __construct($entityId, $type, $configuration)
- {
- $this->id = (string) Uuid::uuid4();
- $this->entityId = $entityId;
- $this->type = $type;
- $this->configuration = $configuration;
+ private function __construct(
+ #[ORM\Column]
+ public string $entityId,
+ #[ORM\Column]
+ public string $type,
+ #[ORM\Column(type: 'text')]
+ public string $configuration,
+ ) {
+ $this->id = (string)Uuid::uuid4();
}
- /**
- * @param string $entityId
- * @param array $configuration
- * @return SamlEntity
- */
- public static function createServiceProvider($entityId, array $configuration)
+ public static function createServiceProvider(string $entityId, array $configuration): self
{
- return new self($entityId, self::TYPE_SP, json_encode($configuration));
+ $encodedConfiguration = json_encode($configuration);
+ if (!is_string($encodedConfiguration)) {
+ throw new RuntimeException('Unable to json_encode the configuration array in SamlEntity::createServiceProvider');
+ }
+ return new self($entityId, self::TYPE_SP, $encodedConfiguration);
}
- /**
- * @param string $entityId
- * @param array $configuration
- * @return SamlEntity
- */
- public static function createIdentityProvider($entityId, array $configuration)
+ public static function createIdentityProvider(string $entityId, array $configuration): self
{
- return new self($entityId, self::TYPE_IDP, json_encode($configuration));
+ $encodedConfiguration = json_encode($configuration);
+ if (!is_string($encodedConfiguration)) {
+ throw new RuntimeException('Unable to json_encode the configuration array in SamlEntity::createServiceProvider');
+ }
+ return new self($entityId, self::TYPE_IDP, $encodedConfiguration);
}
}
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SamlEntityRepository.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SamlEntityRepository.php
index 615fb4d6b..639b56cee 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SamlEntityRepository.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SamlEntityRepository.php
@@ -20,24 +20,23 @@
use Doctrine\ORM\EntityRepository;
+/**
+ * @extends EntityRepository
+ */
class SamlEntityRepository extends EntityRepository
{
/**
* Replace all configured service provider SamlEntities with the new SamlEntities.
- *
- * @param array $newSamlEntities
*/
- public function replaceAllSps(array $newSamlEntities)
+ public function replaceAllSps(array $newSamlEntities): void
{
$this->replaceAllOfType(SamlEntity::TYPE_SP, $newSamlEntities);
}
/**
* Replace all configured identity provider SamlEntities with the new SamlEntities.
- *
- * @param array $newSamlEntities
*/
- public function replaceAllIdps(array $newSamlEntities)
+ public function replaceAllIdps(array $newSamlEntities): void
{
$this->replaceAllOfType(SamlEntity::TYPE_IDP, $newSamlEntities);
}
@@ -46,24 +45,15 @@ public function replaceAllIdps(array $newSamlEntities)
* Replace all configured SamlEntities with the new SamlEntities.
*
* Will be updated later, see https://www.pivotaltracker.com/story/show/83532704
- *
- * @param string $type
- * @param array $newSamlEntities
*/
- private function replaceAllOfType($type, array $newSamlEntities)
+ private function replaceAllOfType(string $type, array $newSamlEntities): void
{
$entityManager = $this->getEntityManager();
- $counter = 0;
$this->removeAllOfType($type);
- $entityManager->flush();
foreach ($newSamlEntities as $samlEntity) {
$entityManager->persist($samlEntity);
-
- if (++$counter % 25 === 0) {
- $entityManager->flush();
- }
}
$entityManager->flush();
@@ -71,16 +61,16 @@ private function replaceAllOfType($type, array $newSamlEntities)
/**
* Remove all configured SamlEntities of a specific type
- *
- * @param string $type
*/
- private function removeAllOfType($type)
+ private function removeAllOfType(string $type): void
{
$this
->getEntityManager()
->createQuery(
- 'DELETE FROM SurfnetStepupMiddlewareGatewayBundle:SamlEntity se WHERE se.type = :type'
+ 'DELETE FROM '.SamlEntity::class.' se WHERE se.type = :type',
)
->execute(['type' => $type]);
+
+ $this->getEntityManager()->clear();
}
}
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SecondFactor.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SecondFactor.php
index 313495ea7..de35a6fef 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SecondFactor.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/SecondFactor.php
@@ -19,112 +19,54 @@
namespace Surfnet\StepupMiddleware\GatewayBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
+use Surfnet\StepupMiddleware\GatewayBundle\Repository\SecondFactorRepository;
/**
* WARNING: Any schema change made to this entity should also be applied to the Gateway SecondFactor entity!
* @see Surfnet\StepupGateway\GatewayBundle\Entity\SecondFactor (in OpenConext/Stepup-Gateway project)
*
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\GatewayBundle\Repository\SecondFactorRepository")
- * @ORM\Table(
- * indexes={
- * @ORM\Index(name="idx_secondfactor_nameid", columns={"name_id"}),
- * }
- * )
* @SuppressWarnings(PHPMD.UnusedPrivateFields)
*/
+#[ORM\Table]
+#[ORM\Index(name: 'idx_secondfactor_nameid', columns: ['name_id'])]
+#[ORM\Entity(repositoryClass: SecondFactorRepository::class)]
class SecondFactor
{
- /**
- * @var int
- *
- * @ORM\Id
- * @ORM\Column(length=36)
- */
- private $id;
-
- /**
- * @var string
- *
- * @ORM\Id
- * @ORM\Column(length=36)
- */
- private $identityId;
-
- /**
- * @var string
- *
- * @ORM\Column(length=200)
- */
- private $nameId;
-
- /**
- * @var string
- *
- * @ORM\Column(length=200)
- */
- private $institution;
-
- /**
- * In which language to display any second factor verification screens.
- *
- * @var string
- *
- * @ORM\Column
- */
- public $displayLocale;
-
- /**
- * @var string
- *
- * @ORM\Column(length=36)
- */
- private $secondFactorId;
-
- /**
- * @var string
- *
- * @ORM\Column(length=50)
- */
- private $secondFactorType;
-
- /**
- * @var string
- *
- * @ORM\Column(length=255)
- */
- private $secondFactorIdentifier;
-
- /**
- * This boolean indicates if the second factor token was vetted
- * using one of the vetting types that are considered 'identity-vetted'.
- * That in turn means if the owner of the second factor token has its
- * identity vetted (verified) by a RA(A) at the service desk. This trickles
- * down to the self-vet vetting type. As the token used for self vetting
- * was RA vetted.
- *
- * @ORM\Column(type="boolean", options={"default":"1"})
- */
- private $identityVetted;
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ private string $id;
public function __construct(
- $identityId,
- $nameId,
- $institution,
- $displayLocale,
- $secondFactorId,
- $secondFactorIdentifier,
- $secondFactorType,
- $identityVetted
+ #[ORM\Id]
+ #[ORM\Column(length: 36)]
+ private string $identityId,
+ #[ORM\Column(length: 200)]
+ private string $nameId,
+ #[ORM\Column(length: 200)]
+ private string $institution,
+ /**
+ * In which language to display any second factor verification screens.
+ */
+ #[ORM\Column]
+ public string $displayLocale,
+ #[ORM\Column(length: 36)]
+ private string $secondFactorId,
+ #[ORM\Column(length: 255)]
+ private string $secondFactorIdentifier,
+ #[ORM\Column(length: 50)]
+ private string $secondFactorType,
+ /**
+ * This boolean indicates if the second factor token was vetted
+ * using one of the vetting types that are considered 'identity-vetted'.
+ * That in turn means if the owner of the second factor token has its
+ * identity vetted (verified) by a RA(A) at the service desk. This trickles
+ * down to the self-vet vetting type. As the token used for self vetting
+ * was RA vetted.
+ */
+ #[ORM\Column(type: 'boolean', options: ['default' => '1'])]
+ private bool $identityVetted,
) {
- $this->id = (string) Uuid::uuid4();
- $this->identityId = $identityId;
- $this->nameId = $nameId;
- $this->institution = $institution;
- $this->displayLocale = $displayLocale;
- $this->secondFactorId = $secondFactorId;
- $this->secondFactorIdentifier = $secondFactorIdentifier;
- $this->secondFactorType = $secondFactorType;
- $this->identityVetted = $identityVetted;
+ $this->id = (string)Uuid::uuid4();
}
}
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/WhitelistEntry.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/WhitelistEntry.php
index da7da62f0..1f39c7ee2 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/WhitelistEntry.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Entity/WhitelistEntry.php
@@ -20,23 +20,18 @@
use Doctrine\ORM\Mapping as ORM;
use Surfnet\Stepup\Identity\Value\Institution;
+use Surfnet\StepupMiddleware\GatewayBundle\Repository\WhitelistEntryRepository;
-/**
- * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\GatewayBundle\Repository\WhitelistEntryRepository")
- */
+#[ORM\Entity(repositoryClass: WhitelistEntryRepository::class)]
class WhitelistEntry
{
- /**
- * @ORM\Id
- * @ORM\Column(type="institution")
- *
- * @var Institution
- */
- public $institution;
+ #[ORM\Id]
+ #[ORM\Column(type: 'institution')]
+ public Institution $institution;
- public static function createFrom(Institution $institution)
+ public static function createFrom(Institution $institution): self
{
- $instance = new self();
+ $instance = new self();
$instance->institution = $institution;
return $instance;
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/InstitutionConfigurationProjector.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/InstitutionConfigurationProjector.php
index 9b97ff064..6d4672d8b 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/InstitutionConfigurationProjector.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/InstitutionConfigurationProjector.php
@@ -29,24 +29,15 @@
class InstitutionConfigurationProjector extends Projector
{
- /**
- * @var InstitutionConfigurationRepository
- */
- private $repository;
-
- /**
- * @param InstitutionConfigurationRepository $repository
- */
- public function __construct(InstitutionConfigurationRepository $repository)
+ public function __construct(private readonly InstitutionConfigurationRepository $repository)
{
- $this->repository = $repository;
}
public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event): void
{
$institutionConfiguration = new InstitutionConfiguration(
(string)$event->institution,
- $event->ssoOn2faOption->isEnabled()
+ $event->ssoOn2faOption->isEnabled(),
);
$this->repository->save($institutionConfiguration);
@@ -54,21 +45,19 @@ public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfi
public function applySsoOn2faOptionChangedEvent(SsoOn2faOptionChangedEvent $event): void
{
- $institutionConfiguration = $this->repository->findByInstitution((string) $event->institution);
- if ($institutionConfiguration) {
+ $institutionConfiguration = $this->repository->findByInstitution((string)$event->institution);
+ if ($institutionConfiguration instanceof InstitutionConfiguration) {
$institutionConfiguration->ssoOn2faEnabled = $event->ssoOn2faOption->isEnabled();
$this->repository->save($institutionConfiguration);
return;
}
// It can happen that the event changed for an institution that already exists, but is not yet projected to
// this projection. In that case we can create it.
- if (!$institutionConfiguration) {
- $institutionConfiguration = new InstitutionConfiguration(
- (string)$event->institution,
- $event->ssoOn2faOption->isEnabled()
- );
- $this->repository->save($institutionConfiguration);
- }
+ $institutionConfiguration = new InstitutionConfiguration(
+ (string)$event->institution,
+ $event->ssoOn2faOption->isEnabled(),
+ );
+ $this->repository->save($institutionConfiguration);
}
public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event): void
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/SamlEntityProjector.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/SamlEntityProjector.php
index 875777308..3b9a5675d 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/SamlEntityProjector.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/SamlEntityProjector.php
@@ -26,23 +26,12 @@
class SamlEntityProjector extends Projector
{
- /**
- * @var SamlEntityRepository
- */
- private $samlEntityRepository;
-
- /**
- * @param SamlEntityRepository $samlEntityRepository
- */
- public function __construct(SamlEntityRepository $samlEntityRepository)
- {
- $this->samlEntityRepository = $samlEntityRepository;
+ public function __construct(
+ private readonly SamlEntityRepository $samlEntityRepository,
+ ) {
}
- /**
- * @param ServiceProvidersUpdatedEvent $event
- */
- public function applyServiceProvidersUpdatedEvent(ServiceProvidersUpdatedEvent $event)
+ public function applyServiceProvidersUpdatedEvent(ServiceProvidersUpdatedEvent $event): void
{
$spConfigurations = [];
foreach ($event->serviceProviders as $configuration) {
@@ -55,10 +44,7 @@ public function applyServiceProvidersUpdatedEvent(ServiceProvidersUpdatedEvent $
$this->samlEntityRepository->replaceAllSps($spConfigurations);
}
- /**
- * @param IdentityProvidersUpdatedEvent $event
- */
- public function applyIdentityProvidersUpdatedEvent(IdentityProvidersUpdatedEvent $event)
+ public function applyIdentityProvidersUpdatedEvent(IdentityProvidersUpdatedEvent $event): void
{
$spConfigurations = [];
foreach ($event->identityProviders as $configuration) {
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/SecondFactorProjector.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/SecondFactorProjector.php
index 0d9cdc06b..fd217359c 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/SecondFactorProjector.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/SecondFactorProjector.php
@@ -34,80 +34,72 @@
class SecondFactorProjector extends Projector
{
- /**
- * @var SecondFactorRepository
- */
- private $repository;
-
- /**
- * @param SecondFactorRepository $repository
- */
- public function __construct(SecondFactorRepository $repository)
+ public function __construct(private readonly SecondFactorRepository $repository)
{
- $this->repository = $repository;
}
- public function applyYubikeySecondFactorBootstrappedEvent(YubikeySecondFactorBootstrappedEvent $event)
+ public function applyYubikeySecondFactorBootstrappedEvent(YubikeySecondFactorBootstrappedEvent $event): void
{
$this->repository->save(
new SecondFactor(
- (string) $event->identityId,
- (string) $event->nameId,
- (string) $event->identityInstitution,
- (string) $event->preferredLocale,
- (string) $event->secondFactorId,
- (string) $event->yubikeyPublicId,
+ (string)$event->identityId,
+ (string)$event->nameId,
+ (string)$event->identityInstitution,
+ (string)$event->preferredLocale,
+ (string)$event->secondFactorId,
+ (string)$event->yubikeyPublicId,
'yubikey',
- true
- )
+ true,
+ ),
);
}
- public function applySecondFactorMigratedEvent(SecondFactorMigratedEvent $event)
+ public function applySecondFactorMigratedEvent(SecondFactorMigratedEvent $event): void
{
$this->repository->save(
new SecondFactor(
- (string) $event->identityId,
- (string) $event->targetNameId,
- (string) $event->identityInstitution,
- (string) $event->preferredLocale,
- (string) $event->newSecondFactorId,
+ (string)$event->identityId,
+ (string)$event->targetNameId,
+ (string)$event->identityInstitution,
+ (string)$event->preferredLocale,
+ (string)$event->newSecondFactorId,
$event->secondFactorIdentifier,
$event->secondFactorType,
- $this->isIdentityVetted($event->vettingType)
- )
+ $this->isIdentityVetted($event->vettingType),
+ ),
);
}
- public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event)
+ public function applySecondFactorVettedEvent(SecondFactorVettedEvent $event): void
{
$this->repository->save(
new SecondFactor(
- (string) $event->identityId,
- (string) $event->nameId,
- (string) $event->identityInstitution,
- (string) $event->preferredLocale,
- (string) $event->secondFactorId,
+ (string)$event->identityId,
+ (string)$event->nameId,
+ (string)$event->identityInstitution,
+ (string)$event->preferredLocale,
+ (string)$event->secondFactorId,
$event->secondFactorIdentifier,
$event->secondFactorType,
- $this->isIdentityVetted($event->vettingType)
- )
+ $this->isIdentityVetted($event->vettingType),
+ ),
);
}
- public function applySecondFactorVettedWithoutTokenProofOfPossession(SecondFactorVettedWithoutTokenProofOfPossession $event)
- {
+ public function applySecondFactorVettedWithoutTokenProofOfPossession(
+ SecondFactorVettedWithoutTokenProofOfPossession $event,
+ ): void {
$this->repository->save(
new SecondFactor(
- (string) $event->identityId,
- (string) $event->nameId,
- (string) $event->identityInstitution,
- (string) $event->preferredLocale,
- (string) $event->secondFactorId,
+ (string)$event->identityId,
+ (string)$event->nameId,
+ (string)$event->identityInstitution,
+ (string)$event->preferredLocale,
+ (string)$event->secondFactorId,
$event->secondFactorIdentifier,
$event->secondFactorType,
- $this->isIdentityVetted($event->vettingType)
- )
+ $this->isIdentityVetted($event->vettingType),
+ ),
);
}
@@ -116,46 +108,50 @@ private function isIdentityVetted(VettingType $vettingType): bool
return $vettingType->type() !== VettingType::TYPE_SELF_ASSERTED_REGISTRATION;
}
- protected function applyVettedSecondFactorRevokedEvent(VettedSecondFactorRevokedEvent $event)
+ protected function applyVettedSecondFactorRevokedEvent(VettedSecondFactorRevokedEvent $event): void
{
$secondFactor = $this->repository->findOneBySecondFactorId($event->secondFactorId);
if ($secondFactor === null) {
- throw new RuntimeException(sprintf(
- 'Expected to find a second factor having secondFactorId "%s", found none.',
- $event->secondFactorId
- ));
+ throw new RuntimeException(
+ sprintf(
+ 'Expected to find a second factor having secondFactorId "%s", found none.',
+ $event->secondFactorId,
+ ),
+ );
}
$this->repository->remove($secondFactor);
}
protected function applyCompliedWithVettedSecondFactorRevocationEvent(
- CompliedWithVettedSecondFactorRevocationEvent $event
- ) {
+ CompliedWithVettedSecondFactorRevocationEvent $event,
+ ): void {
$secondFactor = $this->repository->findOneBySecondFactorId($event->secondFactorId);
if ($secondFactor === null) {
- throw new RuntimeException(sprintf(
- 'Expected to find a second factor having secondFactorId "%s", found none.',
- $event->secondFactorId
- ));
+ throw new RuntimeException(
+ sprintf(
+ 'Expected to find a second factor having secondFactorId "%s", found none.',
+ $event->secondFactorId,
+ ),
+ );
}
$this->repository->remove($secondFactor);
}
- protected function applyLocalePreferenceExpressedEvent(LocalePreferenceExpressedEvent $event)
+ protected function applyLocalePreferenceExpressedEvent(LocalePreferenceExpressedEvent $event): void
{
$secondFactors = $this->repository->findByIdentityId($event->identityId);
foreach ($secondFactors as $secondFactor) {
- $secondFactor->displayLocale = (string) $event->preferredLocale;
+ $secondFactor->displayLocale = (string)$event->preferredLocale;
$this->repository->save($secondFactor);
}
}
- protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event)
+ protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
$this->repository->removeByIdentityId($event->identityId);
}
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/WhitelistProjector.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/WhitelistProjector.php
index 1b04429fb..8c9bd5838 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/WhitelistProjector.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Projector/WhitelistProjector.php
@@ -28,23 +28,11 @@
class WhitelistProjector extends Projector
{
- /**
- * @var WhitelistEntryRepository
- */
- private $whitelistEntryRepository;
-
- /**
- * @param WhitelistEntryRepository $whitelistRepository
- */
- public function __construct(WhitelistEntryRepository $whitelistRepository)
+ public function __construct(private readonly WhitelistEntryRepository $whitelistEntryRepository)
{
- $this->whitelistEntryRepository = $whitelistRepository;
}
- /**
- * @param WhitelistCreatedEvent $event
- */
- protected function applyWhitelistCreatedEvent(WhitelistCreatedEvent $event)
+ protected function applyWhitelistCreatedEvent(WhitelistCreatedEvent $event): void
{
$whitelistEntries = [];
foreach ($event->whitelistedInstitutions as $institution) {
@@ -54,10 +42,7 @@ protected function applyWhitelistCreatedEvent(WhitelistCreatedEvent $event)
$this->whitelistEntryRepository->saveEntries($whitelistEntries);
}
- /**
- * @param WhitelistReplacedEvent $event
- */
- protected function applyWhitelistReplacedEvent(WhitelistReplacedEvent $event)
+ protected function applyWhitelistReplacedEvent(WhitelistReplacedEvent $event): void
{
$this->whitelistEntryRepository->removeAll();
@@ -69,10 +54,7 @@ protected function applyWhitelistReplacedEvent(WhitelistReplacedEvent $event)
$this->whitelistEntryRepository->saveEntries($whitelistEntries);
}
- /**
- * @param InstitutionsAddedToWhitelistEvent $event
- */
- protected function applyInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhitelistEvent $event)
+ protected function applyInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhitelistEvent $event): void
{
$whitelistEntries = [];
foreach ($event->addedInstitutions as $institution) {
@@ -82,10 +64,7 @@ protected function applyInstitutionsAddedToWhitelistEvent(InstitutionsAddedToWhi
$this->whitelistEntryRepository->saveEntries($whitelistEntries);
}
- /**
- * @param InstitutionsRemovedFromWhitelistEvent $event
- */
- protected function applyInstitutionsRemovedFromWhitelistEvent(InstitutionsRemovedFromWhitelistEvent $event)
+ protected function applyInstitutionsRemovedFromWhitelistEvent(InstitutionsRemovedFromWhitelistEvent $event): void
{
$institutions = [];
foreach ($event->removedInstitutions as $institution) {
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/InstitutionConfigurationRepository.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/InstitutionConfigurationRepository.php
index 361998209..51f3a9409 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/InstitutionConfigurationRepository.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/InstitutionConfigurationRepository.php
@@ -23,6 +23,9 @@
use Doctrine\ORM\EntityRepository;
use Surfnet\StepupMiddleware\GatewayBundle\Entity\InstitutionConfiguration;
+/**
+ * @extends EntityRepository
+ */
class InstitutionConfigurationRepository extends EntityRepository
{
public function findByInstitution(string $institution): ?InstitutionConfiguration
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/SecondFactorRepository.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/SecondFactorRepository.php
index dcfd29f47..ca0ab2592 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/SecondFactorRepository.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/SecondFactorRepository.php
@@ -23,49 +23,44 @@
use Surfnet\Stepup\Identity\Value\SecondFactorId;
use Surfnet\StepupMiddleware\GatewayBundle\Entity\SecondFactor;
+/**
+ * @extends EntityRepository
+ */
class SecondFactorRepository extends EntityRepository
{
- /**
- * @param SecondFactor $secondFactor
- */
- public function save(SecondFactor $secondFactor)
+ public function save(SecondFactor $secondFactor): void
{
$this->getEntityManager()->persist($secondFactor);
$this->getEntityManager()->flush();
}
/**
- * @param SecondFactorId $secondFactorId
* @return SecondFactor|null
*/
- public function findOneBySecondFactorId(SecondFactorId $secondFactorId)
+ public function findOneBySecondFactorId(SecondFactorId $secondFactorId): ?object
{
- return $this->findOneBy(['secondFactorId' => (string) $secondFactorId]);
+ return $this->findOneBy(['secondFactorId' => (string)$secondFactorId]);
}
/**
- * @param IdentityId $identityId
* @return SecondFactor[]
*/
- public function findByIdentityId(IdentityId $identityId)
+ public function findByIdentityId(IdentityId $identityId): array
{
- return $this->findBy(['identityId' => (string) $identityId]);
+ return $this->findBy(['identityId' => (string)$identityId]);
}
- public function removeByIdentityId(IdentityId $identityId)
+ public function removeByIdentityId(IdentityId $identityId): void
{
$this->getEntityManager()->createQueryBuilder()
- ->delete($this->_entityName, 'sf')
+ ->delete($this->getEntityName(), 'sf')
->where('sf.identityId = :identityId')
->setParameter('identityId', $identityId->getIdentityId())
->getQuery()
->execute();
}
- /**
- * @param SecondFactor $secondFactor
- */
- public function remove(SecondFactor $secondFactor)
+ public function remove(SecondFactor $secondFactor): void
{
$this->getEntityManager()->remove($secondFactor);
$this->getEntityManager()->flush();
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/WhitelistEntryRepository.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/WhitelistEntryRepository.php
index 4c0461dea..dbf9a97fa 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/WhitelistEntryRepository.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Repository/WhitelistEntryRepository.php
@@ -18,17 +18,28 @@
namespace Surfnet\StepupMiddleware\GatewayBundle\Repository;
+use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
+use Doctrine\ORM\Mapping\ClassMetadata;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\StepupMiddleware\GatewayBundle\Entity\WhitelistEntry;
+/**
+ * @extends EntityRepository
+ */
class WhitelistEntryRepository extends EntityRepository
{
+ public function __construct(EntityManagerInterface $em, ClassMetadata $class)
+ {
+ parent::__construct($em, $class);
+ }
+
+
/**
* @param Institution[] $institutions
- * @return array
+ * @return WhitelistEntry[]
*/
- public function findEntriesByInstitutions(array $institutions)
+ public function findEntriesByInstitutions(array $institutions): array
{
$qb = $this->createQueryBuilder('w');
@@ -41,7 +52,7 @@ public function findEntriesByInstitutions(array $institutions)
/**
* @param WhitelistEntry[] $whitelistEntries
*/
- public function saveEntries(array $whitelistEntries)
+ public function saveEntries(array $whitelistEntries): void
{
$entityManager = $this->getEntityManager();
@@ -55,19 +66,21 @@ public function saveEntries(array $whitelistEntries)
/**
* Removes all WhitelistEntries
*/
- public function removeAll()
+ public function removeAll(): void
{
$this->createQueryBuilder('w')
->delete()
->where('1 = 1')
->getQuery()
->execute();
+
+ $this->getEntityManager()->clear();
}
/**
* @param WhitelistEntry[] $whitelistEntries
*/
- public function remove(array $whitelistEntries)
+ public function remove(array $whitelistEntries): void
{
$entityManager = $this->getEntityManager();
@@ -75,6 +88,6 @@ public function remove(array $whitelistEntries)
$entityManager->remove($whitelistEntry);
}
- $entityManager->flush();
+ $entityManager->clear();
}
}
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Resources/config/projection.yml b/src/Surfnet/StepupMiddleware/GatewayBundle/Resources/config/projection.yml
index a678a91c4..e1106de72 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Resources/config/projection.yml
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Resources/config/projection.yml
@@ -1,24 +1,24 @@
services:
- surfnet_stepup_middleware_gateway.projector.institution_configuration:
- class: Surfnet\StepupMiddleware\GatewayBundle\Projector\InstitutionConfigurationProjector
- arguments:
- - "@middleware.gateway_repository.institution_configuration"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
+ surfnet_stepup_middleware_gateway.projector.institution_configuration:
+ class: Surfnet\StepupMiddleware\GatewayBundle\Projector\InstitutionConfigurationProjector
+ arguments:
+ - "@middleware.gateway_repository.institution_configuration"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
- surfnet_stepup_middleware_gateway.projector.second_factor:
- class: Surfnet\StepupMiddleware\GatewayBundle\Projector\SecondFactorProjector
- arguments:
- - "@middleware.gateway_repository.second_factors"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
+ surfnet_stepup_middleware_gateway.projector.second_factor:
+ class: Surfnet\StepupMiddleware\GatewayBundle\Projector\SecondFactorProjector
+ arguments:
+ - "@middleware.gateway_repository.second_factors"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
- surfnet_stepup_middleware_gateway.projector.saml_entity:
- class: Surfnet\StepupMiddleware\GatewayBundle\Projector\SamlEntityProjector
- arguments:
- - "@middleware.gateway_repository.saml_entities"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
+ surfnet_stepup_middleware_gateway.projector.saml_entity:
+ class: Surfnet\StepupMiddleware\GatewayBundle\Projector\SamlEntityProjector
+ arguments:
+ - "@middleware.gateway_repository.saml_entities"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
- surfnet_stepup_middleware_gateway.projector.whitelist_entry:
- class: Surfnet\StepupMiddleware\GatewayBundle\Projector\WhitelistProjector
- arguments:
- - "@middleware.gateway_repository.whitelist_entry"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
+ surfnet_stepup_middleware_gateway.projector.whitelist_entry:
+ class: Surfnet\StepupMiddleware\GatewayBundle\Projector\WhitelistProjector
+ arguments:
+ - "@middleware.gateway_repository.whitelist_entry"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Resources/config/repositories.yml b/src/Surfnet/StepupMiddleware/GatewayBundle/Resources/config/repositories.yml
index de9b33b72..8a4fbae31 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Resources/config/repositories.yml
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Resources/config/repositories.yml
@@ -1,24 +1,24 @@
services:
- middleware.gateway_repository.saml_entities:
- class: Surfnet\StepupMiddleware\GatewayBundle\Entity\SamlEntityRepository
- factory: ["@doctrine.orm.gateway_entity_manager", getRepository]
- arguments:
- - 'Surfnet\StepupMiddleware\GatewayBundle\Entity\SamlEntity'
+ middleware.gateway_repository.saml_entities:
+ class: Surfnet\StepupMiddleware\GatewayBundle\Entity\SamlEntityRepository
+ factory: [ "@doctrine.orm.gateway_entity_manager", getRepository ]
+ arguments:
+ - 'Surfnet\StepupMiddleware\GatewayBundle\Entity\SamlEntity'
- middleware.gateway_repository.second_factors:
- class: Surfnet\StepupMiddleware\GatewayBundle\Repository\SecondFactorRepository
- factory: ["@doctrine.orm.gateway_entity_manager", getRepository]
- arguments:
- - 'Surfnet\StepupMiddleware\GatewayBundle\Entity\SecondFactor'
+ middleware.gateway_repository.second_factors:
+ class: Surfnet\StepupMiddleware\GatewayBundle\Repository\SecondFactorRepository
+ factory: [ "@doctrine.orm.gateway_entity_manager", getRepository ]
+ arguments:
+ - 'Surfnet\StepupMiddleware\GatewayBundle\Entity\SecondFactor'
- middleware.gateway_repository.institution_configuration:
- class: Surfnet\StepupMiddleware\GatewayBundle\Repository\InstitutionConfigurationRepository
- factory: ["@doctrine.orm.gateway_entity_manager", getRepository]
- arguments:
- - 'Surfnet\StepupMiddleware\GatewayBundle\Entity\InstitutionConfiguration'
+ middleware.gateway_repository.institution_configuration:
+ class: Surfnet\StepupMiddleware\GatewayBundle\Repository\InstitutionConfigurationRepository
+ factory: [ "@doctrine.orm.gateway_entity_manager", getRepository ]
+ arguments:
+ - 'Surfnet\StepupMiddleware\GatewayBundle\Entity\InstitutionConfiguration'
- middleware.gateway_repository.whitelist_entry:
- class: Surfnet\StepupMiddleware\GatewayBundle\Repository\WhitelistEntryRepository
- factory: ["@doctrine.orm.gateway_entity_manager", getRepository]
- arguments:
- - 'Surfnet\StepupMiddleware\GatewayBundle\Entity\WhitelistEntry'
+ middleware.gateway_repository.whitelist_entry:
+ class: Surfnet\StepupMiddleware\GatewayBundle\Repository\WhitelistEntryRepository
+ factory: [ "@doctrine.orm.gateway_entity_manager", getRepository ]
+ arguments:
+ - 'Surfnet\StepupMiddleware\GatewayBundle\Entity\WhitelistEntry'
diff --git a/src/Surfnet/StepupMiddleware/GatewayBundle/Tests/Projector/InstitutionConfigurationProjectorTest.php b/src/Surfnet/StepupMiddleware/GatewayBundle/Tests/Projector/InstitutionConfigurationProjectorTest.php
index 3acc9e2b6..497b3a3e6 100644
--- a/src/Surfnet/StepupMiddleware/GatewayBundle/Tests/Projector/InstitutionConfigurationProjectorTest.php
+++ b/src/Surfnet/StepupMiddleware/GatewayBundle/Tests/Projector/InstitutionConfigurationProjectorTest.php
@@ -21,8 +21,10 @@
namespace Surfnet\StepupMiddleware\GatewayBundle\Tests\Projector;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Configuration\Event\SsoOn2faOptionChangedEvent;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
@@ -33,11 +35,12 @@
class InstitutionConfigurationProjectorTest extends TestCase
{
- use m\Adapter\Phpunit\MockeryPHPUnitIntegration;
+ use MockeryPHPUnitIntegration;
- private $projector;
+ private InstitutionConfigurationProjector $projector;
+
+ private InstitutionConfigurationRepository&MockInterface $repository;
- private $repository;
protected function setUp(): void
{
$repository = m::mock(InstitutionConfigurationRepository::class);
@@ -46,33 +49,36 @@ protected function setUp(): void
$this->projector = $projector;
}
- public function test_create_row_when_non_existent()
+ public function test_create_row_when_non_existent(): void
{
$event = new SsoOn2faOptionChangedEvent(
new InstitutionConfigurationId(Uuid::uuid4()->toString()),
new Institution('institution-a.nl'),
- new SsoOn2faOption(true)
+ new SsoOn2faOption(true),
);
$this->repository->shouldReceive('findByInstitution')->with('institution-a.nl')->andReturn(null);
- $this->repository->shouldReceive('save')->withArgs(function(InstitutionConfiguration $configuration){
- return $configuration->institution === 'institution-a.nl' && $configuration->ssoOn2faEnabled === true;
- });
+ $this->repository->shouldReceive('save')->withArgs(
+ fn(InstitutionConfiguration $configuration,
+ ): bool => $configuration->institution === 'institution-a.nl' && $configuration->ssoOn2faEnabled,
+ );
$this->projector->applySsoOn2faOptionChangedEvent($event);
}
- public function test_updates_existing_row()
+
+ public function test_updates_existing_row(): void
{
$event = new SsoOn2faOptionChangedEvent(
new InstitutionConfigurationId(Uuid::uuid4()->toString()),
new Institution('institution-a.nl'),
- new SsoOn2faOption(true)
+ new SsoOn2faOption(true),
);
$configuration = new InstitutionConfiguration('institution-a.nl', false);
$this->repository->shouldReceive('findByInstitution')->with('institution-a.nl')->andReturn($configuration);
- $this->repository->shouldReceive('save')->withArgs(function(InstitutionConfiguration $configuration){
- return $configuration->institution === 'institution-a.nl' && $configuration->ssoOn2faEnabled === true;
- });
+ $this->repository->shouldReceive('save')->withArgs(
+ fn(InstitutionConfiguration $configuration,
+ ): bool => $configuration->institution === 'institution-a.nl' && $configuration->ssoOn2faEnabled,
+ );
$this->projector->applySsoOn2faOptionChangedEvent($event);
}
diff --git a/src/Surfnet/StepupMiddleware/Kernel.php b/src/Surfnet/StepupMiddleware/Kernel.php
new file mode 100644
index 000000000..388440656
--- /dev/null
+++ b/src/Surfnet/StepupMiddleware/Kernel.php
@@ -0,0 +1,32 @@
+id = (string) Uuid::uuid4();
+ $self->id = (string)Uuid::uuid4();
$self->name = $name;
$self->locale = $locale;
@@ -85,7 +73,7 @@ public function getId(): string
/**
* @return string
*/
- public function getName()
+ public function getName(): string
{
return $this->name;
}
@@ -93,7 +81,7 @@ public function getName()
/**
* @return string
*/
- public function getLocale()
+ public function getLocale(): string
{
return $this->locale;
}
@@ -101,7 +89,7 @@ public function getLocale()
/**
* @return string
*/
- public function getHtmlContent()
+ public function getHtmlContent(): string
{
return $this->htmlContent;
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Projector/EmailTemplatesProjector.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Projector/EmailTemplatesProjector.php
index 4a0a17ef1..51b22ebfc 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Projector/EmailTemplatesProjector.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Projector/EmailTemplatesProjector.php
@@ -25,17 +25,12 @@
final class EmailTemplatesProjector extends Projector
{
- /**
- * @var \Surfnet\StepupMiddleware\ManagementBundle\Configuration\Repository\EmailTemplateRepository
- */
- private $repository;
-
- public function __construct(EmailTemplateRepository $repository)
- {
- $this->repository = $repository;
+ public function __construct(
+ private readonly EmailTemplateRepository $repository,
+ ) {
}
- public function applyEmailTemplatesUpdatedEvent(EmailTemplatesUpdatedEvent $event)
+ public function applyEmailTemplatesUpdatedEvent(EmailTemplatesUpdatedEvent $event): void
{
$this->repository->removeAll();
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Repository/EmailTemplateRepository.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Repository/EmailTemplateRepository.php
index 1c86e5f30..c21759d3d 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Repository/EmailTemplateRepository.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Repository/EmailTemplateRepository.php
@@ -19,9 +19,12 @@
namespace Surfnet\StepupMiddleware\ManagementBundle\Configuration\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
use Surfnet\StepupMiddleware\ManagementBundle\Configuration\Entity\EmailTemplate;
+/**
+ * @extends ServiceEntityRepository
+ */
final class EmailTemplateRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
@@ -35,7 +38,7 @@ public function __construct(ManagerRegistry $registry)
* @param string $fallbackLocale
* @return EmailTemplate|null
*/
- public function findOneByName($name, $preferredLocale, $fallbackLocale)
+ public function findOneByName(mixed $name, mixed $preferredLocale, mixed $fallbackLocale): ?EmailTemplate
{
return $this
->createQueryBuilder('tpl')
@@ -45,7 +48,7 @@ public function findOneByName($name, $preferredLocale, $fallbackLocale)
'CASE WHEN tpl.locale = :preferredLocale THEN 2
WHEN tpl.locale = :fallbackLocale THEN 1
ELSE 0
- END AS HIDDEN localePreference'
+ END AS HIDDEN localePreference',
)
->setParameter('preferredLocale', $preferredLocale)
->setParameter('fallbackLocale', $fallbackLocale)
@@ -62,7 +65,7 @@ public function findOneByName($name, $preferredLocale, $fallbackLocale)
* removed from the IdentityMap. This to prevent issues when replaying the events, where
* deleting them with a delete query would cause errors due to templates not being found.
*/
- public function removeAll()
+ public function removeAll(): void
{
$templates = $this->findAll();
$em = $this->getEntityManager();
@@ -76,7 +79,7 @@ public function removeAll()
unset($templates);
}
- public function save(EmailTemplate $template)
+ public function save(EmailTemplate $template): void
{
$entityManager = $this->getEntityManager();
$entityManager->persist($template);
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Service/EmailTemplateService.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Service/EmailTemplateService.php
index 9dbda5d4e..30b5cd606 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Service/EmailTemplateService.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Configuration/Service/EmailTemplateService.php
@@ -24,17 +24,11 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\RuntimeException;
use Surfnet\StepupMiddleware\ManagementBundle\Configuration\Repository\EmailTemplateRepository;
-final class EmailTemplateService implements CommandHandlingEmailTemplateService
+final readonly class EmailTemplateService implements CommandHandlingEmailTemplateService
{
- /**
- * @var \Surfnet\StepupMiddleware\ManagementBundle\Configuration\Repository\EmailTemplateRepository
- */
- private $repository;
-
public function __construct(
- EmailTemplateRepository $repository
+ private EmailTemplateRepository $repository,
) {
- $this->repository = $repository;
}
/**
@@ -43,7 +37,7 @@ public function __construct(
* @param string $fallbackLocale
* @return null|EmailTemplate
*/
- public function findByName($name, $preferredLocale, $fallbackLocale)
+ public function findByName(string $name, string $preferredLocale, string $fallbackLocale): ?EmailTemplate
{
try {
$emailTemplateEntity = $this->repository->findOneByName($name, $preferredLocale, $fallbackLocale);
@@ -51,7 +45,7 @@ public function findByName($name, $preferredLocale, $fallbackLocale)
throw new RuntimeException($e->getMessage(), 0, $e);
}
- if (!$emailTemplateEntity) {
+ if (!$emailTemplateEntity instanceof \Surfnet\StepupMiddleware\ManagementBundle\Configuration\Entity\EmailTemplate) {
return null;
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/ConfigurationController.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/ConfigurationController.php
index e06914207..21f34bc25 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/ConfigurationController.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/ConfigurationController.php
@@ -19,51 +19,52 @@
namespace Surfnet\StepupMiddleware\ManagementBundle\Controller;
use DateTime;
-use Rhumsaa\Uuid\Uuid;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Ramsey\Uuid\Uuid;
+use Surfnet\Stepup\Helper\JsonHelper;
+use Surfnet\StepupMiddleware\ApiBundle\Exception\BadCommandRequestException;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\UpdateConfigurationCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\TransactionAwarePipeline;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Surfnet\StepupMiddleware\ManagementBundle\Validator\Constraints\HasValidConfigurationStructure;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Validator\Validator\ValidatorInterface;
-class ConfigurationController extends Controller
+class ConfigurationController extends AbstractController
{
- /**
- * @return TransactionAwarePipeline
- */
- private $pipeline;
-
- public function __construct(TransactionAwarePipeline $pipeline)
- {
- $this->pipeline = $pipeline;
+ public function __construct(
+ private readonly TransactionAwarePipeline $pipeline,
+ private readonly ValidatorInterface $validator,
+ ) {
}
- public function updateAction(Request $request)
+ public function update(Request $request): JsonResponse
{
- $command = new UpdateConfigurationCommand();
- $command->UUID = (string) Uuid::uuid4();
+ $this->denyAccessUnlessGranted('ROLE_MANAGEMENT');
+
+ $violations = $this->validator->validate($request->getContent(), new HasValidConfigurationStructure());
+ if ($violations->count() > 0) {
+ throw BadCommandRequestException::withViolations('Invalid configure institutions request', $violations);
+ }
+
+ $command = new UpdateConfigurationCommand();
$command->configuration = $request->getContent();
+ $command->UUID = (string)Uuid::uuid4();
return $this->handleCommand($request, $command);
}
- /**
- * @param Request $request
- * @param Command $command
- * @return JsonResponse
- */
- private function handleCommand(Request $request, Command $command)
+ private function handleCommand(Request $request, AbstractCommand $command): JsonResponse
{
$this->pipeline->process($command);
$serverName = $request->server->get('SERVER_NAME') ?: $request->server->get('SERVER_ADDR');
- $response = new JsonResponse([
- 'status' => 'OK',
+
+ return new JsonResponse([
+ 'status' => 'OK',
'processed_by' => $serverName,
- 'applied_at' => (new DateTime())->format(DateTime::ISO8601)
+ 'applied_at' => (new DateTime())->format(DateTime::ISO8601),
]);
-
- return $response;
}
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/InstitutionConfigurationController.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/InstitutionConfigurationController.php
index 02a27cd34..7f7609425 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/InstitutionConfigurationController.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/InstitutionConfigurationController.php
@@ -21,7 +21,7 @@
use DateTime;
use Exception;
use Psr\Log\LoggerInterface;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\InstitutionRole;
use Surfnet\Stepup\Helper\JsonHelper;
@@ -29,7 +29,7 @@
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionAuthorizationService;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionConfigurationOptionsService;
use Surfnet\StepupMiddleware\ApiBundle\Exception\BadCommandRequestException;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\ReconfigureInstitutionConfigurationOptionsCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\ForbiddenException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\TransactionAwarePipeline;
@@ -46,62 +46,20 @@
*/
final class InstitutionConfigurationController extends AbstractController
{
- /**
- * @return InstitutionConfigurationOptionsService
- */
- private $institutionConfigurationOptionsService;
-
- /**
- * @return InstitutionAuthorizationService
- */
- private $institutionAuthorizationService;
-
- /**
- * @return ValidatorInterface
- */
- private $validator;
-
- /**
- * @return AllowedSecondFactorListService
- */
- private $allowedSecondFactorListService;
-
- /**
- * @return LoggerInterface
- */
- private $logger;
-
- /**
- * @return TransactionAwarePipeline
- */
- private $pipeline;
-
- /**
- * @var DBALConnectionHelper
- */
- private $connectionHelper;
-
public function __construct(
- InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
- InstitutionAuthorizationService $institutionAuthorizationService,
- ValidatorInterface $dataCollectingValidator,
- AllowedSecondFactorListService $allowedSecondFactorListService,
- LoggerInterface $logger,
- TransactionAwarePipeline $pipeline,
- DBALConnectionHelper $dbalConnectionHelper
+ private readonly InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
+ private readonly InstitutionAuthorizationService $institutionAuthorizationService,
+ private readonly ValidatorInterface $validator,
+ private readonly AllowedSecondFactorListService $allowedSecondFactorListService,
+ private readonly LoggerInterface $logger,
+ private readonly TransactionAwarePipeline $pipeline,
+ private DBALConnectionHelper $connectionHelper,
) {
- $this->institutionConfigurationOptionsService = $institutionConfigurationOptionsService;
- $this->institutionAuthorizationService = $institutionAuthorizationService;
- $this->validator = $dataCollectingValidator;
- $this->allowedSecondFactorListService = $allowedSecondFactorListService;
- $this->logger = $logger;
- $this->pipeline = $pipeline;
- $this->connectionHelper = $dbalConnectionHelper;
}
- public function showAction()
+ public function show(): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_MANAGEMENT']);
+ $this->denyAccessUnlessGranted('ROLE_MANAGEMENT');
$institutionConfigurationOptions = $this->institutionConfigurationOptionsService
->findAllInstitutionConfigurationOptions();
@@ -127,20 +85,26 @@ public function showAction()
'allow_self_asserted_tokens' => $options->selfAssertedTokensOption,
'number_of_tokens_per_identity' => $numberOfTokensPerIdentity,
'allowed_second_factors' => $allowedSecondFactorMap->getAllowedSecondFactorListFor(
- $options->institution
+ $options->institution,
),
- 'use_ra' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(InstitutionRole::useRa())->jsonSerialize(),
- 'use_raa' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(InstitutionRole::useRaa())->jsonSerialize(),
- 'select_raa' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(InstitutionRole::selectRaa())->jsonSerialize(),
+ 'use_ra' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(
+ InstitutionRole::useRa(),
+ )->jsonSerialize(),
+ 'use_raa' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(
+ InstitutionRole::useRaa(),
+ )->jsonSerialize(),
+ 'select_raa' => $institutionConfigurationOptionsMap->getAuthorizationOptionsByRole(
+ InstitutionRole::selectRaa(),
+ )->jsonSerialize(),
];
}
return new JsonResponse($overview);
}
- public function reconfigureAction(Request $request)
+ public function reconfigure(Request $request): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_MANAGEMENT']);
+ $this->denyAccessUnlessGranted('ROLE_MANAGEMENT');
$configuration = JsonHelper::decode($request->getContent());
@@ -150,29 +114,29 @@ public function reconfigureAction(Request $request)
}
if (empty($configuration)) {
- $this->logger->notice(sprintf('No institutions to reconfigure: empty configuration received'));
+ $this->logger->notice('No institutions to reconfigure: empty configuration received');
return new JsonResponse([
- 'status' => 'OK',
- 'processed_by' => $request->server->get('SERVER_NAME') ?: $request->server->get('SERVER_ADDR'),
- 'applied_at' => (new DateTime())->format(DateTime::ISO8601),
+ 'status' => 'OK',
+ 'processed_by' => $request->server->get('SERVER_NAME') ?: $request->server->get('SERVER_ADDR'),
+ 'applied_at' => (new DateTime())->format(DateTime::ISO8601),
]);
}
$commands = [];
foreach ($configuration as $institution => $options) {
- $command = new ReconfigureInstitutionConfigurationOptionsCommand();
- $command->UUID = (string) Uuid::uuid4();
- $command->institution = $institution;
- $command->useRaLocationsOption = $options['use_ra_locations'];
+ $command = new ReconfigureInstitutionConfigurationOptionsCommand();
+ $command->UUID = (string)Uuid::uuid4();
+ $command->institution = $institution;
+ $command->useRaLocationsOption = $options['use_ra_locations'];
$command->showRaaContactInformationOption = $options['show_raa_contact_information'];
- $command->verifyEmailOption = $options['verify_email'];
+ $command->verifyEmailOption = $options['verify_email'];
$command->numberOfTokensPerIdentityOption = $options['number_of_tokens_per_identity'];
- $command->allowedSecondFactors = $options['allowed_second_factors'];
+ $command->allowedSecondFactors = $options['allowed_second_factors'];
// The useRa, useRaa and selectRaa options are optional
- $command->useRaOption = isset($options['use_ra']) ? $options['use_ra'] : null;
- $command->useRaaOption = isset($options['use_raa']) ? $options['use_raa'] : null;
- $command->selectRaaOption = isset($options['select_raa']) ? $options['select_raa'] : null;
+ $command->useRaOption = $options['use_ra'] ?? null;
+ $command->useRaaOption = $options['use_raa'] ?? null;
+ $command->selectRaaOption = $options['select_raa'] ?? null;
// So are sso_on_2fa and the allow_self_asserted_tokens options
$command->selfVetOption = $options['self_vet'] ?? null;
$command->ssoOn2faOption = $options['sso_on_2fa'] ?? null;
@@ -182,23 +146,23 @@ public function reconfigureAction(Request $request)
}
$this->logger->notice(
- sprintf('Executing %s reconfigure institution configuration options commands', count($commands))
+ sprintf('Executing %s reconfigure institution configuration options commands', count($commands)),
);
$this->handleCommands($commands);
return new JsonResponse([
- 'status' => 'OK',
- 'processed_by' => $request->server->get('SERVER_NAME') ?: $request->server->get('SERVER_ADDR'),
- 'applied_at' => (new DateTime())->format(DateTime::ISO8601),
+ 'status' => 'OK',
+ 'processed_by' => $request->server->get('SERVER_NAME') ?: $request->server->get('SERVER_ADDR'),
+ 'applied_at' => (new DateTime())->format(DateTime::ISO8601),
]);
}
/**
- * @param Command[] $commands
+ * @param AbstractCommand[] $commands
* @throws Exception
*/
- private function handleCommands(array $commands)
+ private function handleCommands(array $commands): void
{
$connectionHelper = $this->connectionHelper;
@@ -212,7 +176,7 @@ private function handleCommands(array $commands)
throw new AccessDeniedHttpException(
sprintf('Processing of command "%s" is forbidden for this client', $command),
- $e
+ $e,
);
} catch (Exception $exception) {
$connectionHelper->rollBack();
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/RightToBeForgottenController.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/RightToBeForgottenController.php
index b06be09a8..c74ded47c 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/RightToBeForgottenController.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/RightToBeForgottenController.php
@@ -19,15 +19,15 @@
namespace Surfnet\StepupMiddleware\ManagementBundle\Controller;
use DateTime;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Helper\JsonHelper;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\IdentityService;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ForgetIdentityCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\TransactionAwarePipeline;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -36,27 +36,20 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class RightToBeForgottenController extends Controller
+class RightToBeForgottenController extends AbstractController
{
- /**
- * @return TransactionAwarePipeline
- */
- private $pipeline;
-
- /**
- * @var IdentityService
- */
- private $identityService;
-
- public function __construct(TransactionAwarePipeline $pipeline, IdentityService $identityService)
- {
- $this->pipeline = $pipeline;
- $this->identityService = $identityService;
+ public function __construct(
+ /**
+ * @return TransactionAwarePipeline
+ */
+ private readonly TransactionAwarePipeline $pipeline,
+ private readonly IdentityService $identityService,
+ ) {
}
- public function forgetIdentityAction(Request $request)
+ public function forgetIdentity(Request $request): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_MANAGEMENT']);
+ $this->denyAccessUnlessGranted('ROLE_MANAGEMENT');
$payload = JsonHelper::decode($request->getContent());
@@ -71,62 +64,52 @@ public function forgetIdentityAction(Request $request)
$this->assertMayForget(new NameId($payload['name_id']), new Institution($payload['institution']));
$command = new ForgetIdentityCommand();
- $command->UUID = (string) Uuid::uuid4();
- $command->nameId = $payload['name_id'];
+ $command->UUID = (string)Uuid::uuid4();
+ $command->nameId = $payload['name_id'];
$command->institution = $payload['institution'];
return $this->handleCommand($request, $command);
}
- /**
- * @param Request $request
- * @param Command $command
- * @return JsonResponse
- */
- private function handleCommand(Request $request, Command $command)
+ private function handleCommand(Request $request, AbstractCommand $command): JsonResponse
{
$this->pipeline->process($command);
$serverName = $request->server->get('SERVER_NAME') ?: $request->server->get('SERVER_ADDR');
- $response = new JsonResponse([
- 'status' => 'OK',
+
+ return new JsonResponse([
+ 'status' => 'OK',
'processed_by' => $serverName,
- 'applied_at' => (new DateTime())->format(DateTime::ISO8601)
+ 'applied_at' => (new DateTime())->format(DateTime::ISO8601),
]);
-
- return $response;
}
/**
- * @param NameId $nameId
- * @param Institution $institution
* @throws ConflictHttpException
*/
- private function assertMayForget(NameId $nameId, Institution $institution)
+ private function assertMayForget(NameId $nameId, Institution $institution): void
{
$credentials =
$this->identityService->findRegistrationAuthorityCredentialsByNameIdAndInstitution($nameId, $institution);
- if ($credentials === null) {
+ if (!$credentials instanceof \Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RegistrationAuthorityCredentials) {
return;
}
if ($credentials->isSraa()) {
throw new ConflictHttpException(
'Identity is currently configured to act as an SRAA. ' .
- 'Remove its NameID from the configuration and try again.'
+ 'Remove its NameID from the configuration and try again.',
);
}
- if ($credentials->isRaa()) {
- $role = 'RAA';
- } else {
- $role = 'RA';
- }
+ $role = $credentials->isRaa() ? 'RAA' : 'RA';
- throw new ConflictHttpException(sprintf(
- 'Identity is currently accredited as an %s. Retract the accreditation and try again.',
- $role
- ));
+ throw new ConflictHttpException(
+ sprintf(
+ 'Identity is currently accredited as an %s. Retract the accreditation and try again.',
+ $role,
+ ),
+ );
}
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/WhitelistController.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/WhitelistController.php
index dd128bf03..2ae69c0b5 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/WhitelistController.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Controller/WhitelistController.php
@@ -19,16 +19,16 @@
namespace Surfnet\StepupMiddleware\ManagementBundle\Controller;
use DateTime;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Helper\JsonHelper;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\WhitelistService;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Exception\ForbiddenException;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\AddToWhitelistCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\RemoveFromWhitelistCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\ReplaceWhitelistCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\TransactionAwarePipeline;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@@ -37,101 +37,87 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class WhitelistController extends Controller
+class WhitelistController extends AbstractController
{
- /**
- * @return TransactionAwarePipeline
- */
- private $pipeline;
-
- /**
- * @var WhitelistService
- */
- private $whitelistService;
-
- public function __construct(TransactionAwarePipeline $pipeline, WhitelistService $whitelistService)
- {
- $this->pipeline = $pipeline;
- $this->whitelistService = $whitelistService;
+ public function __construct(
+ /**
+ * @return TransactionAwarePipeline
+ */
+ private readonly TransactionAwarePipeline $pipeline,
+ private readonly WhitelistService $whitelistService,
+ ) {
}
- public function replaceWhitelistAction(Request $request)
+ public function replaceWhitelist(Request $request): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_MANAGEMENT']);
+ $this->denyAccessUnlessGranted('ROLE_MANAGEMENT');
- $command = new ReplaceWhitelistCommand();
- $command->UUID = (string) Uuid::uuid4();
+ $command = new ReplaceWhitelistCommand();
+ $command->UUID = (string)Uuid::uuid4();
$command->institutions = $this->getInstitutionsFromBody($request);
return $this->handleCommand($request, $command);
}
- public function addToWhitelistAction(Request $request)
+ public function addToWhitelist(Request $request): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_MANAGEMENT']);
+ $this->denyAccessUnlessGranted('ROLE_MANAGEMENT');
- $command = new AddToWhitelistCommand();
- $command->UUID = (string) Uuid::uuid4();
+ $command = new AddToWhitelistCommand();
+ $command->UUID = (string)Uuid::uuid4();
$command->institutionsToBeAdded = $this->getInstitutionsFromBody($request);
return $this->handleCommand($request, $command);
}
- public function removeFromWhitelistAction(Request $request)
+ public function removeFromWhitelist(Request $request): JsonResponse
{
- $this->denyAccessUnlessGranted(['ROLE_MANAGEMENT']);
+ $this->denyAccessUnlessGranted('ROLE_MANAGEMENT');
- $command = new RemoveFromWhitelistCommand();
- $command->UUID = (string) Uuid::uuid4();
+ $command = new RemoveFromWhitelistCommand();
+ $command->UUID = (string)Uuid::uuid4();
$command->institutionsToBeRemoved = $this->getInstitutionsFromBody($request);
return $this->handleCommand($request, $command);
}
- public function showWhitelistAction()
+ public function showWhitelist(): JsonResponse
{
$entries = $this->whitelistService->getAllEntries();
return new JsonResponse(['institutions' => $entries->getValues()]);
}
- /**
- * @param Request $request
- * @param Command $command
- * @return JsonResponse
- */
- private function handleCommand(Request $request, Command $command)
+ private function handleCommand(Request $request, AbstractCommand $command): JsonResponse
{
try {
$this->pipeline->process($command);
} catch (ForbiddenException $e) {
throw new AccessDeniedHttpException(
sprintf('Processing of command "%s" is forbidden for this client', $command),
- $e
+ $e,
);
}
$serverName = $request->server->get('SERVER_NAME') ?: $request->server->get('SERVER_ADDR');
- $response = new JsonResponse([
- 'status' => 'OK',
+
+ return new JsonResponse([
+ 'status' => 'OK',
'processed_by' => $serverName,
- 'applied_at' => (new DateTime())->format(DateTime::ISO8601),
+ 'applied_at' => (new DateTime())->format(DateTime::ISO8601),
]);
-
- return $response;
}
/**
- * @param Request $request
* @return array
*/
- private function getInstitutionsFromBody(Request $request)
+ private function getInstitutionsFromBody(Request $request): array
{
$decoded = JsonHelper::decode($request->getContent());
if (!isset($decoded['institutions']) || !is_array($decoded['institutions'])) {
throw new BadRequestHttpException(
- 'Request must contain json object with property "institutions" containing an array of institutions'
+ 'Request must contain json object with property "institutions" containing an array of institutions',
);
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/DependencyInjection/Configuration.php b/src/Surfnet/StepupMiddleware/ManagementBundle/DependencyInjection/Configuration.php
index 1adcac2b4..cdb19d9d2 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/DependencyInjection/Configuration.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/DependencyInjection/Configuration.php
@@ -23,14 +23,14 @@
class Configuration implements ConfigurationInterface
{
- public function getConfigTreeBuilder()
+ public function getConfigTreeBuilder(): TreeBuilder
{
- $treeBuilder = new TreeBuilder();
- $rootNode = $treeBuilder->root('surfnet_stepup_middleware_management');
+ $treeBuilder = new TreeBuilder('surfnet_stepup_middleware_management');
+ $rootNode = $treeBuilder->getRootNode();
$rootNode
->children()
- ->scalarNode('email_required_locale')->isRequired()->end()
+ ->scalarNode('email_required_locale')->isRequired()->end()
->end();
return $treeBuilder;
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/DependencyInjection/SurfnetStepupMiddlewareManagementExtension.php b/src/Surfnet/StepupMiddleware/ManagementBundle/DependencyInjection/SurfnetStepupMiddlewareManagementExtension.php
index 4f10d1086..220073974 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/DependencyInjection/SurfnetStepupMiddlewareManagementExtension.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/DependencyInjection/SurfnetStepupMiddlewareManagementExtension.php
@@ -25,7 +25,7 @@
class SurfnetStepupMiddlewareManagementExtension extends Extension
{
- public function load(array $config, ContainerBuilder $container)
+ public function load(array $config, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $config);
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Exception/InvalidArgumentException.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Exception/InvalidArgumentException.php
index 999bf4970..2f8d2533c 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Exception/InvalidArgumentException.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Exception/InvalidArgumentException.php
@@ -20,20 +20,13 @@
class InvalidArgumentException extends \InvalidArgumentException implements Exception
{
- /**
- * @param string $expected description of expected type
- * @param string $parameterName
- * @param mixed $parameter the parameter that is not of the expected type.
- *
- * @return self
- */
- public static function invalidType($expected, $parameterName, $parameter)
+ public static function invalidType(string $expected, string $parameterName, mixed $parameter): self
{
$message = sprintf(
'Invalid argument type: "%s" expected, "%s" given for "%s"',
$expected,
- is_object($parameter) ? get_class($parameter) : gettype($parameter),
- $parameterName
+ get_debug_type($parameter),
+ $parameterName,
);
return new self($message);
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Exception/UnknownDBALConnectionException.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Exception/UnknownDBALConnectionException.php
index 9b4a7f1df..ca4ea355f 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Exception/UnknownDBALConnectionException.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Exception/UnknownDBALConnectionException.php
@@ -22,7 +22,7 @@
final class UnknownDBALConnectionException extends DomainException
{
- public function __construct($connectionName)
+ public function __construct(string $connectionName)
{
parent::__construct(sprintf('DBAL Connection "%s" does not exist', $connectionName));
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Resources/config/routing.yml b/src/Surfnet/StepupMiddleware/ManagementBundle/Resources/config/routing.yml
index 2bfd636fd..e4bf80525 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Resources/config/routing.yml
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Resources/config/routing.yml
@@ -1,48 +1,48 @@
management_configuration_update:
- path: /configuration
- defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\ConfigurationController::updateAction }
- methods: [POST]
- condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /configuration
+ defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\ConfigurationController::update }
+ methods: [ POST ]
+ condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
management_institution_configuration_show:
- path: /institution-configuration
- defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\InstitutionConfigurationController::showAction }
- methods: [GET]
- condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /institution-configuration
+ defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\InstitutionConfigurationController::show }
+ methods: [ GET ]
+ condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
management_institution_configuration_reconfigure:
- path: /institution-configuration
- defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\InstitutionConfigurationController::reconfigureAction }
- methods: [POST]
- condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /institution-configuration
+ defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\InstitutionConfigurationController::reconfigure }
+ methods: [ POST ]
+ condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
management_whitelist_add:
- path: /whitelist/add
- defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\WhitelistController::addToWhitelistAction }
- methods: [POST]
- condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /whitelist/add
+ defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\WhitelistController::addToWhitelist }
+ methods: [ POST ]
+ condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
management_whitelist_replace:
- path: /whitelist/replace
- defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\WhitelistController::replaceWhitelistAction }
- methods: [POST]
- condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /whitelist/replace
+ defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\WhitelistController::replaceWhitelist }
+ methods: [ POST ]
+ condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
management_whitelist_remove:
- path: /whitelist/remove
- defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\WhitelistController::removeFromWhitelistAction }
- methods: [POST]
- condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /whitelist/remove
+ defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\WhitelistController::removeFromWhitelist }
+ methods: [ POST ]
+ condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
management_whitelist_show:
- path: /whitelist
- defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\WhitelistController::showWhitelistAction }
- methods: [GET]
- condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /whitelist
+ defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\WhitelistController::showWhitelist }
+ methods: [ GET ]
+ condition: "request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
management_forget_identity:
- path: /forget-identity
- defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\RightToBeForgottenController::forgetIdentityAction }
- methods: [POST]
- condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
+ path: /forget-identity
+ defaults: { _controller: Surfnet\StepupMiddleware\ManagementBundle\Controller\RightToBeForgottenController::forgetIdentity }
+ methods: [ POST ]
+ condition: "request.headers.get('Content-Type') == 'application/json' && request.headers.get('Accept') matches '/^application\\\\/json($|[;,])/'"
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Resources/config/services.yml b/src/Surfnet/StepupMiddleware/ManagementBundle/Resources/config/services.yml
index 451e9f126..c8132f958 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Resources/config/services.yml
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Resources/config/services.yml
@@ -1,71 +1,72 @@
services:
+ _defaults:
+ autowire: true
+ autoconfigure: true
+ public: false
- Surfnet\StepupMiddleware\ManagementBundle\Controller\:
- resource: '../../Controller'
- autowire: true
- tags: ['controller.service_arguments']
+ Surfnet\StepupMiddleware\ManagementBundle\Controller\:
+ resource: '../../Controller'
+ autowire: true
+ tags: [ 'controller.service_arguments' ]
- Surfnet\StepupMiddleware\ManagementBundle\:
- resource: '../../*'
- autowire: true
- exclude: '../../{DependencyInjection,Entity,Repository,Migrations,Tests,Exception,Controller}'
+ Surfnet\StepupMiddleware\ManagementBundle\:
+ resource: '../../*'
+ autowire: true
+ exclude: '../../{DependencyInjection,Entity,Repository,Migrations,Tests,Exception,Controller}'
- # BC aliases
- Surfnet\StepupMiddleware\ManagementBundle\Service\DBALConnectionHelper: "@surfnet_stepup_middleware_management.dbal_connection_helper"
- Surfnet\StepupMiddleware\ManagementBundle\Validator\EmailTemplatesConfigurationValidator: "@surfnet_stepup_middleware_management.validator.email_templates_configuration"
+ # BC aliases
+ Surfnet\StepupMiddleware\ManagementBundle\Service\DBALConnectionHelper: "@surfnet_stepup_middleware_management.dbal_connection_helper"
+ Surfnet\StepupMiddleware\ManagementBundle\Validator\EmailTemplatesConfigurationValidator: "@surfnet_stepup_middleware_management.validator.email_templates_configuration"
+ surfnet_stepup_middleware_management.validator.configuration:
+ class: Surfnet\StepupMiddleware\ManagementBundle\Validator\ConfigurationStructureValidator
+ arguments:
+ - "@surfnet_stepup_middleware_management.validator.gateway_configuration"
+ - "@surfnet_stepup_middleware_management.validator.email_templates_configuration"
+ tags:
+ - { name: validator.constraint_validator, alias: configuration_structure_validator }
- Liip\FunctionalTestBundle\Validator\DataCollectingValidator: '@validator'
+ surfnet_stepup_middleware_management.validator.gateway_configuration:
+ class: Surfnet\StepupMiddleware\ManagementBundle\Validator\GatewayConfigurationValidator
+ arguments:
+ - "@surfnet_stepup_middleware_management.validator.identity_provider_configuration"
+ - "@surfnet_stepup_middleware_management.validator.service_provider_configuration"
- surfnet_stepup_middleware_management.validator.configuration:
- class: Surfnet\StepupMiddleware\ManagementBundle\Validator\ConfigurationStructureValidator
- arguments:
- - "@surfnet_stepup_middleware_management.validator.gateway_configuration"
- - "@surfnet_stepup_middleware_management.validator.email_templates_configuration"
- tags:
- - { name: validator.constraint_validator, alias: configuration_structure_validator }
+ surfnet_stepup_middleware_management.validator.service_provider_configuration:
+ class: Surfnet\StepupMiddleware\ManagementBundle\Validator\ServiceProviderConfigurationValidator
- surfnet_stepup_middleware_management.validator.gateway_configuration:
- class: Surfnet\StepupMiddleware\ManagementBundle\Validator\GatewayConfigurationValidator
- arguments:
- - "@surfnet_stepup_middleware_management.validator.identity_provider_configuration"
- - "@surfnet_stepup_middleware_management.validator.service_provider_configuration"
+ surfnet_stepup_middleware_management.validator.identity_provider_configuration:
+ class: Surfnet\StepupMiddleware\ManagementBundle\Validator\IdentityProviderConfigurationValidator
- surfnet_stepup_middleware_management.validator.service_provider_configuration:
- class: Surfnet\StepupMiddleware\ManagementBundle\Validator\ServiceProviderConfigurationValidator
+ surfnet_stepup_middleware_management.validator.email_templates_configuration:
+ class: Surfnet\StepupMiddleware\ManagementBundle\Validator\EmailTemplatesConfigurationValidator
+ arguments:
+ - '' # Default locale
- surfnet_stepup_middleware_management.validator.identity_provider_configuration:
- class: Surfnet\StepupMiddleware\ManagementBundle\Validator\IdentityProviderConfigurationValidator
+ surfnet_stepup_middleware_management.validator.reconfigure_institution_request:
+ class: Surfnet\StepupMiddleware\ManagementBundle\Validator\ReconfigureInstitutionRequestValidator
+ arguments:
+ - "@surfnet_stepup_middleware_api.service.configured_institutions"
+ - "@surfnet_stepup.service.second_factor_type"
+ - "@surfnet_stepup_middleware_api.service.whitelist_entry"
+ tags:
+ - { name: validator.constraint_validator, alias: reconfigure_institution_configuration_structure_validator }
- surfnet_stepup_middleware_management.validator.email_templates_configuration:
- class: Surfnet\StepupMiddleware\ManagementBundle\Validator\EmailTemplatesConfigurationValidator
- arguments:
- - '' # Default locale
+ surfnet_stepup_middleware_management.projector.email_templates:
+ class: Surfnet\StepupMiddleware\ManagementBundle\Configuration\Projector\EmailTemplatesProjector
+ arguments:
+ - "@surfnet_stepup_middleware_management.repository.email_template"
+ tags: [ { name: event_bus.event_listener, disable_for_replay: false } ]
- surfnet_stepup_middleware_management.validator.reconfigure_institution_request:
- class: Surfnet\StepupMiddleware\ManagementBundle\Validator\ReconfigureInstitutionRequestValidator
- arguments:
- - "@surfnet_stepup_middleware_api.service.configured_institutions"
- - "@surfnet_stepup.service.second_factor_type"
- - "@surfnet_stepup_middleware_api.service.whitelist_entry"
- tags:
- - { name: validator.constraint_validator, alias: reconfigure_institution_configuration_structure_validator }
+ surfnet_stepup_middleware_management.repository.email_template: '@Surfnet\StepupMiddleware\ManagementBundle\Configuration\Repository\EmailTemplateRepository'
- surfnet_stepup_middleware_management.projector.email_templates:
- class: Surfnet\StepupMiddleware\ManagementBundle\Configuration\Projector\EmailTemplatesProjector
- arguments:
- - "@surfnet_stepup_middleware_management.repository.email_template"
- tags: [{ name: event_bus.event_listener, disable_for_replay: false }]
+ surfnet_stepup_middleware_management.service.email_template:
+ class: Surfnet\StepupMiddleware\ManagementBundle\Configuration\Service\EmailTemplateService
+ arguments: [ "@surfnet_stepup_middleware_management.repository.email_template" ]
- surfnet_stepup_middleware_management.repository.email_template: '@Surfnet\StepupMiddleware\ManagementBundle\Configuration\Repository\EmailTemplateRepository'
-
- surfnet_stepup_middleware_management.service.email_template:
- class: Surfnet\StepupMiddleware\ManagementBundle\Configuration\Service\EmailTemplateService
- arguments: [ "@surfnet_stepup_middleware_management.repository.email_template" ]
-
- surfnet_stepup_middleware_management.dbal_connection_helper:
- class: Surfnet\StepupMiddleware\ManagementBundle\Service\DBALConnectionHelper
- arguments:
- -
- middleware: "@doctrine.dbal.middleware_connection"
- gateway: "@doctrine.dbal.gateway_connection"
+ surfnet_stepup_middleware_management.dbal_connection_helper:
+ class: Surfnet\StepupMiddleware\ManagementBundle\Service\DBALConnectionHelper
+ arguments:
+ - middleware: "@doctrine.dbal.middleware_connection"
+ gateway: "@doctrine.dbal.gateway_connection"
+ deploy: "@doctrine.dbal.deploy_connection"
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Service/DBALConnectionHelper.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Service/DBALConnectionHelper.php
index 096df5eaa..253cb5d06 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Service/DBALConnectionHelper.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Service/DBALConnectionHelper.php
@@ -27,7 +27,7 @@ class DBALConnectionHelper
/**
* @var Connection[]
*/
- private $connections;
+ private array $connections;
/**
* @param Connection[] $connections
@@ -36,7 +36,7 @@ public function __construct(array $connections)
{
foreach ($connections as $connection) {
if (!$connection instanceof Connection) {
- throw InvalidArgumentException::invalidType('\Doctrine\DBAL\Connection', 'connection', $connection);
+ throw InvalidArgumentException::invalidType(Connection::class, 'connection', $connection);
}
}
@@ -46,7 +46,7 @@ public function __construct(array $connections)
/**
* Start transaction on each connection
*/
- public function beginTransaction()
+ public function beginTransaction(): void
{
foreach ($this->connections as $connection) {
$connection->beginTransaction();
@@ -56,7 +56,7 @@ public function beginTransaction()
/**
* Commit transaction on each connection
*/
- public function commit()
+ public function commit(): void
{
foreach ($this->connections as $connection) {
$connection->commit();
@@ -66,7 +66,7 @@ public function commit()
/**
* Roll back the transaction on each connection
*/
- public function rollBack()
+ public function rollBack(): void
{
foreach ($this->connections as $connection) {
$connection->rollBack();
@@ -74,10 +74,9 @@ public function rollBack()
}
/**
- * @param string $connectionName
* @return Connection
*/
- public function getConnection($connectionName)
+ public function getConnection(string $connectionName): Connection
{
if (!is_string($connectionName)) {
throw InvalidArgumentException::invalidType('string', 'connectionName', $connectionName);
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/ConfigurationControllerTest.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/ConfigurationControllerTest.php
index aec5bcc20..80d28853a 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/ConfigurationControllerTest.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/ConfigurationControllerTest.php
@@ -18,35 +18,50 @@
namespace Surfnet\StepupMiddleware\ManagementBundle\Tests\Controller;
-use Liip\TestFixturesBundle\Test\FixturesTrait;
+use Liip\TestFixturesBundle\Services\DatabaseToolCollection;
+use Liip\TestFixturesBundle\Services\DatabaseTools\AbstractDatabaseTool;
+use Liip\TestFixturesBundle\Services\DatabaseTools\ORMSqliteDatabaseTool;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
+use Symfony\Component\HttpFoundation\Response;
class ConfigurationControllerTest extends WebTestCase
{
- use FixturesTrait;
+ use MockeryPHPUnitIntegration;
- /**
- * @var \Symfony\Bundle\FrameworkBundle\Client
- */
- private $client;
+ private KernelBrowser $client;
- /**
- * @var string
- */
- private $password;
+ private string $password;
- /**
- * @var string
- */
- private $passwordRo;
+ private string $passwordRo;
+
+ private AbstractDatabaseTool $databaseTool;
public function setUp(): void
{
- // Initialises schema.
- $this->loadFixtures([]);
$this->client = static::createClient();
- $this->password = $this->client->getKernel()->getContainer()->getParameter('management_password');
- $this->passwordRo = $this->client->getKernel()->getContainer()->getParameter('readonly_api_password');
+ $databaseTool = $this->client->getContainer()->get(DatabaseToolCollection::class);
+ if (!$databaseTool instanceof DatabaseToolCollection) {
+ $this->fail('Unable to grab the ORMSqliteDatabaseTool from the container');
+ }
+ $this->databaseTool = $databaseTool->get();
+ // Initialises schema.
+ $this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
+ $this->databaseTool->loadFixtures([]);
+
+ $managementPassword = $this->client->getKernel()->getContainer()->getParameter('management_password');
+ if (!is_string($managementPassword)) {
+ $this->fail('Unable to grab the management_password parameter from the container');
+ }
+ $this->password = $managementPassword;
+
+ $readOnlyPassword = $this->client->getKernel()->getContainer()->getParameter('readonly_api_password');
+ if (!is_string($readOnlyPassword)) {
+ $this->fail('Unable to grab the readonly_api_password parameter from the container');
+ }
+ $this->passwordRo = $readOnlyPassword;
+
}
public function tearDown(): void
@@ -58,7 +73,7 @@ public function tearDown(): void
* @test
* @group management
*/
- public function requests_with_invalid_content_are_bad_requests()
+ public function requests_with_invalid_content_are_bad_requests(): void
{
$this->client->request(
'POST',
@@ -66,22 +81,26 @@ public function requests_with_invalid_content_are_bad_requests()
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => 'management',
- 'PHP_AUTH_PW' => $this->password
+ 'PHP_AUTH_PW' => $this->password,
],
- json_encode([])
+ '[]',
);
- $this->assertSame(400, $this->client->getResponse()->getStatusCode());
+ $this->assertSame(
+ Response::HTTP_BAD_REQUEST,
+ $this->client->getResponse()->getStatusCode(),
+ (string) $this->client->getResponse()->getContent(),
+ );
}
/**
* @test
* @group management
*/
- public function authorization_is_required()
+ public function authorization_is_required(): void
{
$this->client->request(
'POST',
@@ -89,20 +108,20 @@ public function authorization_is_required()
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json'
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('401', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_UNAUTHORIZED, $this->client->getResponse()->getStatusCode());
}
/**
* @test
* @group management
*/
- public function readonly_user_cannot_modify_configuration()
+ public function readonly_user_cannot_modify_configuration(): void
{
$this->client->request(
'POST',
@@ -110,15 +129,15 @@ public function readonly_user_cannot_modify_configuration()
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => 'apireader',
- 'PHP_AUTH_PW' => $this->passwordRo,
+ 'PHP_AUTH_PW' => $this->passwordRo,
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('403', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_FORBIDDEN, $this->client->getResponse()->getStatusCode());
}
/**
@@ -127,7 +146,7 @@ public function readonly_user_cannot_modify_configuration()
*
* @dataProvider invalidHttpMethodProvider
*/
- public function only_post_requests_are_accepted($invalidHttpMethod)
+ public function only_post_requests_are_accepted(string $invalidHttpMethod): void
{
$this->client->request(
$invalidHttpMethod,
@@ -135,20 +154,20 @@ public function only_post_requests_are_accepted($invalidHttpMethod)
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json'
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('405', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_METHOD_NOT_ALLOWED, $this->client->getResponse()->getStatusCode());
}
/**
* @test
* @group management
*/
- public function json_is_returned_from_the_configuration_api()
+ public function json_is_returned_from_the_configuration_api(): void
{
$this->client->request(
'POST',
@@ -156,33 +175,33 @@ public function json_is_returned_from_the_configuration_api()
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => 'management',
- 'PHP_AUTH_PW' => $this->password,
+ 'PHP_AUTH_PW' => $this->password,
],
- json_encode([])
+ '[]',
);
$this->assertTrue(
$this->client->getResponse()->headers->contains(
'Content-Type',
- 'application/json'
- )
+ 'application/json',
+ ),
);
}
/**
* Dataprovider for only_post_requests_are_accepted
*/
- public function invalidHttpMethodProvider()
+ public function invalidHttpMethodProvider(): array
{
return [
'GET' => ['GET'],
'DELETE' => ['DELETE'],
'HEAD' => ['HEAD'],
'PUT' => ['PUT'],
- 'OPTIONS' => ['OPTIONS']
+ 'OPTIONS' => ['OPTIONS'],
];
}
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/InstitutionConfigurationControllerTest.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/InstitutionConfigurationControllerTest.php
index 3139f3937..93647b23a 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/InstitutionConfigurationControllerTest.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Controller/InstitutionConfigurationControllerTest.php
@@ -18,35 +18,50 @@
namespace Surfnet\StepupMiddleware\ManagementBundle\Tests\Controller;
-use Liip\TestFixturesBundle\Test\FixturesTrait;
+use Liip\TestFixturesBundle\Services\DatabaseToolCollection;
+use Liip\TestFixturesBundle\Services\DatabaseTools\AbstractDatabaseTool;
+use Liip\TestFixturesBundle\Services\DatabaseTools\ORMSqliteDatabaseTool;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
+use Symfony\Component\HttpFoundation\Response;
+use function is_string;
class InstitutionConfigurationControllerTest extends WebTestCase
{
- use FixturesTrait;
+ use MockeryPHPUnitIntegration;
- /**
- * @var \Symfony\Bundle\FrameworkBundle\Client
- */
- private $client;
+ private KernelBrowser $client;
- /**
- * @var string
- */
- private $password;
+ private string $password;
- /**
- * @var string
- */
- private $passwordRo;
+ private string $passwordRo;
+
+ private AbstractDatabaseTool $databaseTool;
public function setUp(): void
{
- // Initialises schema.
- $this->loadFixtures([]);
$this->client = static::createClient();
- $this->password = $this->client->getKernel()->getContainer()->getParameter('management_password');
- $this->passwordRo = $this->client->getKernel()->getContainer()->getParameter('readonly_api_password');
+ $databaseTool = $this->client->getContainer()->get(DatabaseToolCollection::class);
+ if (!$databaseTool instanceof DatabaseToolCollection) {
+ $this->fail('Unable to grab the ORMSqliteDatabaseTool from the container');
+ }
+ $this->databaseTool = $databaseTool->get();
+ // Initialises schema.
+ $this->databaseTool->setExcludedDoctrineTables(['ra_candidate']);
+ $this->databaseTool->loadFixtures([]);
+
+ $managementPassword = $this->client->getKernel()->getContainer()->getParameter('management_password');
+ if (!is_string($managementPassword)) {
+ $this->fail('Unable to grab the management_password parameter from the container');
+ }
+ $this->password = $managementPassword;
+
+ $readOnlyPassword = $this->client->getKernel()->getContainer()->getParameter('readonly_api_password');
+ if (!is_string($readOnlyPassword)) {
+ $this->fail('Unable to grab the readonly_api_password parameter from the container');
+ }
+ $this->passwordRo = $readOnlyPassword;
}
public function tearDown(): void
@@ -58,7 +73,7 @@ public function tearDown(): void
* @test
* @group management
*/
- public function authorization_is_required_for_reconfiguring_institution_configuration_options()
+ public function authorization_is_required_for_reconfiguring_institution_configuration_options(): void
{
$this->client->request(
'POST',
@@ -66,20 +81,20 @@ public function authorization_is_required_for_reconfiguring_institution_configur
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json'
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('401', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_UNAUTHORIZED, $this->client->getResponse()->getStatusCode());
}
/**
* @test
* @group management
*/
- public function readonly_user_cannot_reconfigure_institution_configuration_options()
+ public function readonly_user_cannot_reconfigure_institution_configuration_options(): void
{
$this->client->request(
'POST',
@@ -87,22 +102,22 @@ public function readonly_user_cannot_reconfigure_institution_configuration_optio
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => 'apireader',
- 'PHP_AUTH_PW' => $this->passwordRo,
+ 'PHP_AUTH_PW' => $this->passwordRo,
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('403', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_FORBIDDEN, $this->client->getResponse()->getStatusCode());
}
/**
* @test
* @group management
*/
- public function authorization_is_required_for_querying_institution_configuration_options()
+ public function authorization_is_required_for_querying_institution_configuration_options(): void
{
$this->client->request(
'GET',
@@ -110,36 +125,40 @@ public function authorization_is_required_for_querying_institution_configuration
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json'
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('401', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_UNAUTHORIZED, $this->client->getResponse()->getStatusCode());
}
/**
* @test
* @group management
*/
- public function requests_with_invalid_content_are_bad_requests()
+ public function requests_with_invalid_content_are_bad_requests(): void
{
+ $content = json_encode(['non-existing.organisation.test' => []]);
+ if (!is_string($content)) {
+ $this->fail('Unable to json_encode the content of the request content');
+ }
$this->client->request(
'POST',
'/management/institution-configuration',
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => 'management',
- 'PHP_AUTH_PW' => $this->password
+ 'PHP_AUTH_PW' => $this->password,
],
- json_encode(['non-existing.organisation.test' => []])
+ $content,
);
- $this->assertEquals('400', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_BAD_REQUEST, $this->client->getResponse()->getStatusCode());
}
/**
@@ -147,9 +166,8 @@ public function requests_with_invalid_content_are_bad_requests()
* @group management
*
* @dataProvider invalidHttpMethodProvider
- * @param $invalidHttpMethod
*/
- public function only_post_and_get_requests_are_accepted($invalidHttpMethod)
+ public function only_post_and_get_requests_are_accepted(string $invalidHttpMethod): void
{
$this->client->request(
$invalidHttpMethod,
@@ -157,20 +175,20 @@ public function only_post_and_get_requests_are_accepted($invalidHttpMethod)
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json'
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('405', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_METHOD_NOT_ALLOWED, $this->client->getResponse()->getStatusCode());
}
/**
* @test
* @group management
*/
- public function a_get_request_without_content_is_valid()
+ public function a_get_request_without_content_is_valid(): void
{
$this->client->request(
'GET',
@@ -178,22 +196,22 @@ public function a_get_request_without_content_is_valid()
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => 'management',
- 'PHP_AUTH_PW' => $this->password
+ 'PHP_AUTH_PW' => $this->password,
],
- json_encode([])
+ '[]',
);
- $this->assertEquals('200', $this->client->getResponse()->getStatusCode());
+ $this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
}
/**
* @test
* @group management
*/
- public function json_is_returned_from_the_institution_configuration_api()
+ public function json_is_returned_from_the_institution_configuration_api(): void
{
$this->client->request(
'POST',
@@ -201,30 +219,30 @@ public function json_is_returned_from_the_institution_configuration_api()
[],
[],
[
- 'HTTP_ACCEPT' => 'application/json',
- 'CONTENT_TYPE' => 'application/json',
+ 'HTTP_ACCEPT' => 'application/json',
+ 'CONTENT_TYPE' => 'application/json',
'PHP_AUTH_USER' => 'management',
- 'PHP_AUTH_PW' => $this->password
+ 'PHP_AUTH_PW' => $this->password,
],
- json_encode([])
+ '[]',
);
$this->assertTrue(
$this->client->getResponse()->headers->contains(
'Content-Type',
- 'application/json'
- )
+ 'application/json',
+ ),
);
}
/**
* Dataprovider for only_post_and_get_requests_are_accepted
*/
- public function invalidHttpMethodProvider()
+ public function invalidHttpMethodProvider(): array
{
return [
- 'DELETE' => ['DELETE'],
- 'PUT' => ['PUT'],
+ 'DELETE' => ['DELETE'],
+ 'PUT' => ['PUT'],
'OPTIONS' => ['OPTIONS'],
];
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/ConfigurationValidationTest.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/ConfigurationValidationTest.php
index 43c2469c0..e9b6d6874 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/ConfigurationValidationTest.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/ConfigurationValidationTest.php
@@ -19,27 +19,41 @@
namespace Surfnet\StepupMiddleware\ManagementBundle\Tests\Validator;
use Mockery as m;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\Matcher\MatcherAbstract;
use PHPUnit\Framework\TestCase as TestCase;
+use RuntimeException;
use Surfnet\StepupMiddleware\ManagementBundle\Validator\ConfigurationStructureValidator;
use Surfnet\StepupMiddleware\ManagementBundle\Validator\Constraints\HasValidConfigurationStructure;
use Surfnet\StepupMiddleware\ManagementBundle\Validator\EmailTemplatesConfigurationValidator;
use Surfnet\StepupMiddleware\ManagementBundle\Validator\GatewayConfigurationValidator;
use Surfnet\StepupMiddleware\ManagementBundle\Validator\IdentityProviderConfigurationValidator;
use Surfnet\StepupMiddleware\ManagementBundle\Validator\ServiceProviderConfigurationValidator;
+use Symfony\Component\Validator\Context\ExecutionContextInterface;
+use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
final class ConfigurationValidationTest extends TestCase
{
- public function invalidConfigurations()
+ use MockeryPHPUnitIntegration;
+
+ /**
+ * @return mixed[][]
+ */
+ public function invalidConfigurations(): array
{
$dataSet = [];
-
- foreach (glob(__DIR__ . '/Fixtures/invalid_configuration/*.php') as $invalidConfiguration) {
+ $fixtureDir = __DIR__ . '/Fixtures/invalid_configuration/*.php';
+ $requestData = glob($fixtureDir);
+ if ($requestData === false) {
+ throw new RuntimeException(sprintf('No fixture data found in "%s"', $fixtureDir));
+ }
+ foreach ($requestData as $invalidConfiguration) {
$fixture = include $invalidConfiguration;
$dataSet[basename($invalidConfiguration)] = [
$fixture['configuration'],
- $fixture['expectedPropertyPath']
+ $fixture['expectedPropertyPath'],
];
- };
+ }
return $dataSet;
}
@@ -48,24 +62,22 @@ public function invalidConfigurations()
* @test
* @group command-handler
* @dataProvider invalidConfigurations
- * @param array $configuration
- * @param string $expectedPropertyPath
*/
- public function it_rejects_invalid_configuration($configuration, $expectedPropertyPath)
+ public function it_rejects_invalid_configuration(array $configuration, string $expectedPropertyPath): void
{
- $builder = m::mock('Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface');
+ $builder = m::mock(ConstraintViolationBuilderInterface::class);
$builder->shouldReceive('addViolation')->with()->once();
- $builder->shouldReceive('atPath')->with(self::spy($actualPropertyPath))->once();
+ $builder->shouldReceive('atPath')->with($this->spy($actualPropertyPath))->once();
- $context = m::mock('Symfony\Component\Validator\Context\ExecutionContextInterface');
- $context->shouldReceive('buildViolation')->with(self::spy($errorMessage))->once()->andReturn($builder);
+ $context = m::mock(ExecutionContextInterface::class);
+ $context->shouldReceive('buildViolation')->with($this->spy($errorMessage))->once()->andReturn($builder);
$validator = new ConfigurationStructureValidator(
new GatewayConfigurationValidator(
new IdentityProviderConfigurationValidator(),
- new ServiceProviderConfigurationValidator()
+ new ServiceProviderConfigurationValidator(),
),
- new EmailTemplatesConfigurationValidator('en_GB')
+ new EmailTemplatesConfigurationValidator('en_GB'),
);
$validator->initialize($context);
$validator->validate(json_encode($configuration), new HasValidConfigurationStructure());
@@ -74,22 +86,21 @@ public function it_rejects_invalid_configuration($configuration, $expectedProper
$this->assertEquals(
$expectedPropertyPath,
$actualPropertyPath,
- sprintf("Actual path to erroneous property doesn't match expected path (%s)", $errorMessage)
+ sprintf("Actual path to erroneous property doesn't match expected path (%s)", $errorMessage),
);
}
/**
- * @param mixed &$spy
- * @return \Mockery\Matcher\MatcherAbstract
+ * @return MatcherAbstract
*/
- private static function spy(&$spy)
+ private function spy(mixed &$spy): MatcherAbstract
{
return m::on(
- function ($value) use (&$spy) {
+ function ($value) use (&$spy): bool {
$spy = $value;
return true;
- }
+ },
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_idp_loas.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_idp_loas.php
index 8833dd702..fcaecbdc8 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_idp_loas.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_idp_loas.php
@@ -18,36 +18,36 @@
return [
'expectedPropertyPath' => 'gateway.identity_providers[0].loa',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [
[
"entity_id" => "http://idp.tld/metadata",
- "loa" => [],
+ "loa" => [],
],
],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_sp_acs.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_sp_acs.php
index 307202225..84d057818 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_sp_acs.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_sp_acs.php
@@ -18,31 +18,31 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].acs',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => [],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => [],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_sp_loas.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_sp_loas.php
index 8081c548d..cbefcd946 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_sp_loas.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/empty_sp_loas.php
@@ -18,29 +18,29 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].loa',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [],
- "second_factor_only" => false,
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [],
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_blacklisted_encryption_algorithm.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_blacklisted_encryption_algorithm.php
index a7de73b14..468451094 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_blacklisted_encryption_algorithm.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_blacklisted_encryption_algorithm.php
@@ -18,31 +18,31 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].blacklisted_encryption_algorithms',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [9],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [9],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_blacklisted_encryption_algorithms.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_blacklisted_encryption_algorithms.php
index af68335ba..66c9fb892 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_blacklisted_encryption_algorithms.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_blacklisted_encryption_algorithms.php
@@ -18,31 +18,31 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].blacklisted_encryption_algorithms',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => 9,
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => 9,
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_email_template_locale.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_email_template_locale.php
index 7b90f9aa4..3fe626880 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_email_template_locale.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_email_template_locale.php
@@ -18,33 +18,33 @@
return [
'expectedPropertyPath' => 'email_templates.confirm_email[9]',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}', 9 => ''],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}', 9 => ''],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'recovery_token_created' => ['en_GB' => 'Code {{ commonName }}'],
'recovery_token_revoked' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp.php
index 62d456f47..14c62e7aa 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp.php
@@ -18,31 +18,31 @@
return [
'expectedPropertyPath' => 'gateway.identity_providers[0]',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [9],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp_entity_id.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp_entity_id.php
index 82df849bd..36bc198ce 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp_entity_id.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp_entity_id.php
@@ -18,38 +18,38 @@
return [
'expectedPropertyPath' => 'gateway.identity_providers[0].entity_id',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [
[
"entity_id" => 9,
- "loa" => [
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
],
],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp_loa.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp_loa.php
index b5722ef25..4655ed97e 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp_loa.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idp_loa.php
@@ -18,38 +18,38 @@
return [
'expectedPropertyPath' => 'gateway.identity_providers[0].loa',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [
[
"entity_id" => "http://idp.tld/metadata",
- "loa" => [
+ "loa" => [
"__default__" => 9,
],
],
],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idps.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idps.php
deleted file mode 100644
index c2d268da5..000000000
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_idps.php
+++ /dev/null
@@ -1,50 +0,0 @@
- 'gateway.identity_providers',
- 'configuration' => [
- 'gateway' => [
- 'identity_providers' => 9,
- 'service_providers' => [
- [
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
- "__default__" => "https://entity.tld/authentication/loa2",
- ],
- "second_factor_only" => false,
- "second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
- ],
- ],
- ],
- 'sraa' => ['20394-4320423-439248324'],
- 'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
- 'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
- 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
- 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- ],
- ],
-];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp.php
index e265df570..b278c5059 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp.php
@@ -18,18 +18,18 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0]',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [9],
+ 'service_providers' => [9],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_acs.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_acs.php
index aa3a4aa52..7d32100ac 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_acs.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_acs.php
@@ -18,31 +18,31 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].acs',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => [9],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => [9],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_assertion_encryption_enabled.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_assertion_encryption_enabled.php
index aea9fb23b..13c317681 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_assertion_encryption_enabled.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_assertion_encryption_enabled.php
@@ -18,31 +18,31 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].assertion_encryption_enabled',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => 9,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => 9,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_entity_id.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_entity_id.php
index de3b1e209..61c6f50c8 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_entity_id.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_entity_id.php
@@ -18,31 +18,31 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].entity_id',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => 9,
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => 9,
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_loa.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_loa.php
index 24aced856..d5fffab71 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_loa.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_loa.php
@@ -18,31 +18,31 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].loa',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => 3,
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_loa_uppercase_institution_sho.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_loa_uppercase_institution_sho.php
index c7ac566d3..57a915d1d 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_loa_uppercase_institution_sho.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_loa_uppercase_institution_sho.php
@@ -18,32 +18,32 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].loa',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => 'https://entity.tld/authentication/loa2',
- "InstItuTioN" => 'https://entity.tld/authentication/loa3'
+ "InstItuTioN" => 'https://entity.tld/authentication/loa3',
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_public_key.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_public_key.php
index 04f164597..645b2c6df 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_public_key.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_public_key.php
@@ -18,31 +18,31 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].public_key',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => 9,
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => 9,
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_second_factor_only.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_second_factor_only.php
index a3f6251d2..9d387a8f6 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_second_factor_only.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_second_factor_only.php
@@ -18,31 +18,33 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].second_factor_only',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => 'true',
+ "second_factor_only" => 'true',
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'], 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'], 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_second_factor_only_nameid_patterns.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_second_factor_only_nameid_patterns.php
index 94be77f42..1d83ff344 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_second_factor_only_nameid_patterns.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sp_second_factor_only_nameid_patterns.php
@@ -18,31 +18,33 @@
return [
'expectedPropertyPath' => 'gateway.service_providers[0].second_factor_only_nameid_patterns',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => true,
+ "second_factor_only" => true,
"second_factor_only_nameid_patterns" => "urn:*",
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'], 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'], 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sps.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sps.php
deleted file mode 100644
index 8931cd073..000000000
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sps.php
+++ /dev/null
@@ -1,35 +0,0 @@
- 'gateway.service_providers',
- 'configuration' => [
- 'gateway' => [
- 'identity_providers' => [],
- 'service_providers' => 9,
- ],
- 'sraa' => ['20394-4320423-439248324'],
- 'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
- 'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'], 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'], 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- ],
- ],
-];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sraa.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sraa.php
index 21bcac48e..9cf861103 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sraa.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sraa.php
@@ -18,31 +18,33 @@
return [
'expectedPropertyPath' => 'sraa[0]',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => [9],
+ 'sraa' => [9],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'], 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'], 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sraas.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sraas.php
index aa0960d78..3b5d3b96c 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sraas.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/invalid_sraas.php
@@ -18,31 +18,33 @@
return [
'expectedPropertyPath' => 'sraa',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => 9,
+ 'sraa' => 9,
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'], 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'], 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_confirm_email.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_confirm_email.php
index eb8954c8e..3c9cea46a 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_confirm_email.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_confirm_email.php
@@ -18,30 +18,32 @@
return [
'expectedPropertyPath' => 'email_templates',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'], 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'], 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_locale.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_locale.php
index 4a4024fb1..e8581de28 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_locale.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_locale.php
@@ -18,32 +18,32 @@
return [
'expectedPropertyPath' => 'email_templates.confirm_email',
- 'configuration' => [
+ 'configuration' => [
'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['nl_NL' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['nl_NL' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
'recovery_token_created' => ['en_GB' => 'Code {{ commonName }}'],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_registration_code.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_registration_code.php
index 4719a64c6..98cbdb2b6 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_registration_code.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_registration_code.php
@@ -18,28 +18,28 @@
return [
'expectedPropertyPath' => 'email_templates',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
],
],
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_second_factor_revoked.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_second_factor_revoked.php
index e22fd79bb..9ad984d75 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_second_factor_revoked.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_email_template_second_factor_revoked.php
@@ -18,30 +18,30 @@
return [
'expectedPropertyPath' => 'email_templates',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
- 'service_providers' => [
+ 'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "public_key" => "MIIE...",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
- "second_factor_only" => false,
+ "second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => [],
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => ['20394-4320423-439248324'],
+ 'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
],
],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_sps.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_sps.php
index 37c4689a0..f16ce8de0 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_sps.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/missing_sps.php
@@ -24,13 +24,13 @@
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_email_templates.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_email_templates.php
index 9b7b4c0ee..3cd10dc10 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_email_templates.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_email_templates.php
@@ -18,8 +18,8 @@
return [
'expectedPropertyPath' => '(root)',
- 'configuration' => [
+ 'configuration' => [
'gateway' => [],
- 'sraa' => [],
+ 'sraa' => [],
],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_gateway.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_gateway.php
index 38d80ffbc..eaeb13e57 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_gateway.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_gateway.php
@@ -18,5 +18,5 @@
return [
'expectedPropertyPath' => '(root)',
- 'configuration' => [],
+ 'configuration' => [],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_acs.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_acs.php
index fd487ef6a..53036be90 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_acs.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_acs.php
@@ -23,27 +23,27 @@
'identity_providers' => [],
'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
+ "entity_id" => "https://entity.tld/id",
"public_key" => "MIIE...",
- "loa" => [
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
- ]
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
+ ],
],
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_assertion_encryption_enabled.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_assertion_encryption_enabled.php
index 344e8fb21..2ad4b032b 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_assertion_encryption_enabled.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_assertion_encryption_enabled.php
@@ -23,27 +23,27 @@
'identity_providers' => [],
'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
+ "entity_id" => "https://entity.tld/id",
"public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "blacklisted_encryption_algorithms" => []
- ]
+ "blacklisted_encryption_algorithms" => [],
+ ],
],
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_blacklisted_encryption_algorithms.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_blacklisted_encryption_algorithms.php
index e4ea8cf39..f2916e2a6 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_blacklisted_encryption_algorithms.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_blacklisted_encryption_algorithms.php
@@ -23,27 +23,27 @@
'identity_providers' => [],
'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
+ "entity_id" => "https://entity.tld/id",
"public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- ]
+ "assertion_encryption_enabled" => false,
+ ],
],
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_entity_id.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_entity_id.php
index 15a1623b0..95edd3e80 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_entity_id.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_entity_id.php
@@ -24,26 +24,26 @@
'service_providers' => [
[
"public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
- ]
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
+ ],
],
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_loas.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_loas.php
index e9113338d..ad0fd331a 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_loas.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_loas.php
@@ -23,25 +23,25 @@
'identity_providers' => [],
'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
+ "entity_id" => "https://entity.tld/id",
"public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
+ "acs" => ["https://entity.tld/consume-assertion"],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
- ]
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
+ ],
],
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_public_key.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_public_key.php
index 5183de8c3..3a5df34b7 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_public_key.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sp_public_key.php
@@ -23,27 +23,27 @@
'identity_providers' => [],
'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "entity_id" => "https://entity.tld/id",
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
- ]
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
+ ],
],
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sps.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sps.php
index 561e6e4c3..904ec0eb3 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sps.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sps.php
@@ -25,13 +25,13 @@
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sraa.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sraa.php
index a4e1e2fad..ecce9fab5 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sraa.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_sraa.php
@@ -18,7 +18,7 @@
return [
'expectedPropertyPath' => '(root)',
- 'configuration' => [
+ 'configuration' => [
'gateway' => [],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_email_template.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_email_template.php
index fe0fe3ca8..8bfb9ae62 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_email_template.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_email_template.php
@@ -23,29 +23,29 @@
'identity_providers' => [],
'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
+ "entity_id" => "https://entity.tld/id",
"public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
- ]
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
+ ],
],
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'superfluous_key' => 'lemon',
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'superfluous_key' => 'lemon',
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_gateway.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_gateway.php
index 60ecd680d..c7178f1c5 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_gateway.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_gateway.php
@@ -24,28 +24,28 @@
'identity_providers' => [],
'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
+ "entity_id" => "https://entity.tld/id",
"public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
- ]
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
+ ],
],
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_gateway_sp.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_gateway_sp.php
index 0c0243a21..020413aa2 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_gateway_sp.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_gateway_sp.php
@@ -24,28 +24,28 @@
'service_providers' => [
[
'superfluous_key' => 'lemon',
- "entity_id" => "https://entity.tld/id",
+ "entity_id" => "https://entity.tld/id",
"public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
- ]
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
+ ],
],
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_root.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_root.php
index 9001cd862..3cd189021 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_root.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/no_superfluous_keys_root.php
@@ -24,28 +24,28 @@
'identity_providers' => [],
'service_providers' => [
[
- "entity_id" => "https://entity.tld/id",
+ "entity_id" => "https://entity.tld/id",
"public_key" => "MIIE...",
- "acs" => ["https://entity.tld/consume-assertion"],
- "loa" => [
+ "acs" => ["https://entity.tld/consume-assertion"],
+ "loa" => [
"__default__" => "https://entity.tld/authentication/loa2",
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
- ]
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
+ ],
],
],
'sraa' => ['20394-4320423-439248324'],
'email_templates' => [
- 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
- 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
+ 'confirm_email' => ['en_GB' => 'Verify {{ commonName }}'],
+ 'registration_code_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'registration_code_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
- 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
- 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
+ 'vetted' => ['en_GB' => 'Vetted {{ commonName }}'],
+ 'second_factor_revoked' => ['en_GB' => 'Revoked token for {{ commonName }}'],
'second_factor_verification_reminder_with_ras' => ['en_GB' => 'Code {{ commonName }}'],
'second_factor_verification_reminder_with_ra_locations' => ['en_GB' => 'Code {{ commonName }}'],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_email_templates.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_email_templates.php
index 2bb90a029..4cd6698a0 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_email_templates.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_email_templates.php
@@ -18,8 +18,8 @@
return [
'expectedPropertyPath' => 'email_templates',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
'service_providers' => [
[
@@ -27,16 +27,16 @@
'public_key' => 'MIIEEE...',
'acs' => ['http://entity.tld/consume-assertion'],
'loa' => [
- '__default__' => 'http://gateway.tld/loa/1'
+ '__default__' => 'http://gateway.tld/loa/1',
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => [],
+ 'sraa' => [],
'email_templates' => null,
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_gateway.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_gateway.php
index 0dfc5aec1..3e1fe7757 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_gateway.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_gateway.php
@@ -18,9 +18,9 @@
return [
'expectedPropertyPath' => 'gateway',
- 'configuration' => [
- 'gateway' => null,
- 'sraa' => [],
+ 'configuration' => [
+ 'gateway' => null,
+ 'sraa' => [],
'email_templates' => [],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_sraa.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_sraa.php
index 5320fee28..b0f3b1822 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_sraa.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_array_sraa.php
@@ -18,8 +18,8 @@
return [
'expectedPropertyPath' => 'sraa',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
'service_providers' => [
[
@@ -27,16 +27,16 @@
'public_key' => 'MIIEEE...',
'acs' => ['http://entity.tld/consume-assertion'],
'loa' => [
- '__default__' => 'http://gateway.tld/loa/1'
+ '__default__' => 'http://gateway.tld/loa/1',
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => null,
+ 'sraa' => null,
'email_templates' => [],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_strings_sraa.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_strings_sraa.php
index 6732cc31c..bc5c4cce9 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_strings_sraa.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_configuration/not_strings_sraa.php
@@ -18,8 +18,8 @@
return [
'expectedPropertyPath' => 'sraa[0]',
- 'configuration' => [
- 'gateway' => [
+ 'configuration' => [
+ 'gateway' => [
'identity_providers' => [],
'service_providers' => [
[
@@ -27,18 +27,18 @@
'public_key' => 'MIIEEE...',
'acs' => ['http://entity.tld/consume-assertion'],
'loa' => [
- '__default__' => 'http://gateway.tld/loa/1'
+ '__default__' => 'http://gateway.tld/loa/1',
],
"second_factor_only" => false,
"second_factor_only_nameid_patterns" => [],
- "assertion_encryption_enabled" => false,
- "blacklisted_encryption_algorithms" => []
+ "assertion_encryption_enabled" => false,
+ "blacklisted_encryption_algorithms" => [],
],
],
],
- 'sraa' => [
- 9
+ 'sraa' => [
+ 9,
],
'email_templates' => [],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/greater_thant_zero_number_of_tokens_per_identity_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/greater_thant_zero_number_of_tokens_per_identity_option.php
index af9f38f62..8278042d9 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/greater_thant_zero_number_of_tokens_per_identity_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/greater_thant_zero_number_of_tokens_per_identity_option.php
@@ -29,6 +29,6 @@
'allow_self_asserted_tokens' => false,
'number_of_tokens_per_identity' => -1,
'allowed_second_factors' => [],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_allowed_second_factors_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_allowed_second_factors_option.php
index 908bb25af..8669955d3 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_allowed_second_factors_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_allowed_second_factors_option.php
@@ -28,6 +28,6 @@
'sso_on_2fa' => false,
'allow_self_asserted_tokens' => false,
'number_of_tokens_per_identity' => 1,
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_show_raa_contact_information_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_show_raa_contact_information_option.php
index fbfeeb3d5..b17bbeca7 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_show_raa_contact_information_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_show_raa_contact_information_option.php
@@ -28,6 +28,6 @@
'allow_self_asserted_tokens' => false,
'number_of_tokens_per_identity' => 2,
'allowed_second_factors' => [],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_use_ra_locations_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_use_ra_locations_option.php
index f3a9b9cc2..b26a29bda 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_use_ra_locations_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/missing_use_ra_locations_option.php
@@ -28,6 +28,6 @@
'allow_self_asserted_tokens' => false,
'number_of_tokens_per_identity' => 1,
'allowed_second_factors' => [],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_array_allowed_second_factors_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_array_allowed_second_factors_option.php
index cd2cb17d0..f4b4a7650 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_array_allowed_second_factors_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_array_allowed_second_factors_option.php
@@ -29,6 +29,6 @@
'allow_self_asserted_tokens' => false,
'number_of_tokens_per_identity' => 3,
'allowed_second_factors' => false,
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_array_use_raa.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_array_use_raa.php
index 2f391a4ec..97ff3f256 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_array_use_raa.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_array_use_raa.php
@@ -32,6 +32,6 @@
"use_ra" => [],
"use_raa" => "surfnet.nl",
"select_raa" => ["surfnet.nl"],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_allow_self_asserted_tokens_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_allow_self_asserted_tokens_option.php
index b36257646..1ba6fecd6 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_allow_self_asserted_tokens_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_allow_self_asserted_tokens_option.php
@@ -27,6 +27,6 @@
'allow_self_asserted_tokens' => "false",
'number_of_tokens_per_identity' => 1,
'allowed_second_factors' => [],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_self_vet_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_self_vet_option.php
index cef3023d0..81b911bd0 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_self_vet_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_self_vet_option.php
@@ -27,6 +27,6 @@
'self_vet' => 'yes',
'number_of_tokens_per_identity' => 1,
'allowed_second_factors' => [],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_show_raa_contact_information_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_show_raa_contact_information_option.php
index d9b5e7712..415c8468d 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_show_raa_contact_information_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_show_raa_contact_information_option.php
@@ -30,5 +30,5 @@
'number_of_tokens_per_identity' => 1,
'allowed_second_factors' => [],
],
- ]
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_sso_on_2fa_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_sso_on_2fa_option.php
index 52ff933be..c4941d3d8 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_sso_on_2fa_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_sso_on_2fa_option.php
@@ -27,6 +27,6 @@
'sso_on_2fa' => -1,
'number_of_tokens_per_identity' => 1,
'allowed_second_factors' => [],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_use_ra_locations_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_use_ra_locations_option.php
index fb9862cb1..12f2fbcaf 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_use_ra_locations_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_boolean_use_ra_locations_option.php
@@ -29,6 +29,6 @@
'allow_self_asserted_tokens' => false,
'number_of_tokens_per_identity' => 2,
'allowed_second_factors' => [],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_integer_ii_number_of_tokens_per_identity_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_integer_ii_number_of_tokens_per_identity_option.php
index 3ad445139..44e6a382b 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_integer_ii_number_of_tokens_per_identity_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_integer_ii_number_of_tokens_per_identity_option.php
@@ -29,6 +29,6 @@
'allow_self_asserted_tokens' => false,
'number_of_tokens_per_identity' => 3.1415,
'allowed_second_factors' => [],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_integer_number_of_tokens_per_identity_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_integer_number_of_tokens_per_identity_option.php
index 98a092c45..697727fc6 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_integer_number_of_tokens_per_identity_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_integer_number_of_tokens_per_identity_option.php
@@ -29,6 +29,6 @@
'allow_self_asserted_tokens' => false,
'number_of_tokens_per_identity' => true,
'allowed_second_factors' => [],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_strings_allowed_second_factors_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_strings_allowed_second_factors_option.php
index 60830d867..49c7c8492 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_strings_allowed_second_factors_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_strings_allowed_second_factors_option.php
@@ -32,7 +32,7 @@
1,
2,
3,
- ]
- ]
- ]
+ ],
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_valid_second_factor_types_allowed_second_factors_option.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_valid_second_factor_types_allowed_second_factors_option.php
index c4ad0e57b..68636c6d5 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_valid_second_factor_types_allowed_second_factors_option.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_valid_second_factor_types_allowed_second_factors_option.php
@@ -29,8 +29,8 @@
'allow_self_asserted_tokens' => false,
'number_of_tokens_per_identity' => 4,
'allowed_second_factors' => [
- 'faux_second_factor'
+ 'faux_second_factor',
],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_whitelisted_institution_use_raa.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_whitelisted_institution_use_raa.php
index 2be4f6d5f..641843703 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_whitelisted_institution_use_raa.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/not_whitelisted_institution_use_raa.php
@@ -18,7 +18,7 @@
return [
'expectedPropertyPath' => 'Institution(surfnet.nl)',
- 'expectErrorMessageToContain' => 'All values of option "use_raa" should be known institutions.',
+ 'expectErrorMessageToContain' => 'All values of option "use_raa" for "surfnet.nl" should be known institutions.',
'reconfigureInstitutionRequest' => [
'surfnet.nl' => [
"use_ra_locations" => true,
@@ -32,6 +32,6 @@
"use_ra" => ["surfnet.nl"],
"use_raa" => ["example.com"],
"select_raa" => ["surfnet.nl"],
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/with_extra_options.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/with_extra_options.php
index bee84c9d3..2fa69bb1e 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/with_extra_options.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/Fixtures/invalid_reconfigure_institution_request/with_extra_options.php
@@ -30,6 +30,6 @@
'number_of_tokens_per_identity' => 2,
'allowed_second_factors' => [],
'extra_option' => 'cannot be handled',
- ]
- ]
+ ],
+ ],
];
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/ReconfigureInstitutionRequestValidatorTest.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/ReconfigureInstitutionRequestValidatorTest.php
index ab8fb92d7..1e656e485 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/ReconfigureInstitutionRequestValidatorTest.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Tests/Validator/ReconfigureInstitutionRequestValidatorTest.php
@@ -20,7 +20,10 @@
use Doctrine\Common\Collections\ArrayCollection;
use Mockery;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
+use Mockery\Matcher\MatcherAbstract;
use PHPUnit\Framework\TestCase;
+use RuntimeException;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Identity\Value\Institution as IdentityInstitution;
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
@@ -35,16 +38,25 @@
class ReconfigureInstitutionRequestValidatorTest extends TestCase
{
- public function invalidReconfigureInstitutionRequests()
+ use MockeryPHPUnitIntegration;
+
+ /**
+ * @return mixed[][]
+ */
+ public function invalidReconfigureInstitutionRequests(): array
{
$dataSet = [];
-
- foreach (glob(__DIR__ . '/Fixtures/invalid_reconfigure_institution_request/*.php') as $invalidConfiguration) {
+ $fixtureDir = __DIR__ . '/Fixtures/invalid_reconfigure_institution_request/*.php';
+ $requestData = glob($fixtureDir);
+ if ($requestData === false) {
+ throw new RuntimeException(sprintf('No fixture data found in "%s"', $fixtureDir));
+ }
+ foreach ($requestData as $invalidConfiguration) {
$fixture = include $invalidConfiguration;
$dataSet[basename($invalidConfiguration)] = [
$fixture['reconfigureInstitutionRequest'],
$fixture['expectedPropertyPath'],
- $fixture['expectErrorMessageToContain']
+ $fixture['expectErrorMessageToContain'],
];
}
@@ -55,16 +67,13 @@ public function invalidReconfigureInstitutionRequests()
* @test
* @group validator
* @dataProvider invalidReconfigureInstitutionRequests
- * @param array $reconfigureRequest
- * @param string $expectedPropertyPath
- * @param string $expectErrorMessageToContain
*/
public function it_rejects_invalid_configuration(
- $reconfigureRequest,
- $expectedPropertyPath,
- $expectErrorMessageToContain
- ) {
- $existingInstitution = ConfiguredInstitution::createFrom(new Institution('surfnet.nl'));
+ array $reconfigureRequest,
+ string $expectedPropertyPath,
+ string $expectErrorMessageToContain,
+ ): void {
+ $existingInstitution = ConfiguredInstitution::createFrom(new Institution('surfnet.nl'));
$anotherExistingInstitution = ConfiguredInstitution::createFrom(new Institution('another-organisation.test'));
$configuredInstitutionServiceMock = Mockery::mock(ConfiguredInstitutionService::class);
@@ -72,27 +81,27 @@ public function it_rejects_invalid_configuration(
->shouldReceive('getAll')
->andReturn([
$existingInstitution,
- $anotherExistingInstitution
+ $anotherExistingInstitution,
]);
$builder = Mockery::mock(ConstraintViolationBuilderInterface::class);
$builder->shouldReceive('addViolation')->with()->once();
- $builder->shouldReceive('atPath')->with(self::spy($actualPropertyPath))->once();
+ $builder->shouldReceive('atPath')->with($this->spy($actualPropertyPath))->once();
$context = Mockery::mock(ExecutionContextInterface::class);
- $context->shouldReceive('buildViolation')->with(self::spy($actualErrorMessage))->once()->andReturn($builder);
+ $context->shouldReceive('buildViolation')->with($this->spy($actualErrorMessage))->once()->andReturn($builder);
$secondFactorTypeServiceMock = Mockery::mock(SecondFactorTypeService::class);
$secondFactorTypeServiceMock->shouldReceive('getAvailableSecondFactorTypes')->andReturn(['yubikey', 'sms']);
$whitelistedInstitution = WhitelistEntry::createFrom(new IdentityInstitution('surfnet.nl'));
$whitelistServiceMock = Mockery::mock(WhitelistService::class);
- $whitelistServiceMock->shouldReceive('getAllEntries')->andReturn(new ArrayCollection([$whitelistedInstitution]));
+ $whitelistServiceMock->shouldReceive('getAllEntries')->andReturn(new ArrayCollection([$whitelistedInstitution]),);
$validator = new ReconfigureInstitutionRequestValidator(
$configuredInstitutionServiceMock,
$secondFactorTypeServiceMock,
- $whitelistServiceMock
+ $whitelistServiceMock,
);
$validator->initialize($context);
$validator->validate($reconfigureRequest, new ValidReconfigureInstitutionsRequest);
@@ -101,7 +110,7 @@ public function it_rejects_invalid_configuration(
$this->assertEquals(
$expectedPropertyPath,
$actualPropertyPath,
- sprintf('Actual path to erroneous property does not match expected path (%s)', $actualErrorMessage)
+ sprintf('Actual path to erroneous property does not match expected path (%s)', $actualErrorMessage),
);
$this->assertStringContainsString(
$expectErrorMessageToContain,
@@ -109,8 +118,8 @@ public function it_rejects_invalid_configuration(
sprintf(
'The error message (%s) does not contain the expected message (%s)',
$actualErrorMessage,
- $expectErrorMessageToContain
- )
+ $expectErrorMessageToContain,
+ ),
);
}
@@ -118,7 +127,7 @@ public function it_rejects_invalid_configuration(
* @test
* @group validator
*/
- public function reconfigure_institution_request_cannot_contain_institutions_that_do_not_exist()
+ public function reconfigure_institution_request_cannot_contain_institutions_that_do_not_exist(): void
{
$existingInstitutions = [];
$nonExistentInstitution = 'non-existing.organisation.test';
@@ -130,7 +139,7 @@ public function reconfigure_institution_request_cannot_contain_institutions_that
$builder->shouldReceive('addViolation')->with()->once();
$context = Mockery::mock(ExecutionContextInterface::class);
- $context->shouldReceive('buildViolation')->once()->with(self::spy($errorMessage))->andReturn($builder);
+ $context->shouldReceive('buildViolation')->once()->with($this->spy($errorMessage))->andReturn($builder);
$configuredInstitutionServiceMock = Mockery::mock(ConfiguredInstitutionService::class);
$configuredInstitutionServiceMock
@@ -145,7 +154,7 @@ public function reconfigure_institution_request_cannot_contain_institutions_that
$validator = new ReconfigureInstitutionRequestValidator(
$configuredInstitutionServiceMock,
$secondFactorTypeServiceMock,
- $whitelistServiceMock
+ $whitelistServiceMock,
);
$validator->initialize($context);
@@ -158,29 +167,29 @@ public function reconfigure_institution_request_cannot_contain_institutions_that
* @test
* @group validator
*/
- public function validation_for_existing_institutions_is_done_case_insensitively()
+ public function validation_for_existing_institutions_is_done_case_insensitively(): void
{
$existingInstitutions = [ConfiguredInstitution::createFrom(new Institution('surfnet.nl'))];
$differentlyCasedButSameInstitution = 'Surfnet.nl';
$invalidRequest = [
$differentlyCasedButSameInstitution => [
- 'use_ra_locations' => false,
+ 'use_ra_locations' => false,
'show_raa_contact_information' => true,
- 'verify_email' => false,
+ 'verify_email' => false,
'sso_on_2fa' => false,
'self_vet' => false,
'allow_self_asserted_tokens' => false,
'number_of_tokens_per_identity' => 1,
- 'allowed_second_factors' => [],
+ 'allowed_second_factors' => [],
],
];
$builder = Mockery::mock(ConstraintViolationBuilderInterface::class);
- $builder->shouldReceive('addViolation')->never();
+ $builder->shouldNotHaveReceived('addViolation');
$context = Mockery::mock(ExecutionContextInterface::class);
- $context->shouldReceive('buildViolation')->never();
+ $context->shouldNotHaveReceived('buildViolation');
$configuredInstitutionServiceMock = Mockery::mock(ConfiguredInstitutionService::class);
$configuredInstitutionServiceMock
@@ -194,7 +203,7 @@ public function validation_for_existing_institutions_is_done_case_insensitively(
$validator = new ReconfigureInstitutionRequestValidator(
$configuredInstitutionServiceMock,
$secondFactorTypeServiceMock,
- $whitelistServiceMock
+ $whitelistServiceMock,
);
$validator->initialize($context);
@@ -207,19 +216,19 @@ public function validation_for_existing_institutions_is_done_case_insensitively(
* @test
* @group validator
*/
- public function valid_reconfigure_institution_requests_do_not_cause_any_violations()
+ public function valid_reconfigure_institution_requests_do_not_cause_any_violations(): void
{
$institution = 'surfnet.nl';
$validRequest = [
$institution => [
- 'use_ra_locations' => true,
+ 'use_ra_locations' => true,
'show_raa_contact_information' => true,
- 'verify_email' => true,
+ 'verify_email' => true,
'self_vet' => false,
'sso_on_2fa' => false,
'allow_self_asserted_tokens' => false,
'number_of_tokens_per_identity' => 3,
- 'allowed_second_factors' => [],
+ 'allowed_second_factors' => [],
],
];
@@ -232,16 +241,16 @@ public function valid_reconfigure_institution_requests_do_not_cause_any_violatio
->andReturn([$existingInstitution]);
$context = Mockery::mock(ExecutionContextInterface::class);
- $context->shouldReceive('buildViolation')->never();
+ $context->shouldNotHaveReceived('buildViolation');
$secondFactorTypeServiceMock = Mockery::mock(SecondFactorTypeService::class);
$secondFactorTypeServiceMock->shouldReceive('getAvailableSecondFactorTypes')->andReturn(['yubikey', 'sms']);
$whitelistServiceMock = Mockery::mock(WhitelistService::class);
- $whitelistServiceMock->shouldReceive('getAllEntries')->andReturn(new ArrayCollection([$whitelistedInstitution]));
+ $whitelistServiceMock->shouldReceive('getAllEntries')->andReturn(new ArrayCollection([$whitelistedInstitution]),);
$validator = new ReconfigureInstitutionRequestValidator(
$configuredInstitutionServiceMock,
$secondFactorTypeServiceMock,
- $whitelistServiceMock
+ $whitelistServiceMock,
);
$validator->initialize($context);
$validator->validate($validRequest, new ValidReconfigureInstitutionsRequest);
@@ -251,17 +260,16 @@ public function valid_reconfigure_institution_requests_do_not_cause_any_violatio
}
/**
- * @param mixed &$spy
- * @return \Mockery\Matcher\MatcherAbstract
+ * @return MatcherAbstract
*/
- private static function spy(&$spy)
+ private function spy(mixed &$spy): MatcherAbstract
{
return Mockery::on(
- function ($value) use (&$spy) {
+ function ($value) use (&$spy): bool {
$spy = $value;
return true;
- }
+ },
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/Assert.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/Assert.php
index 0fc7f95b6..319029029 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/Assert.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/Assert.php
@@ -22,13 +22,17 @@
final class Assert
{
- public static function keysMatch(array $value, array $keys, $message = null, $propertyPath = null)
+ /**
+ * @param array $value
+ * @param array $keys
+ */
+ public static function keysMatch(array $value, array $keys, ?string $message = null, ?string $propertyPath = null): void
{
$keysOfValue = array_keys($value);
$extraKeys = array_diff($keysOfValue, $keys);
$missingKeys = array_diff($keys, $keysOfValue);
- if (count($extraKeys) === 0 && count($missingKeys) === 0) {
+ if ($extraKeys === [] && $missingKeys === []) {
return;
}
@@ -37,12 +41,17 @@ public static function keysMatch(array $value, array $keys, $message = null, $pr
0,
$propertyPath,
$value,
- ['expected' => $keys, 'actual' => $keysOfValue]
+ ['expected' => $keys, 'actual' => $keysOfValue],
);
}
- public static function requiredAndOptionalOptions(array $value, array $required, array $optional, $message = null, $propertyPath = null)
- {
+ public static function requiredAndOptionalOptions(
+ array $value,
+ array $required,
+ array $optional,
+ ?string $message = null,
+ ?string $propertyPath = null,
+ ): void {
// Filter out the optional items from the value array
$requiredValueSet = array_diff_key($value, array_flip($optional));
@@ -53,7 +62,7 @@ public static function requiredAndOptionalOptions(array $value, array $required,
$keysOfValue = array_keys($value);
$extraKeys = array_diff($keysOfValue, array_merge($optional, $required));
- if (count($extraKeys) === 0) {
+ if ($extraKeys === []) {
return;
}
@@ -62,7 +71,7 @@ public static function requiredAndOptionalOptions(array $value, array $required,
0,
$propertyPath,
$value,
- ['expected' => $optional, 'actual' => $keysOfValue]
+ ['expected' => $optional, 'actual' => $keysOfValue],
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ConfigurationStructureValidator.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ConfigurationStructureValidator.php
index 7809ac6ea..9d9d38cb3 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ConfigurationStructureValidator.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ConfigurationStructureValidator.php
@@ -19,12 +19,15 @@
namespace Surfnet\StepupMiddleware\ManagementBundle\Validator;
use Assert\Assertion;
+use Assert\AssertionFailedException;
use Assert\InvalidArgumentException as AssertionException;
use InvalidArgumentException as CoreInvalidArgumentException;
use Surfnet\Stepup\Helper\JsonHelper;
use Surfnet\StepupMiddleware\ManagementBundle\Validator\Assert as StepupAssert;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
+use Symfony\Component\Validator\Violation\ConstraintViolationBuilder;
+use TypeError;
/**
* Once the Assert 2.0 library has been built this should be converted to the lazy assertions so we can report
@@ -32,27 +35,15 @@
*/
class ConfigurationStructureValidator extends ConstraintValidator
{
- /**
- * @var GatewayConfigurationValidator
- */
- private $gatewayConfigurationValidator;
-
- /**
- * @var EmailTemplatesConfigurationValidator
- */
- private $emailTemplatesConfigurationValidator;
-
public function __construct(
- GatewayConfigurationValidator $gatewayConfigurationValidator,
- EmailTemplatesConfigurationValidator $emailTemplatesConfigurationValidator
+ private readonly GatewayConfigurationValidator $gatewayConfigurationValidator,
+ private readonly EmailTemplatesConfigurationValidator $emailTemplatesConfigurationValidator,
) {
- $this->gatewayConfigurationValidator = $gatewayConfigurationValidator;
- $this->emailTemplatesConfigurationValidator = $emailTemplatesConfigurationValidator;
}
- public function validate($value, Constraint $constraint)
+ public function validate(mixed $value, Constraint $constraint): void
{
- /** @var \Symfony\Component\Validator\Violation\ConstraintViolationBuilder|false $violation */
+ /** @var ConstraintViolationBuilder|false $violation */
$violation = false;
try {
@@ -62,7 +53,7 @@ public function validate($value, Constraint $constraint)
// method is not in the interface yet, but the old method is deprecated.
$violation = $this->context->buildViolation($exception->getMessage());
$violation->atPath($exception->getPropertyPath());
- } catch (CoreInvalidArgumentException $exception) {
+ } catch (CoreInvalidArgumentException|TypeError $exception) {
$violation = $this->context->buildViolation($exception->getMessage());
}
@@ -72,21 +63,19 @@ public function validate($value, Constraint $constraint)
}
}
- private function decodeJson($rawValue)
+ private function decodeJson(string $rawValue): mixed
{
return JsonHelper::decode($rawValue);
}
- public function validateRoot($configuration)
+ public function validateRoot(array $configuration): void
{
- Assertion::isArray($configuration, 'Invalid body structure, must be an object', '(root)');
-
$acceptedProperties = ['gateway', 'sraa', 'email_templates'];
StepupAssert::keysMatch(
$configuration,
$acceptedProperties,
- sprintf("Expected only properties '%s'", join(',', $acceptedProperties)),
- '(root)'
+ sprintf("Expected only properties '%s'", implode(',', $acceptedProperties)),
+ '(root)',
);
$this->validateGatewayConfiguration($configuration, 'gateway');
@@ -94,36 +83,40 @@ public function validateRoot($configuration)
$this->validateEmailTemplatesConfiguration($configuration, 'email_templates');
}
- private function validateGatewayConfiguration($configuration, $propertyPath)
+ private function validateGatewayConfiguration(array $configuration, string $propertyPath): void
{
Assertion::isArray($configuration['gateway'], 'Property "gateway" must have an object as value', $propertyPath);
$this->gatewayConfigurationValidator->validate($configuration['gateway'], $propertyPath);
}
- private function validateSraaConfiguration($configuration, $propertyPath)
+ private function validateSraaConfiguration(array $configuration, string $propertyPath): void
{
Assertion::isArray(
$configuration['sraa'],
'Property sraa must have an array of name_ids (string) as value',
- $propertyPath
+ $propertyPath,
);
foreach ($configuration['sraa'] as $index => $value) {
Assertion::string(
$value,
'value must be a string (the name_id of the SRAA)',
- $propertyPath . '[' . $index. ']'
+ $propertyPath . '[' . $index . ']',
);
}
}
- private function validateEmailTemplatesConfiguration($configuration, $propertyPath)
+ /**
+ * @param array $configuration
+ * @throws AssertionFailedException
+ */
+ private function validateEmailTemplatesConfiguration(array $configuration, string $propertyPath): void
{
Assertion::isArray(
$configuration['email_templates'],
'Property "email_templates" must have an object as value',
- $propertyPath
+ $propertyPath,
);
$this->emailTemplatesConfigurationValidator->validate($configuration['email_templates'], $propertyPath);
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ConfigurationValidatorInterface.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ConfigurationValidatorInterface.php
index d9c641c12..c85b43277 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ConfigurationValidatorInterface.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ConfigurationValidatorInterface.php
@@ -18,13 +18,13 @@
namespace Surfnet\StepupMiddleware\ManagementBundle\Validator;
+use Assert\InvalidArgumentException;
+
interface ConfigurationValidatorInterface
{
/**
- * @param array $configuration
- * @param string $propertyPath
- * @return void
- * @throws \Assert\InvalidArgumentException
+ * @param array $configuration
+ * @throws InvalidArgumentException
*/
- public function validate(array $configuration, $propertyPath);
+ public function validate(array $configuration, string $propertyPath): void;
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/Constraints/HasValidConfigurationStructure.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/Constraints/HasValidConfigurationStructure.php
index 33c90308b..1dc578658 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/Constraints/HasValidConfigurationStructure.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/Constraints/HasValidConfigurationStructure.php
@@ -1,5 +1,6 @@
requiredLocale = $requiredLocale;
}
- public function validate(array $configuration, $propertyPath)
+ /**
+ * @param array $configuration
+ * @throws \Assert\AssertionFailedException
+ */
+ public function validate(array $configuration, string $propertyPath): void
{
$templateNames = [
'confirm_email',
@@ -58,15 +59,15 @@ public function validate(array $configuration, $propertyPath)
StepupAssert::keysMatch(
$configuration,
$templateNames,
- sprintf("Expected only templates '%s'", join(',', $templateNames)),
- $propertyPath
+ sprintf("Expected only templates '%s'", implode(',', $templateNames)),
+ $propertyPath,
);
foreach ($templateNames as $templateName) {
Assertion::isArray(
$configuration[$templateName],
'Property "' . $templateName . '" must have an object as value',
- $propertyPath
+ $propertyPath,
);
$templatePropertyPath = $propertyPath . '.' . $templateName;
@@ -75,7 +76,7 @@ public function validate(array $configuration, $propertyPath)
$configuration[$templateName],
$this->requiredLocale,
"Required property '" . $this->requiredLocale . "' is missing",
- $templatePropertyPath
+ $templatePropertyPath,
);
foreach ($configuration[$templateName] as $locale => $template) {
@@ -83,12 +84,12 @@ public function validate(array $configuration, $propertyPath)
Assertion::string(
$locale,
'Locale must be string',
- $localePropertyPath
+ $localePropertyPath,
);
Assertion::string(
$template,
"Property '" . $this->requiredLocale . "' must have a string as value",
- $localePropertyPath
+ $localePropertyPath,
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/GatewayConfigurationValidator.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/GatewayConfigurationValidator.php
index f49f47a39..f590135d5 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/GatewayConfigurationValidator.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/GatewayConfigurationValidator.php
@@ -19,59 +19,45 @@
namespace Surfnet\StepupMiddleware\ManagementBundle\Validator;
use Assert\Assertion;
+use Assert\AssertionFailedException;
use Surfnet\StepupMiddleware\ManagementBundle\Validator\Assert as StepupAssert;
class GatewayConfigurationValidator implements ConfigurationValidatorInterface
{
- /**
- * @var \Surfnet\StepupMiddleware\ManagementBundle\Validator\IdentityProviderConfigurationValidator
- */
- private $identityProviderConfigurationValidator;
-
- /**
- * @var \Surfnet\StepupMiddleware\ManagementBundle\Validator\ServiceProviderConfigurationValidator
- */
- private $serviceProviderConfigurationValidator;
-
public function __construct(
- IdentityProviderConfigurationValidator $identityProviderConfigurationValidator,
- ServiceProviderConfigurationValidator $serviceProviderConfigurationValidator
+ private readonly IdentityProviderConfigurationValidator $identityProviderConfigurationValidator,
+ private readonly ServiceProviderConfigurationValidator $serviceProviderConfigurationValidator,
) {
- $this->identityProviderConfigurationValidator = $identityProviderConfigurationValidator;
- $this->serviceProviderConfigurationValidator = $serviceProviderConfigurationValidator;
}
/**
- * @param array $gatewayConfiguration
- * @param string $propertyPath
+ * @param array $configuration
*/
- public function validate(array $gatewayConfiguration, $propertyPath)
+ public function validate(array $configuration, string $propertyPath): void
{
StepupAssert::keysMatch(
- $gatewayConfiguration,
+ $configuration,
['service_providers', 'identity_providers'],
"Expected properties 'service_providers' and 'identity_providers'",
- $propertyPath
+ $propertyPath,
);
$this->validateIdentityProviders(
- $gatewayConfiguration['identity_providers'],
- $propertyPath . '.identity_providers'
+ $configuration['identity_providers'],
+ $propertyPath . '.identity_providers',
);
$this->validateServiceProviders(
- $gatewayConfiguration['service_providers'],
- $propertyPath . '.service_providers'
+ $configuration['service_providers'],
+ $propertyPath . '.service_providers',
);
}
- private function validateIdentityProviders($identityProviders, $propertyPath)
+ /**
+ * @param array> $identityProviders
+ * @throws AssertionFailedException
+ */
+ private function validateIdentityProviders(array $identityProviders, string $propertyPath): void
{
- Assertion::isArray(
- $identityProviders,
- 'identity_providers must have an array of identity provider configurations as value',
- $propertyPath
- );
-
foreach ($identityProviders as $index => $identityProvider) {
$path = $propertyPath . '[' . $index . ']';
Assertion::isArray($identityProvider, 'Identity provider must be an object', $path);
@@ -80,17 +66,16 @@ private function validateIdentityProviders($identityProviders, $propertyPath)
}
}
- private function validateServiceProviders($serviceProviders, $propertyPath)
+ /**
+ * @param array> $serviceProviders
+ * @throws AssertionFailedException
+ */
+ private function validateServiceProviders(array $serviceProviders, string $propertyPath): void
{
- Assertion::isArray(
- $serviceProviders,
- 'service_providers must have an array of service provider configurations as value',
- $propertyPath
- );
Assertion::true(
count($serviceProviders) >= 1,
'at least one service_provider must be configured',
- $propertyPath
+ $propertyPath,
);
foreach ($serviceProviders as $index => $serviceProvider) {
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/IdentityProviderConfigurationValidator.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/IdentityProviderConfigurationValidator.php
index 51bb47326..223127820 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/IdentityProviderConfigurationValidator.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/IdentityProviderConfigurationValidator.php
@@ -23,14 +23,15 @@
class IdentityProviderConfigurationValidator implements ConfigurationValidatorInterface
{
- public function validate(array $configuration, $propertyPath)
+ /**
+ * @param array $configuration
+ */
+ public function validate(array $configuration, string $propertyPath): void
{
- Assertion::isArray($configuration, 'invalid configuration format, must be an object', $propertyPath);
-
$requiredProperties = [
'entity_id',
'loa',
- 'use_pdp'
+ 'use_pdp',
];
if (empty($configuration['use_pdp'])) {
@@ -42,9 +43,9 @@ public function validate(array $configuration, $propertyPath)
$requiredProperties,
sprintf(
"The following properties must be present: '%s'; other properties are not supported",
- join("', '", $requiredProperties)
+ implode("', '", $requiredProperties),
),
- $propertyPath
+ $propertyPath,
);
$this->validateStringValue($configuration, 'entity_id', $propertyPath);
@@ -52,37 +53,28 @@ public function validate(array $configuration, $propertyPath)
$this->validateBooleanValue($configuration, 'use_pdp', $propertyPath);
}
- /**
- * @param array $configuration
- * @param string $name
- * @param string $propertyPath
- */
- private function validateStringValue($configuration, $name, $propertyPath)
+ private function validateStringValue(array $configuration, string $name, string $propertyPath): void
{
Assertion::string($configuration[$name], 'value must be a string', $propertyPath . '.' . $name);
}
- /**
- * @param array $configuration
- * @param string $name
- * @param string $propertyPath
- */
- private function validateBooleanValue($configuration, $name, $propertyPath)
+ private function validateBooleanValue(array $configuration, string $name, string $propertyPath): void
{
Assertion::boolean($configuration[$name], 'value must be a boolean', $propertyPath . '.' . $name);
}
- /**
- * @param array $configuration
- * @param string $propertyPath
- */
- private function validateLoaDefinition($configuration, $propertyPath)
+ private function validateLoaDefinition(array $configuration, string $propertyPath): void
{
$value = $configuration['loa'];
- $path = $propertyPath . '.loa';
+ $path = $propertyPath . '.loa';
Assertion::isArray($value, 'must be an object', $path);
- Assertion::keyExists($value, '__default__', "must have the default loa set on the '__default__' property", $path);
+ Assertion::keyExists(
+ $value,
+ '__default__',
+ "must have the default loa set on the '__default__' property",
+ $path,
+ );
Assertion::allString($value, 'all properties must contain strings as values', $path);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ReconfigureInstitutionRequestValidator.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ReconfigureInstitutionRequestValidator.php
index bd3b9a97a..29c5e93c7 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ReconfigureInstitutionRequestValidator.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ReconfigureInstitutionRequestValidator.php
@@ -19,6 +19,7 @@
namespace Surfnet\StepupMiddleware\ManagementBundle\Validator;
use Assert\Assertion;
+use Assert\AssertionFailedException;
use Assert\InvalidArgumentException as AssertionException;
use InvalidArgumentException as CoreInvalidArgumentException;
use Surfnet\StepupBundle\Service\SecondFactorTypeService;
@@ -30,47 +31,33 @@
use Surfnet\StepupMiddleware\ManagementBundle\Validator\Assert as StepupAssert;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
+use Symfony\Component\Validator\Violation\ConstraintViolationBuilder;
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) Coupling to assertion classes is rather high, might be a good candidate for refactoring
+ */
final class ReconfigureInstitutionRequestValidator extends ConstraintValidator
{
- /**
- * @var ConfiguredInstitutionService
- */
- private $configuredInstitutionsService;
-
/**
* @var string[] internal cache, access through getConfiguredInstitutions()
*/
- private $configuredInstitutions;
-
- /**
- * @var SecondFactorTypeService
- */
- private $secondFactorTypeService;
-
- /**
- * @var WhitelistService
- */
- private $whitelistService;
+ private ?array $configuredInstitutions = null;
/**
* @var string[] internal cache, access through getWhitelistedInstitutions()
*/
- private $whitelistedInstitutions;
+ private ?array $whitelistedInstitutions = null;
public function __construct(
- ConfiguredInstitutionService $configuredInstitutionsService,
- SecondFactorTypeService $secondFactorTypeService,
- WhitelistService $whitelistService
+ private readonly ConfiguredInstitutionService $configuredInstitutionsService,
+ private readonly SecondFactorTypeService $secondFactorTypeService,
+ private readonly WhitelistService $whitelistService,
) {
- $this->configuredInstitutionsService = $configuredInstitutionsService;
- $this->secondFactorTypeService = $secondFactorTypeService;
- $this->whitelistService = $whitelistService;
}
- public function validate($value, Constraint $constraint)
+ public function validate(mixed $value, Constraint $constraint): void
{
- /** @var \Symfony\Component\Validator\Violation\ConstraintViolationBuilder|false $violation */
+ /** @var ConstraintViolationBuilder|false $violation */
$violation = false;
try {
@@ -88,9 +75,8 @@ public function validate($value, Constraint $constraint)
}
}
- public function validateRoot(array $configuration)
+ public function validateRoot(array $configuration): void
{
- Assertion::isArray($configuration, 'Invalid body structure, must be an object', '(root)');
$this->validateInstitutionsExist(array_keys($configuration));
foreach ($configuration as $institution => $options) {
@@ -98,26 +84,22 @@ public function validateRoot(array $configuration)
}
}
- /**
- * @param array $institutions
- */
- public function validateInstitutionsExist(array $institutions)
+ public function validateInstitutionsExist(array $institutions): void
{
$configuredInstitutions = $this->getConfiguredInstitutions();
$nonExistentInstitutions = $this->determineNonExistentInstitutions($institutions, $configuredInstitutions);
- if (!empty($nonExistentInstitutions)) {
+ if ($nonExistentInstitutions !== []) {
throw new InvalidArgumentException(
- sprintf('Cannot reconfigure non-existent institution(s): %s', implode(', ', $nonExistentInstitutions))
+ sprintf('Cannot reconfigure non-existent institution(s): %s', implode(', ', $nonExistentInstitutions)),
);
}
}
- public function validateInstitutionConfigurationOptions(array $options, string $institution)
+ public function validateInstitutionConfigurationOptions(array $options, string $institution): void
{
$propertyPath = sprintf('Institution(%s)', $institution);
- Assertion::isArray($options, 'Invalid institution configuration, must be an object', $propertyPath);
$requiredOptions = [
'use_ra_locations',
'show_raa_contact_information',
@@ -140,73 +122,73 @@ public function validateInstitutionConfigurationOptions(array $options, string $
sprintf(
'Invalid option(s) for "%s". Required options: "%s"; Optional options: "%s"',
$institution,
- join(', ', $requiredOptions),
- join(', ', $optionalOptions)
+ implode(', ', $requiredOptions),
+ implode(', ', $optionalOptions),
),
- $propertyPath
+ $propertyPath,
);
Assertion::boolean(
$options['use_ra_locations'],
sprintf('Option "use_ra_locations" for "%s" must be a boolean value', $institution),
- $propertyPath
+ $propertyPath,
);
Assertion::boolean(
$options['show_raa_contact_information'],
sprintf('Option "show_raa_contact_information" for "%s" must be a boolean value', $institution),
- $propertyPath
+ $propertyPath,
);
Assertion::boolean(
$options['verify_email'],
sprintf('Option "verify_email" for "%s" must be a boolean value', $institution),
- $propertyPath
+ $propertyPath,
);
if (isset($options['self_vet'])) {
Assertion::boolean(
$options['self_vet'],
sprintf('Option "self_vet" for "%s" must be a boolean value', $institution),
- $propertyPath
+ $propertyPath,
);
}
if (isset($options['sso_on_2fa'])) {
Assertion::boolean(
$options['sso_on_2fa'],
sprintf('Option "sso_on_2fa" for "%s" must be a boolean value', $institution),
- $propertyPath
+ $propertyPath,
);
}
if (isset($options['allow_self_asserted_tokens'])) {
Assertion::nullOrBoolean(
$options['allow_self_asserted_tokens'],
sprintf('Option "allow_self_asserted_tokens" for "%s" must be a boolean value', $institution),
- $propertyPath
+ $propertyPath,
);
}
Assertion::integer(
$options['number_of_tokens_per_identity'],
sprintf('Option "number_of_tokens_per_identity" for "%s" must be an integer value', $institution),
- $propertyPath
+ $propertyPath,
);
Assertion::min(
$options['number_of_tokens_per_identity'],
0,
sprintf('Option "number_of_tokens_per_identity" for "%s" must be greater than or equal to 0', $institution),
- $propertyPath
+ $propertyPath,
);
Assertion::isArray(
$options['allowed_second_factors'],
sprintf('Option "allowed_second_factors" for "%s" must be an array of strings', $institution),
- $propertyPath
+ $propertyPath,
);
Assertion::allString(
$options['allowed_second_factors'],
sprintf('Option "allowed_second_factors" for "%s" must be an array of strings', $institution),
- $propertyPath
+ $propertyPath,
);
Assertion::allInArray(
$options['allowed_second_factors'],
$this->secondFactorTypeService->getAvailableSecondFactorTypes(),
'Option "allowed_second_factors" for "%s" must contain valid second factor types',
- $propertyPath
+ $propertyPath,
);
$this->validateAuthorizationSettings($options, $institution, $propertyPath);
}
@@ -216,17 +198,15 @@ public function validateInstitutionConfigurationOptions(array $options, string $
*
* @return string[]
*/
- private function getConfiguredInstitutions()
+ private function getConfiguredInstitutions(): array
{
- if (!empty($this->configuredInstitutions)) {
+ if ($this->configuredInstitutions !== null && $this->configuredInstitutions !== []) {
return $this->configuredInstitutions;
}
$this->configuredInstitutions = array_map(
- function (ConfiguredInstitution $configuredInstitution) {
- return $configuredInstitution->institution->getInstitution();
- },
- $this->configuredInstitutionsService->getAll()
+ fn(ConfiguredInstitution $configuredInstitution): string => $configuredInstitution->institution->getInstitution(),
+ $this->configuredInstitutionsService->getAll(),
);
return $this->configuredInstitutions;
@@ -237,17 +217,15 @@ function (ConfiguredInstitution $configuredInstitution) {
*
* @return string[]
*/
- private function getWhitelistedInstitutions()
+ private function getWhitelistedInstitutions(): array
{
- if (!empty($this->whitelistedInstitutions)) {
+ if ($this->whitelistedInstitutions !== null && $this->whitelistedInstitutions !== []) {
return $this->whitelistedInstitutions;
}
$this->whitelistedInstitutions = array_map(
- function (WhitelistEntry $whitelistEntry) {
- return (string)$whitelistEntry->institution;
- },
- $this->whitelistService->getAllEntries()->toArray()
+ fn(WhitelistEntry $whitelistEntry): string => (string)$whitelistEntry->institution,
+ $this->whitelistService->getAllEntries()->toArray(),
);
return $this->whitelistedInstitutions;
@@ -255,25 +233,23 @@ function (WhitelistEntry $whitelistEntry) {
/**
* @param string[] $institutions
- * @param $configuredInstitutions
+ * @param string[] $configuredInstitutions
* @return string[]
*/
- public function determineNonExistentInstitutions(array $institutions, $configuredInstitutions)
+ public function determineNonExistentInstitutions(array $institutions, array $configuredInstitutions): array
{
$normalizedConfiguredInstitutions = array_map(
- function ($institution) {
- return strtolower($institution);
- },
- $configuredInstitutions
+ fn($institution): string => strtolower((string)$institution),
+ $configuredInstitutions,
);
return array_filter(
$institutions,
- function ($institution) use ($normalizedConfiguredInstitutions) {
+ function ($institution) use ($normalizedConfiguredInstitutions): bool {
$normalizedInstitution = strtolower($institution);
return !in_array($normalizedInstitution, $normalizedConfiguredInstitutions);
- }
+ },
);
}
@@ -283,13 +259,13 @@ function ($institution) use ($normalizedConfiguredInstitutions) {
* - The optional options should contain whitelisted institutions
* - Or be empty
*
- * @param $authorizationSettings
- * @param $institution
- * @param $propertyPath
- * @throws \Assert\AssertionFailedException
+ * @throws AssertionFailedException
*/
- private function validateAuthorizationSettings($authorizationSettings, $institution, $propertyPath)
- {
+ private function validateAuthorizationSettings(
+ array $authorizationSettings,
+ string $institution,
+ string $propertyPath,
+ ): void {
$acceptedOptions = [
'use_ra',
'use_raa',
@@ -302,26 +278,26 @@ private function validateAuthorizationSettings($authorizationSettings, $institut
if (in_array($optionName, $acceptedOptions)) {
// 1. Value must be array
Assertion::isArray(
- $authorizationSettings[$optionName],
+ $setting,
sprintf(
'Option "%s" for "%s" must be an array of strings. ("%s") was passed.',
$optionName,
$institution,
- var_export($setting, true)
+ var_export($setting, true),
),
- $propertyPath
+ $propertyPath,
);
// 2. The contents of the array must be empty or string
Assertion::allString(
- $authorizationSettings[$optionName],
+ $setting,
sprintf(
- 'All values of option "%s" should be of type string. ("%s") was passed.',
+ 'All values of option "%s" for "%s" should be of type string. ("%s") was passed.',
$optionName,
$institution,
- var_export($setting, true)
+ var_export($setting, true),
),
- $propertyPath
+ $propertyPath,
);
// 3. The institutions that are used in the configuration, should be known, configured, institutions
@@ -329,12 +305,12 @@ private function validateAuthorizationSettings($authorizationSettings, $institut
$authorizationSettings[$optionName],
$whitelistedInstitutions,
sprintf(
- 'All values of option "%s" should be known institutions. ("%s") was passed.',
+ 'All values of option "%s" for "%s" should be known institutions. ("%s") was passed.',
$optionName,
$institution,
- var_export($setting, true)
+ var_export($setting, true),
),
- $propertyPath
+ $propertyPath,
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ServiceProviderConfigurationValidator.php b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ServiceProviderConfigurationValidator.php
index 1f91d124c..3da30b8a0 100644
--- a/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ServiceProviderConfigurationValidator.php
+++ b/src/Surfnet/StepupMiddleware/ManagementBundle/Validator/ServiceProviderConfigurationValidator.php
@@ -23,10 +23,11 @@
class ServiceProviderConfigurationValidator implements ConfigurationValidatorInterface
{
- public function validate(array $configuration, $propertyPath)
+ /**
+ * @param array $configuration
+ */
+ public function validate(array $configuration, string $propertyPath): void
{
- Assertion::isArray($configuration, 'invalid configuration format, must be an object', $propertyPath);
-
$requiredProperties = [
'entity_id',
'public_key',
@@ -38,7 +39,7 @@ public function validate(array $configuration, $propertyPath)
'blacklisted_encryption_algorithms',
'use_pdp',
'allow_sso_on_2fa',
- 'set_sso_cookie_on_2fa'
+ 'set_sso_cookie_on_2fa',
];
if (empty($configuration['use_pdp'])) {
@@ -58,9 +59,9 @@ public function validate(array $configuration, $propertyPath)
$requiredProperties,
sprintf(
"The following properties must be present: '%s'; other properties are not supported",
- join("', '", $requiredProperties)
+ implode("', '", $requiredProperties),
),
- $propertyPath
+ $propertyPath,
);
$this->validateStringValue($configuration, 'entity_id', $propertyPath);
@@ -70,100 +71,77 @@ public function validate(array $configuration, $propertyPath)
$this->validateBooleanValue(
$configuration,
'assertion_encryption_enabled',
- $propertyPath
+ $propertyPath,
);
$this->validateBooleanValue(
$configuration,
'second_factor_only',
- $propertyPath
+ $propertyPath,
);
$this->validateListOfNameIdPatterns(
$configuration,
'second_factor_only_nameid_patterns',
- $propertyPath
+ $propertyPath,
);
$this->validateStringValues(
$configuration,
'blacklisted_encryption_algorithms',
- $propertyPath
+ $propertyPath,
);
$this->validateBooleanValue($configuration, 'use_pdp', $propertyPath);
$this->validateBooleanValue($configuration, 'allow_sso_on_2fa', $propertyPath);
$this->validateBooleanValue($configuration, 'set_sso_cookie_on_2fa', $propertyPath);
}
- /**
- * @param array $configuration
- * @param string $name
- * @param string $propertyPath
- */
- private function validateStringValue($configuration, $name, $propertyPath)
+ private function validateStringValue(array $configuration, string $name, string $propertyPath): void
{
Assertion::string($configuration[$name], 'value must be a string', $propertyPath . '.' . $name);
}
- /**
- * @param array $configuration
- * @param string $name
- * @param string $propertyPath
- */
- private function validateStringValues($configuration, $name, $propertyPath)
+ private function validateStringValues(array $configuration, string $name, string $propertyPath): void
{
Assertion::isArray($configuration[$name], 'value must be an array', $propertyPath . '.' . $name);
Assertion::allString($configuration[$name], 'value must be an array of strings', $propertyPath . '.' . $name);
}
- /**
- * @param array $configuration
- * @param string $name
- * @param string $propertyPath
- */
- private function validateBooleanValue($configuration, $name, $propertyPath)
+ private function validateBooleanValue(array $configuration, string $name, string $propertyPath): void
{
Assertion::boolean($configuration[$name], 'value must be a boolean', $propertyPath . '.' . $name);
}
- /**
- * @param array $configuration
- * @param string $propertyPath
- */
- private function validateAssertionConsumerUrls($configuration, $propertyPath)
+ private function validateAssertionConsumerUrls(array $configuration, string $propertyPath): void
{
$value = $configuration['acs'];
- $propertyPath = $propertyPath . '.acs';
+ $propertyPath .= '.acs';
Assertion::isArray($value, 'must contain a non-empty array of strings', $propertyPath);
Assertion::true(count($value) >= 1, 'array must contain at least one value', $propertyPath);
Assertion::allString($value, 'must be an array of strings', $propertyPath);
}
- /**
- * @param array $configuration
- * @param string $propertyPath
- */
- private function validateLoaDefinition($configuration, $propertyPath)
+ private function validateLoaDefinition(array $configuration, string $propertyPath): void
{
$value = $configuration['loa'];
- $path = $propertyPath . '.loa';
+ $path = $propertyPath . '.loa';
Assertion::isArray($value, 'must be an object', $path);
- Assertion::keyExists($value, '__default__', "must have the default loa set on the '__default__' property", $path);
+ Assertion::keyExists(
+ $value,
+ '__default__',
+ "must have the default loa set on the '__default__' property",
+ $path,
+ );
Assertion::allString($value, 'all properties must contain strings as values', $path);
// Test if all SP specific LoA configuration entries are lower case.
$this->assertValidInstitutionIdentifiers(
$value,
'The shacHomeOrganisation names in SP LoA configuration must all be lower case',
- $path
+ $path,
);
}
- /**
- * @param array $configuration
- * @param string $name
- * @param string $propertyPath
- */
- private function validateListOfNameIdPatterns($configuration, $name, $propertyPath)
+ private function validateListOfNameIdPatterns(array $configuration, string $name, string $propertyPath): void
{
$value = $configuration[$name];
$propertyPath = $propertyPath . '.' . $name;
@@ -182,15 +160,13 @@ private function validateListOfNameIdPatterns($configuration, $name, $propertyPa
* 'My.Institution' => 'loa2', // invalid
* ]
*
- * @param array $spLoaConfiguration
- * @param string $message
- * @param $propertyPath
*/
- private function assertValidInstitutionIdentifiers(array $spLoaConfiguration, $message, $propertyPath)
- {
- $assertLowerCase = function ($sho) {
- return ($sho === strtolower($sho));
- };
+ private function assertValidInstitutionIdentifiers(
+ array $spLoaConfiguration,
+ string $message,
+ string $propertyPath,
+ ): void {
+ $assertLowerCase = fn($sho): bool => $sho === strtolower((string)$sho);
// The array keys match the institution name / SHO.
$lowerCaseTestResults = array_map($assertLowerCase, array_keys($spLoaConfiguration));
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapGsspSecondFactorCommand.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapGsspSecondFactorCommand.php
index 814d8354d..c757b4608 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapGsspSecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapGsspSecondFactorCommand.php
@@ -19,7 +19,7 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command;
use Exception;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService;
@@ -28,27 +28,17 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
final class BootstrapGsspSecondFactorCommand extends Command
{
- /**
- * @var BootstrapCommandService
- */
- private $bootstrapService;
- /**
- * @var TransactionHelper
- */
- private $transactionHelper;
-
- public function __construct(BootstrapCommandService $bootstrapService, TransactionHelper $transactionHelper)
- {
- $this->bootstrapService = $bootstrapService;
- $this->transactionHelper = $transactionHelper;
+ public function __construct(
+ private readonly BootstrapCommandService $bootstrapService,
+ private readonly TransactionHelper $transactionHelper,
+ ) {
parent::__construct();
}
- protected function configure()
+ protected function configure(): void
{
$this
->setDescription('Creates a Generic SAML Second Factor (GSSF) second factor for a specified user')
@@ -57,29 +47,30 @@ protected function configure()
->addArgument(
'gssp-token-type',
InputArgument::REQUIRED,
- 'The GSSP token type as defined in the GSSP config, for example tiqr or webauthn'
+ 'The GSSP token type as defined in the GSSP config, for example tiqr or webauthn',
)
->addArgument(
'gssp-token-identifier',
InputArgument::REQUIRED,
- 'The identifier of the token as registered at the GSSP'
+ 'The identifier of the token as registered at the GSSP',
)
->addArgument(
'registration-status',
InputArgument::REQUIRED,
- 'Valid arguments: unverified, verified, vetted'
+ 'Valid arguments: unverified, verified, vetted',
)
->addArgument('actor-id', InputArgument::REQUIRED, 'The id of the vetting actor');
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ /**
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength) Method length could be reduced by deconstructing the bootstrapping
+ * of the required data and the vetting of the GSSP
+ */
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$registrationStatus = $input->getArgument('registration-status');
$this->bootstrapService->validRegistrationStatus($registrationStatus);
- $this->bootstrapService->setToken(
- new AnonymousToken('cli.bootstrap-gssp-token', 'cli', ['ROLE_SS', 'ROLE_RA'])
- );
$nameId = new NameId($input->getArgument('name-id'));
$institutionText = $input->getArgument('institution');
$institution = new Institution($institutionText);
@@ -93,14 +84,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
sprintf(
'An identity with name ID "%s" from institution "%s" does not exist, create it first.',
$nameId->getNameId(),
- $institution->getInstitution()
- )
+ $institution->getInstitution(),
+ ),
);
- return;
+ return 1;
}
$identity = $this->bootstrapService->getIdentity($nameId, $institution);
- $output->writeln(sprintf('Adding a %s %s GSSP token for %s', $registrationStatus, $tokenType, $identity->commonName));
+ $output->writeln(
+ sprintf(
+ 'Adding a %s %s GSSP token for %s',
+ $registrationStatus,
+ $tokenType,
+ $identity->commonName,
+ ),
+ );
$this->transactionHelper->beginTransaction();
$secondFactorId = Uuid::uuid4()->toString();
@@ -108,11 +106,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
switch ($registrationStatus) {
case "unverified":
$output->writeln(sprintf('Creating an unverified %s token', $tokenType));
- $this->bootstrapService->proveGsspPossession($secondFactorId, $identity, $tokenType, $tokenIdentifier);
+ $this->bootstrapService->proveGsspPossession(
+ $secondFactorId,
+ $identity,
+ $tokenType,
+ $tokenIdentifier,
+ );
break;
case "verified":
$output->writeln(sprintf('Creating an unverified %s token', $tokenType));
- $this->bootstrapService->proveGsspPossession($secondFactorId, $identity, $tokenType, $tokenIdentifier);
+ $this->bootstrapService->proveGsspPossession(
+ $secondFactorId,
+ $identity,
+ $tokenType,
+ $tokenIdentifier,
+ );
if ($mailVerificationRequired) {
$output->writeln(sprintf('Creating an verified %s token', $tokenType));
$this->bootstrapService->verifyEmail($identity, $tokenType);
@@ -120,7 +128,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
break;
case "vetted":
$output->writeln(sprintf('Creating an unverified %s token', $tokenType));
- $this->bootstrapService->proveGsspPossession($secondFactorId, $identity, $tokenType, $tokenIdentifier);
+ $this->bootstrapService->proveGsspPossession(
+ $secondFactorId,
+ $identity,
+ $tokenType,
+ $tokenIdentifier,
+ );
if ($mailVerificationRequired) {
$output->writeln(sprintf('Creating an verified %s token', $tokenType));
$this->bootstrapService->verifyEmail($identity, $tokenType);
@@ -131,7 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$actorId,
$identity,
$secondFactorId,
- $tokenIdentifier
+ $tokenIdentifier,
);
break;
}
@@ -141,19 +154,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
sprintf(
'An Error occurred when trying to bootstrap the %s token: "%s"',
$tokenType,
- $e->getMessage()
- )
+ $e->getMessage(),
+ ),
);
$this->transactionHelper->rollback();
- throw $e;
+ return 1;
}
$output->writeln(
sprintf(
'Successfully %s %s second factor with UUID %s',
$registrationStatus,
$tokenType,
- $secondFactorId
- )
+ $secondFactorId,
+ ),
);
+ return 0;
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapIdentityCommand.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapIdentityCommand.php
index 09f1caf0a..7b8b7e0b6 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapIdentityCommand.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapIdentityCommand.php
@@ -27,27 +27,17 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
final class BootstrapIdentityCommand extends Command
{
- /**
- * @var BootstrapCommandService
- */
- private $bootstrapService;
- /**
- * @var TransactionHelper
- */
- private $transactionHelper;
-
- public function __construct(BootstrapCommandService $bootstrapService, TransactionHelper $transactionHelper)
- {
- $this->bootstrapService = $bootstrapService;
- $this->transactionHelper = $transactionHelper;
+ public function __construct(
+ private readonly BootstrapCommandService $bootstrapService,
+ private readonly TransactionHelper $transactionHelper,
+ ) {
parent::__construct();
}
- protected function configure()
+ protected function configure(): void
{
$this
->setDescription('Creates an identity')
@@ -59,12 +49,8 @@ protected function configure()
->addArgument('actor-id', InputArgument::REQUIRED, 'The id of the vetting actor');
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
- $this->bootstrapService->setToken(
- new AnonymousToken('cli.bootstrap-identity-with-sms-token', 'cli', ['ROLE_SS'])
- );
-
$nameId = new NameId($input->getArgument('name-id'));
$institutionText = $input->getArgument('institution');
$institution = new Institution($institutionText);
@@ -81,28 +67,36 @@ protected function execute(InputInterface $input, OutputInterface $output)
sprintf(
'An identity with name ID "%s" from institution "%s" already exists',
$nameId->getNameId(),
- $institution->getInstitution()
- )
+ $institution->getInstitution(),
+ ),
);
- return;
+ return 1;
}
try {
$this->transactionHelper->beginTransaction();
$output->writeln('Creating a new identity');
- $identity = $this->bootstrapService->createIdentity($institution, $nameId, $commonName, $email, $preferredLocale);
+ $identity = $this->bootstrapService->createIdentity(
+ $institution,
+ $nameId,
+ $commonName,
+ $email,
+ $preferredLocale,
+ );
$this->transactionHelper->finishTransaction();
} catch (Exception $e) {
$output->writeln(
sprintf(
'An Error occurred when trying to bootstrap the identity: "%s"',
- $e->getMessage()
- )
+ $e->getMessage(),
+ ),
);
$this->transactionHelper->rollback();
- throw $e;
+ return 1;
}
$output->writeln(
- sprintf('Successfully created identity with UUID %s', $identity->id)
+ sprintf('Successfully created identity with UUID %s', $identity->id),
);
+
+ return 0;
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapIdentityWithYubikeySecondFactorCommand.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapIdentityWithYubikeySecondFactorCommand.php
index 14b746717..8226fc65d 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapIdentityWithYubikeySecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapIdentityWithYubikeySecondFactorCommand.php
@@ -18,44 +18,29 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command;
-use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Exception;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\BootstrapIdentityWithYubikeySecondFactorCommand
as BootstrapIdentityWithYubikeySecondFactorIdentityCommand;
-use Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService;
use Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
final class BootstrapIdentityWithYubikeySecondFactorCommand extends Command
{
- /** @var BootstrapCommandService */
- private $bootstrapService;
+ protected static $defaultName = 'middleware:bootstrap:identity-with-yubikey';
- /**
- * @var TransactionHelper
- */
- private $transactionHelper;
-
- /**
- * @var IdentityRepository
- */
- private $projectionRepository;
-
- protected function configure()
+ protected function configure(): void
{
$this
- ->setName('middleware:bootstrap:identity-with-yubikey')
->setDescription('Creates an identity with a vetted Yubikey second factor')
->addArgument('name-id', InputArgument::REQUIRED, 'The NameID of the identity to create')
->addArgument('institution', InputArgument::REQUIRED, 'The institution of the identity to create')
@@ -65,28 +50,20 @@ protected function configure()
->addArgument(
'yubikey',
InputArgument::REQUIRED,
- 'The public ID of the Yubikey. Remove the last 32 characters of a Yubikey OTP to acquire this.'
+ 'The public ID of the Yubikey. Remove the last 32 characters of a Yubikey OTP to acquire this.',
);
}
public function __construct(
- BootstrapCommandService $bootstrapService,
- ServiceEntityRepository $projectionRepository,
- TransactionHelper $transactionHelper
+ private readonly IdentityRepository $projectionRepository,
+ private readonly TransactionHelper $transactionHelper,
) {
parent::__construct();
- $this->bootstrapService = $bootstrapService;
- $this->projectionRepository = $projectionRepository;
- $this->transactionHelper = $transactionHelper;
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
- $this->bootstrapService->setToken(
- new AnonymousToken('cli.bootstrap-yubikey-token', 'cli', ['ROLE_SS', 'ROLE_RA', 'ROLE_MANAGEMENT'])
- );
-
- $nameId = new NameId($input->getArgument('name-id'));
+ $nameId = new NameId($input->getArgument('name-id'));
$institution = new Institution($input->getArgument('institution'));
if ($this->projectionRepository->hasIdentityWithNameIdAndInstitution($nameId, $institution)) {
@@ -94,22 +71,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
sprintf(
'An identity with name ID "%s" from institution "%s" already exists',
$nameId->getNameId(),
- $institution->getInstitution()
- )
+ $institution->getInstitution(),
+ ),
);
return 1;
}
- $command = new BootstrapIdentityWithYubikeySecondFactorIdentityCommand();
- $command->UUID = (string) Uuid::uuid4();
- $command->identityId = (string) Uuid::uuid4();
- $command->nameId = $input->getArgument('name-id');
- $command->institution = $input->getArgument('institution');
- $command->commonName = $input->getArgument('common-name');
- $command->email = $input->getArgument('email');
+ $command = new BootstrapIdentityWithYubikeySecondFactorIdentityCommand();
+ $command->UUID = (string)Uuid::uuid4();
+ $command->identityId = (string)Uuid::uuid4();
+ $command->nameId = $input->getArgument('name-id');
+ $command->institution = $input->getArgument('institution');
+ $command->commonName = $input->getArgument('common-name');
+ $command->email = $input->getArgument('email');
$command->preferredLocale = $input->getArgument('preferred-locale');
- $command->secondFactorId = (string) Uuid::uuid4();
+ $secondFactorId = (string)Uuid::uuid4();
+ $command->secondFactorId = $secondFactorId;
$command->yubikeyPublicId = $input->getArgument('yubikey');
$this->transactionHelper->beginTransaction();
@@ -118,19 +96,24 @@ protected function execute(InputInterface $input, OutputInterface $output)
$command = $this->transactionHelper->process($command);
$this->transactionHelper->finishTransaction();
} catch (Exception $e) {
- $output->writeln(sprintf(
- 'An Error occurred when trying to bootstrap the token for identity: "%s"',
- $e->getMessage()
- ));
+ $output->writeln(
+ sprintf(
+ 'An Error occurred when trying to bootstrap the token for identity: "%s"',
+ $e->getMessage(),
+ ),
+ );
$this->transactionHelper->rollBack();
throw $e;
}
- $output->writeln(sprintf(
- 'Successfully registered a Yubikey token with UUID %s',
- $command->secondFactorId
- ));
+ $output->writeln(
+ sprintf(
+ 'Successfully registered a Yubikey token with UUID %s',
+ $secondFactorId,
+ ),
+ );
+ return 0;
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapSmsSecondFactorCommand.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapSmsSecondFactorCommand.php
index 3179785d4..b79000553 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapSmsSecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapSmsSecondFactorCommand.php
@@ -19,7 +19,7 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command;
use Exception;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService;
@@ -28,27 +28,17 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
final class BootstrapSmsSecondFactorCommand extends Command
{
- /**
- * @var BootstrapCommandService
- */
- private $bootstrapService;
- /**
- * @var TransactionHelper
- */
- private $transactionHelper;
-
- public function __construct(BootstrapCommandService $bootstrapService, TransactionHelper $transactionHelper)
- {
- $this->bootstrapService = $bootstrapService;
- $this->transactionHelper = $transactionHelper;
+ public function __construct(
+ private readonly BootstrapCommandService $bootstrapService,
+ private readonly TransactionHelper $transactionHelper,
+ ) {
parent::__construct();
}
- protected function configure()
+ protected function configure(): void
{
$this
->setDescription('Creates a SMS second factor for a specified user')
@@ -57,24 +47,21 @@ protected function configure()
->addArgument(
'phone-number',
InputArgument::REQUIRED,
- 'The phone number of the user should be formatted like "+31 (0) 612345678"'
+ 'The phone number of the user should be formatted like "+31 (0) 612345678"',
)
->addArgument(
'registration-status',
InputArgument::REQUIRED,
- 'Valid arguments: unverified, verified, vetted'
+ 'Valid arguments: unverified, verified, vetted',
)
->addArgument('actor-id', InputArgument::REQUIRED, 'The id of the vetting actor');
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$registrationStatus = $input->getArgument('registration-status');
$this->bootstrapService->validRegistrationStatus($registrationStatus);
- $this->bootstrapService->setToken(
- new AnonymousToken('cli.bootstrap-sms-token', 'cli', ['ROLE_SS', 'ROLE_RA'])
- );
$nameId = new NameId($input->getArgument('name-id'));
$institutionText = $input->getArgument('institution');
$institution = new Institution($institutionText);
@@ -87,14 +74,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
sprintf(
'An identity with name ID "%s" from institution "%s" does not exist, create it first.',
$nameId->getNameId(),
- $institution->getInstitution()
- )
+ $institution->getInstitution(),
+ ),
);
- return;
+ return 1;
}
$identity = $this->bootstrapService->getIdentity($nameId, $institution);
- $output->writeln(sprintf('Adding a %s SMS token for %s', $registrationStatus, $identity->commonName));
+ $output->writeln(
+ sprintf('Adding a %s SMS token for %s', $registrationStatus, $identity->commonName),
+ );
$this->transactionHelper->beginTransaction();
$secondFactorId = Uuid::uuid4()->toString();
@@ -125,7 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$actorId,
$identity,
$secondFactorId,
- $phoneNumber
+ $phoneNumber,
);
break;
}
@@ -134,17 +123,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(
sprintf(
'An Error occurred when trying to bootstrap the SMS token: "%s"',
- $e->getMessage()
- )
+ $e->getMessage(),
+ ),
);
$this->transactionHelper->rollback();
- throw $e;
+ return 1;
}
$output->writeln(
sprintf(
'Successfully registered a SMS token with UUID %s',
- $secondFactorId
- )
+ $secondFactorId,
+ ),
);
+ return 0;
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapYubikeySecondFactorCommand.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapYubikeySecondFactorCommand.php
index 61e6e525d..ee35cd331 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapYubikeySecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/BootstrapYubikeySecondFactorCommand.php
@@ -19,7 +19,7 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command;
use Exception;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService;
@@ -28,27 +28,17 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
final class BootstrapYubikeySecondFactorCommand extends Command
{
- /**
- * @var BootstrapCommandService
- */
- private $bootstrapService;
- /**
- * @var TransactionHelper
- */
- private $transactionHelper;
-
- public function __construct(BootstrapCommandService $bootstrapService, TransactionHelper $transactionHelper)
- {
- $this->bootstrapService = $bootstrapService;
- $this->transactionHelper = $transactionHelper;
+ public function __construct(
+ private readonly BootstrapCommandService $bootstrapService,
+ private readonly TransactionHelper $transactionHelper,
+ ) {
parent::__construct();
}
- protected function configure()
+ protected function configure(): void
{
$this
->setDescription('Creates a Yubikey second factor for a specified user')
@@ -57,24 +47,21 @@ protected function configure()
->addArgument(
'yubikey',
InputArgument::REQUIRED,
- 'The public ID of the Yubikey. Remove the last 32 characters of a Yubikey OTP to acquire this.'
+ 'The public ID of the Yubikey. Remove the last 32 characters of a Yubikey OTP to acquire this.',
)
->addArgument(
'registration-status',
InputArgument::REQUIRED,
- 'Valid arguments: unverified, verified, vetted'
+ 'Valid arguments: unverified, verified, vetted',
)
->addArgument('actor-id', InputArgument::REQUIRED, 'The id of the vetting actor');
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$registrationStatus = $input->getArgument('registration-status');
$this->bootstrapService->validRegistrationStatus($registrationStatus);
- $this->bootstrapService->setToken(
- new AnonymousToken('cli.bootstrap-yubikey-token', 'cli', ['ROLE_SS', 'ROLE_RA'])
- );
$nameId = new NameId($input->getArgument('name-id'));
$institutionText = $input->getArgument('institution');
$institution = new Institution($institutionText);
@@ -88,14 +75,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
sprintf(
'An identity with name ID "%s" from institution "%s" does not exist, create it first.',
$nameId->getNameId(),
- $institution->getInstitution()
- )
+ $institution->getInstitution(),
+ ),
);
- return;
+ return 1;
}
$identity = $this->bootstrapService->getIdentity($nameId, $institution);
- $output->writeln(sprintf('Adding a %s Yubikey token for %s', $registrationStatus, $identity->commonName));
+ $output->writeln(
+ sprintf('Adding a %s Yubikey token for %s', $registrationStatus, $identity->commonName),
+ );
$this->transactionHelper->beginTransaction();
$secondFactorId = Uuid::uuid4()->toString();
@@ -126,7 +115,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$actorId,
$identity,
$secondFactorId,
- $yubikey
+ $yubikey,
);
break;
}
@@ -135,17 +124,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(
sprintf(
'An Error occurred when trying to bootstrap the Yubikey token: "%s"',
- $e->getMessage()
- )
+ $e->getMessage(),
+ ),
);
$this->transactionHelper->rollback();
- throw $e;
+ return 1;
}
$output->writeln(
sprintf(
'Successfully registered a second factor with UUID %s',
- $secondFactorId
- )
+ $secondFactorId,
+ ),
);
+ return 0;
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/EmailVerifiedSecondFactorRemindersCommand.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/EmailVerifiedSecondFactorRemindersCommand.php
index 4650bd4a3..9f9b11964 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/EmailVerifiedSecondFactorRemindersCommand.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/EmailVerifiedSecondFactorRemindersCommand.php
@@ -24,7 +24,7 @@
use Exception;
use InvalidArgumentException;
use Psr\Log\LoggerInterface;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Identity\Command\SendVerifiedSecondFactorRemindersCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\TransactionAwarePipeline;
@@ -44,59 +44,36 @@
*/
final class EmailVerifiedSecondFactorRemindersCommand extends Command
{
- /**
- * @var TransactionAwarePipeline
- */
- private $pipeline;
+ protected static $defaultName = 'middleware:cron:email-reminder';
- /**
- * @var BufferedEventBus
- */
- private $eventBus;
-
- /**
- * @var DBALConnectionHelper
- */
- private $connection;
-
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- protected function configure()
+ protected function configure(): void
{
$this
- ->setName('middleware:cron:email-reminder')
->setDescription('Sends email reminders to identities with verified tokens more than 7 days old.')
->addOption(
'dry-run',
null,
InputOption::VALUE_NONE,
- 'Run in dry mode, not sending any email'
+ 'Run in dry mode, not sending any email',
)
->addOption(
'date',
null,
InputOption::VALUE_OPTIONAL,
- 'The date (Y-m-d) that should be used for sending reminder email messages, defaults to TODAY - 7'
+ 'The date (Y-m-d) that should be used for sending reminder email messages, defaults to TODAY - 7',
);
}
public function __construct(
- TransactionAwarePipeline $pipeline,
- BufferedEventBus $eventBus,
- DBALConnectionHelper $connection,
- LoggerInterface $logger
+ private readonly TransactionAwarePipeline $pipeline,
+ private readonly BufferedEventBus $eventBus,
+ private readonly DBALConnectionHelper $connection,
+ private readonly LoggerInterface $logger,
) {
- $this->pipeline = $pipeline;
- $this->eventBus = $eventBus;
- $this->connection = $connection;
- $this->logger = $logger;
parent::__construct();
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
try {
$this->validateInput($input);
@@ -109,7 +86,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
$date = new DateTime();
$date->sub(new DateInterval('P7D'));
if ($input->hasOption('date') && !is_null($input->getOption('date'))) {
- $date = DateTime::createFromFormat('Y-m-d', $input->getOption('date'));
+ $receivedDate = $input->getOption('date');
+ $date = DateTime::createFromFormat('Y-m-d', $receivedDate);
+ if ($date === false) {
+ $output->writeln(
+ sprintf(
+ 'Error processing the "date" option. Please review the received input: "%s" ',
+ $receivedDate
+ )
+ );
+ return 1;
+ }
}
$dryRun = false;
@@ -133,13 +120,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->connection->rollBack();
throw $e;
}
+ return 0;
}
- private function validateInput(InputInterface $input)
+ private function validateInput(InputInterface $input): void
{
if ($input->hasOption('date')) {
$date = $input->getOption('date');
- Assertion::nullOrDate($date, 'Y-m-d', 'Expected date to be a string and formatted in the Y-m-d date format');
+ Assertion::nullOrDate(
+ $date,
+ 'Y-m-d',
+ 'Expected date to be a string and formatted in the Y-m-d date format',
+ );
}
if ($input->hasOption('dry-run')) {
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/MigrateSecondFactorCommand.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/MigrateSecondFactorCommand.php
index a86eb44b6..66a6e148b 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/MigrateSecondFactorCommand.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/MigrateSecondFactorCommand.php
@@ -30,54 +30,39 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
-use function sprintf;
final class MigrateSecondFactorCommand extends Command
{
- /**
- * @var BootstrapCommandService
- */
- private $bootstrapService;
- /**
- * @var TransactionHelper
- */
- private $transactionHelper;
-
- public function __construct(BootstrapCommandService $bootstrapService, TransactionHelper $transactionHelper)
- {
- $this->bootstrapService = $bootstrapService;
- $this->transactionHelper = $transactionHelper;
+ public function __construct(
+ private readonly BootstrapCommandService $bootstrapService,
+ private readonly TransactionHelper $transactionHelper,
+ ) {
parent::__construct();
}
- protected function configure()
+ protected function configure(): void
{
$this
->setDescription('Migrates the tokens of an identity to a new institution while preserving the old tokens')
->addArgument(
'old-name-id',
InputArgument::REQUIRED,
- 'The old NameID of the identity used as the source of the tokens to move'
+ 'The old NameID of the identity used as the source of the tokens to move',
)
->addArgument(
'new-name-id',
InputArgument::REQUIRED,
- 'The new NameID of the identity to move the tokens to'
+ 'The new NameID of the identity to move the tokens to',
)
->addArgument('target-institution', InputArgument::OPTIONAL, 'The institution of the target identity')
->addArgument('email', InputArgument::OPTIONAL, 'The e-mail address of the identity to create');
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$sourceNameId = new NameId($input->getArgument('old-name-id'));
$targetNameId = new NameId($input->getArgument('new-name-id'));
- $this->bootstrapService->setToken(
- new AnonymousToken('cli.bootstrap-yubikey-token', 'cli', ['ROLE_SS', 'ROLE_RA'])
- );
-
$output->writeln(sprintf('Starting token migration for %s', $sourceNameId));
$sourceIdentity = $this->bootstrapService->getIdentityByNameId($sourceNameId);
$targetIdentity = $this->bootstrapService->getIdentityByNameId($targetNameId);
@@ -86,15 +71,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->transactionHelper->beginTransaction();
// Check if target identity should be created
- if ($targetIdentity === null) {
+ if (!$targetIdentity instanceof Identity) {
$output->writeln(
- sprintf('Target with NameID %s does not exist, creating new identity', $targetNameId)
+ sprintf('Target with NameID %s does not exist, creating new identity', $targetNameId),
);
$identityId = $this->createIdentity($targetNameId, $sourceIdentity, $input);
$output->writeln(
- sprintf('Successfully created identity with UUID %s', $identityId)
+ sprintf('Successfully created identity with UUID %s', $identityId),
);
@@ -109,7 +94,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->bootstrapService->migrateVettedSecondFactor($sourceIdentity, $targetIdentity, $secondFactor);
$output->writeln(sprintf('Moved token %s', $secondFactor->id));
} else {
- $output->writeln(sprintf('Skipped moving token %s, already present"', $secondFactor->id));
+ $output->writeln(
+ sprintf('Skipped moving token %s, already present"', $secondFactor->id),
+ );
}
}
@@ -118,24 +105,26 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(
sprintf(
'An Error occurred when trying to move the tokens of identity: "%s"',
- $e->getMessage()
- )
+ $e->getMessage(),
+ ),
);
$this->transactionHelper->rollback();
- throw $e;
+ return 1;
}
$output->writeln(
- sprintf('Successfully moved tokens from identity %s to identity %s', $sourceIdentity->id, $targetIdentity->id)
+ sprintf(
+ 'Successfully moved tokens from identity %s to identity %s',
+ $sourceIdentity->id,
+ $targetIdentity->id,
+ ),
);
+ return 0;
}
/**
- * @param NameId $targetNameId
- * @param Identity $sourceIdentity
- * @param InputInterface $input
* @return string
*/
- private function createIdentity(NameId $targetNameId, Identity $sourceIdentity, InputInterface $input)
+ private function createIdentity(NameId $targetNameId, Identity $sourceIdentity, InputInterface $input): string
{
$newInstitution = $input->getArgument('target-institution');
$newEmail = $input->getArgument('email');
@@ -150,7 +139,7 @@ private function createIdentity(NameId $targetNameId, Identity $sourceIdentity,
$targetNameId,
$sourceIdentity->commonName->getCommonName(),
$newEmail,
- $sourceIdentity->preferredLocale->getLocale()
+ $sourceIdentity->preferredLocale->getLocale(),
);
return $identity->id;
@@ -159,7 +148,7 @@ private function createIdentity(NameId $targetNameId, Identity $sourceIdentity,
private function tokenExists(array $targetSecondFactors, VettedSecondFactor $sourceSecondFactor): bool
{
foreach ($targetSecondFactors as $secondFactor) {
- if ($secondFactor->isEqual($secondFactor)) {
+ if ($secondFactor->isEqual($sourceSecondFactor)) {
return true;
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/ReplayEventsCommand.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/ReplayEventsCommand.php
index 854ad9fee..9ffd9648d 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/ReplayEventsCommand.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/ReplayEventsCommand.php
@@ -19,6 +19,7 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command;
use Surfnet\StepupMiddleware\MiddlewareBundle\Service\EventStreamReplayer;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\FormatterHelper;
use Symfony\Component\Console\Helper\QuestionHelper;
@@ -26,76 +27,70 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
-use Symfony\Component\HttpKernel\KernelInterface;
+#[AsCommand(
+ name: 'middleware:event:replay',
+ description: 'Wipes all read models and repopulates the tables from the event store. Use the
+ --no-interaction option to perform the event replay without the additional confirmation question.'
+)]
class ReplayEventsCommand extends Command
{
- /**
- * @var EventStreamReplayer
- */
- private $replayer;
-
- public function __construct(EventStreamReplayer $eventStreamReplayer)
- {
+ public function __construct(
+ private readonly EventStreamReplayer $replayer,
+ private readonly string $environment,
+ ) {
parent::__construct();
- $this->replayer = $eventStreamReplayer;
}
- protected function configure()
+ protected function configure(): void
{
$this
- ->setName('middleware:event:replay')
- ->setDescription(
- 'Wipes all read models and repopulates the tables from the event store. Use the
- --no-interaction option to perform the event replay without the additional confirmation question.'
- )
- ->addOption(
- 'increments',
- 'i',
- InputOption::VALUE_REQUIRED,
- 'The amount of events that are replayed at once (repeated until all events are replayed)',
- 1000
- );
+ ->addOption(
+ 'increments',
+ 'i',
+ InputOption::VALUE_REQUIRED,
+ 'The amount of events that are replayed at once (repeated until all events are replayed)',
+ 1000,
+ );
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
- /** @var KernelInterface $kernel */
- $kernel = $this->getApplication()->getKernel();
- $environment = $kernel->getEnvironment();
/** @var FormatterHelper $formatter */
$formatter = $this->getHelper('formatter');
// Be careful, when using the no-interaction option you will not get the confirmation question
$noInteraction = $input->getOption('no-interaction');
- if (!in_array($environment, ['dev_event_replay', 'prod_event_replay', 'smoketest_event_replay'])) {
- $output->writeln($formatter->formatBlock(
- [
- '',
- 'This command may only be executed using env "dev_event_replay", "prod_event_replay", or
+ if (!in_array($this->environment, ['dev_event_replay', 'prod_event_replay', 'smoketest_event_replay'])) {
+ $output->writeln(
+ $formatter->formatBlock(
+ [
+ '',
+ 'This command may only be executed using env "dev_event_replay", "prod_event_replay", or
"smoketest_event_replay"',
- ''
- ],
- 'error'
- ));
+ '',
+ ],
+ 'error',
+ ),
+ );
- return;
+ return 1;
}
/** @var QuestionHelper $interrogator */
$interrogator = $this->getHelper('question');
- if ($environment === 'prod_event_replay') {
+ if ($this->environment === 'prod_event_replay') {
$wantToRunOnProd = new ConfirmationQuestion(
'You have selected to run this on production. Have you disabled all access to the production '
- .'environment? (y/N)',
- false
+ . 'environment? (y/N)',
+ false,
);
if (!$interrogator->ask($input, $output, $wantToRunOnProd)) {
$output->writeln('Not starting the replay');
- return;
+ return 1;
}
}
@@ -104,11 +99,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(
$formatter->formatBlock(
sprintf('Increments must be a positive integer, "%s" given', $input->getOption('increments')),
- 'error'
- )
+ 'error',
+ ),
);
- return;
+ return 1;
}
if (!$noInteraction) {
@@ -127,15 +122,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!$interrogator->ask($input, $output, $areYouSure)) {
$output->writeln('Replay cancelled!');
- return;
+ return 1;
}
}
$output->writeln(['', $formatter->formatBlock('Starting Event Replay', 'info')]);
$output->writeln(
- $formatter->formatBlock(' >> If it is interrupted it must be rerun till completed', 'comment')
+ $formatter->formatBlock(' >> If it is interrupted it must be rerun till completed', 'comment'),
);
$this->replayer->replayEvents($output, $increments);
+ return 0;
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/ReplaySpecificEventsCommand.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/ReplaySpecificEventsCommand.php
index 194ad6036..50aef8adb 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/ReplaySpecificEventsCommand.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Console/Command/ReplaySpecificEventsCommand.php
@@ -22,6 +22,7 @@
use Surfnet\StepupMiddleware\MiddlewareBundle\EventSourcing\ProjectorCollection;
use Surfnet\StepupMiddleware\MiddlewareBundle\Service\PastEventsService;
use Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionAwareEventDispatcher;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
@@ -29,85 +30,64 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
+#[AsCommand(
+ name: 'stepup:event:replay',
+ description: 'replay specified events for specified projectors'
+)]
class ReplaySpecificEventsCommand extends Command
{
- const OPTION_LIST_EVENTS = 'list-events';
- const OPTION_LIST_PROJECTORS = 'list-projectors';
-
- /**
- * @var EventCollection
- */
- private $collection;
-
- /**
- * @var PastEventsService
- */
- private $pastEventsService;
-
- /**
- * @var TransactionAwareEventDispatcher
- */
- private $eventDispatcher;
- /**
- * @var ProjectorCollection
- */
- private $projectorCollection;
-
- protected function configure()
+ public const OPTION_LIST_EVENTS = 'list-events';
+ public const OPTION_LIST_PROJECTORS = 'list-projectors';
+
+ protected function configure(): void
{
$this
- ->setName('stepup:event:replay')
- ->setDescription('replay specified events for specified projectors')
->addOption(
self::OPTION_LIST_EVENTS,
null,
InputOption::VALUE_NONE,
- 'List all events available to replay'
+ 'List all events available to replay',
)
->addOption(
self::OPTION_LIST_PROJECTORS,
null,
InputOption::VALUE_NONE,
- 'List all projectors available for which events can be replayed'
+ 'List all projectors available for which events can be replayed',
);
}
public function __construct(
- EventCollection $collection,
- ProjectorCollection $projectorCollection,
- PastEventsService $pastEventsService,
- TransactionAwareEventDispatcher $eventDispatcher
+ private readonly EventCollection $collection,
+ private readonly ProjectorCollection $projectorCollection,
+ private readonly PastEventsService $pastEventsService,
+ private readonly TransactionAwareEventDispatcher $eventDispatcher,
) {
- $this->collection = $collection;
- $this->projectorCollection = $projectorCollection;
- $this->pastEventsService = $pastEventsService;
- $this->eventDispatcher = $eventDispatcher;
parent::__construct();
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
- $availableEvents = $this->collection->getEventNames();
+ $availableEvents = $this->collection->getEventNames();
$availableProjectors = $this->projectorCollection->getProjectorNames();
if ($input->getOption(self::OPTION_LIST_EVENTS)) {
$output->writeln('The following events can be replayed:');
- $output->writeln(!empty($availableEvents) ? $availableEvents : 'None.');
+ $output->writeln($availableEvents === [] ? 'None.' : $availableEvents);
- return;
+ return 0;
}
if ($input->getOption(self::OPTION_LIST_PROJECTORS)) {
$output->writeln('Events can be replayed for the following projectors:');
- $output->writeln(!empty($availableProjectors) ? $availableProjectors : 'None.');
+ $output->writeln($availableProjectors === [] ? 'None.' : $availableProjectors);
- return;
+ return 0;
}
- if (count($availableProjectors) === 0) {
- $output->writeln('There are no projectors configured to reply events for');
+ if ($availableProjectors === []) {
+ $output->writeln('There are no projectors configured to replay events for');
- return;
+ return 1;
}
/** @var QuestionHelper $questionHelper */
@@ -115,21 +95,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
$selectEventsQuestion = new ChoiceQuestion(
'Which events would you like to replay? Please supply a comma-separated list of numbers.',
- $availableEvents
+ $availableEvents,
);
$selectEventsQuestion->setMultiselect(true);
- $chosenEvents = $questionHelper->ask($input, $output, $selectEventsQuestion);
+ $chosenEvents = $questionHelper->ask($input, $output, $selectEventsQuestion);
$eventSelection = $this->collection->select($chosenEvents);
$selectProjectorsQuestion = new ChoiceQuestion(
'For which projectors would you like to replay the selected events? '
. 'Please supply a comma-separated list of numbers.',
- $availableProjectors
+ $availableProjectors,
);
$selectProjectorsQuestion->setMultiselect(true);
- $chosenProjectors = $questionHelper->ask($input, $output, $selectProjectorsQuestion);
+ $chosenProjectors = $questionHelper->ask($input, $output, $selectProjectorsQuestion);
$projectorSelection = $this->projectorCollection->selectByNames($chosenProjectors);
$events = $this->pastEventsService->findEventsBy($eventSelection);
@@ -141,5 +121,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('Dispatching events');
$this->eventDispatcher->dispatch($events);
+ return 0;
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/CompilerPass/CollectProjectorsForEventReplayCompilerPass.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/CompilerPass/CollectProjectorsForEventReplayCompilerPass.php
index 6778a225d..a153238db 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/CompilerPass/CollectProjectorsForEventReplayCompilerPass.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/CompilerPass/CollectProjectorsForEventReplayCompilerPass.php
@@ -24,7 +24,7 @@
class CollectProjectorsForEventReplayCompilerPass implements CompilerPassInterface
{
- public function process(ContainerBuilder $container)
+ public function process(ContainerBuilder $container): void
{
$projectorCollectionDefinition = $container->getDefinition('middleware.event_replay.projector_collection');
$projectorDefinitions = $container->findTaggedServiceIds('projector.register_for_replay');
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/Configuration.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/Configuration.php
index 852bbdd2b..4e32baf4c 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/Configuration.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/Configuration.php
@@ -23,37 +23,34 @@
class Configuration implements ConfigurationInterface
{
- public function getConfigTreeBuilder()
+ public function getConfigTreeBuilder(): TreeBuilder
{
- $treeBuilder = new TreeBuilder();
-
- $treeBuilder
- ->root('surfnet_stepup_middleware_middleware')
- ->children()
- ->arrayNode('second_factors_display_name')->isRequired()->scalarPrototype()->end()->end()
- ->scalarNode('email_verification_window')
- ->info('The amount of seconds after which the email verification url/code expires')
- ->defaultValue(3600)
- ->validate()
- ->ifTrue(function ($seconds) {
- return !is_int($seconds) || $seconds < 1;
- })
- ->thenInvalid(
- 'The email verification window must be a positive integer'
- )
- ->end()
- ->end()
- ->arrayNode('enabled_generic_second_factors')
- ->isRequired()
- ->prototype('array')
- ->children()
- ->scalarNode('loa')
- ->isRequired()
- ->info('The lao level of the Gssf')
- ->end()
- ->end()
- ->end()
- ->end();
+ $treeBuilder = new TreeBuilder('surfnet_stepup_middleware_middleware');
+ $rootNode = $treeBuilder->getRootNode();
+ $rootNode
+ ->children()
+ ->arrayNode('second_factors_display_name')->isRequired()->scalarPrototype()->end()->end()
+ ->scalarNode('email_verification_window')
+ ->info('The amount of seconds after which the email verification url/code expires')
+ ->defaultValue(3600)
+ ->validate()
+ ->ifTrue(fn($seconds): bool => !is_int($seconds) || $seconds < 1)
+ ->thenInvalid(
+ 'The email verification window must be a positive integer',
+ )
+ ->end()
+ ->end()
+ ->arrayNode('enabled_generic_second_factors')
+ ->isRequired()
+ ->prototype('array')
+ ->children()
+ ->scalarNode('loa')
+ ->isRequired()
+ ->info('The lao level of the Gssf')
+ ->end()
+ ->end()
+ ->end()
+ ->end();
return $treeBuilder;
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/SurfnetStepupMiddlewareMiddlewareExtension.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/SurfnetStepupMiddlewareMiddlewareExtension.php
index e2f77034d..8d76d5c63 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/SurfnetStepupMiddlewareMiddlewareExtension.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/DependencyInjection/SurfnetStepupMiddlewareMiddlewareExtension.php
@@ -18,6 +18,7 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\DependencyInjection;
+use Surfnet\Stepup\Identity\Entity\ConfigurableSettings;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -27,7 +28,7 @@
class SurfnetStepupMiddlewareMiddlewareExtension extends Extension
{
- public function load(array $config, ContainerBuilder $container)
+ public function load(array $config, ContainerBuilder $container): void
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), $config);
@@ -38,7 +39,7 @@ public function load(array $config, ContainerBuilder $container)
$fileLoader->load('event_replaying.yml');
$definition = (new Definition())
- ->setClass('Surfnet\Stepup\Identity\Entity\ConfigurableSettings')
+ ->setClass(ConfigurableSettings::class)
->setFactory('Surfnet\Stepup\Identity\Entity\ConfigurableSettings::create')
->setArguments([$config['email_verification_window'], $container->getParameter('locales')]);
@@ -46,7 +47,7 @@ public function load(array $config, ContainerBuilder $container)
$container->setParameter(
'middleware.enabled_generic_second_factors',
- $config['enabled_generic_second_factors']
+ $config['enabled_generic_second_factors'],
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/DBALEventHydrator.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/DBALEventHydrator.php
index 86a4a1db5..67702b702 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/DBALEventHydrator.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/DBALEventHydrator.php
@@ -23,99 +23,65 @@
use Broadway\Domain\DomainMessage;
use Broadway\Serializer\SimpleInterfaceSerializer;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Exception;
+use Doctrine\DBAL\Statement;
use PDO;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\Forgettable;
use Surfnet\StepupMiddleware\CommandHandlingBundle\SensitiveData\SensitiveData;
class DBALEventHydrator
{
- /**
- * @var Connection
- */
- private $connection;
-
- /**
- * @var SimpleInterfaceSerializer
- */
- private $payloadSerializer;
-
- /**
- * @var SimpleInterfaceSerializer
- */
- private $metadataSerializer;
-
- /**
- * @var string
- */
- private $eventStreamTableName;
-
- /**
- * @var string
- */
- private $sensitiveDataTable;
-
- /**
- * @var \Doctrine\DBAL\Driver\Statement
- */
- private $loadStatement = null;
+ private ?Statement $loadStatement = null;
/**
- * @param Connection $connection
- * @param SimpleInterfaceSerializer $payloadSerializer
- * @param SimpleInterfaceSerializer $metadataSerializer
- * @param string $eventStreamTable
- * @param string $sensitiveDataTable
+ * @param string $eventStreamTableName
+ * @param string $sensitiveDataTable
*/
public function __construct(
- Connection $connection,
- SimpleInterfaceSerializer $payloadSerializer,
- SimpleInterfaceSerializer $metadataSerializer,
- $eventStreamTable,
- $sensitiveDataTable
+ private readonly Connection $connection,
+ private readonly SimpleInterfaceSerializer $payloadSerializer,
+ private readonly SimpleInterfaceSerializer $metadataSerializer,
+ private $eventStreamTableName,
+ private $sensitiveDataTable,
) {
- $this->connection = $connection;
- $this->payloadSerializer = $payloadSerializer;
- $this->metadataSerializer = $metadataSerializer;
- $this->eventStreamTableName = $eventStreamTable;
- $this->sensitiveDataTable = $sensitiveDataTable;
}
- /**
- * @return string
- * @throws \Doctrine\DBAL\DBALException
- */
- public function getCount()
+ public function getCount(): int
{
$statement = $this->connection->prepare('SELECT COUNT(1) AS cnt FROM ' . $this->eventStreamTableName);
- $statement->execute();
+ $result = $statement->executeQuery();
- $row = $statement->fetch();
+ $row = $result->fetchAssociative();
- return $row['cnt'];
+ if (!$row) {
+ return 0;
+ }
+
+ return (int) $row['cnt'];
}
- /**
- * @param int $limit
- * @param int $offset
- * @return DomainEventStream
- */
- public function getFromTill($limit, $offset)
+ public function getFromTill(int $limit, int $offset): DomainEventStream
{
$statement = $this->prepareLoadStatement();
$statement->bindValue('limit', $limit, PDO::PARAM_INT);
$statement->bindValue('offset', $offset, PDO::PARAM_INT);
- $statement->execute();
+ $result = $statement->executeQuery();
- $events = array();
- while ($row = $statement->fetch()) {
+ $events = [];
+
+ while ($row = $result->fetchAssociative()) {
$events[] = $this->deserializeEvent($row);
}
return new DomainEventStream($events);
}
- public function fetchByEventTypes($eventTypes)
+ /**
+ * @param string[] $eventTypes
+ * @throws Exception
+ */
+ public function fetchByEventTypes(array $eventTypes): DomainEventStream
{
$eventTypePlaceholders = implode(', ', array_fill(0, count($eventTypes), '?'));
@@ -128,40 +94,40 @@ public function fetchByEventTypes($eventTypes)
ON %es%.uuid = %sd%.identity_id
AND %es%.playhead = %sd%.playhead
WHERE %es%.type IN ($eventTypePlaceholders)
- ORDER BY recorded_on, playhead ASC"
+ ORDER BY recorded_on, playhead ASC",
);
$statement = $this->connection->prepare($query);
- $statement->execute($eventTypes);
+ $results = $statement->executeQuery($eventTypes);
- $events = array();
- while ($row = $statement->fetch()) {
+ $events = [];
+ foreach ($results->fetchAllAssociative() as $row) {
$events[] = $this->deserializeEvent($row);
}
return new DomainEventStream($events);
}
- private function deserializeEvent($row)
+ private function deserializeEvent(array $row): DomainMessage
{
- $event = $this->payloadSerializer->deserialize(json_decode($row['payload'], true));
+ $event = $this->payloadSerializer->deserialize(json_decode((string)$row['payload'], true));
if ($event instanceof Forgettable) {
- $event->setSensitiveData(SensitiveData::deserialize(json_decode($row['sensitive_data'], true)));
+ $event->setSensitiveData(SensitiveData::deserialize(json_decode((string)$row['sensitive_data'], true)));
}
return new DomainMessage(
$row['uuid'],
$row['playhead'],
- $this->metadataSerializer->deserialize(json_decode($row['metadata'], true)),
+ $this->metadataSerializer->deserialize(json_decode((string)$row['metadata'], true)),
$event,
- DateTime::fromString($row['recorded_on'])
+ DateTime::fromString($row['recorded_on']),
);
}
- private function prepareLoadStatement()
+ private function prepareLoadStatement(): Statement
{
- if ($this->loadStatement === null) {
+ if (!$this->loadStatement instanceof Statement) {
$query = str_replace(
['%es%', '%sd%'],
[$this->eventStreamTableName, $this->sensitiveDataTable],
@@ -171,7 +137,7 @@ private function prepareLoadStatement()
ON %es%.uuid = %sd%.identity_id
AND %es%.playhead = %sd%.playhead
ORDER BY recorded_on ASC
- LIMIT :limit OFFSET :offset'
+ LIMIT :limit OFFSET :offset',
);
$this->loadStatement = $this->connection->prepare($query);
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/EventCollection.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/EventCollection.php
index 97fcce385..7c826b3fd 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/EventCollection.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/EventCollection.php
@@ -19,28 +19,37 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\EventSourcing;
use ArrayIterator;
+use Iterator;
use IteratorAggregate;
use Surfnet\StepupMiddleware\MiddlewareBundle\Exception\InvalidArgumentException;
+/**
+ * @implements IteratorAggregate
+ */
final class EventCollection implements IteratorAggregate
{
/**
* @var string[]
*/
- private $eventNames = [];
+ private array $eventNames = [];
+ /**
+ * @param string[] $eventNames
+ */
public function __construct(array $eventNames)
{
foreach ($eventNames as $eventName) {
- if (!is_string($eventName) || empty($eventName)) {
+ if (!is_string($eventName) || ($eventName === '' || $eventName === '0')) {
throw InvalidArgumentException::invalidType('non-empty string', 'eventName', $eventName);
}
if (!class_exists($eventName)) {
- throw new InvalidArgumentException(sprintf(
- 'Cannot create EventCollection: class "%s" does not exist',
- $eventName
- ));
+ throw new InvalidArgumentException(
+ sprintf(
+ 'Cannot create EventCollection: class "%s" does not exist',
+ $eventName,
+ ),
+ );
}
$this->eventNames[] = $eventName;
@@ -50,51 +59,48 @@ public function __construct(array $eventNames)
/**
* @return string[]
*/
- public function getEventNames()
+ public function getEventNames(): array
{
return $this->eventNames;
}
- public function formatAsEventStreamTypes()
+ /**
+ * @return string[]
+ */
+ public function formatAsEventStreamTypes(): array
{
return array_map(
- function ($eventName) {
- return strtr($eventName, '\\', '.');
- },
- $this->eventNames
+ fn($eventName): string => strtr($eventName, '\\', '.'),
+ $this->eventNames,
);
}
- /**
- * @param array $subset
- * @return EventCollection
- */
- public function select(array $subset)
+ public function select(array $subset): self
{
$nonAvailableEventNames = array_diff($subset, $this->eventNames);
- if (!empty($nonAvailableEventNames)) {
+ if ($nonAvailableEventNames !== []) {
throw new InvalidArgumentException(
sprintf(
'Subset of event names contains event names not present in collection: %s',
- implode(', ', $nonAvailableEventNames)
- )
+ implode(', ', $nonAvailableEventNames),
+ ),
);
}
return new self($subset);
}
- /**
- * @param $eventName
- * @return bool
- */
- public function contains($eventName)
+
+ public function contains(string $eventName): bool
{
return in_array($eventName, $this->eventNames);
}
- public function getIterator()
+ /**
+ * @return Iterator
+ */
+ public function getIterator(): Iterator
{
return new ArrayIterator($this->eventNames);
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/ProjectorCollection.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/ProjectorCollection.php
index de683c885..37f28af7e 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/ProjectorCollection.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/EventSourcing/ProjectorCollection.php
@@ -20,42 +20,40 @@
use ArrayIterator;
use Broadway\EventHandling\EventListener as ProjectorInterface;
+use Iterator;
use IteratorAggregate;
use Surfnet\StepupMiddleware\MiddlewareBundle\Exception\InvalidArgumentException;
+/**
+ * @implements IteratorAggregate
+ */
final class ProjectorCollection implements IteratorAggregate
{
/**
* @var ProjectorInterface[]
*/
- private $projectors = [];
+ private array $projectors = [];
- /**
- * @param ProjectorInterface $projector
- */
- public function add(ProjectorInterface $projector)
+ public function add(ProjectorInterface $projector): void
{
- $this->projectors[get_class($projector)] = $projector;
+ $this->projectors[$projector::class] = $projector;
}
/**
* @return string[]
*/
- public function getProjectorNames()
+ public function getProjectorNames(): array
{
return array_map(
- function (ProjectorInterface $projector) {
- return get_class($projector);
- },
- array_values($this->projectors)
+ fn(ProjectorInterface $projector): string => $projector::class,
+ array_values($this->projectors),
);
}
/**
- * @param array $projectorNames
* @return ProjectorCollection
*/
- public function selectByNames(array $projectorNames)
+ public function selectByNames(array $projectorNames): ProjectorCollection
{
$subsetCollection = new ProjectorCollection;
@@ -64,8 +62,8 @@ public function selectByNames(array $projectorNames)
throw new InvalidArgumentException(
sprintf(
'Cannot select a subset of projectors, because projector "%s" is not present in the collection',
- $projectorName
- )
+ $projectorName,
+ ),
);
}
@@ -76,15 +74,14 @@ public function selectByNames(array $projectorNames)
}
/**
- * @param ProjectorInterface $projector
* @return bool
*/
- public function contains(ProjectorInterface $projector)
+ public function contains(ProjectorInterface $projector): bool
{
- return array_key_exists(get_class($projector), $this->projectors);
+ return array_key_exists($projector::class, $this->projectors);
}
- public function getIterator()
+ public function getIterator(): Iterator
{
return new ArrayIterator($this->projectors);
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Exception/InvalidArgumentException.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Exception/InvalidArgumentException.php
index a3a6e32e5..bf6bf3528 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Exception/InvalidArgumentException.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Exception/InvalidArgumentException.php
@@ -22,20 +22,13 @@
class InvalidArgumentException extends CoreInvalidArgumentException
{
- /**
- * @param string $expected description of expected type
- * @param string $parameterName
- * @param mixed $parameter the parameter that is not of the expected type.
- *
- * @return self
- */
- public static function invalidType($expected, $parameterName, $parameter)
+ public static function invalidType(string $expected, string $parameterName, mixed $parameter): self
{
$message = sprintf(
'Invalid argument type: "%s" expected, "%s" given for "%s"',
$expected,
- is_object($parameter) ? get_class($parameter) : gettype($parameter),
- $parameterName
+ get_debug_type($parameter),
+ $parameterName,
);
return new self($message);
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Exception/UnknownDBALConnectionException.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Exception/UnknownDBALConnectionException.php
index 974a4401a..dbfa99fc0 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Exception/UnknownDBALConnectionException.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Exception/UnknownDBALConnectionException.php
@@ -22,7 +22,7 @@
final class UnknownDBALConnectionException extends DomainException
{
- public function __construct($connectionName)
+ public function __construct(string $connectionName)
{
parent::__construct(sprintf('DBAL Connection "%s" does not exist', $connectionName));
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/InstitutionConfigurationProvider.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/InstitutionConfigurationProvider.php
index cd2f4c10b..938e905b8 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/InstitutionConfigurationProvider.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/InstitutionConfigurationProvider.php
@@ -22,39 +22,16 @@
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionConfigurationOptionsService;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\RaLocationService;
-final class InstitutionConfigurationProvider
+final readonly class InstitutionConfigurationProvider
{
- /**
- * @var ConfiguredInstitutionService
- */
- private $configuredInstitutionService;
-
- /**
- * @var InstitutionConfigurationOptionsService
- */
- private $institutionConfigurationOptionsService;
-
- /**
- * @var RaLocationService
- */
- private $raLocationService;
-
- /**
- * @param ConfiguredInstitutionService $configuredInstitutionService
- * @param InstitutionConfigurationOptionsService $institutionConfigurationOptionsService
- * @param RaLocationService $raLocationService
- */
public function __construct(
- ConfiguredInstitutionService $configuredInstitutionService,
- InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
- RaLocationService $raLocationService
+ private ConfiguredInstitutionService $configuredInstitutionService,
+ private InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
+ private RaLocationService $raLocationService,
) {
- $this->configuredInstitutionService = $configuredInstitutionService;
- $this->institutionConfigurationOptionsService = $institutionConfigurationOptionsService;
- $this->raLocationService = $raLocationService;
}
- public function loadData()
+ public function loadData(): InstitutionConfigurationState
{
$configuredInstitutions = $this->configuredInstitutionService->getAll();
$institutionConfigurationOptions = $this->institutionConfigurationOptionsService
@@ -64,7 +41,7 @@ public function loadData()
return InstitutionConfigurationState::load(
$configuredInstitutions,
$institutionConfigurationOptions,
- $raLocations
+ $raLocations,
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/InstitutionConfigurationState.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/InstitutionConfigurationState.php
index b56b1501c..1b45df2c9 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/InstitutionConfigurationState.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/InstitutionConfigurationState.php
@@ -18,32 +18,29 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Migrations\InstitutionConfiguration;
+use Generator;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\ConfiguredInstitution;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionConfigurationOptions;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\RaLocation;
use Surfnet\StepupMiddleware\MiddlewareBundle\Exception\RuntimeException;
-final class InstitutionConfigurationState
+final readonly class InstitutionConfigurationState
{
/**
- * @var MappedInstitutionConfiguration[]
- */
- private $mappedInstitutionConfigurations;
-
- /**
- * @param ConfiguredInstitution[] $configuredInstitutions
+ * @param ConfiguredInstitution[] $configuredInstitutions
* @param InstitutionConfigurationOptions[] $institutionConfigurationOptions
- * @param RaLocation[] $raLocations
+ * @param RaLocation[] $raLocations
* @return InstitutionConfigurationState
*/
public static function load(
- $configuredInstitutions,
- $institutionConfigurationOptions,
- $raLocations
- ) {
- $optionInstitutions = array_map(function (InstitutionConfigurationOptions $options) {
- return $options->institution->getInstitution();
- }, $institutionConfigurationOptions);
+ array $configuredInstitutions,
+ array $institutionConfigurationOptions,
+ array $raLocations,
+ ): self {
+ $optionInstitutions = array_map(
+ fn(InstitutionConfigurationOptions $options): string => $options->institution->getInstitution(),
+ $institutionConfigurationOptions,
+ );
$mappedConfigurationOptions = array_combine($optionInstitutions, $institutionConfigurationOptions);
$mappedRaLocations = [];
@@ -56,15 +53,17 @@ public static function load(
foreach ($configuredInstitutions as $institution) {
$institutionName = $institution->institution->getInstitution();
if (!array_key_exists($institutionName, $mappedConfigurationOptions)) {
- throw new RuntimeException(sprintf(
- 'Institution "%s" has been configured, but does not have options.',
- $institutionName
- ));
+ throw new RuntimeException(
+ sprintf(
+ 'Institution "%s" has been configured, but does not have options.',
+ $institutionName,
+ ),
+ );
}
/** @var InstitutionConfigurationOptions $options */
$options = $mappedConfigurationOptions[$institutionName];
- $locations = isset($mappedRaLocations[$institutionName]) ? $mappedRaLocations[$institutionName] : [];
+ $locations = $mappedRaLocations[$institutionName] ?? [];
$mappedInstitutionConfigurations[] = new MappedInstitutionConfiguration(
$institution->institution,
@@ -73,7 +72,7 @@ public static function load(
$options->verifyEmailOption,
$options->selfVetOption,
$options->numberOfTokensPerIdentityOption,
- $locations
+ $locations,
);
}
@@ -83,15 +82,14 @@ public static function load(
/**
* @param MappedInstitutionConfiguration[] $mappedInstitutionConfigurations
*/
- private function __construct(array $mappedInstitutionConfigurations)
+ private function __construct(private array $mappedInstitutionConfigurations)
{
- $this->mappedInstitutionConfigurations = $mappedInstitutionConfigurations;
}
/**
- * @return \Generator
+ * @return Generator
*/
- public function inferRemovalCommands()
+ public function inferRemovalCommands(): Generator
{
foreach ($this->mappedInstitutionConfigurations as $mappedInstitutionConfiguration) {
yield $mappedInstitutionConfiguration->inferRemoveInstitutionConfigurationByIdCommand();
@@ -99,9 +97,9 @@ public function inferRemovalCommands()
}
/**
- * @return \Generator
+ * @return Generator
*/
- public function inferCreateCommands()
+ public function inferCreateCommands(): Generator
{
foreach ($this->mappedInstitutionConfigurations as $mappedInstitutionConfiguration) {
yield $mappedInstitutionConfiguration->inferCreateInstitutionConfigurationCommand();
@@ -109,9 +107,9 @@ public function inferCreateCommands()
}
/**
- * @return \Generator
+ * @return Generator
*/
- public function inferReconfigureCommands()
+ public function inferReconfigureCommands(): Generator
{
foreach ($this->mappedInstitutionConfigurations as $mappedInstitutionConfiguration) {
yield $mappedInstitutionConfiguration->inferReconfigureInstitutionConfigurationCommand();
@@ -119,9 +117,9 @@ public function inferReconfigureCommands()
}
/**
- * @return \Generator
+ * @return Generator
*/
- public function inferAddRaLocationCommands()
+ public function inferAddRaLocationCommands(): Generator
{
foreach ($this->mappedInstitutionConfigurations as $mappedInstitutionConfiguration) {
foreach ($mappedInstitutionConfiguration->inferAddRaLocationCommands() as $command) {
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/MappedInstitutionConfiguration.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/MappedInstitutionConfiguration.php
index f49457f16..b30a48c62 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/MappedInstitutionConfiguration.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Migrations/InstitutionConfiguration/MappedInstitutionConfiguration.php
@@ -18,11 +18,10 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Migrations\InstitutionConfiguration;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
+use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption;
use Surfnet\Stepup\Configuration\Value\SelfVetOption;
-use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\RaLocation;
-use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption;
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption;
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
@@ -31,105 +30,48 @@
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\ReconfigureInstitutionConfigurationOptionsCommand;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Configuration\Command\RemoveInstitutionConfigurationByUnnormalizedIdCommand;
-final class MappedInstitutionConfiguration
+final readonly class MappedInstitutionConfiguration
{
- /**
- * @var Institution
- */
- private $institution;
-
- /**
- * @var ShowRaaContactInformationOption
- */
- private $showRaaContactInformationOption;
-
- /**
- * @var UseRaLocationsOption
- */
- private $useRaLocationsOption;
-
- /**
- * @var VerifyEmailOption
- */
- private $verifyEmailOption;
-
- /** @var SelfVetOption */
- private $selfVetOption;
-
- /**
- * @var NumberOfTokensPerIdentityOption
- */
- private $numberOfTokensPerIdentityOption;
-
- /**
- * @var RaLocation[]
- */
- private $raLocations;
-
- /**
- * @param Institution $institution
- * @param UseRaLocationsOption $useRaLocationsOption
- * @param ShowRaaContactInformationOption $showRaaContactInformationOption
- * @param VerifyEmailOption $verifyEmailOption
- * @param SelfVetOption $setVetOption
- * @param NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption
- * @param RaLocation[] $raLocations
- */
public function __construct(
- Institution $institution,
- UseRaLocationsOption $useRaLocationsOption,
- ShowRaaContactInformationOption $showRaaContactInformationOption,
- VerifyEmailOption $verifyEmailOption,
- SelfVetOption $selfVetOption,
- NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption,
- array $raLocations
+ private Institution $institution,
+ private UseRaLocationsOption $useRaLocationsOption,
+ private ShowRaaContactInformationOption $showRaaContactInformationOption,
+ private VerifyEmailOption $verifyEmailOption,
+ private SelfVetOption $selfVetOption,
+ private NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption,
+ private array $raLocations,
) {
- $this->institution = $institution;
- $this->useRaLocationsOption = $useRaLocationsOption;
- $this->showRaaContactInformationOption = $showRaaContactInformationOption;
- $this->verifyEmailOption = $verifyEmailOption;
- $this->selfVetOption = $selfVetOption;
- $this->numberOfTokensPerIdentityOption = $numberOfTokensPerIdentityOption;
- $this->raLocations = $raLocations;
}
- /**
- * @return RemoveInstitutionConfigurationByUnnormalizedIdCommand
- */
- public function inferRemoveInstitutionConfigurationByIdCommand()
+ public function inferRemoveInstitutionConfigurationByIdCommand(): RemoveInstitutionConfigurationByUnnormalizedIdCommand
{
- $command = new RemoveInstitutionConfigurationByUnnormalizedIdCommand();
- $command->UUID = (string) Uuid::uuid4();
+ $command = new RemoveInstitutionConfigurationByUnnormalizedIdCommand();
+ $command->UUID = (string)Uuid::uuid4();
$command->institution = $this->institution->getInstitution();
return $command;
}
- /**
- * @return CreateInstitutionConfigurationCommand
- */
- public function inferCreateInstitutionConfigurationCommand()
+ public function inferCreateInstitutionConfigurationCommand(): CreateInstitutionConfigurationCommand
{
- $command = new CreateInstitutionConfigurationCommand();
- $command->UUID = (string) Uuid::uuid4();
+ $command = new CreateInstitutionConfigurationCommand();
+ $command->UUID = (string)Uuid::uuid4();
$command->institution = $this->institution->getInstitution();
return $command;
}
- /**
- * @return ReconfigureInstitutionConfigurationOptionsCommand
- */
- public function inferReconfigureInstitutionConfigurationCommand()
+ public function inferReconfigureInstitutionConfigurationCommand(): ReconfigureInstitutionConfigurationOptionsCommand
{
- $command = new ReconfigureInstitutionConfigurationOptionsCommand();
- $command->UUID = (string) Uuid::uuid4();
- $command->institution = $this->institution->getInstitution();
- $command->useRaLocationsOption = $this->useRaLocationsOption->isEnabled();
+ $command = new ReconfigureInstitutionConfigurationOptionsCommand();
+ $command->UUID = (string)Uuid::uuid4();
+ $command->institution = $this->institution->getInstitution();
+ $command->useRaLocationsOption = $this->useRaLocationsOption->isEnabled();
$command->showRaaContactInformationOption = $this->showRaaContactInformationOption->isEnabled();
- $command->verifyEmailOption = $this->verifyEmailOption->isEnabled();
- $command->selfVetOption= $this->selfVetOption->isEnabled();
- $command->numberOfTokensPerIdentityOption = $this->numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity();
+ $command->verifyEmailOption = $this->verifyEmailOption->isEnabled();
+ $command->selfVetOption = $this->selfVetOption->isEnabled();
+ $command->numberOfTokensPerIdentityOption = $this->numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity(
+ );
return $command;
}
@@ -137,19 +79,19 @@ public function inferReconfigureInstitutionConfigurationCommand()
/**
* @return AddRaLocationCommand[]
*/
- public function inferAddRaLocationCommands()
+ public function inferAddRaLocationCommands(): array
{
$commands = [];
$institution = $this->institution->getInstitution();
foreach ($this->raLocations as $raLocation) {
- $command = new AddRaLocationCommand();
- $command->UUID = (string) Uuid::uuid4();
- $command->institution = $institution;
- $command->raLocationId = $raLocation->id ;
- $command->raLocationName = $raLocation->name->getRaLocationName();
+ $command = new AddRaLocationCommand();
+ $command->UUID = (string)Uuid::uuid4();
+ $command->institution = $institution;
+ $command->raLocationId = $raLocation->id;
+ $command->raLocationName = $raLocation->name->getRaLocationName();
$command->contactInformation = $raLocation->contactInformation->getContactInformation();
- $command->location = $raLocation->location->getLocation();
+ $command->location = $raLocation->location->getLocation();
$commands[] = $command;
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/console_commands.yml b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/console_commands.yml
index 4a58ffc2d..a3cf334cf 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/console_commands.yml
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/console_commands.yml
@@ -1,84 +1,84 @@
services:
- Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService:
- arguments:
- - "@surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline"
- - "@surfnet_stepup_middleware_command_handling.metadata_enricher.actor"
- - "@security.token_storage"
- - "@surfnet_stepup_middleware_api.repository.identity"
- - "@surfnet_stepup_middleware_api.repository.unverified_second_factor"
- - "@surfnet_stepup_middleware_api.repository.verified_second_factor"
- - "@surfnet_stepup_middleware_api.repository.vetted_second_factor"
- - "@surfnet_stepup_middleware_api.repository.institution_configuration_options"
+ Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService:
+ arguments:
+ - "@surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline"
+ - "@surfnet_stepup_middleware_command_handling.metadata_enricher.actor"
+ - "@security.token_storage"
+ - "@surfnet_stepup_middleware_api.repository.identity"
+ - "@surfnet_stepup_middleware_api.repository.unverified_second_factor"
+ - "@surfnet_stepup_middleware_api.repository.verified_second_factor"
+ - "@surfnet_stepup_middleware_api.repository.vetted_second_factor"
+ - "@surfnet_stepup_middleware_api.repository.institution_configuration_options"
- Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper:
- arguments:
- - "@surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline"
- - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
- - "@surfnet_stepup_middleware_middleware.dbal_connection_helper"
+ Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper:
+ arguments:
+ - "@surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline"
+ - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
+ - "@surfnet_stepup_middleware_middleware.dbal_connection_helper"
- Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\ReplaySpecificEventsCommand:
- tags:
- - { name: 'console.command', command: 'stepup:event:replay' }
- arguments:
- - "@middleware.event_replay.event_collection"
- - "@middleware.event_replay.projector_collection"
- - "@middleware.event_replay.past_events_service"
- - "@middleware.event_replay.transaction_aware_event_dispatcher"
+ Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\ReplaySpecificEventsCommand:
+ tags:
+ - { name: 'console.command', command: 'stepup:event:replay' }
+ arguments:
+ - "@middleware.event_replay.event_collection"
+ - "@middleware.event_replay.projector_collection"
+ - "@middleware.event_replay.past_events_service"
+ - "@middleware.event_replay.transaction_aware_event_dispatcher"
- Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\ReplayEventsCommand:
- tags:
- - { name: 'console.command', command: 'middleware:event:replay' }
- arguments:
- - "@middleware.event_replay.event_stream_replayer"
+ Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\ReplayEventsCommand:
+ tags:
+ - { name: 'console.command', command: 'middleware:event:replay' }
+ arguments:
+ - "@middleware.event_replay.event_stream_replayer"
+ - '%env(APP_ENV)%'
- Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\BootstrapIdentityWithYubikeySecondFactorCommand:
- tags:
- - { name: 'console.command', command: 'middleware:bootstrap:identity-with-yubikey' }
- arguments:
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService'
- - "@surfnet_stepup_middleware_api.repository.identity"
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
+ Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\BootstrapIdentityWithYubikeySecondFactorCommand:
+ tags:
+ - { name: 'console.command', command: 'middleware:bootstrap:identity-with-yubikey' }
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.identity"
+ - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
- Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\EmailVerifiedSecondFactorRemindersCommand:
- tags:
- - { name: 'console.command', command: 'middleware:cron:email-reminder' }
- arguments:
- - "@surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline"
- - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
- - "@surfnet_stepup_middleware_middleware.dbal_connection_helper"
- - "@logger"
+ Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\EmailVerifiedSecondFactorRemindersCommand:
+ tags:
+ - { name: 'console.command', command: 'middleware:cron:email-reminder' }
+ arguments:
+ - "@surfnet_stepup_middleware_command_handling.pipeline.transaction_aware_pipeline"
+ - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
+ - "@surfnet_stepup_middleware_middleware.dbal_connection_helper"
+ - "@logger"
- Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\BootstrapIdentityCommand:
- arguments:
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService'
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
- tags:
- - { name: 'console.command', command: 'middleware:bootstrap:identity' }
+ Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\BootstrapIdentityCommand:
+ arguments:
+ - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService'
+ - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
+ tags:
+ - { name: 'console.command', command: 'middleware:bootstrap:identity' }
- Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\BootstrapSmsSecondFactorCommand:
- arguments:
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService'
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
- tags:
- - { name: 'console.command', command: 'middleware:bootstrap:sms' }
+ Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\BootstrapSmsSecondFactorCommand:
+ arguments:
+ - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService'
+ - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
+ tags:
+ - { name: 'console.command', command: 'middleware:bootstrap:sms' }
- Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\BootstrapYubikeySecondFactorCommand:
- arguments:
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService'
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
- tags:
- - { name: 'console.command', command: 'middleware:bootstrap:yubikey' }
+ Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\BootstrapYubikeySecondFactorCommand:
+ arguments:
+ - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService'
+ - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
+ tags:
+ - { name: 'console.command', command: 'middleware:bootstrap:yubikey' }
- Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\BootstrapGsspSecondFactorCommand:
- arguments:
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService'
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
- tags:
- - { name: 'console.command', command: 'middleware:bootstrap:gssp' }
+ Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\BootstrapGsspSecondFactorCommand:
+ arguments:
+ - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService'
+ - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
+ tags:
+ - { name: 'console.command', command: 'middleware:bootstrap:gssp' }
- Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\MigrateSecondFactorCommand:
- arguments:
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService'
- - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
- tags:
- - { name: 'console.command', command: 'middleware:migrate:vetted-tokens' }
+ Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\MigrateSecondFactorCommand:
+ arguments:
+ - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\BootstrapCommandService'
+ - '@Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionHelper'
+ tags:
+ - { name: 'console.command', command: 'middleware:migrate:vetted-tokens' }
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/event_replaying.yml b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/event_replaying.yml
index e1cd08140..ed1533dc7 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/event_replaying.yml
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/event_replaying.yml
@@ -1,40 +1,40 @@
services:
- middleware.event_replay.event_collection:
- class: Surfnet\StepupMiddleware\MiddlewareBundle\EventSourcing\EventCollection
- arguments:
- - "%registered_events%"
+ middleware.event_replay.event_collection:
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\EventSourcing\EventCollection
+ arguments:
+ - "%registered_events%"
- middleware.event_replay.projector_collection:
- class: Surfnet\StepupMiddleware\MiddlewareBundle\EventSourcing\ProjectorCollection
+ middleware.event_replay.projector_collection:
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\EventSourcing\ProjectorCollection
- middleware.event_replay.transaction_aware_event_dispatcher:
- class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionAwareEventDispatcher
- arguments:
- - "@surfnet_stepup_middleware_middleware.dbal_connection_helper"
- - "@middleware.event_replay.replaying_event_dispatcher"
+ middleware.event_replay.transaction_aware_event_dispatcher:
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\TransactionAwareEventDispatcher
+ arguments:
+ - "@surfnet_stepup_middleware_middleware.dbal_connection_helper"
+ - "@middleware.event_replay.replaying_event_dispatcher"
- middleware.event_replay.replaying_event_dispatcher:
- class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\ReplayingEventDispatcher
+ middleware.event_replay.replaying_event_dispatcher:
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\ReplayingEventDispatcher
- middleware.event_replay.past_events_service:
- class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\PastEventsService
- arguments:
- - "@middleware.event_replay.dbal_event_hydrator"
+ middleware.event_replay.past_events_service:
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\PastEventsService
+ arguments:
+ - "@middleware.event_replay.dbal_event_hydrator"
- middleware.event_replay.dbal_event_hydrator:
- public: false
- class: Surfnet\StepupMiddleware\MiddlewareBundle\EventSourcing\DBALEventHydrator
- arguments:
- - "@doctrine.dbal.middleware_connection"
- - "@surfnet_stepup.event_store.simple_serializer"
- - "@surfnet_stepup.event_store.simple_serializer"
- - 'event_stream'
- - 'event_stream_sensitive_data'
+ middleware.event_replay.dbal_event_hydrator:
+ public: false
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\EventSourcing\DBALEventHydrator
+ arguments:
+ - "@doctrine.dbal.middleware_connection"
+ - "@surfnet_stepup.event_store.simple_serializer"
+ - "@surfnet_stepup.event_store.simple_serializer"
+ - 'event_stream'
+ - 'event_stream_sensitive_data'
- middleware.event_replay.event_stream_replayer:
- public: true
- class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\EventStreamReplayer
- arguments:
- - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
- - "@middleware.event_replay.dbal_event_hydrator"
- - "@surfnet_stepup_middleware_middleware.dbal_connection_helper"
+ middleware.event_replay.event_stream_replayer:
+ public: true
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\EventStreamReplayer
+ arguments:
+ - "@surfnet_stepup_middleware_command_handling.event_bus.buffered"
+ - "@middleware.event_replay.dbal_event_hydrator"
+ - "@surfnet_stepup_middleware_middleware.dbal_connection_helper"
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/services.yml b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/services.yml
index 7277bc9fd..d15802dee 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/services.yml
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Resources/config/services.yml
@@ -1,47 +1,49 @@
services:
- # Remove the public: true default once DI is implemented throughout the StepUp applications. See Pivotal #138225085
- _defaults:
- public: true
+ # Remove the public: true default once DI is implemented throughout the StepUp applications. See Pivotal #138225085
+ _defaults:
+ autowire: true
+ autoconfigure: true
+ public: false
- logger:
- alias: 'monolog.logger'
- public: true
+ logger:
+ alias: 'monolog.logger'
+ public: true
- surfnet_stepup_middleware_middleware.dbal_connection_helper:
- class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\DBALConnectionHelper
- arguments:
- -
- middleware: "@doctrine.dbal.middleware_connection"
- gateway: "@doctrine.dbal.gateway_connection"
+ surfnet_stepup_middleware_middleware.dbal_connection_helper:
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\DBALConnectionHelper
+ arguments:
+ - middleware: "@doctrine.dbal.middleware_connection"
+ gateway: "@doctrine.dbal.gateway_connection"
+ deploy: "@doctrine.dbal.deploy_connection"
- surfnet_stepup_middleware_middleware.institution_configuration_provider:
- class: Surfnet\StepupMiddleware\MiddlewareBundle\Migrations\InstitutionConfiguration\InstitutionConfigurationProvider
- arguments:
- - "@surfnet_stepup_middleware_api.service.configured_institutions"
- - "@surfnet_stepup_middleware_api.service.institution_configuration_options"
- - "@surfnet_stepup_middleware_api.service.ra_location"
+ surfnet_stepup_middleware_middleware.institution_configuration_provider:
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\Migrations\InstitutionConfiguration\InstitutionConfigurationProvider
+ arguments:
+ - "@surfnet_stepup_middleware_api.service.configured_institutions"
+ - "@surfnet_stepup_middleware_api.service.institution_configuration_options"
+ - "@surfnet_stepup_middleware_api.service.ra_location"
- surfnet_stepup_middleware_middleware.verfied_second_factor_reminder:
- class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\VerifiedSecondFactorReminderService
- arguments:
- - "@surfnet_stepup_middleware_api.repository.verified_second_factor"
- - "@surfnet_stepup_middleware_api.repository.identity"
- - "@surfnet_stepup_middleware_middleware.verfied_second_factor_reminder_mailer"
- - "@logger"
+ surfnet_stepup_middleware_middleware.verfied_second_factor_reminder:
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\VerifiedSecondFactorReminderService
+ arguments:
+ - "@surfnet_stepup_middleware_api.repository.verified_second_factor"
+ - "@surfnet_stepup_middleware_api.repository.identity"
+ - "@surfnet_stepup_middleware_middleware.verfied_second_factor_reminder_mailer"
+ - "@logger"
- surfnet_stepup_middleware_middleware.verfied_second_factor_reminder_mailer:
- class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\VerifiedSecondFactorReminderMailService
- arguments:
- - "@mailer.mailer"
- - "@surfnet_stepup_middleware_command_handling.email_sender"
- - "@translator"
- - "@surfnet_stepup_middleware_management.service.email_template"
- - "@surfnet_stepup_middleware_api.service.institution_configuration_options"
- - "@surfnet_stepup_middleware_api.service.ra_listing"
- - "@surfnet_stepup_middleware_api.service.ra_location"
- - "" # Fallback locale
+ surfnet_stepup_middleware_middleware.verfied_second_factor_reminder_mailer:
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\VerifiedSecondFactorReminderMailService
+ arguments:
+ - "@mailer.mailer"
+ - "@surfnet_stepup_middleware_command_handling.email_sender"
+ - "@translator"
+ - "@surfnet_stepup_middleware_management.service.email_template"
+ - "@surfnet_stepup_middleware_api.service.institution_configuration_options"
+ - "@surfnet_stepup_middleware_api.service.ra_listing"
+ - "@surfnet_stepup_middleware_api.service.ra_location"
+ - "" # Fallback locale
- surfnet_stepup_middleware_middleware.second_factor_display_name_resolver:
- public: false
- class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\SecondFactorDisplayNameResolverService
- arguments: ['%second_factors_display_name%']
+ surfnet_stepup_middleware_middleware.second_factor_display_name_resolver:
+ public: false
+ class: Surfnet\StepupMiddleware\MiddlewareBundle\Service\SecondFactorDisplayNameResolverService
+ arguments: [ '%second_factors_display_name%' ]
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/BootstrapCommandService.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/BootstrapCommandService.php
index a3a277c5a..d4ee0a008 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/BootstrapCommandService.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/BootstrapCommandService.php
@@ -18,7 +18,7 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Service;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Configuration\Value\Institution as ConfigurationInstitution;
use Surfnet\Stepup\Identity\Value\Institution;
use Surfnet\Stepup\Identity\Value\NameId;
@@ -49,70 +49,47 @@
*/
class BootstrapCommandService
{
- /** @var Pipeline */
- private $pipeline;
- /** @var TokenStorageInterface */
- private $tokenStorage;
- /** @var MetadataEnricher */
- private $enricher;
- /** @var IdentityRepository */
- private $identityRepository;
- /** @var UnverifiedSecondFactorRepository */
- private $unverifiedSecondFactorRepository;
- /** @var VerifiedSecondFactorRepository */
- private $verifiedSecondFactorRepository;
- /** @var InstitutionConfigurationOptionsRepository */
- private $institutionConfigurationRepository;
- /** @var VettedSecondFactorRepository */
- private $vettedSecondFactorRepository;
-
- private $validRegistrationStatuses = ['unverified', 'verified', 'vetted'];
+ /**
+ * @var string[]
+ */
+ private array $validRegistrationStatuses = ['unverified', 'verified', 'vetted'];
public function __construct(
- Pipeline $pipeline,
- MetadataEnricher $enricher,
- TokenStorageInterface $tokenStorage,
- IdentityRepository $identityRepository,
- UnverifiedSecondFactorRepository $unverifiedSecondFactorRepository,
- VerifiedSecondFactorRepository $verifiedSecondFactorRepository,
- VettedSecondFactorRepository $vettedSecondFactorRepository,
- InstitutionConfigurationOptionsRepository $institutionConfigurationOptionsRepository
+ private readonly Pipeline $pipeline,
+ private readonly MetadataEnricher $enricher,
+ private readonly TokenStorageInterface $tokenStorage,
+ private readonly IdentityRepository $identityRepository,
+ private readonly UnverifiedSecondFactorRepository $unverifiedSecondFactorRepository,
+ private readonly VerifiedSecondFactorRepository $verifiedSecondFactorRepository,
+ private readonly VettedSecondFactorRepository $vettedSecondFactorRepository,
+ private readonly InstitutionConfigurationOptionsRepository $institutionConfigurationRepository,
) {
- $this->pipeline = $pipeline;
- $this->enricher = $enricher;
- $this->tokenStorage = $tokenStorage;
- $this->identityRepository = $identityRepository;
- $this->unverifiedSecondFactorRepository = $unverifiedSecondFactorRepository;
- $this->verifiedSecondFactorRepository = $verifiedSecondFactorRepository;
- $this->institutionConfigurationRepository = $institutionConfigurationOptionsRepository;
- $this->vettedSecondFactorRepository = $vettedSecondFactorRepository;
}
- public function setToken(TokenInterface $token)
+ public function setToken(TokenInterface $token): void
{
$this->tokenStorage->setToken($token);
}
- /**
- * @param string $registrationStatus
- */
- public function validRegistrationStatus($registrationStatus)
+ public function validRegistrationStatus(string $registrationStatus): void
{
if (!in_array($registrationStatus, $this->validRegistrationStatuses)) {
throw new InvalidArgumentException(
sprintf(
'Invalid argument provided for the "registration-status" argument. One of: %s is expected. Received: "%s"',
implode(', ', $this->validRegistrationStatuses),
- $registrationStatus
- )
+ $registrationStatus,
+ ),
);
}
}
- public function requiresMailVerification(string $institution)
+ public function requiresMailVerification(string $institution): bool
{
- $configuration = $this->institutionConfigurationRepository->findConfigurationOptionsFor(new ConfigurationInstitution($institution));
- if ($configuration) {
+ $configuration = $this->institutionConfigurationRepository->findConfigurationOptionsFor(
+ new ConfigurationInstitution($institution),
+ );
+ if ($configuration instanceof \Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionConfigurationOptions) {
return $configuration->verifyEmailOption->isEnabled();
}
return true;
@@ -123,14 +100,14 @@ public function vetSecondFactor(
string $actorId,
Identity $identity,
string $secondFactorId,
- string $secondFactorIdentifier
- ) :void {
+ string $secondFactorIdentifier,
+ ): void {
$verifiedSecondFactor = $this->verifiedSecondFactorRepository->findOneBy(
- ['identityId' => $identity->id, 'type' => $tokenType]
+ ['identityId' => $identity->id, 'type' => $tokenType],
);
$command = new VetSecondFactorCommand();
- $command->UUID = (string) Uuid::uuid4();
+ $command->UUID = (string)Uuid::uuid4();
$command->authorityId = $actorId;
$command->identityId = $identity->id;
$command->secondFactorId = $secondFactorId;
@@ -143,21 +120,13 @@ public function vetSecondFactor(
$this->pipeline->process($command);
}
- /**
- * @param Institution $institution
- * @param NameId $nameId
- * @param $commonName
- * @param $email
- * @param $preferredLocale
- * @return CreateIdentityCommand
- */
public function createIdentity(
Institution $institution,
NameId $nameId,
- $commonName,
- $email,
- $preferredLocale
- ) {
+ string $commonName,
+ string $email,
+ string $preferredLocale,
+ ): CreateIdentityCommand {
$command = new CreateIdentityCommand();
$command->UUID = (string)Uuid::uuid4();
$command->id = (string)Uuid::uuid4();
@@ -172,8 +141,12 @@ public function createIdentity(
return $command;
}
- public function proveGsspPossession($secondFactorId, $identity, $tokenType, $tokenIdentifier)
- {
+ public function proveGsspPossession(
+ string $secondFactorId,
+ Identity $identity,
+ string $tokenType,
+ string $tokenIdentifier
+ ): void {
$command = new ProveGssfPossessionCommand();
$command->UUID = (string)Uuid::uuid4();
$command->secondFactorId = $secondFactorId;
@@ -184,8 +157,11 @@ public function proveGsspPossession($secondFactorId, $identity, $tokenType, $tok
$this->pipeline->process($command);
}
- public function provePhonePossession($secondFactorId, $identity, $phoneNumber)
- {
+ public function provePhonePossession(
+ string $secondFactorId,
+ Identity $identity,
+ string $phoneNumber
+ ): void {
$command = new ProvePhonePossessionCommand();
$command->UUID = (string)Uuid::uuid4();
$command->secondFactorId = $secondFactorId;
@@ -195,8 +171,11 @@ public function provePhonePossession($secondFactorId, $identity, $phoneNumber)
$this->pipeline->process($command);
}
- public function proveYubikeyPossession($secondFactorId, $identity, $yubikeyPublicId)
- {
+ public function proveYubikeyPossession(
+ string $secondFactorId,
+ Identity $identity,
+ string $yubikeyPublicId
+ ): void {
$command = new ProveYubikeyPossessionCommand();
$command->UUID = (string)Uuid::uuid4();
$command->secondFactorId = $secondFactorId;
@@ -206,10 +185,12 @@ public function proveYubikeyPossession($secondFactorId, $identity, $yubikeyPubli
$this->pipeline->process($command);
}
- public function verifyEmail(Identity $identity, string $tokenType)
- {
+ public function verifyEmail(
+ Identity $identity,
+ string $tokenType
+ ): void {
$unverifiedSecondFactor = $this->unverifiedSecondFactorRepository->findOneBy(
- ['identityId' => $identity->id, 'type' => $tokenType]
+ ['identityId' => $identity->id, 'type' => $tokenType],
);
$command = new VerifyEmailCommand();
@@ -220,8 +201,11 @@ public function verifyEmail(Identity $identity, string $tokenType)
$this->pipeline->process($command);
}
- public function migrateVettedSecondFactor(Identity $sourceIdentity, Identity $targetIdentity, VettedSecondFactor $vettedSecondFactor)
- {
+ public function migrateVettedSecondFactor(
+ Identity $sourceIdentity,
+ Identity $targetIdentity,
+ VettedSecondFactor $vettedSecondFactor,
+ ): void {
$command = new CommandHandlingMigrateSecondFactorCommand();
$command->UUID = (string)Uuid::uuid4();
$command->sourceIdentityId = $sourceIdentity->id;
@@ -232,7 +216,7 @@ public function migrateVettedSecondFactor(Identity $sourceIdentity, Identity $ta
$this->pipeline->process($command);
}
- public function enrichEventMetadata($actorId)
+ public function enrichEventMetadata(string $actorId): void
{
$actor = $this->identityRepository->findOneBy(['id' => $actorId]);
@@ -242,32 +226,25 @@ public function enrichEventMetadata($actorId)
$this->enricher->setMetadata($metadata);
}
- /**
- * @return Identity
- */
- public function getIdentity(NameId $nameId, Institution $institution)
+ public function getIdentity(NameId $nameId, Institution $institution): Identity
{
return $this->identityRepository->findOneByNameIdAndInstitution($nameId, $institution);
}
- /**
- ** @return Identity
- */
- public function getIdentityByNameId(NameId $nameId)
+ public function getIdentityByNameId(NameId $nameId): ?Identity
{
return $this->identityRepository->findOneByNameId($nameId);
}
- public function identityExists(NameId $nameId, Institution $institution)
+ public function identityExists(NameId $nameId, Institution $institution): bool
{
return $this->identityRepository->hasIdentityWithNameIdAndInstitution($nameId, $institution);
}
/**
- * @param Identity $identity
* @return array|VettedSecondFactor[]
*/
- public function getVettedSecondFactorsFromIdentity(Identity $identity)
+ public function getVettedSecondFactorsFromIdentity(Identity $identity): array
{
return $this->vettedSecondFactorRepository->findBy(['identityId' => $identity->id]);
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/DBALConnectionHelper.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/DBALConnectionHelper.php
index e987b210a..a2abed8a6 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/DBALConnectionHelper.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/DBALConnectionHelper.php
@@ -27,7 +27,7 @@ class DBALConnectionHelper
/**
* @var Connection[]
*/
- private $connections;
+ private array $connections;
/**
* @param Connection[] $connections
@@ -36,8 +36,15 @@ public function __construct(array $connections)
{
foreach ($connections as $connection) {
if (!$connection instanceof Connection) {
- throw InvalidArgumentException::invalidType('\Doctrine\DBAL\Connection', 'connection', $connection);
+ throw InvalidArgumentException::invalidType(Connection::class, 'connection', $connection);
}
+ if (!$connection->getDatabasePlatform()->supportsSavepoints()) {
+ throw new InvalidArgumentException(sprintf(
+ "Connection for database '%s' does not support nested savepoints",
+ $connection->getDatabase()
+ ));
+ }
+ $connection->setNestTransactionsWithSavepoints(true);
}
$this->connections = $connections;
@@ -46,7 +53,7 @@ public function __construct(array $connections)
/**
* Start transaction on each connection
*/
- public function beginTransaction()
+ public function beginTransaction(): void
{
foreach ($this->connections as $connection) {
$connection->beginTransaction();
@@ -56,7 +63,7 @@ public function beginTransaction()
/**
* Commit transaction on each connection
*/
- public function commit()
+ public function commit(): void
{
foreach ($this->connections as $connection) {
$connection->commit();
@@ -66,7 +73,7 @@ public function commit()
/**
* Roll back the transaction on each connection
*/
- public function rollBack()
+ public function rollBack(): void
{
foreach ($this->connections as $connection) {
$connection->rollBack();
@@ -74,15 +81,10 @@ public function rollBack()
}
/**
- * @param string $connectionName
* @return Connection
*/
- public function getConnection($connectionName)
+ public function getConnection(string $connectionName): Connection
{
- if (!is_string($connectionName)) {
- throw InvalidArgumentException::invalidType('string', 'connectionName', $connectionName);
- }
-
if (!array_key_exists($connectionName, $this->connections)) {
throw new UnknownDBALConnectionException($connectionName);
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/EventDispatcher.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/EventDispatcher.php
index bb67d1f3c..5c5694417 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/EventDispatcher.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/EventDispatcher.php
@@ -18,20 +18,12 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Service;
-use Broadway\Domain\DomainEventStreamInterface;
-use Broadway\ReadModel\ProjectorInterface;
+use Broadway\Domain\DomainEventStream;
+use Broadway\EventHandling\EventListener;
interface EventDispatcher
{
- /**
- * @param ProjectorInterface $projector
- * @return void
- */
- public function registerProjector(ProjectorInterface $projector);
+ public function registerProjector(EventListener $projector): void;
- /**
- * @param DomainEventStreamInterface $event
- * @return void
- */
- public function dispatch(DomainEventStreamInterface $event);
+ public function dispatch(DomainEventStream $event): void;
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/EventStreamReplayer.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/EventStreamReplayer.php
index 65da85b25..d54d41318 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/EventStreamReplayer.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/EventStreamReplayer.php
@@ -18,91 +18,88 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Service;
-use Broadway\Domain\DomainEventStream;
use Broadway\Domain\DomainMessage;
+use Doctrine\DBAL\Exception\InvalidArgumentException;
use Exception;
use Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus;
use Surfnet\StepupMiddleware\MiddlewareBundle\EventSourcing\DBALEventHydrator;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\OutputInterface;
+use Throwable;
class EventStreamReplayer
{
- /**
- * @var BufferedEventBus
- */
- private $eventBus;
-
- /**
- * @var DBALEventHydrator
- */
- private $eventHydrator;
-
- /**
- * @var DBALConnectionHelper
- */
- private $connectionHelper;
-
/**
* @var string[]
*/
- private $middlewareTables = [
- 'unverified_second_factor',
- 'verified_second_factor',
- 'vetted_second_factor',
+ private array $middlewareTables = [
+ 'allowed_second_factor',
+ 'audit_log',
'configured_institution',
- 'institution_configuration_options',
+ 'email_templates',
+ 'identity',
+ 'identity_self_asserted_token_options',
'institution_authorization',
+ 'institution_configuration_options',
+ 'institution_listing',
+// 'institution_with_ra_locations',
+ 'ra_listing',
'ra_location',
'ra_second_factor',
- 'identity',
- 'sraa',
- 'audit_log',
- 'ra_listing',
+ 'recovery_token',
'second_factor_revocation',
+ 'sraa',
+ 'unverified_second_factor',
+ 'verified_second_factor',
+ 'vetted_second_factor',
+ 'vetting_type_hint',
'whitelist_entry',
];
/**
* @var string[]
*/
- private $gatewayTables = [
- 'second_factor',
+ private array $gatewayTables = [
+ 'institution_configuration',
'saml_entity',
+ 'second_factor',
'whitelist_entry',
];
public function __construct(
- BufferedEventBus $eventBus,
- DBALEventHydrator $eventHydrator,
- DBALConnectionHelper $connectionHelper
+ private readonly BufferedEventBus $eventBus,
+ private readonly DBALEventHydrator $eventHydrator,
+ private readonly DBALConnectionHelper $connectionHelper,
) {
- $this->eventBus = $eventBus;
- $this->eventHydrator = $eventHydrator;
- $this->connectionHelper = $connectionHelper;
ProgressBar::setFormatDefinition(
'event_replay',
" %message%\n"
. ' %current%/%max% [%bar%] %percent:3s%%%elapsed:6s%/'
- . "%estimated:-6s%\n %memory:6s%"
+ . "%estimated:-6s%\n %memory:6s%",
);
}
- public function replayEvents(OutputInterface $output, $increments)
+ public function replayEvents(OutputInterface $output, int $increments): void
{
$preparationProgress = new ProgressBar($output, 3);
$preparationProgress->setFormat('event_replay');
$preparationProgress->setMessage('Starting Transaction');
$this->connectionHelper->beginTransaction();
+ $preparationProgress->clear();
$preparationProgress->advance();
try {
$preparationProgress->setMessage('Removing data from Read Tables');
+ $preparationProgress->clear();
$this->wipeReadTables($output);
+
+ $preparationProgress->setMessage('Done wiping');
+ $preparationProgress->clear();
$preparationProgress->advance();
$preparationProgress->setMessage('Determining amount of events to replay...');
+ $preparationProgress->clear();
$totalEvents = $this->eventHydrator->getCount();
$preparationProgress->advance();
@@ -110,15 +107,17 @@ public function replayEvents(OutputInterface $output, $increments)
if ($totalEvents == 0) {
// Spaces are needed to overwrite the previous message.
$preparationProgress->setMessage('There are no events to replay. Done. ');
+ $preparationProgress->clear();
$preparationProgress->finish();
return;
} else {
$defaultMessage = sprintf(
'Found %s Events, replaying in increments of %d',
$totalEvents,
- $increments
+ $increments,
);
$preparationProgress->setMessage($defaultMessage);
+ $preparationProgress->clear();
$preparationProgress->finish();
}
@@ -127,7 +126,6 @@ public function replayEvents(OutputInterface $output, $increments)
$replayProgress->setMessage($defaultMessage);
for ($count = 0; $count < $totalEvents; $count += $increments) {
- /** @var DomainEventStream $eventStream */
$eventStream = $this->eventHydrator->getFromTill($increments, $count);
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) {
@@ -135,9 +133,10 @@ public function replayEvents(OutputInterface $output, $increments)
foreach ($eventStream->getIterator() as $event) {
/** @var DomainMessage $event */
$messages[] = sprintf(
- ' > Publishing Event "%s" for UUID "%s"',
+ ' > Publishing Event %s "%s" for UUID "%s"',
+ $event->getRecordedOn()->toString(),
$event->getType(),
- $event->getId()
+ $event->getId(),
);
}
@@ -156,7 +155,9 @@ public function replayEvents(OutputInterface $output, $increments)
$replayProgress->finish();
$output->writeln(['', 'Done', '']);
- } catch (Exception $e) {
+ } catch (Throwable $e) {
+ echo $e->getMessage()."\n";
+
$this->connectionHelper->rollBack();
if (isset($replayProgress)) {
$replayProgress->setMessage(sprintf('ERROR OCCURRED: "%s"', $e->getMessage()));
@@ -167,39 +168,46 @@ public function replayEvents(OutputInterface $output, $increments)
}
}
- private function wipeReadTables(OutputInterface $output)
+ /**
+ * @throws InvalidArgumentException|\Doctrine\DBAL\Exception
+ */
+ private function wipeReadTables(OutputInterface $output): void
{
if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
$output->writeln('Retrieving connections to wipe READ tables');
}
$middlewareConnection = $this->connectionHelper->getConnection('middleware');
- $gatewayConnection = $this->connectionHelper->getConnection('gateway');
+ $gatewayConnection = $this->connectionHelper->getConnection('gateway');
$middlewareDatabaseName = $middlewareConnection->getDatabase();
- $gatewayDatabaseName = $gatewayConnection->getDatabase();
+ $gatewayDatabaseName = $gatewayConnection->getDatabase();
foreach ($this->middlewareTables as $table) {
$rows = $middlewareConnection->delete($table, [1 => 1]);
if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
- $output->writeln(sprintf(
- 'Deleted %d rows from table %s.%s',
- $rows,
- $middlewareDatabaseName,
- $table
- ));
+ $output->writeln(
+ sprintf(
+ 'Deleted %d rows from table %s.%s',
+ $rows,
+ $middlewareDatabaseName,
+ $table,
+ ),
+ );
}
}
foreach ($this->gatewayTables as $table) {
$rows = $gatewayConnection->delete($table, [1 => 1]);
if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
- $output->writeln(sprintf(
- 'Deleted %d rows from table %s.%s',
- $rows,
- $gatewayDatabaseName,
- $table
- ));
+ $output->writeln(
+ sprintf(
+ 'Deleted %d rows from table %s.%s',
+ $rows,
+ $gatewayDatabaseName,
+ $table,
+ ),
+ );
}
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/PastEventsService.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/PastEventsService.php
index 27da5d086..bedf349ca 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/PastEventsService.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/PastEventsService.php
@@ -18,26 +18,20 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Service;
+use Broadway\Domain\DomainEventStream;
use Surfnet\StepupMiddleware\MiddlewareBundle\EventSourcing\DBALEventHydrator;
use Surfnet\StepupMiddleware\MiddlewareBundle\EventSourcing\EventCollection;
-final class PastEventsService
+final readonly class PastEventsService
{
- /**
- * @var DBALEventHydrator
- */
- private $eventHydrator;
-
- public function __construct(DBALEventHydrator $eventHydrator)
+ public function __construct(private DBALEventHydrator $eventHydrator)
{
- $this->eventHydrator = $eventHydrator;
}
/**
- * @param EventCollection $events
- * @return \Broadway\Domain\DomainEventStream
+ * @return DomainEventStream
*/
- public function findEventsBy(EventCollection $events)
+ public function findEventsBy(EventCollection $events): DomainEventStream
{
return $this->eventHydrator->fetchByEventTypes($events->formatAsEventStreamTypes());
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/ReplayingEventDispatcher.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/ReplayingEventDispatcher.php
index ec7f33a66..d276232b9 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/ReplayingEventDispatcher.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/ReplayingEventDispatcher.php
@@ -18,25 +18,22 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Service;
-use Broadway\Domain\DomainEventStreamInterface;
-use Broadway\ReadModel\ProjectorInterface;
+use Broadway\Domain\DomainEventStream;
+use Broadway\EventHandling\EventListener;
final class ReplayingEventDispatcher implements EventDispatcher
{
/**
- * @var ProjectorInterface[]
+ * @var EventListener[]
*/
- private $projectors;
+ private ?array $projectors = null;
- /**
- * @param ProjectorInterface $projector
- */
- public function registerProjector(ProjectorInterface $projector)
+ public function registerProjector(EventListener $projector): void
{
$this->projectors[] = $projector;
}
- public function dispatch(DomainEventStreamInterface $events)
+ public function dispatch(DomainEventStream $events): void
{
foreach ($events as $event) {
foreach ($this->projectors as $projector) {
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/SecondFactorDisplayNameResolverService.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/SecondFactorDisplayNameResolverService.php
index cbe55b9c1..0882c86ad 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/SecondFactorDisplayNameResolverService.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/SecondFactorDisplayNameResolverService.php
@@ -1,7 +1,7 @@
secondFactors = $secondFactors;
}
/**
- * @param SecondFactorType $secondFactorType
- *
* @return string
*/
public function resolveByType(SecondFactorType $secondFactorType): string
{
- return $this->secondFactors[(string) $secondFactorType] ?? ucfirst((string) $secondFactorType);
+ return $this->secondFactors[(string)$secondFactorType] ?? ucfirst((string)$secondFactorType);
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/TransactionAwareEventDispatcher.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/TransactionAwareEventDispatcher.php
index eb1fdb9b2..b8697a53f 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/TransactionAwareEventDispatcher.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/TransactionAwareEventDispatcher.php
@@ -18,34 +18,24 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Service;
-use Broadway\Domain\DomainEventStreamInterface;
-use Broadway\ReadModel\ProjectorInterface;
+use Broadway\Domain\DomainEventStream;
+use Broadway\EventHandling\EventListener;
use Exception;
-final class TransactionAwareEventDispatcher implements EventDispatcher
+final readonly class TransactionAwareEventDispatcher implements EventDispatcher
{
- /**
- * @var EventDispatcher
- */
- private $eventDispatcher;
-
- /**
- * @var DBALConnectionHelper
- */
- private $connectionHelper;
-
- public function __construct(DBALConnectionHelper $connectionHelper, EventDispatcher $eventDispatcher)
- {
- $this->connectionHelper = $connectionHelper;
- $this->eventDispatcher = $eventDispatcher;
+ public function __construct(
+ private DBALConnectionHelper $connectionHelper,
+ private EventDispatcher $eventDispatcher,
+ ) {
}
- public function registerProjector(ProjectorInterface $projector)
+ public function registerProjector(EventListener $projector): void
{
$this->eventDispatcher->registerProjector($projector);
}
- public function dispatch(DomainEventStreamInterface $events)
+ public function dispatch(DomainEventStream $events): void
{
$this->connectionHelper->beginTransaction();
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/TransactionHelper.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/TransactionHelper.php
index ef4c35b36..9764ce1ec 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/TransactionHelper.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/TransactionHelper.php
@@ -18,24 +18,17 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Service;
-use Broadway\EventHandling\EventBus as EventBusInterface;
-use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\Command as MiddlewareCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\Command\AbstractCommand;
+use Surfnet\StepupMiddleware\CommandHandlingBundle\EventHandling\BufferedEventBus;
use Surfnet\StepupMiddleware\CommandHandlingBundle\Pipeline\Pipeline;
-final class TransactionHelper
+final readonly class TransactionHelper
{
- /** @var Pipeline */
- private $pipeline;
- /** @var EventBusInterface */
- private $eventBus;
- /** @var DBALConnectionHelper */
- private $connection;
-
- public function __construct(Pipeline $pipeline, EventBusInterface $eventBus, DBALConnectionHelper $connection)
- {
- $this->pipeline = $pipeline;
- $this->eventBus = $eventBus;
- $this->connection = $connection;
+ public function __construct(
+ private Pipeline $pipeline,
+ private BufferedEventBus $eventBus,
+ private DBALConnectionHelper $connection,
+ ) {
}
public function beginTransaction(): void
@@ -54,7 +47,7 @@ public function rollback(): void
$this->connection->rollBack();
}
- public function process(MiddlewareCommand $command): MiddlewareCommand
+ public function process(AbstractCommand $command): AbstractCommand
{
return $this->pipeline->process($command);
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderMailService.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderMailService.php
index 25b1353f5..221c31369 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderMailService.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderMailService.php
@@ -19,8 +19,9 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Service;
use Assert\Assertion;
-use DateTime;
use Surfnet\Stepup\Configuration\Value\Institution;
+use Surfnet\Stepup\DateTime\DateTime;
+use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\RaLocation;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\InstitutionConfigurationOptionsService;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Service\RaLocationService;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Service\RaListingService;
@@ -32,156 +33,105 @@
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\MailerInterface as Mailer;
use Symfony\Component\Mime\Address;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class VerifiedSecondFactorReminderMailService
{
- /**
- * @var Mailer
- */
- private $mailer;
-
- /**
- * @var Sender
- */
- private $sender;
-
- /**
- * @var TranslatorInterface
- */
- private $translator;
-
- /**
- * @var EmailTemplateService
- */
- private $emailTemplateService;
-
- /**
- * @var InstitutionConfigurationOptionsService
- */
- private $institutionConfigurationOptionsService;
-
- /**
- * @var RaListingService
- */
- private $raListingService;
-
- /**
- * @var RaLocationService
- */
- private $raLocationService;
-
- /**
- * @var string
- */
- private $fallbackLocale;
+ private readonly string $fallbackLocale;
public function __construct(
- Mailer $mailer,
- Sender $sender,
- TranslatorInterface $translator,
- EmailTemplateService $emailTemplateService,
- InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
- RaListingService $raListingService,
- RaLocationService $raLocationService,
- string $fallbackLocale
+ private readonly Mailer $mailer,
+ private readonly Sender $sender,
+ private readonly TranslatorInterface $translator,
+ private readonly EmailTemplateService $emailTemplateService,
+ private readonly InstitutionConfigurationOptionsService $institutionConfigurationOptionsService,
+ private readonly RaListingService $raListingService,
+ private readonly RaLocationService $raLocationService,
+ string $fallbackLocale,
) {
Assertion::string($fallbackLocale, 'Fallback locale "%s" expected to be string, type %s given');
- $this->mailer = $mailer;
- $this->sender = $sender;
- $this->translator = $translator;
- $this->emailTemplateService = $emailTemplateService;
- $this->institutionConfigurationOptionsService = $institutionConfigurationOptionsService;
- $this->raListingService = $raListingService;
- $this->raLocationService = $raLocationService;
$this->fallbackLocale = $fallbackLocale;
}
/**
- * @param VerifiedTokenInformation $tokenInformation
- * @return int
+ * @throws TransportExceptionInterface
*/
- public function sendReminder(VerifiedTokenInformation $tokenInformation)
+ public function sendReminder(VerifiedTokenInformation $tokenInformation): void
{
- $institution = new Institution((string) $tokenInformation->getInstitution());
+ $institution = new Institution($tokenInformation->getInstitution());
$institutionConfigurationOptions = $this->institutionConfigurationOptionsService
->findInstitutionConfigurationOptionsFor($institution);
if ($institutionConfigurationOptions->useRaLocationsOption->isEnabled()) {
- return $this->sendReminderWithInstitution(
+ $this->sendReminderWithInstitution(
$tokenInformation->getPreferredLocale(),
$tokenInformation->getCommonName(),
$tokenInformation->getEmail(),
$tokenInformation->getRequestedAt(),
$tokenInformation->getRegistrationCode(),
- $this->raLocationService->listRaLocationsFor($institution)
+ $this->raLocationService->listRaLocationsFor($institution),
);
+ return;
}
$ras = $this->raListingService->listRegistrationAuthoritiesFor($tokenInformation->getInstitution());
if ($institutionConfigurationOptions->showRaaContactInformationOption->isEnabled()) {
- return $this->sendReminderWithRas(
+ $this->sendReminderWithRas(
$tokenInformation->getPreferredLocale(),
$tokenInformation->getCommonName(),
$tokenInformation->getEmail(),
$tokenInformation->getRequestedAt(),
$tokenInformation->getRegistrationCode(),
- $ras
+ $ras,
);
+ return;
}
- $rasWithoutRaas = array_filter($ras, function (RegistrationAuthorityCredentials $ra) {
- return !$ra->isRaa();
- });
+ $rasWithoutRaas = array_filter($ras, fn(RegistrationAuthorityCredentials $ra): bool => !$ra->isRaa());
- return $this->sendReminderWithRas(
+ $this->sendReminderWithRas(
$tokenInformation->getPreferredLocale(),
$tokenInformation->getCommonName(),
$tokenInformation->getEmail(),
$tokenInformation->getRequestedAt(),
$tokenInformation->getRegistrationCode(),
- $rasWithoutRaas
+ $rasWithoutRaas,
);
}
/**
- * @param string $locale
- * @param string $commonName
- * @param string $email
- * @param DateTime $requestedAt
- * @param $registrationCode
- * @return void
+ * @param RaLocation[]|null $raLocations
* @throws TransportExceptionInterface
*/
private function sendReminderWithInstitution(
- $locale,
- $commonName,
- $email,
- $requestedAt,
- $registrationCode,
- $raLocations
- ) {
+ string $locale,
+ string $commonName,
+ string $email,
+ DateTime $requestedAt,
+ string $registrationCode,
+ ?array $raLocations,
+ ): void {
$subject = $this->translator->trans(
'ss.mail.registration_email.subject',
['%commonName%' => $commonName],
'messages',
- $locale
+ $locale,
);
$emailTemplate = $this->emailTemplateService->findByName(
'second_factor_verification_reminder_with_ra_locations',
$locale,
- $this->fallbackLocale
+ $this->fallbackLocale,
);
$parameters = [
'templateString' => $emailTemplate->htmlContent,
'locale' => $locale,
'commonName' => $commonName,
- 'expirationDate' => $requestedAt,
+ 'expirationDate' => (string)$requestedAt,
'registrationCode' => $registrationCode,
'raLocations' => $raLocations,
];
@@ -195,32 +145,36 @@ private function sendReminderWithInstitution(
$this->mailer->send($email);
}
+ /**
+ * @param RegistrationAuthorityCredentials[] $ras
+ * @throws TransportExceptionInterface
+ */
private function sendReminderWithRas(
- $locale,
- $commonName,
- $email,
- $requestedAt,
- $registrationCode,
- array $ras
- ) {
+ string $locale,
+ string $commonName,
+ string $email,
+ DateTime $requestedAt,
+ string $registrationCode,
+ array $ras,
+ ): void {
$subject = $this->translator->trans(
'ss.mail.registration_email.subject',
['%commonName%' => $commonName],
'messages',
- $locale
+ $locale,
);
$emailTemplate = $this->emailTemplateService->findByName(
'second_factor_verification_reminder_with_ras',
$locale,
- $this->fallbackLocale
+ $this->fallbackLocale,
);
$parameters = [
'templateString' => $emailTemplate->htmlContent,
'locale' => $locale,
'commonName' => $commonName,
- 'expirationDate' => $requestedAt,
+ 'expirationDate' => (string)$requestedAt,
'registrationCode' => $registrationCode,
'ras' => $ras,
];
@@ -229,7 +183,7 @@ private function sendReminderWithRas(
->from(new Address($this->sender->getEmail(), $this->sender->getName()))
->to(new Address($email, $commonName))
->subject($subject)
- ->htmlTemplate('SurfnetStepupMiddlewareCommandHandling/SecondFactorMailService/email.html.twig')
+ ->htmlTemplate('@SurfnetStepupMiddlewareCommandHandling/SecondFactorMailService/email.html.twig')
->context($parameters);
$this->mailer->send($email);
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderService.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderService.php
index d18d153cb..0954262fe 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderService.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderService.php
@@ -19,6 +19,7 @@
use Assert\Assertion;
use DateTime;
+use Exception;
use InvalidArgumentException;
use Psr\Log\LoggerInterface;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\IdentityRepository;
@@ -31,71 +32,39 @@
*/
class VerifiedSecondFactorReminderService
{
- /**
- * @var VerifiedSecondFactorRepository
- */
- private $verifiedRepository;
-
- /**
- * @var IdentityRepository
- */
- private $identityRepository;
-
- /**
- * @var VerifiedSecondFactorReminderMailService
- */
- private $mailService;
-
- /**
- * @var LoggerInterface
- */
- private $logger;
-
- /**
- * @param VerifiedSecondFactorRepository $verifiedRepository
- * @param IdentityRepository $identityRepository
- * @param VerifiedSecondFactorReminderMailService $mailService
- * @param LoggerInterface $logger
- */
public function __construct(
- VerifiedSecondFactorRepository $verifiedRepository,
- IdentityRepository $identityRepository,
- VerifiedSecondFactorReminderMailService $mailService,
- LoggerInterface $logger
+ private readonly VerifiedSecondFactorRepository $verifiedRepository,
+ private readonly IdentityRepository $identityRepository,
+ private readonly VerifiedSecondFactorReminderMailService $mailService,
+ private readonly LoggerInterface $logger,
) {
- $this->verifiedRepository = $verifiedRepository;
- $this->identityRepository = $identityRepository;
- $this->mailService = $mailService;
- $this->logger = $logger;
}
- /**
- * @param DateTime $date
- * @param bool $dryRun
- */
- public function sendReminders(DateTime $date, $dryRun)
+ public function sendReminders(DateTime $date, bool $dryRun): void
{
$this->logger->info(
sprintf(
'Sending reminders for date: %s. dry run mode is %s',
$date->format('Y-m-d'),
- ($dryRun ? 'enabled' : 'disabled')
- )
+ ($dryRun ? 'enabled' : 'disabled'),
+ ),
);
$totalNumberSent = 0;
$tokenInformationCollection = $this->buildCollection($date);
- if (!empty($tokenInformationCollection)) {
+ if ($tokenInformationCollection !== []) {
$this->logger->info(sprintf('%d token reminder(s) will be sent', count($tokenInformationCollection)));
foreach ($tokenInformationCollection as $tokenInformation) {
- if (!$dryRun) {
- $numberSent = $this->mailService->sendReminder($tokenInformation);
- } else {
- $numberSent = 1;
+ try {
+ $this->mailService->sendReminder($tokenInformation);
+ $wasSent = 1;
+ } catch (Exception) {
+ $wasSent = 0;
}
+ $numberSent = $dryRun ? 1 : $wasSent;
$this->logger->info(
sprintf(
@@ -104,8 +73,8 @@ public function sendReminders(DateTime $date, $dryRun)
($dryRun ? 'in dry run mode ' : ''),
$tokenInformation->getEmail(),
$tokenInformation->getTokenId(),
- $tokenInformation->getTokenType()
- )
+ $tokenInformation->getTokenType(),
+ ),
);
$totalNumberSent += $numberSent;
}
@@ -115,16 +84,15 @@ public function sendReminders(DateTime $date, $dryRun)
sprintf(
'%d reminders %s been sent',
$totalNumberSent,
- ($dryRun ? 'would have' : 'have')
- )
+ ($dryRun ? 'would have' : 'have'),
+ ),
);
}
/**
- * @param DateTime $date
* @return VerifiedTokenInformation[]
*/
- private function buildCollection(DateTime $date)
+ private function buildCollection(DateTime $date): array
{
$collection = [];
@@ -136,8 +104,8 @@ private function buildCollection(DateTime $date)
sprintf(
'Identity not found with id "%s" for second factor token "%s"',
$token->identityId,
- $token->id
- )
+ $token->id,
+ ),
);
$collection[] = VerifiedTokenInformation::fromEntity($token, $identity);
} catch (InvalidArgumentException $e) {
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/SurfnetStepupMiddlewareMiddlewareBundle.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/SurfnetStepupMiddlewareMiddlewareBundle.php
index e19d0f741..d82ac1ea7 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/SurfnetStepupMiddlewareMiddlewareBundle.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/SurfnetStepupMiddlewareMiddlewareBundle.php
@@ -18,18 +18,13 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle;
-use Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\BootstrapIdentityWithYubikeySecondFactorCommand;
-use Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\EmailVerifiedSecondFactorRemindersCommand;
-use Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\ReplayEventsCommand;
-use Surfnet\StepupMiddleware\MiddlewareBundle\Console\Command\ReplaySpecificEventsCommand;
use Surfnet\StepupMiddleware\MiddlewareBundle\DependencyInjection\CompilerPass\CollectProjectorsForEventReplayCompilerPass;
-use Symfony\Component\Console\Application;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class SurfnetStepupMiddlewareMiddlewareBundle extends Bundle
{
- public function build(ContainerBuilder $container)
+ public function build(ContainerBuilder $container): void
{
parent::build($container);
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/EventSourcing/EventCollectionTest.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/EventSourcing/EventCollectionTest.php
index 74a4fca85..2f20311e5 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/EventSourcing/EventCollectionTest.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/EventSourcing/EventCollectionTest.php
@@ -18,6 +18,7 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Tests\EventSourcing;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as TestCase;
use stdClass;
use Surfnet\Stepup\Configuration\Event\NewConfigurationCreatedEvent;
@@ -27,26 +28,28 @@
class EventCollectionTest extends TestCase
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group event-replay
*
* @dataProvider emptyOrNonStringProvider
- * @param $emptyOrNonString
*/
- public function an_event_collection_must_be_created_from_an_array_of_non_empty_strings($emptyOrNonString)
- {
+ public function an_event_collection_must_be_created_from_an_array_of_non_empty_strings(
+ bool|int|string|stdClass|array|null $emptyOrNonString,
+ ): void {
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid argument type: "non-empty string" expected');
- new EventCollection([$emptyOrNonString]);
+ new EventCollection([$emptyOrNonString]); // @phpstan-ignore-line argument.type: Warning about a faulty constructor argument is exactly what we are testing here
}
/**
* @test
* @group event-replay
*/
- public function an_event_collection_must_contain_event_names_that_are_existing_class_names()
+ public function an_event_collection_must_contain_event_names_that_are_existing_class_names(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('does not exist');
@@ -60,13 +63,13 @@ public function an_event_collection_must_contain_event_names_that_are_existing_c
* @test
* @group event-replay
*/
- public function an_event_collection_contains_given_event_names()
+ public function an_event_collection_contains_given_event_names(): void
{
$eventCollection = new EventCollection([NewConfigurationCreatedEvent::class]);
$this->assertTrue(
$eventCollection->contains(NewConfigurationCreatedEvent::class),
- 'EventCollection should contain NewConfigurationCreatedEvent but it does not'
+ 'EventCollection should contain NewConfigurationCreatedEvent but it does not',
);
}
@@ -74,7 +77,7 @@ public function an_event_collection_contains_given_event_names()
* @test
* @group event-replay
*/
- public function event_names_can_be_retrieved_from_an_event_collection()
+ public function event_names_can_be_retrieved_from_an_event_collection(): void
{
$eventNames = [NewConfigurationCreatedEvent::class];
$eventCollection = new EventCollection($eventNames);
@@ -84,7 +87,7 @@ public function event_names_can_be_retrieved_from_an_event_collection()
$this->assertSame(
$eventNames,
$actualEventNames,
- 'Event names cannot be correctly retrieved from an EventCollection'
+ 'Event names cannot be correctly retrieved from an EventCollection',
);
}
@@ -92,13 +95,13 @@ public function event_names_can_be_retrieved_from_an_event_collection()
* @test
* @group event-replay
*/
- public function an_event_collection_does_not_contain_given_event_names()
+ public function an_event_collection_does_not_contain_given_event_names(): void
{
$eventCollection = new EventCollection([SecondFactorVettedEvent::class]);
$this->assertFalse(
$eventCollection->contains(NewConfigurationCreatedEvent::class),
- 'EventCollection should not contain NewConfigurationCreatedEvent but it does'
+ 'EventCollection should not contain NewConfigurationCreatedEvent but it does',
);
}
@@ -106,7 +109,7 @@ public function an_event_collection_does_not_contain_given_event_names()
* @test
* @group event-replay
*/
- public function a_subset_of_events_can_be_selected_from_an_event_collection()
+ public function a_subset_of_events_can_be_selected_from_an_event_collection(): void
{
$eventCollection = new EventCollection([NewConfigurationCreatedEvent::class, SecondFactorVettedEvent::class]);
@@ -114,7 +117,7 @@ public function a_subset_of_events_can_be_selected_from_an_event_collection()
$this->assertTrue(
$subset->contains(NewConfigurationCreatedEvent::class),
- 'EventCollection subset should contain NewConfigurationCreatedEvent but it did not'
+ 'EventCollection subset should contain NewConfigurationCreatedEvent but it did not',
);
}
@@ -122,7 +125,7 @@ public function a_subset_of_events_can_be_selected_from_an_event_collection()
* @test
* @group event-replay
*/
- public function a_subset_containing_events_not_present_in_the_event_collection_cannot_be_selected()
+ public function a_subset_containing_events_not_present_in_the_event_collection_cannot_be_selected(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Subset of event names contains event names not present in collection');
@@ -135,7 +138,7 @@ public function a_subset_containing_events_not_present_in_the_event_collection_c
* @test
* @group event-replay
*/
- public function events_in_an_event_collection_can_be_formatted_as_event_stream_compatible_event_types()
+ public function events_in_an_event_collection_can_be_formatted_as_event_stream_compatible_event_types(): void
{
$eventCollection = new EventCollection([NewConfigurationCreatedEvent::class, SecondFactorVettedEvent::class]);
@@ -148,11 +151,14 @@ public function events_in_an_event_collection_can_be_formatted_as_event_stream_c
$this->assertEquals(
$expectedEventTypes,
$actualEventTypes,
- 'The events in the event collection should have been formatted as event stream compatible event types but they have not'
+ 'The events in the event collection should have been formatted as event stream compatible event types but they have not',
);
}
- public function emptyOrNonStringProvider()
+ /**
+ * @return array
+ */
+ public function emptyOrNonStringProvider(): array
{
return [
'null' => [null],
@@ -161,7 +167,7 @@ public function emptyOrNonStringProvider()
'float' => [123],
'empty string' => [''],
'object' => [new stdClass()],
- 'array' => [[]]
+ 'array' => [[]],
];
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/EventSourcing/ProjectorCollectionTest.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/EventSourcing/ProjectorCollectionTest.php
index 4473d7306..603d2b44f 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/EventSourcing/ProjectorCollectionTest.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/EventSourcing/ProjectorCollectionTest.php
@@ -29,13 +29,14 @@
class ProjectorCollectionTest extends TestCase
{
+ use m\Adapter\Phpunit\MockeryPHPUnitIntegration;
/**
* @test
* @group event-replay
*/
- public function projectors_can_be_added_to_a_projector_collection_during_runtime()
+ public function projectors_can_be_added_to_a_projector_collection_during_runtime(): void
{
- $sraaProjector = new SraaProjector(m::mock(SraaRepository::class));
+ $sraaProjector = new SraaProjector(m::mock(SraaRepository::class));
$whitelistProjector = new WhitelistProjector(m::mock(WhitelistEntryRepository::class));
$projectorCollection = new ProjectorCollection;
@@ -44,11 +45,11 @@ public function projectors_can_be_added_to_a_projector_collection_during_runtime
$this->assertTrue(
$projectorCollection->contains($sraaProjector),
- 'ProjectorCollection should have contained added SraaProjector but it did not'
+ 'ProjectorCollection should have contained added SraaProjector but it did not',
);
$this->assertTrue(
$projectorCollection->contains($whitelistProjector),
- 'ProjectorCollection should have contained added WhitelistProjector but it did not'
+ 'ProjectorCollection should have contained added WhitelistProjector but it did not',
);
}
@@ -56,9 +57,9 @@ public function projectors_can_be_added_to_a_projector_collection_during_runtime
* @test
* @group event-replay
*/
- public function projector_names_can_be_retrieved_from_a_projector_collection()
+ public function projector_names_can_be_retrieved_from_a_projector_collection(): void
{
- $sraaProjector = new SraaProjector(m::mock(SraaRepository::class));
+ $sraaProjector = new SraaProjector(m::mock(SraaRepository::class));
$whitelistProjector = new WhitelistProjector(m::mock(WhitelistEntryRepository::class));
$projectorCollection = new ProjectorCollection;
@@ -66,12 +67,12 @@ public function projector_names_can_be_retrieved_from_a_projector_collection()
$projectorCollection->add($whitelistProjector);
$expectedProjectorNames = [SraaProjector::class, WhitelistProjector::class];
- $actualProjectorNames = $projectorCollection->getProjectorNames();
+ $actualProjectorNames = $projectorCollection->getProjectorNames();
$this->assertSame(
$expectedProjectorNames,
$actualProjectorNames,
- 'Projector names cannot be retrieved correctly from a ProjectorCollection'
+ 'Projector names cannot be retrieved correctly from a ProjectorCollection',
);
}
@@ -79,24 +80,24 @@ public function projector_names_can_be_retrieved_from_a_projector_collection()
* @test
* @group event-replay
*/
- public function a_subset_of_projectors_can_be_selected_from_a_projector_collection()
+ public function a_subset_of_projectors_can_be_selected_from_a_projector_collection(): void
{
- $sraaProjector = new SraaProjector( m::mock(SraaRepository::class));
+ $sraaProjector = new SraaProjector(m::mock(SraaRepository::class));
$whitelistProjector = new WhitelistProjector(m::mock(WhitelistEntryRepository::class));
$projectorCollection = new ProjectorCollection;
$projectorCollection->add($sraaProjector);
$projectorCollection->add($whitelistProjector);
- $projectorSelection = $projectorCollection->selectByNames([get_class($sraaProjector)]);
+ $projectorSelection = $projectorCollection->selectByNames([$sraaProjector::class]);
$this->assertTrue(
$projectorSelection->contains($sraaProjector),
- 'Subset of ProjectorCollection should contain SraaProjector but it did not'
+ 'Subset of ProjectorCollection should contain SraaProjector but it did not',
);
$this->assertFalse(
$projectorSelection->contains($whitelistProjector),
- 'Subset of ProjectorCollection should contain WhitelistProjector but it did not'
+ 'Subset of ProjectorCollection should contain WhitelistProjector but it did not',
);
}
@@ -104,17 +105,17 @@ public function a_subset_of_projectors_can_be_selected_from_a_projector_collecti
* @test
* @group event-replay
*/
- public function a_subset_containing_projectors_not_present_in_a_projector_collection_cannot_be_selected()
+ public function a_subset_containing_projectors_not_present_in_a_projector_collection_cannot_be_selected(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('not present in the collection');
- $sraaProjector = new SraaProjector( m::mock(SraaRepository::class));
+ $sraaProjector = new SraaProjector(m::mock(SraaRepository::class));
$nonPresentWhitelistProjector = new WhitelistProjector(m::mock(WhitelistEntryRepository::class));
$projectorCollection = new ProjectorCollection;
$projectorCollection->add($sraaProjector);
- $projectorCollection->selectByNames([get_class($nonPresentWhitelistProjector)]);
+ $projectorCollection->selectByNames([$nonPresentWhitelistProjector::class]);
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/Migrations/InstitutionConfiguration/MappedInstitutionConfigurationTest.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/Migrations/InstitutionConfiguration/MappedInstitutionConfigurationTest.php
index 0c96be50e..fa9802a14 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/Migrations/InstitutionConfiguration/MappedInstitutionConfigurationTest.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/Migrations/InstitutionConfiguration/MappedInstitutionConfigurationTest.php
@@ -18,8 +18,9 @@
namespace Surfnet\StepupMiddleware\MiddlewareBundle\Tests\Migrations\InstitutionConfiguration;
+use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as UnitTest;
-use Rhumsaa\Uuid\Uuid;
+use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\Configuration\Value\ContactInformation;
use Surfnet\Stepup\Configuration\Value\Institution;
use Surfnet\Stepup\Configuration\Value\Location;
@@ -38,11 +39,13 @@
class MappedInstitutionConfigurationTest extends UnitTest
{
+ use MockeryPHPUnitIntegration;
+
/**
* @test
* @group middleware-migration
*/
- public function infers_the_correct_remove_institution_configuration_command()
+ public function infers_the_correct_remove_institution_configuration_command(): void
{
$institution = new Institution('Babelfish Inc.');
$useRaLocationsOption = UseRaLocationsOption::getDefault();
@@ -59,7 +62,7 @@ public function infers_the_correct_remove_institution_configuration_command()
$verifyEmailOption,
$selfVetOption,
$numberOfTokensPerIdentityOption,
- $raLocations
+ $raLocations,
);
$command = $mapped->inferRemoveInstitutionConfigurationByIdCommand();
@@ -72,7 +75,7 @@ public function infers_the_correct_remove_institution_configuration_command()
* @test
* @group middleware-migration
*/
- public function infers_the_correct_create_institution_configuration_command()
+ public function infers_the_correct_create_institution_configuration_command(): void
{
$institution = new Institution('Babelfish Inc.');
$useRaLocationsOption = UseRaLocationsOption::getDefault();
@@ -89,7 +92,7 @@ public function infers_the_correct_create_institution_configuration_command()
$verifyEmailOption,
$selfVetOption,
$numberOfTokensPerIdentityOption,
- $raLocations
+ $raLocations,
);
$command = $mapped->inferCreateInstitutionConfigurationCommand();
@@ -102,7 +105,7 @@ public function infers_the_correct_create_institution_configuration_command()
* @test
* @group middleware-migration
*/
- public function infers_the_correct_reconfigure_institution_configuration_command()
+ public function infers_the_correct_reconfigure_institution_configuration_command(): void
{
$institution = new Institution('Babelfish Inc.');
$useRaLocationsOption = new UseRaLocationsOption(true);
@@ -119,7 +122,7 @@ public function infers_the_correct_reconfigure_institution_configuration_command
$verifyEmailOption,
$selfVetOption,
$numberOfTokensPerIdentityOption,
- $raLocations
+ $raLocations,
);
$command = $mapped->inferReconfigureInstitutionConfigurationCommand();
@@ -136,15 +139,15 @@ public function infers_the_correct_reconfigure_institution_configuration_command
* @test
* @group middleware-migration
*/
- public function no_ra_locations_means_no_add_ra_location_command()
+ public function no_ra_locations_means_no_add_ra_location_command(): void
{
- $institution = new Institution('Babelfish Inc.');
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution('Babelfish Inc.');
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(false);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$selfVetOption = SelfVetOption::getDefault();
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(1);
- $raLocations = [];
+ $raLocations = [];
$mapped = new MappedInstitutionConfiguration(
$institution,
@@ -153,7 +156,7 @@ public function no_ra_locations_means_no_add_ra_location_command()
$verifyEmailOption,
$selfVetOption,
$numberOfTokensPerIdentityOption,
- $raLocations
+ $raLocations,
);
$commands = $mapped->inferAddRaLocationCommands();
@@ -165,22 +168,22 @@ public function no_ra_locations_means_no_add_ra_location_command()
* @test
* @group middleware-migration
*/
- public function a_single_ra_location_means_a_single_correct_add_ra_location_command()
+ public function a_single_ra_location_means_a_single_correct_add_ra_location_command(): void
{
- $institution = new Institution('Babelfish Inc.');
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution('Babelfish Inc.');
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(false);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$selfVetOption = SelfVetOption::getDefault();
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(0);
- $raLocation = RaLocation::create(
- (string) Uuid::uuid4(),
+ $raLocation = RaLocation::create(
+ (string)Uuid::uuid4(),
$institution,
new RaLocationName('Some Location'),
new Location('Somewhere here or there'),
- new ContactInformation('Per phone.')
+ new ContactInformation('Per phone.'),
);
- $raLocations = [$raLocation];
+ $raLocations = [$raLocation];
$mapped = new MappedInstitutionConfiguration(
$institution,
@@ -189,7 +192,7 @@ public function a_single_ra_location_means_a_single_correct_add_ra_location_comm
$verifyEmailOption,
$selfVetOption,
$numberOfTokensPerIdentityOption,
- $raLocations
+ $raLocations,
);
$commands = $mapped->inferAddRaLocationCommands();
@@ -197,6 +200,9 @@ public function a_single_ra_location_means_a_single_correct_add_ra_location_comm
$this->assertEquals(1, count($commands));
$command = reset($commands);
+ if (!$command) {
+ $this->fail('The command should be in the set of commands');
+ }
$this->assertCommandMatches($command, $institution, $raLocation);
}
@@ -204,30 +210,30 @@ public function a_single_ra_location_means_a_single_correct_add_ra_location_comm
* @test
* @group middleware-migration
*/
- public function multiple_ra_locations_mean_multiple_correct_add_ra_location_commands()
+ public function multiple_ra_locations_mean_multiple_correct_add_ra_location_commands(): void
{
- $institution = new Institution('Babelfish Inc.');
- $useRaLocationsOption = new UseRaLocationsOption(true);
+ $institution = new Institution('Babelfish Inc.');
+ $useRaLocationsOption = new UseRaLocationsOption(true);
$showRaaContactInformationOption = new ShowRaaContactInformationOption(false);
- $verifyEmailOption = new VerifyEmailOption(true);
+ $verifyEmailOption = new VerifyEmailOption(true);
$selfVetOption = SelfVetOption::getDefault();
$numberOfTokensPerIdentityOption = new NumberOfTokensPerIdentityOption(2);
- $firstRaLocation = RaLocation::create(
- (string) Uuid::uuid4(),
+ $firstRaLocation = RaLocation::create(
+ (string)Uuid::uuid4(),
$institution,
new RaLocationName('Some Location'),
new Location('Somewhere here or there'),
- new ContactInformation('Per phone.')
+ new ContactInformation('Per phone.'),
);
- $secondRaLocation = RaLocation::create(
- (string) Uuid::uuid4(),
+ $secondRaLocation = RaLocation::create(
+ (string)Uuid::uuid4(),
$institution,
new RaLocationName('Somewhere else'),
new Location('Utrecht, The Netherlands'),
- new ContactInformation('Shout really hard')
+ new ContactInformation('Shout really hard'),
);
- $raLocations = [$firstRaLocation, $secondRaLocation];
+ $raLocations = [$firstRaLocation, $secondRaLocation];
$mapped = new MappedInstitutionConfiguration(
$institution,
@@ -236,7 +242,7 @@ public function multiple_ra_locations_mean_multiple_correct_add_ra_location_comm
$verifyEmailOption,
$selfVetOption,
$numberOfTokensPerIdentityOption,
- $raLocations
+ $raLocations,
);
$commands = $mapped->inferAddRaLocationCommands();
@@ -249,15 +255,15 @@ public function multiple_ra_locations_mean_multiple_correct_add_ra_location_comm
public function assertCommandMatches(
AddRaLocationCommand $command,
Institution $institution,
- RaLocation $raLocation
- ) {
+ RaLocation $raLocation,
+ ): void {
$this->assertEquals($institution->getInstitution(), $command->institution);
$this->assertEquals($raLocation->id, $command->raLocationId);
$this->assertEquals($raLocation->name->getRaLocationName(), $command->raLocationName);
$this->assertEquals($raLocation->location->getLocation(), $command->location);
$this->assertEquals(
$raLocation->contactInformation->getContactInformation(),
- $command->contactInformation
+ $command->contactInformation,
);
}
}
diff --git a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/Service/SecondFactorDisplayNameResolverServiceTest.php b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/Service/SecondFactorDisplayNameResolverServiceTest.php
index c5ae30c7c..b8429fac7 100644
--- a/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/Service/SecondFactorDisplayNameResolverServiceTest.php
+++ b/src/Surfnet/StepupMiddleware/MiddlewareBundle/Tests/Service/SecondFactorDisplayNameResolverServiceTest.php
@@ -1,7 +1,7 @@
verifiedSecondFactorRepository,
$this->identityRepository,
$this->mailService,
- $this->logger
+ $this->logger,
);
}
- public function test_no_token_reminders_sent()
+ public function test_no_token_reminders_sent(): void
{
$date = new DateTime('2018-01-01');
@@ -95,13 +89,13 @@ public function test_no_token_reminders_sent()
$this->assertInstanceOf(VerifiedSecondFactorReminderService::class, $this->service);
}
- public function test_one_token_reminders_sent()
+ public function test_one_token_reminders_sent(): void
{
$date = new DateTime('2018-01-01');
$this->logger
->shouldReceive('info')
- ->once()
+ ->times()
->with('Sending reminders for date: 2018-01-01. dry run mode is disabled');
$tokens = $this->buildVerifiedSecondFactors(1, $date);
@@ -138,7 +132,9 @@ public function test_one_token_reminders_sent()
$this->logger
->shouldReceive('info')
->once()
- ->with('Message successfully sent to "mail@example1.org" with token id "fa125c7c-c9ee-11e7-8001-000000000001" of type "yubikey"');
+ ->with(
+ 'Message successfully sent to "mail@example1.org" with token id "fa125c7c-c9ee-11e7-8001-000000000001" of type "yubikey"',
+ );
$this->logger
->shouldReceive('info')
@@ -150,7 +146,7 @@ public function test_one_token_reminders_sent()
$this->assertInstanceOf(VerifiedSecondFactorReminderService::class, $this->service);
}
- public function test_one_token_reminders_sent_failing_mailer()
+ public function test_one_token_reminders_sent_failing_mailer(): void
{
$date = new DateTime('2018-01-01');
@@ -183,12 +179,14 @@ public function test_one_token_reminders_sent_failing_mailer()
$this->mailService
->shouldReceive('sendReminder')
->once()
- ->andReturn(0);
+ ->andThrow(TransportException::class);
$this->logger
->shouldReceive('info')
->once()
- ->with('Message was not sent to "mail@example1.org" with token id "fa125c7c-c9ee-11e7-8001-000000000001" of type "yubikey"');
+ ->with(
+ 'Message was not sent to "mail@example1.org" with token id "fa125c7c-c9ee-11e7-8001-000000000001" of type "yubikey"',
+ );
$this->logger
->shouldReceive('info')
@@ -200,7 +198,7 @@ public function test_one_token_reminders_sent_failing_mailer()
$this->assertInstanceOf(VerifiedSecondFactorReminderService::class, $this->service);
}
- public function test_multiple_tokens_reminders_sent()
+ public function test_multiple_tokens_reminders_sent(): void
{
$date = new DateTime('2018-01-01');
@@ -239,7 +237,11 @@ public function test_multiple_tokens_reminders_sent()
$this->logger
->shouldReceive('info')
- ->with(\Mockery::pattern('/^Message successfully sent to "mail@example\d.org" with token id "fa125c7c-c9ee-11e7-800\d-00000000000\d" of type "yubikey"/'))
+ ->with(
+ m::pattern(
+ '/^Message successfully sent to "mail@example\d.org" with token id "fa125c7c-c9ee-11e7-800\d-00000000000\d" of type "yubikey"/',
+ ),
+ )
->times(9);
$this->logger
@@ -252,7 +254,7 @@ public function test_multiple_tokens_reminders_sent()
$this->assertInstanceOf(VerifiedSecondFactorReminderService::class, $this->service);
}
- public function test_missing_identity()
+ public function test_missing_identity(): void
{
$date = new DateTime('2018-01-01');
@@ -290,7 +292,7 @@ public function test_missing_identity()
$this->assertInstanceOf(VerifiedSecondFactorReminderService::class, $this->service);
}
- public function test_one_token_reminders_sent_dry_run()
+ public function test_one_token_reminders_sent_dry_run(): void
{
$date = new DateTime('2018-01-01');
@@ -322,7 +324,9 @@ public function test_one_token_reminders_sent_dry_run()
$this->logger
->shouldReceive('info')
->once()
- ->with('Message successfully sent in dry run mode to "mail@example1.org" with token id "fa125c7c-c9ee-11e7-8001-000000000001" of type "yubikey"');
+ ->with(
+ 'Message successfully sent in dry run mode to "mail@example1.org" with token id "fa125c7c-c9ee-11e7-8001-000000000001" of type "yubikey"',
+ );
$this->logger
->shouldReceive('info')
@@ -334,7 +338,7 @@ public function test_one_token_reminders_sent_dry_run()
$this->assertInstanceOf(VerifiedSecondFactorReminderService::class, $this->service);
}
- public function test_multiple_tokens_reminders_sent_dry_run()
+ public function test_multiple_tokens_reminders_sent_dry_run(): void
{
$date = new DateTime('2018-01-01');
@@ -367,7 +371,11 @@ public function test_multiple_tokens_reminders_sent_dry_run()
$this->logger
->shouldReceive('info')
- ->with(\Mockery::pattern('/^Message successfully sent in dry run mode to "mail@example\d.org" with token id "fa125c7c-c9ee-11e7-800\d-00000000000\d" of type "yubikey"/'))
+ ->with(
+ m::pattern(
+ '/^Message successfully sent in dry run mode to "mail@example\d.org" with token id "fa125c7c-c9ee-11e7-800\d-00000000000\d" of type "yubikey"/',
+ ),
+ )
->times(9);
$this->logger
@@ -380,7 +388,7 @@ public function test_multiple_tokens_reminders_sent_dry_run()
$this->assertInstanceOf(VerifiedSecondFactorReminderService::class, $this->service);
}
- public function test_no_token_reminders_sent_dry_run()
+ public function test_no_token_reminders_sent_dry_run(): void
{
$date = new DateTime('2018-01-01');
@@ -405,19 +413,17 @@ public function test_no_token_reminders_sent_dry_run()
}
/**
- * @param int $numberOfResults
- * @param DateTime $requestedAt
* @return VerifiedSecondFactor[]
*/
- private function buildVerifiedSecondFactors($numberOfResults, DateTime $requestedAt)
+ private function buildVerifiedSecondFactors(int $numberOfResults, DateTime $requestedAt): array
{
$collection = [];
- for ($i=1; $i<=$numberOfResults; $i++) {
+ for ($i = 1; $i <= $numberOfResults; $i++) {
$token = new VerifiedSecondFactor();
$token->id = "fa125c7c-c9ee-11e7-800{$i}-00000000000{$i}";
- $token->identityId = $i;
+ $token->identityId = (string) $i;
$token->registrationCode = "CODE_{$i}";
- $token->registrationRequestedAt = $requestedAt;
+ $token->registrationRequestedAt = new MiddlewareDateTime($requestedAt);
$token->type = 'yubikey';
$token->commonName = "John Doe {$i}";
$collection[] = $token;
@@ -427,19 +433,17 @@ private function buildVerifiedSecondFactors($numberOfResults, DateTime $requeste
}
/**
- * @param VerifiedSecondFactor $token
* @return Identity
*/
- private function buildIdentity(VerifiedSecondFactor $token)
+ private function buildIdentity(VerifiedSecondFactor $token): Identity
{
$identity = new Identity();
$identity->id = $token->identityId;
- $identity->commonName = "John Doe {$token->identityId}";
- $identity->institution = "Institution {$token->identityId}";
- $identity->preferredLocale = 'nl_NL';
- $identity->email = "mail@example{$token->identityId}.org";
+ $identity->commonName = new CommonName("John Doe {$token->identityId}");
+ $identity->institution = new Institution("Institution {$token->identityId}");
+ $identity->preferredLocale = new Locale('nl_NL');
+ $identity->email = new Email("mail@example{$token->identityId}.org");
return $identity;
-
}
}
diff --git a/symfony.lock b/symfony.lock
index e33a02b27..a0bb09272 100644
--- a/symfony.lock
+++ b/symfony.lock
@@ -165,9 +165,6 @@
"monolog/monolog": {
"version": "1.25.4"
},
- "moontoast/math": {
- "version": "1.2.1"
- },
"myclabs/deep-copy": {
"version": "1.9.5"
},
@@ -201,12 +198,6 @@
"pagerfanta/pagerfanta": {
"version": "v1.1.0"
},
- "paragonie/constant_time_encoding": {
- "version": "v2.5.0"
- },
- "paragonie/random_compat": {
- "version": "v2.0.18"
- },
"pdepend/pdepend": {
"version": "2.7.1"
},
@@ -219,11 +210,17 @@
"phpmd/phpmd": {
"version": "2.8.2"
},
- "phpseclib/bcmath_compat": {
- "version": "1.0.5"
- },
- "phpseclib/phpseclib": {
- "version": "2.0.27"
+ "phpstan/phpstan": {
+ "version": "1.10",
+ "recipe": {
+ "repo": "github.com/symfony/recipes-contrib",
+ "branch": "main",
+ "version": "1.0",
+ "ref": "5e490cc197fb6bb1ae22e5abbc531ddc633b6767"
+ },
+ "files": [
+ "phpstan.dist.neon"
+ ]
},
"phpunit/php-code-coverage": {
"version": "7.0.10"
@@ -317,18 +314,6 @@
"sebastian/version": {
"version": "2.0.1"
},
- "sensio/framework-extra-bundle": {
- "version": "5.2",
- "recipe": {
- "repo": "github.com/symfony/recipes",
- "branch": "master",
- "version": "5.2",
- "ref": "fb7e19da7f013d0d422fa9bce16f5c510e27609b"
- },
- "files": [
- "config/packages/sensio_framework_extra.yaml"
- ]
- },
"simplesamlphp/saml2": {
"version": "v3.2.6"
},
@@ -393,9 +378,6 @@
"symfony/dom-crawler": {
"version": "v4.4.10"
},
- "symfony/dotenv": {
- "version": "v4.4.9"
- },
"symfony/error-handler": {
"version": "v4.4.10"
},
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 469dccee4..8a716bd9e 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -1,5 +1,21 @@
authzRepository = $kernel->getContainer()->get(AuthorizationRepository::class);
$fixture = file_get_contents(__DIR__ . '/Fixture/test2.sql');
- $manager->getConnection()->exec($fixture);
+ $manager->getConnection()->executeStatement($fixture);
$manager->flush();
}
@@ -93,7 +93,7 @@ public function test_get_institutions_for_role_matrix(
RegistrationAuthorityRole $requiredRole,
IdentityId $identity,
array $expectedInstitutions
- ) {
+ ): void {
$institutions = $this->authzRepository->getInstitutionsForRole($requiredRole, $identity);
$results = $this->flattenInstitutionResults($institutions);
@@ -102,8 +102,8 @@ public function test_get_institutions_for_role_matrix(
$expectedInstitutions,
sprintf(
'The results do not match the expected results. Actual "%s" versus expected: "%s"',
- implode($results, ','),
- implode($expectedInstitutions, ',')
+ implode(',', $results),
+ implode(',', $expectedInstitutions)
)
);
}
@@ -111,14 +111,17 @@ public function test_get_institutions_for_role_matrix(
/**
* @dataProvider selectRaaMatrix
*/
- public function test_select_raa_authorization(IdentityId $identityId, array $expected)
+ public function test_select_raa_authorization(IdentityId $identityId, array $expected): void
{
$institutions = $this->authzRepository->getInstitutionsForSelectRaaRole($identityId);
$this->assertEquals($expected, $this->flattenInstitutionResults($institutions));
}
- private function flattenInstitutionResults(InstitutionCollection $collection)
+ /**
+ * @return mixed[]
+ */
+ private function flattenInstitutionResults(InstitutionCollection $collection): array
{
$institutions = [];
/** @var Institution $institution */
diff --git a/translations/messages.en_GB.xliff b/translations/messages.en_GB.xliff
index 1ddcaccf6..4a44e9e1b 100644
--- a/translations/messages.en_GB.xliff
+++ b/translations/messages.en_GB.xliff
@@ -1,188 +1,145 @@
-
-
+
+
-
- The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.
+
-
+
- English
- /vendor/surfnet/stepup-bundle/src/Resources/views/translations.twig
+ English
-
+
- Dutch
- /vendor/surfnet/stepup-bundle/src/Resources/views/translations.twig
+ Dutch
-
+ Your %tokenType% token was revoked
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorRevocationMailService.php
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorRevocationMailService.php
-
+ Token registration: confirm your e-mail address
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/EmailVerificationMailService.php
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/views/translations.twig
-
+ Recovery method ready for use
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RecoveryTokenMailService.php
-
+
- Your recovery method was revoked
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RecoveryTokenMailService.php
+ Your recovery method was revoked
-
+ Token activation: activate your token
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RegistrationMailService.php
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RegistrationMailService.php
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/views/translations.twig
- /src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderMailService.php
- /src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderMailService.php
-
+ Token activation reminder: activate your token
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/views/translations.twig
-
+ Token ready to use - authentication in two steps
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorVettedMailService.php
-
+
- stepup.error.authentication_error.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.authentication_error.description
-
+
- stepup.error.authentication_error.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.authentication_error.title
-
+
- stepup.error.authn_failed.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.authn_failed.description
-
+
- stepup.error.authn_failed.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.authn_failed.title
-
+
- stepup.error.error_code
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.error_code
-
+
- stepup.error.generic_error.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.generic_error.description
-
+
- stepup.error.generic_error.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.generic_error.title
-
+
- stepup.error.hostname
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.hostname
-
+
- stepup.error.ip_address
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.ip_address
-
+
- stepup.error.page_not_found.text
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error404.html.twig
+ stepup.error.page_not_found.text
-
+
- stepup.error.page_not_found.title
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error404.html.twig
+ stepup.error.page_not_found.title
-
+
- stepup.error.precondition_not_met.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.precondition_not_met.description
-
+
- stepup.error.precondition_not_met.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.precondition_not_met.title
-
+
- stepup.error.request_id
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.request_id
-
+
- stepup.error.signature_validation_failed.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.signature_validation_failed.description
-
+
- stepup.error.signature_validation_failed.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.signature_validation_failed.title
-
+
- stepup.error.support_page.text
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error404.html.twig
+ stepup.error.support_page.text
-
+
- stepup.error.timestamp
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.timestamp
-
+
- stepup.error.unknown_service_provider.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.unknown_service_provider.title
-
+
- stepup.error.unsigned_request.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.unsigned_request.description
-
+
- stepup.error.unsigned_request.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.unsigned_request.title
-
+
- stepup.error.unsupported_signature.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.unsupported_signature.description
-
+
- stepup.error.unsupported_signature.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.unsupported_signature.title
-
+
- stepup.error.user_agent
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.user_agent
-
+
- Switch
- /vendor/surfnet/stepup-bundle/src/Form/Type/SwitchLocaleType.php
+ Switch
diff --git a/translations/messages.nl_NL.xliff b/translations/messages.nl_NL.xliff
index dfd838fe2..a7a754757 100644
--- a/translations/messages.nl_NL.xliff
+++ b/translations/messages.nl_NL.xliff
@@ -1,189 +1,146 @@
-
-
+
+
-
- The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.
+
-
+
- Engels
- /vendor/surfnet/stepup-bundle/src/Resources/views/translations.twig
+ Engels
-
+
- Nederlands
- /vendor/surfnet/stepup-bundle/src/Resources/views/translations.twig
+ Nederlands
-
+
- Je %tokenType% token is ingetrokken
+ Je %tokenType% token is ingetrokken
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorRevocationMailService.php
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorRevocationMailService.php
-
+ Token registratie: bevestig je e-mailadres
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/EmailVerificationMailService.php
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/views/translations.twig
-
+ Je herstelmethode is klaar voor gebruik
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RecoveryTokenMailService.php
-
+
- Je herstelmethode is ingetrokken
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RecoveryTokenMailService.php
+ Je herstelmethode is ingetrokken
-
+ Token activatie: activeer je token
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RegistrationMailService.php
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/RegistrationMailService.php
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/views/translations.twig
- /src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderMailService.php
- /src/Surfnet/StepupMiddleware/MiddlewareBundle/Service/VerifiedSecondFactorReminderMailService.php
-
+ Token activatie herinnering: activeer je token
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Resources/views/translations.twig
-
+ Token klaar voor gebruik - inloggen in twee stappen
- /src/Surfnet/StepupMiddleware/CommandHandlingBundle/Identity/Service/SecondFactorVettedMailService.php
-
+
- stepup.error.authentication_error.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.authentication_error.description
-
+
- stepup.error.authentication_error.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.authentication_error.title
-
+
- stepup.error.authn_failed.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.authn_failed.description
-
+
- stepup.error.authn_failed.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.authn_failed.title
-
+
- stepup.error.error_code
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.error_code
-
+
- stepup.error.generic_error.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.generic_error.description
-
+
- stepup.error.generic_error.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.generic_error.title
-
+
- stepup.error.hostname
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.hostname
-
+
- stepup.error.ip_address
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.ip_address
-
+
- stepup.error.page_not_found.text
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error404.html.twig
+ stepup.error.page_not_found.text
-
+
- stepup.error.page_not_found.title
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error404.html.twig
+ stepup.error.page_not_found.title
-
+
- stepup.error.precondition_not_met.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.precondition_not_met.description
-
+
- stepup.error.precondition_not_met.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.precondition_not_met.title
-
+
- stepup.error.request_id
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.request_id
-
+
- stepup.error.signature_validation_failed.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.signature_validation_failed.description
-
+
- stepup.error.signature_validation_failed.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.signature_validation_failed.title
-
+
- stepup.error.support_page.text
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error404.html.twig
+ stepup.error.support_page.text
-
+
- stepup.error.timestamp
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.timestamp
-
+
- stepup.error.unknown_service_provider.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.unknown_service_provider.title
-
+
- stepup.error.unsigned_request.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.unsigned_request.description
-
+
- stepup.error.unsigned_request.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.unsigned_request.title
-
+
- stepup.error.unsupported_signature.description
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.unsupported_signature.description
-
+
- stepup.error.unsupported_signature.title
- /vendor/surfnet/stepup-bundle/src/Controller/ExceptionController.php
+ stepup.error.unsupported_signature.title
-
+
- stepup.error.user_agent
- /vendor/surfnet/stepup-bundle/src/Resources/views/Exception/error.html.twig
+ stepup.error.user_agent
-
+
- Vertalen
- /vendor/surfnet/stepup-bundle/src/Form/Type/SwitchLocaleType.php
+ Vertalen
diff --git a/translations/validators.en_GB.xliff b/translations/validators.en_GB.xliff
index f8b062e4c..52afa847b 100644
--- a/translations/validators.en_GB.xliff
+++ b/translations/validators.en_GB.xliff
@@ -1,34 +1,37 @@
-
-
+
+
-
- The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.
+
-
+
- stepup.send_sms_command.recipient.may_not_be_empty
+ stepup.send_sms_command.recipient.may_not_be_empty
-
+
- stepup.send_sms_command.recipient.must_be_string
+ stepup.send_sms_command.recipient.must_be_string
-
+
- stepup.send_sms_command.recipient.must_consist_of_digits
+ stepup.send_sms_command.recipient.must_consist_of_digits
-
+
- stepup.verify_possession_of_phone_command.challenge.may_not_be_empty
+ stepup.verify_possession_of_phone_command.challenge.may_not_be_empty
-
+
- stepup.verify_possession_of_phone_command.challenge.must_be_string
+ stepup.verify_possession_of_phone_command.challenge.must_be_string
-
+
- stepup.verify_possession_of_phone_command.second_factor_id.must_be_string
+ stepup.verify_possession_of_phone_command.second_factor_id.must_be_string
+
+
+
+ __Error
diff --git a/translations/validators.nl_NL.xliff b/translations/validators.nl_NL.xliff
index 624fa7551..361fe2838 100644
--- a/translations/validators.nl_NL.xliff
+++ b/translations/validators.nl_NL.xliff
@@ -1,34 +1,37 @@
-
-
+
+
-
- The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.
+
-
+
- stepup.send_sms_command.recipient.may_not_be_empty
+ stepup.send_sms_command.recipient.may_not_be_empty
-
+
- stepup.send_sms_command.recipient.must_be_string
+ stepup.send_sms_command.recipient.must_be_string
-
+
- stepup.send_sms_command.recipient.must_consist_of_digits
+ stepup.send_sms_command.recipient.must_consist_of_digits
-
+
- stepup.verify_possession_of_phone_command.challenge.may_not_be_empty
+ stepup.verify_possession_of_phone_command.challenge.may_not_be_empty
-
+
- stepup.verify_possession_of_phone_command.challenge.must_be_string
+ stepup.verify_possession_of_phone_command.challenge.must_be_string
-
+
- stepup.verify_possession_of_phone_command.second_factor_id.must_be_string
+ stepup.verify_possession_of_phone_command.second_factor_id.must_be_string
+
+
+
+ __Error