Skip to content

Commit fbfbee4

Browse files
committed
replace test-clients' builders from the operators repository with the ones from test-clients repository
Signed-off-by: Lukas Kral <lukywill16@gmail.com>
1 parent 9949df4 commit fbfbee4

58 files changed

Lines changed: 2661 additions & 3026 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
<skodjob-doc.version>0.6.0</skodjob-doc.version>
122122
<helm-client.version>0.0.15</helm-client.version>
123123
<access-operator.version>0.2.0</access-operator.version>
124+
<test-clients.version>0.13.0</test-clients.version>
124125
<!-- properties to skip surefire tests during failsafe execution -->
125126
<skipTests>false</skipTests>
126127
<skip.surefire.tests>${skipTests}</skip.surefire.tests>
@@ -793,6 +794,12 @@
793794
<artifactId>api</artifactId>
794795
<version>${access-operator.version}</version>
795796
</dependency>
797+
<dependency>
798+
<groupId>io.strimzi.test-clients</groupId>
799+
<artifactId>builders</artifactId>
800+
<version>0.14.0-SNAPSHOT</version>
801+
<scope>provided</scope>
802+
</dependency>
796803
</dependencies>
797804
</dependencyManagement>
798805

systemtest/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@
261261
<groupId>com.marcnuri.helm-java</groupId>
262262
<artifactId>helm-java</artifactId>
263263
</dependency>
264+
<dependency>
265+
<groupId>io.strimzi.test-clients</groupId>
266+
<artifactId>builders</artifactId>
267+
</dependency>
264268
</dependencies>
265269

