|
18 | 18 |
|
19 | 19 | import org.junit.Test;
|
20 | 20 |
|
21 |
| -import org.springframework.security.saml2.credentials.Saml2X509Credential; |
22 | 21 | import org.springframework.security.saml2.provider.service.servlet.filter.Saml2WebSsoAuthenticationFilter;
|
23 | 22 |
|
24 | 23 | import static org.assertj.core.api.Assertions.assertThat;
|
25 |
| -import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.relyingPartySigningCredential; |
26 |
| -import static org.springframework.security.saml2.credentials.TestSaml2X509Credentials.relyingPartyVerifyingCredential; |
| 24 | +import static org.springframework.security.saml2.provider.service.registration.Saml2MessageBinding.POST; |
| 25 | +import static org.springframework.security.saml2.provider.service.registration.TestRelyingPartyRegistrations.relyingPartyRegistration; |
27 | 26 |
|
28 | 27 | public class RelyingPartyRegistrationTests {
|
29 | 28 |
|
30 | 29 | @Test
|
31 | 30 | public void withRelyingPartyRegistrationWorks() {
|
32 |
| - RelyingPartyRegistration registration = relyingPartyRegistration(); |
| 31 | + RelyingPartyRegistration registration = relyingPartyRegistration() |
| 32 | + .providerDetails(p -> p.binding(POST)) |
| 33 | + .providerDetails(p -> p.signAuthNRequest(false)) |
| 34 | + .build(); |
33 | 35 | RelyingPartyRegistration copy = RelyingPartyRegistration.withRelyingPartyRegistration(registration).build();
|
34 | 36 | compareRegistrations(registration, copy);
|
35 | 37 | }
|
@@ -58,38 +60,9 @@ private void compareRegistrations(RelyingPartyRegistration registration, Relying
|
58 | 60 | .isEqualTo("https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php");
|
59 | 61 | assertThat(copy.getProviderDetails().getBinding())
|
60 | 62 | .isEqualTo(registration.getProviderDetails().getBinding())
|
61 |
| - .isEqualTo(Saml2MessageBinding.POST); |
| 63 | + .isEqualTo(POST); |
62 | 64 | assertThat(copy.getProviderDetails().isSignAuthNRequest())
|
63 | 65 | .isEqualTo(registration.getProviderDetails().isSignAuthNRequest())
|
64 | 66 | .isFalse();
|
65 | 67 | }
|
66 |
| - |
67 |
| - |
68 |
| - private RelyingPartyRegistration relyingPartyRegistration() { |
69 |
| - //remote IDP entity ID |
70 |
| - String idpEntityId = "https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php"; |
71 |
| - //remote WebSSO Endpoint - Where to Send AuthNRequests to |
72 |
| - String webSsoEndpoint = "https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php"; |
73 |
| - //local registration ID |
74 |
| - String registrationId = "simplesamlphp"; |
75 |
| - //local entity ID - autogenerated based on URL |
76 |
| - String localEntityIdTemplate = "{baseUrl}/saml2/service-provider-metadata/{registrationId}"; |
77 |
| - //local signing (and decryption key) |
78 |
| - Saml2X509Credential signingCredential = relyingPartySigningCredential(); |
79 |
| - //IDP certificate for verification of incoming messages |
80 |
| - Saml2X509Credential idpVerificationCertificate = relyingPartyVerifyingCredential(); |
81 |
| - String acsUrlTemplate = "{baseUrl}" + Saml2WebSsoAuthenticationFilter.DEFAULT_FILTER_PROCESSES_URI; |
82 |
| - return RelyingPartyRegistration.withRegistrationId(registrationId) |
83 |
| - .providerDetails(c -> { |
84 |
| - c.webSsoUrl(webSsoEndpoint); |
85 |
| - c.binding(Saml2MessageBinding.POST); |
86 |
| - c.signAuthNRequest(false); |
87 |
| - c.entityId(idpEntityId); |
88 |
| - }) |
89 |
| - .credentials(c -> c.add(signingCredential)) |
90 |
| - .credentials(c -> c.add(idpVerificationCertificate)) |
91 |
| - .localEntityIdTemplate(localEntityIdTemplate) |
92 |
| - .assertionConsumerServiceUrlTemplate(acsUrlTemplate) |
93 |
| - .build(); |
94 |
| - } |
95 | 68 | }
|
0 commit comments