|
39 | 39 | import org.opensaml.saml.saml2.core.SubjectConfirmation; |
40 | 40 | import org.opensaml.saml.saml2.core.SubjectConfirmationData; |
41 | 41 | import org.opensaml.saml.saml2.core.impl.AuthnStatementBuilder; |
| 42 | +import org.opensaml.saml.saml2.core.impl.IssuerBuilder; |
| 43 | +import org.opensaml.saml.saml2.core.impl.IssuerImpl; |
42 | 44 | import org.opensaml.saml.saml2.encryption.Encrypter; |
43 | 45 | import org.opensaml.security.credential.BasicCredential; |
44 | 46 | import org.opensaml.security.credential.Credential; |
|
83 | 85 | import static org.hamcrest.Matchers.contains; |
84 | 86 | import static org.hamcrest.Matchers.containsInAnyOrder; |
85 | 87 | import static org.hamcrest.Matchers.containsString; |
| 88 | +import static org.hamcrest.Matchers.endsWith; |
86 | 89 | import static org.hamcrest.Matchers.equalTo; |
| 90 | +import static org.hamcrest.Matchers.hasLength; |
87 | 91 | import static org.hamcrest.Matchers.instanceOf; |
88 | 92 | import static org.hamcrest.Matchers.is; |
89 | 93 | import static org.hamcrest.Matchers.iterableWithSize; |
@@ -1370,6 +1374,28 @@ public void testFailureWhenIdPCredentialsAreNull() throws Exception { |
1370 | 1374 | } |
1371 | 1375 | } |
1372 | 1376 |
|
| 1377 | + public void testDescribeNullIssuer() { |
| 1378 | + assertThat(authenticator.describeIssuer(null), equalTo("")); |
| 1379 | + } |
| 1380 | + |
| 1381 | + public void testDescribeIssuer() { |
| 1382 | + final Issuer issuer = new IssuerBuilder().buildObject(); |
| 1383 | + issuer.setValue("https://idp.saml.elastic.test/"); |
| 1384 | + assertThat( |
| 1385 | + authenticator.describeIssuer(issuer), |
| 1386 | + equalTo(" The issuer included in the SAML message was [https://idp.saml.elastic.test/]") |
| 1387 | + ); |
| 1388 | + } |
| 1389 | + |
| 1390 | + public void testDescribeVeryLongIssuer() { |
| 1391 | + final Issuer issuer = new IssuerBuilder().buildObject(); |
| 1392 | + issuer.setValue("https://idp.saml.elastic.test/" + "a".repeat(128)); |
| 1393 | + |
| 1394 | + final String description = authenticator.describeIssuer(issuer); |
| 1395 | + assertThat(description, hasLength(114)); |
| 1396 | + assertThat(description, endsWith("...")); |
| 1397 | + } |
| 1398 | + |
1373 | 1399 | private interface CryptoTransform { |
1374 | 1400 | String transform(String xml, Tuple<X509Certificate, PrivateKey> keyPair) throws Exception; |
1375 | 1401 | } |
|
0 commit comments