266270
<build>
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
* Copyright Strimzi authors.
3+
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
4+
*/
5+
package io.strimzi.systemtest.kafkaclients;
6+
7+
import io.fabric8.kubernetes.api.model.EnvVar;
8+
import io.fabric8.kubernetes.api.model.EnvVarBuilder;
9+
import io.skodjob.kubetest4j.resources.KubeResourceManager;
10+
import io.strimzi.api.kafka.model.kafka.KafkaResources;
11+
import io.strimzi.operator.common.Util;
12+
import io.strimzi.systemtest.keycloak.KeycloakInstance;
13+
import io.strimzi.testclients.configuration.Authentication;
14+
import io.strimzi.testclients.configuration.AuthenticationBuilder;
15+
import org.apache.kafka.common.security.auth.SecurityProtocol;
16+
17+
import java.util.ArrayList;
18+
import java.util.List;
19+
20+
public class ClientsAuthentication {
21+
public static Authentication configureTlsScramSha(String namespaceName, String userName, String clusterName) {
22+
return configureScramSha(namespaceName, userName, SecurityProtocol.SASL_SSL)
23+
.withNewSsl()
24+
.withSslTruststoreCertificate(KafkaResources.clusterCaCertificateSecretName(clusterName))
25+
.endSsl()
26+
.build();
27+
}
28+
29+
public static Authentication configurePlainScramSha(String namespaceName, String userName) {
30+
return configureScramSha(namespaceName, userName, SecurityProtocol.SASL_PLAINTEXT).build();
31+
}
32+
33+
public static AuthenticationBuilder configureScramSha(String namespaceName, String userName, SecurityProtocol securityProtocol) {
34+
final String saslJaasConfigEncrypted = KubeResourceManager.get().kubeClient().getClient().secrets().inNamespace(namespaceName).withName(userName).get().getData().get("sasl.jaas.config");
35+
final String saslJaasConfigDecrypted = Util.decodeFromBase64(saslJaasConfigEncrypted);
36+
37+
return new AuthenticationBuilder()
38+
.withNewSasl()
39+
.withSaslJaasConfig(saslJaasConfigDecrypted)
40+
.withSaslMechanism("SCRAM-SHA-512")
41+
.endSasl()
42+
.withSecurityProtocol(securityProtocol.toString());
43+
}
44+
45+
public static Authentication configureTls(String clusterName, String userName) {
46+
return configureTls(KafkaResources.clusterCaCertificateSecretName(clusterName), userName, userName);
47+
}
48+
49+
public static Authentication configureTlsCustomCerts(String caCertificateSecretName, String keystoreSecretName) {
50+
return configureTls(caCertificateSecretName, keystoreSecretName, keystoreSecretName);
51+
}
52+
53+
private static Authentication configureTls(String caCertificateSecretName, String keystoreKeySecretName, String keystoreCertificateChainSecretName) {
54+
return new AuthenticationBuilder()
55+
.withNewSsl()
56+
.withSslTruststoreCertificate(caCertificateSecretName)
57+
.withSslKeystoreKey(keystoreKeySecretName)
58+
.withSslKeystoreCertificateChain(keystoreCertificateChainSecretName)
59+
.endSsl()
60+
.withNewSasl()
61+
.withSaslMechanism("GSSAPI")
62+
.endSasl()
63+
.withSecurityProtocol(SecurityProtocol.SSL.toString())
64+
.build();
65+
}
66+
67+
public static Authentication configureTlsOAuth(String clusterName, String oauthClientId, String oauthClientSecret, String oauthTokenEndpointUri) {
68+
EnvVar oauthSslEndpointEnvVar = new EnvVarBuilder()
69+
.withName("OAUTH_SSL_ENDPOINT_IDENTIFICATION_ALGORITHM")
70+
.withValue("")
71+
.build();
72+
73+
return configureOAuth(oauthClientId, oauthClientSecret, oauthTokenEndpointUri, List.of(oauthSslEndpointEnvVar))
74+
.withNewSsl()
75+
.withSslTruststoreCertificate(KafkaResources.clusterCaCertificateSecretName(clusterName))
76+
.withSslKeystoreKey(oauthClientId)
77+
.withSslKeystoreCertificateChain(oauthClientId)
78+
.endSsl()
79+
.build();
80+
}
81+
82+
public static Authentication configureOAuthPlain(String oauthClientId, String oauthClientSecret, String oauthTokenEndpointUri) {
83+
return configureOAuth(oauthClientId, oauthClientSecret, oauthTokenEndpointUri, null).build();
84+
}
85+
86+
private static AuthenticationBuilder configureOAuth(String oauthClientId, String oauthClientSecret, String oauthTokenEndpointUri, List<EnvVar> additionalEnvVars) {
87+
List<EnvVar> envVars = new ArrayList<>(List.of(
88+
new EnvVarBuilder()
89+
.withName("OAUTH_SSL_TRUSTSTORE_CERTIFICATES")
90+
.withNewValueFrom()
91+
.withNewSecretKeyRef()
92+
.withName(KeycloakInstance.KEYCLOAK_SECRET_NAME)
93+
.withKey(KeycloakInstance.KEYCLOAK_SECRET_CERT)
94+
.endSecretKeyRef()
95+
.endValueFrom()
96+
.build(),
97+
new EnvVarBuilder()
98+
.withName("OAUTH_SSL_TRUSTSTORE_TYPE")
99+
.withValue("PEM")
100+
.build(),
101+
new EnvVarBuilder()
102+
.withName("OAUTH_CLIENT_SECRET")
103+
.editOrNewValueFrom()
104+
.withNewSecretKeyRef()
105+
.withName(oauthClientSecret)
106+
.withKey("clientSecret")
107+
.endSecretKeyRef()
108+
.endValueFrom()
109+
.build()
110+
));
111+
112+
if (additionalEnvVars != null) {
113+
envVars.addAll(additionalEnvVars);
114+
}
115+
116+
return new AuthenticationBuilder()
117+
.withNewOauth()
118+
.withOauthClientId(oauthClientId)
119+
.withOauthTokenEndpointUri(oauthTokenEndpointUri)
120+
.withAdditionalOAuthEnvVars(envVars)
121+
.endOauth();
122+
}
123+
}

systemtest/src/main/java/io/strimzi/systemtest/kafkaclients/internalClients/BaseClients.java

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

0 commit comments

Comments
 (0)