|
16 | 16 |
|
17 | 17 | package org.springframework.security.saml2.credentials;
|
18 | 18 |
|
19 |
| -import org.springframework.security.converter.RsaKeyConverters; |
20 |
| - |
21 | 19 | import org.junit.Before;
|
22 | 20 | import org.junit.Rule;
|
23 | 21 | import org.junit.Test;
|
24 | 22 | import org.junit.rules.ExpectedException;
|
| 23 | +import org.springframework.security.converter.RsaKeyConverters; |
25 | 24 |
|
26 | 25 | import java.io.ByteArrayInputStream;
|
27 | 26 | import java.security.PrivateKey;
|
@@ -88,13 +87,17 @@ public void constructorWhenRelyingPartyWithCredentialsThenItSucceeds() {
|
88 | 87 | new Saml2X509Credential(key, certificate, SIGNING);
|
89 | 88 | new Saml2X509Credential(key, certificate, SIGNING, DECRYPTION);
|
90 | 89 | new Saml2X509Credential(key, certificate, DECRYPTION);
|
| 90 | + Saml2X509Credential.signing(key, certificate); |
| 91 | + Saml2X509Credential.decryption(key, certificate); |
91 | 92 | }
|
92 | 93 |
|
93 | 94 | @Test
|
94 | 95 | public void constructorWhenAssertingPartyWithCredentialsThenItSucceeds() {
|
95 | 96 | new Saml2X509Credential(certificate, VERIFICATION);
|
96 | 97 | new Saml2X509Credential(certificate, VERIFICATION, ENCRYPTION);
|
97 | 98 | new Saml2X509Credential(certificate, ENCRYPTION);
|
| 99 | + Saml2X509Credential.verification(certificate); |
| 100 | + Saml2X509Credential.encryption(certificate); |
98 | 101 | }
|
99 | 102 |
|
100 | 103 | @Test
|
@@ -145,5 +148,51 @@ public void constructorWhenAssertingPartyWithDecryptionUsageThenItFails() {
|
145 | 148 | new Saml2X509Credential(certificate, DECRYPTION);
|
146 | 149 | }
|
147 | 150 |
|
| 151 | + @Test |
| 152 | + public void factoryWhenRelyingPartyForSigningWithoutCredentialsThenItFails() { |
| 153 | + exception.expect(IllegalArgumentException.class); |
| 154 | + Saml2X509Credential.signing(null, null); |
| 155 | + } |
148 | 156 |
|
| 157 | + @Test |
| 158 | + public void factoryWhenRelyingPartyForSigningWithoutPrivateKeyThenItFails() { |
| 159 | + exception.expect(IllegalArgumentException.class); |
| 160 | + Saml2X509Credential.signing(null, certificate); |
| 161 | + } |
| 162 | + |
| 163 | + @Test |
| 164 | + public void factoryWhenRelyingPartyForSigningWithoutCertificateThenItFails() { |
| 165 | + exception.expect(IllegalArgumentException.class); |
| 166 | + Saml2X509Credential.signing(key, null); |
| 167 | + } |
| 168 | + |
| 169 | + @Test |
| 170 | + public void factoryWhenRelyingPartyForDecryptionWithoutCredentialsThenItFails() { |
| 171 | + exception.expect(IllegalArgumentException.class); |
| 172 | + Saml2X509Credential.decryption(null, null); |
| 173 | + } |
| 174 | + |
| 175 | + @Test |
| 176 | + public void factoryWhenRelyingPartyForDecryptionWithoutPrivateKeyThenItFails() { |
| 177 | + exception.expect(IllegalArgumentException.class); |
| 178 | + Saml2X509Credential.decryption(null, certificate); |
| 179 | + } |
| 180 | + |
| 181 | + @Test |
| 182 | + public void factoryWhenRelyingPartyForDecryptionWithoutCertificateThenItFails() { |
| 183 | + exception.expect(IllegalArgumentException.class); |
| 184 | + Saml2X509Credential.decryption(key, null); |
| 185 | + } |
| 186 | + |
| 187 | + @Test |
| 188 | + public void factoryWhenAssertingPartyForVerificationWithoutCertificateThenItFails() { |
| 189 | + exception.expect(IllegalArgumentException.class); |
| 190 | + Saml2X509Credential.verification(null); |
| 191 | + } |
| 192 | + |
| 193 | + @Test |
| 194 | + public void factoryWhenAssertingPartyForEncryptionWithoutCertificateThenItFails() { |
| 195 | + exception.expect(IllegalArgumentException.class); |
| 196 | + Saml2X509Credential.encryption(null); |
| 197 | + } |
149 | 198 | }
|
0 commit comments