Skip to content

Commit 85158fb

Browse files
chore: [DevOps] bump the test group across 1 directory with 3 updates (#1043)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Alexander Dümont <alexander.duemont@sap.com>
1 parent 1f41955 commit 85158fb

File tree

14 files changed

+123
-96
lines changed

14 files changed

+123
-96
lines changed

cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/ClientCertificateAuthenticationLocalTest.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@
3737

3838
class ClientCertificateAuthenticationLocalTest
3939
{
40-
private static final String CCA_PASSWORD = "cca-password";
41-
private static final String JKS_PATH =
42-
"src/test/resources/" + ClientCertificateAuthenticationLocalTest.class.getSimpleName() + "/client-cert.pkcs12";
40+
private static final String JKS_PREFIX =
41+
"src/test/resources/" + ClientCertificateAuthenticationLocalTest.class.getSimpleName();
42+
private static final String SERVER_TRUST_STORE = JKS_PREFIX + "/certs/truststore.jks";
43+
private static final String SERVER_TRUST_STORE_PASS = "changeit";
44+
private static final String SERVER_KEY_STORE = JKS_PREFIX + "/certs/server.jks";
45+
private static final String SERVER_KEY_STORE_PASS = "changeit";
46+
private static final String CLIENT_KEY_STORE = JKS_PREFIX + "/certs/client1.p12";
47+
private static final String CLIENT_KEY_STORE_PASS = "changeit";
4348

4449
@RegisterExtension
4550
static final WireMockExtension server =
@@ -71,7 +76,7 @@ void testClientCorrectlyConfigured()
7176
.authenticationType(AuthenticationType.CLIENT_CERTIFICATE_AUTHENTICATION)
7277
.proxyType(ProxyType.INTERNET)
7378
.keyStore(getClientKeyStore())
74-
.keyStorePassword(CCA_PASSWORD)
79+
.keyStorePassword(CLIENT_KEY_STORE_PASS)
7580
.trustAllCertificates()
7681
.build());
7782

@@ -82,7 +87,7 @@ void testClientCorrectlyConfigured()
8287

8388
assertThat(context.getUserToken()).isNotNull();
8489
assertThat(context.getUserToken()).isInstanceOf(X500Principal.class);
85-
assertThat(((X500Principal) context.getUserToken()).getName()).contains("CN=localhost");
90+
assertThat(((X500Principal) context.getUserToken()).getName()).contains("CN=client1");
8691

8792
// assert keystore methods have been used
8893
Mockito.verify(destination).getKeyStorePassword();
@@ -122,8 +127,11 @@ private static WireMockConfiguration buildWireMockConfiguration()
122127
.httpDisabled(true)
123128
.dynamicHttpsPort()
124129
.needClientAuth(true)
125-
.trustStorePath(JKS_PATH)
126-
.trustStorePassword(CCA_PASSWORD)
130+
.keystorePath(SERVER_KEY_STORE)
131+
.keystorePassword(SERVER_KEY_STORE_PASS)
132+
.keyManagerPassword(SERVER_KEY_STORE_PASS)
133+
.trustStorePath(SERVER_TRUST_STORE)
134+
.trustStorePassword(SERVER_TRUST_STORE_PASS)
127135
.trustStoreType("JKS");
128136
}
129137

@@ -134,7 +142,7 @@ private static KeyStore getClientKeyStore()
134142
NoSuchAlgorithmException
135143
{
136144
final KeyStore keyStore = KeyStore.getInstance("PKCS12");
137-
keyStore.load(new FileInputStream(JKS_PATH), CCA_PASSWORD.toCharArray());
145+
keyStore.load(new FileInputStream(CLIENT_KEY_STORE), CLIENT_KEY_STORE_PASS.toCharArray());
138146
return keyStore;
139147
}
140148
}

cloudplatform/connectivity-apache-httpclient5/src/test/resources/ClientCertificateAuthenticationLocalTest/README.md

Lines changed: 103 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,112 @@ The credential files are generated from command line. This process can be automa
55

66
## CREATE CLIENT CREDENTIALS
77

8-
* Generate key pair
9-
```bash
10-
openssl req -x509 -newkey rsa:2048 -utf8 -days 3650 -nodes -config client-cert.conf -keyout client-cert.key -out client-cert.crt
8+
* Client keystore
119
```
10+
docker run --rm -v $(pwd)/certs:/certs eclipse-temurin:17-jre \
11+
keytool -genkeypair \
12+
-alias client1 \
13+
-keyalg RSA \
14+
-keysize 2048 \
15+
-validity 3650 \
16+
-storetype JKS \
17+
-keystore /certs/client1.jks \
18+
-storepass changeit \
19+
-keypass changeit \
20+
-dname "CN=client1"
21+
```
22+
23+
<details><summary>(Windows)</summary>
1224

13-
* Generate _PKCS#12_ keystore
14-
```bash
15-
openssl pkcs12 -export -inkey client-cert.key -in client-cert.crt -out client-cert.p12 -password "pass:cca-password"
25+
```
26+
docker run --rm -v ${pwd}/certs:/certs eclipse-temurin:17-jre keytool -genkeypair -alias client1 -keyalg RSA -keysize 2048 -validity 3650 -storetype JKS -keystore /certs/client1.jks -storepass changeit -keypass changeit -dname "CN=client1"
1627
```
1728

