1
1
/*
2
- * Copyright 2002-2020 the original author or authors.
2
+ * Copyright 2002-2022 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
17
17
package org .springframework .security .saml2 .provider .service .registration ;
18
18
19
19
import org .junit .jupiter .api .Test ;
20
+
20
21
import org .springframework .security .saml2 .core .Saml2X509Credential ;
21
22
import org .springframework .security .saml2 .core .TestSaml2X509Credentials ;
22
23
import org .springframework .security .saml2 .provider .service .servlet .filter .Saml2WebSsoAuthenticationFilter ;
@@ -81,9 +82,9 @@ public void buildWhenUsingDefaultsThenAssertionConsumerServiceBindingDefaultsToP
81
82
RelyingPartyRegistration relyingPartyRegistration = RelyingPartyRegistration .withRegistrationId ("id" )
82
83
.entityId ("entity-id" ).assertionConsumerServiceLocation ("location" )
83
84
.assertingPartyDetails ((assertingParty ) -> assertingParty .entityId ("entity-id" )
84
- .singleSignOnServiceLocation ("location" )
85
- . verificationX509Credentials (( c ) -> c .add (TestSaml2X509Credentials .relyingPartyVerifyingCredential ()))
86
- ) .build ();
85
+ .singleSignOnServiceLocation ("location" ). verificationX509Credentials (
86
+ ( c ) -> c .add (TestSaml2X509Credentials .relyingPartyVerifyingCredential () )))
87
+ .build ();
87
88
assertThat (relyingPartyRegistration .getAssertionConsumerServiceBinding ()).isEqualTo (Saml2MessageBinding .POST );
88
89
}
89
90
@@ -98,36 +99,51 @@ public void buildPreservesCredentialsOrder() {
98
99
99
100
// Test with the alt credentials first
100
101
RelyingPartyRegistration relyingPartyRegistration = TestRelyingPartyRegistrations .noCredentials ()
101
- .assertingPartyDetails ((assertingParty ) -> assertingParty
102
- .verificationX509Credentials ((c ) -> { c .add (altApCredential ); c .add (verifyingCredential ); })
103
- .encryptionX509Credentials ((c ) -> { c .add (altApCredential ); c .add (encryptingCredential ); }))
104
- .signingX509Credentials (c -> { c .add (altRpCredential ); c .add (signingCredential ); })
105
- .decryptionX509Credentials (c -> { c .add (altRpCredential ); c .add (decryptionCredential ); })
106
- .build ();
107
- assertThat (relyingPartyRegistration .getSigningX509Credentials ())
108
- .containsExactly (altRpCredential , signingCredential );
109
- assertThat (relyingPartyRegistration .getDecryptionX509Credentials ())
110
- .containsExactly (altRpCredential , decryptionCredential );
102
+ .assertingPartyDetails ((assertingParty ) -> assertingParty .verificationX509Credentials ((c ) -> {
103
+ c .add (altApCredential );
104
+ c .add (verifyingCredential );
105
+ }).encryptionX509Credentials ((c ) -> {
106
+ c .add (altApCredential );
107
+ c .add (encryptingCredential );
108
+ })).signingX509Credentials ((c ) -> {
109
+ c .add (altRpCredential );
110
+ c .add (signingCredential );
111
+ }).decryptionX509Credentials ((c ) -> {
112
+ c .add (altRpCredential );
113
+ c .add (decryptionCredential );
114
+ }).build ();
115
+ assertThat (relyingPartyRegistration .getSigningX509Credentials ()).containsExactly (altRpCredential ,
116
+ signingCredential );
117
+ assertThat (relyingPartyRegistration .getDecryptionX509Credentials ()).containsExactly (altRpCredential ,
118
+ decryptionCredential );
111
119
assertThat (relyingPartyRegistration .getAssertingPartyDetails ().getVerificationX509Credentials ())
112
120
.containsExactly (altApCredential , verifyingCredential );
113
121
assertThat (relyingPartyRegistration .getAssertingPartyDetails ().getEncryptionX509Credentials ())
114
122
.containsExactly (altApCredential , encryptingCredential );
115
123
116
124
// Test with the alt credentials last
117
125
relyingPartyRegistration = TestRelyingPartyRegistrations .noCredentials ()
118
- .assertingPartyDetails ((assertingParty ) -> assertingParty
119
- .verificationX509Credentials ((c ) -> { c .add (verifyingCredential ); c .add (altApCredential ); })
120
- .encryptionX509Credentials ((c ) -> { c .add (encryptingCredential ); c .add (altApCredential ); }))
121
- .signingX509Credentials (c -> { c .add (signingCredential ); c .add (altRpCredential ); })
122
- .decryptionX509Credentials (c -> { c .add (decryptionCredential ); c .add (altRpCredential ); })
123
- .build ();
124
- assertThat (relyingPartyRegistration .getSigningX509Credentials ())
125
- .containsExactly (signingCredential , altRpCredential );
126
- assertThat (relyingPartyRegistration .getDecryptionX509Credentials ())
127
- .containsExactly (decryptionCredential , altRpCredential );
126
+ .assertingPartyDetails ((assertingParty ) -> assertingParty .verificationX509Credentials ((c ) -> {
127
+ c .add (verifyingCredential );
128
+ c .add (altApCredential );
129
+ }).encryptionX509Credentials ((c ) -> {
130
+ c .add (encryptingCredential );
131
+ c .add (altApCredential );
132
+ })).signingX509Credentials ((c ) -> {
133
+ c .add (signingCredential );
134
+ c .add (altRpCredential );
135
+ }).decryptionX509Credentials ((c ) -> {
136
+ c .add (decryptionCredential );
137
+ c .add (altRpCredential );
138
+ }).build ();
139
+ assertThat (relyingPartyRegistration .getSigningX509Credentials ()).containsExactly (signingCredential ,
140
+ altRpCredential );
141
+ assertThat (relyingPartyRegistration .getDecryptionX509Credentials ()).containsExactly (decryptionCredential ,
142
+ altRpCredential );
128
143
assertThat (relyingPartyRegistration .getAssertingPartyDetails ().getVerificationX509Credentials ())
129
144
.containsExactly (verifyingCredential , altApCredential );
130
145
assertThat (relyingPartyRegistration .getAssertingPartyDetails ().getEncryptionX509Credentials ())
131
146
.containsExactly (encryptingCredential , altApCredential );
132
147
}
148
+
133
149
}
0 commit comments