Skip to content

Commit 604c79c

Browse files
committed
fix: move certificates in kubernetes-client-api to avoid collisions with those from mockwebserver
Signed-off-by: Marc Nuri <[email protected]>
1 parent 0f8f649 commit 604c79c

File tree

10 files changed

+14
-13
lines changed

10 files changed

+14
-13
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#### Bugs
66
* Fix #5501: (crd-generator) Fix fallback value of `Default` annotation in presence of multiple accessors
77
* Fix #5522: type inference fixed by bumping Sundrio to 0.101.2 (see https://github.com/sundrio/sundrio/pull/431)
8+
* Fix #5554: move certificates in kubernetes-client-api to avoid collisions with those from mockwebserver
89

910
#### Improvements
1011

kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/internal/CertUtilsTest.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
class CertUtilsTest {
4646

47-
private static final String FABRIC8_STORE_PATH = Utils.filePath(CertUtilsTest.class.getResource("/ssl/fabric8-store"));
47+
private static final String FABRIC8_STORE_PATH = Utils.filePath(CertUtilsTest.class.getResource("/ssl-test/fabric8-store"));
4848
private static final String FABRIC8_STORE_PASSPHRASE = "fabric8";
4949
private Properties systemProperties;
5050

@@ -76,7 +76,7 @@ void handleReadOnlyJavaTrustStore() throws Exception {
7676
KeyStore trustStore = Mockito.spy(system);
7777
Mockito.doThrow(KeyStoreException.class).when(trustStore).setCertificateEntry(Mockito.anyString(), Mockito.any());
7878
KeyStore result = CertUtils.mergePemCertsIntoTrustStore(
79-
CertUtils.getInputStreamFromDataOrFile(null, "src/test/resources/ssl/multiple-certs.pem"), trustStore, true);
79+
CertUtils.getInputStreamFromDataOrFile(null, "src/test/resources/ssl-test/multiple-certs.pem"), trustStore, true);
8080

8181
assertNotSame(trustStore, result);
8282
assertThat(Collections.list(result.aliases()))
@@ -88,7 +88,7 @@ void handleReadOnlyJavaTrustStore() throws Exception {
8888
@Test
8989
void loadingMultipleCertsFromSameFile() throws Exception {
9090
KeyStore ts = CertUtils.createTrustStore(
91-
null, "src/test/resources/ssl/multiple-certs.pem", null, "changeit");
91+
null, "src/test/resources/ssl-test/multiple-certs.pem", null, "changeit");
9292

9393
assertThat(Collections.list(ts.aliases()))
9494
.hasSizeGreaterThanOrEqualTo(2)
@@ -99,15 +99,15 @@ void loadingMultipleCertsFromSameFile() throws Exception {
9999
@Test
100100
void loadingMultipleCertsWithSameSubjectFromSameFile() throws Exception {
101101
KeyStore ts = CertUtils.createTrustStore(
102-
null, "src/test/resources/ssl/nonunique-subject.pem", null, "changeit");
102+
null, "src/test/resources/ssl-test/nonunique-subject.pem", null, "changeit");
103103

104104
assertTrue(ts.size() >= 2);
105105
}
106106

107107
@Test
108108
void loadTrustStoreFromFileUsingConfigProperties() throws Exception {
109109
KeyStore trustStore = CertUtils.createTrustStore(
110-
null, "src/test/resources/ssl/multiple-certs.pem", FABRIC8_STORE_PATH, FABRIC8_STORE_PASSPHRASE);
110+
null, "src/test/resources/ssl-test/multiple-certs.pem", FABRIC8_STORE_PATH, FABRIC8_STORE_PASSPHRASE);
111111

112112
assertThat(Collections.list(trustStore.aliases()))
113113
.hasSizeGreaterThanOrEqualTo(3)
@@ -123,7 +123,7 @@ void loadTrustStoreFromFileUsingSystemProperties() throws Exception {
123123
System.setProperty("javax.net.ssl.trustStorePassword", FABRIC8_STORE_PASSPHRASE);
124124

125125
KeyStore trustStore = CertUtils.createTrustStore(
126-
null, "src/test/resources/ssl/multiple-certs.pem", null, null);
126+
null, "src/test/resources/ssl-test/multiple-certs.pem", null, null);
127127

128128
assertEquals(3, trustStore.size());
129129
verifyFabric8InStore(trustStore);
@@ -132,8 +132,8 @@ void loadTrustStoreFromFileUsingSystemProperties() throws Exception {
132132
@Test
133133
void loadKeyStoreFromFileUsingConfigProperties() throws Exception {
134134
KeyStore trustStore = CertUtils.createKeyStore(
135-
null, "src/test/resources/ssl/multiple-certs.pem",
136-
null, "src/test/resources/ssl/fabric8", "RSA", "changeit",
135+
null, "src/test/resources/ssl-test/multiple-certs.pem",
136+
null, "src/test/resources/ssl-test/fabric8", "RSA", "changeit",
137137
FABRIC8_STORE_PATH, FABRIC8_STORE_PASSPHRASE);
138138

139139
assertEquals(2, trustStore.size());
@@ -145,8 +145,8 @@ void loadKeyStoreFromFileUsingSystemProperties() throws Exception {
145145
System.setProperty("javax.net.ssl.keyStore", FABRIC8_STORE_PATH);
146146
System.setProperty("javax.net.ssl.keyStorePassword", String.valueOf(FABRIC8_STORE_PASSPHRASE));
147147

148-
String privateKeyPath = Utils.filePath(getClass().getResource("/ssl/fabric8"));
149-
String multipleCertsPath = Utils.filePath(getClass().getResource("/ssl/multiple-certs.pem"));
148+
String privateKeyPath = Utils.filePath(getClass().getResource("/ssl-test/fabric8"));
149+
String multipleCertsPath = Utils.filePath(getClass().getResource("/ssl-test/multiple-certs.pem"));
150150

151151
KeyStore trustStore = CertUtils.createKeyStore(null, multipleCertsPath, null, privateKeyPath, "RSA", "changeit", null,
152152
null);
@@ -159,7 +159,7 @@ void loadKeyStoreFromFileUsingSystemProperties() throws Exception {
159159
void getInputStreamFromDataOrFileShouldNotDecodedPEMAgain() throws IOException {
160160
// Given
161161
File certFile = new File(
162-
Objects.requireNonNull(getClass().getResource("/ssl/valid-non-base64-encoded-cert.pem")).getFile());
162+
Objects.requireNonNull(getClass().getResource("/ssl-test/valid-non-base64-encoded-cert.pem")).getFile());
163163
String certData = new String(Files.readAllBytes(certFile.toPath()));
164164

165165
// When
@@ -188,7 +188,7 @@ void getInputStreamFromDataOrFileShouldDecodeBase64EncodedString() throws IOExce
188188
void storeKeyFallbacksToDefault() throws Exception {
189189
// When
190190
final KeyStore result = CertUtils.createTrustStore(
191-
null, "src/test/resources/ssl/multiple-certs.pem", null, "");
191+
null, "src/test/resources/ssl-test/multiple-certs.pem", null, "");
192192
// Then
193193
assertThat(Collections.list(result.aliases()))
194194
.hasSizeGreaterThanOrEqualTo(2)
@@ -203,7 +203,7 @@ private void verifyFabric8InStore(KeyStore trustStore)
203203
assertNotNull(certificate);
204204

205205
KeyStore storeWithCert = CertUtils.createTrustStore(
206-
null, "src/test/resources/ssl/fabric8.crt", null, "");
206+
null, "src/test/resources/ssl-test/fabric8.crt", null, "");
207207
String certificateAlias = storeWithCert.getCertificateAlias(certificate);
208208
assertNotNull(certificateAlias);
209209
}

0 commit comments

Comments
 (0)