|
24 | 24 | import java.net.URL; |
25 | 25 | import java.nio.file.Files; |
26 | 26 | import java.nio.file.Paths; |
| 27 | +import java.security.KeyStore; |
| 28 | +import java.security.cert.X509Certificate; |
27 | 29 | import java.util.Base64; |
28 | 30 | import java.util.Collections; |
29 | 31 | import java.util.Enumeration; |
@@ -91,11 +93,18 @@ public void configure_system_credentials() throws Exception { |
91 | 93 | byte[] actualBytes = keyStoreSource.getUploadedKeystore().getPlainData(); |
92 | 94 | assertThat("The bytes in Jenkins should be identical to the source file", actualBytes, equalTo(expectedBytes)); |
93 | 95 |
|
94 | | - Enumeration<String> aliases = certImpl.getKeyStore().aliases(); |
| 96 | + KeyStore keyStore = certImpl.getKeyStore(); |
| 97 | + Enumeration<String> aliases = keyStore.aliases(); |
95 | 98 | assertThat("Keystore should not be empty", aliases.hasMoreElements(), equalTo(true)); |
96 | 99 |
|
97 | | - String firstAlias = aliases.nextElement(); |
98 | | - assertThat("Alias should contain a valid key", certImpl.getKeyStore().isKeyEntry(firstAlias), equalTo(true)); |
| 100 | + String alias = aliases.nextElement(); |
| 101 | + X509Certificate certificate = (X509Certificate) keyStore.getCertificate(alias); |
| 102 | + assertThat(certificate, notNullValue()); |
| 103 | + |
| 104 | + String subject = certificate.getSubjectX500Principal().getName(); |
| 105 | + assertThat(subject, containsString("CN=Test")); |
| 106 | + |
| 107 | + assertThat(certificate.getType(), equalTo("X.509")); |
99 | 108 |
|
100 | 109 | List<BasicSSHUserPrivateKey> sshPrivateKeys = CredentialsProvider.lookupCredentials( |
101 | 110 | BasicSSHUserPrivateKey.class, jenkins, ACL.SYSTEM, Collections.emptyList()); |
|
0 commit comments