18-
* Transform to JKS
29+
</details>
30+
31+
* Export client certificate
32+
```
33+
docker run --rm -v $(pwd)/certs:/certs eclipse-temurin:17-jre \
34+
keytool -exportcert \
35+
-alias client1 \
36+
-keystore /certs/client1.jks \
37+
-storepass changeit \
38+
-file /certs/client1.cer
39+
```
40+
41+
<details><summary>(Windows)</summary>
42+
43+
```
44+
docker run --rm -v ${pwd}/certs:/certs eclipse-temurin:17-jre keytool -exportcert -alias client1 -keystore /certs/client1.jks -storepass changeit -file /certs/client1.cer
45+
```
1946

20-
```bash
21-
keytool -importkeystore -deststorepass "cca-password" -destkeypass "cca-password" -srckeystore client-cert.p12 -srcstorepass "cca-password" -deststoretype pkcs12 -destkeystore client-cert.pkcs12
47+
</details>
48+
49+
* PKCS12 keystore for client
50+
51+
```
52+
docker run --rm -v $(pwd)/certs:/certs eclipse-temurin:17-jre \
53+
keytool -importkeystore \
54+
-srckeystore /certs/client1.jks \
55+
-srcstoretype JKS \
56+
-srcstorepass changeit \
57+
-destkeystore /certs/client1.p12 \
58+
-deststoretype PKCS12 \
59+
-deststorepass changeit \
60+
-destkeypass changeit
2261
```
62+
63+
<details><summary>(Windows)</summary>
64+
65+
```
66+
docker run --rm -v ${pwd}/certs:/certs eclipse-temurin:17-jre keytool -importkeystore -srckeystore /certs/client1.jks -srcstoretype JKS -srcstorepass changeit -destkeystore /certs/client1.p12 -deststoretype PKCS12 -deststorepass changeit -destkeypass changeit
67+
```
68+
69+
</details>
70+
71+
72+
## CREATE SERVER CREDENTIALS
73+
74+
* Server keystore. Run once
75+
```
76+
docker run --rm -v $(pwd)/certs:/certs eclipse-temurin:17-jre \
77+
keytool -genkeypair \
78+
-alias wiremock-server \
79+
-keyalg RSA \
80+
-keysize 2048 \
81+
-validity 3650 \
82+
-storetype JKS \
83+
-keystore /certs/server.jks \
84+
-storepass changeit \
85+
-keypass changeit \
86+
-dname "CN=localhost" \
87+
-ext SAN=dns:localhost,ip:127.0.0.1
88+
```
89+
90+
<details><summary>(Windows)</summary>
91+
92+
```
93+
docker run --rm -v ${pwd}/certs:/certs eclipse-temurin:17-jre keytool -genkeypair -alias wiremock-server -keyalg RSA -keysize 2048 -validity 3650 -storetype JKS -keystore /certs/server.jks -storepass changeit -keypass changeit -dname "CN=localhost" -ext SAN=dns:localhost,ip:127.0.0.1
94+
```
95+
96+
</details>
97+
98+
* Truststore for wiremock
99+
100+
```
101+
docker run --rm -v $(pwd)/certs:/certs eclipse-temurin:17-jre \
102+
keytool -importcert \
103+
-alias client1 \
104+
-file /certs/client1.cer \
105+
-keystore /certs/truststore.jks \
106+
-storepass changeit \
107+
-noprompt
108+
```
109+
110+
<details><summary>(Windows)</summary>
111+
112+
```
113+
docker run --rm -v ${pwd}/certs:/certs eclipse-temurin:17-jre keytool -importcert -alias client1 -file /certs/client1.cer -keystore /certs/truststore.jks -storepass changeit -noprompt
114+
```
115+
116+
</details>

cloudplatform/connectivity-apache-httpclient5/src/test/resources/ClientCertificateAuthenticationLocalTest/client-cert.conf

Lines changed: 0 additions & 25 deletions
This file was deleted.

cloudplatform/connectivity-apache-httpclient5/src/test/resources/ClientCertificateAuthenticationLocalTest/client-cert.crt

Lines changed: 0 additions & 22 deletions
This file was deleted.

cloudplatform/connectivity-apache-httpclient5/src/test/resources/ClientCertificateAuthenticationLocalTest/client-cert.key

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)