use of org.bf2.systemtest.framework.SecurityUtils.TlsConfig in project kas-fleetshard by bf2fc6cc711aee1a0c2a.
the class ManagedKafkaResourceType method getDefault.
/**
* get common default managedkafka instance
*
* @throws Exception
*/
public static ManagedKafka getDefault(String namespace, String appName, KeycloakInstance keycloak, String strimziVersion, String kafkaVersion) throws Exception {
final String tlsCert;
final String tlsKey;
String hostDomain = SystemTestEnvironment.BOOTSTRAP_HOST_DOMAIN;
if (!KubeClient.getInstance().isGenericKubernetes()) {
OpenShiftClient cli = KubeClient.getInstance().client().adapt(OpenShiftClient.class);
hostDomain = Optional.ofNullable(cli.operator().ingressControllers().inNamespace("openshift-ingress-operator").withName("sharded").get()).orElse(cli.operator().ingressControllers().inNamespace("openshift-ingress-operator").withName("default").get()).getStatus().getDomain();
}
if (SystemTestEnvironment.DUMMY_CERT.equals(SystemTestEnvironment.ENDPOINT_TLS_CERT)) {
SecurityUtils.TlsConfig tlsConfig = SecurityUtils.getTLSConfig(hostDomain);
tlsCert = tlsConfig.getCert();
tlsKey = tlsConfig.getKey();
} else {
tlsCert = SystemTestEnvironment.ENDPOINT_TLS_CERT;
tlsKey = SystemTestEnvironment.ENDPOINT_TLS_KEY;
}
final String oauthClientId;
final String oauthTlsCert;
final String oauthClientSecret;
final String oauthUserClaim;
final String oauthFallbackUserClaim;
final String oauthJwksEndpoint;
final String oauthTokenEndpoint;
final String oauthIssuerEndpoint;
if (keycloak != null) {
oauthClientId = "kafka";
oauthTlsCert = keycloak.getKeycloakCert();
oauthClientSecret = "kafka";
oauthUserClaim = keycloak.getUserNameClaim();
oauthFallbackUserClaim = keycloak.getFallbackUserNameClaim();
oauthJwksEndpoint = keycloak.getJwksEndpointUri();
oauthTokenEndpoint = keycloak.getOauthTokenEndpointUri();
oauthIssuerEndpoint = keycloak.getValidIssuerUri();
} else if (SystemTestEnvironment.DUMMY_OAUTH_JWKS_URI.equals(SystemTestEnvironment.OAUTH_JWKS_ENDPOINT)) {
oauthClientId = null;
oauthTlsCert = null;
oauthClientSecret = null;
oauthUserClaim = null;
oauthFallbackUserClaim = null;
oauthJwksEndpoint = null;
oauthTokenEndpoint = null;
oauthIssuerEndpoint = null;
} else {
// use defined values by env vars for oauth
oauthClientId = SystemTestEnvironment.OAUTH_CLIENT_ID;
oauthTlsCert = SystemTestEnvironment.DUMMY_CERT.equals(SystemTestEnvironment.OAUTH_TLS_CERT) ? null : SystemTestEnvironment.OAUTH_TLS_CERT;
oauthClientSecret = SystemTestEnvironment.OAUTH_CLIENT_SECRET;
oauthUserClaim = SystemTestEnvironment.OAUTH_USER_CLAIM;
oauthFallbackUserClaim = SystemTestEnvironment.OAUTH_FALLBACK_USER_CLAIM;
oauthJwksEndpoint = SystemTestEnvironment.OAUTH_JWKS_ENDPOINT;
oauthTokenEndpoint = SystemTestEnvironment.OAUTH_TOKEN_ENDPOINT;
oauthIssuerEndpoint = SystemTestEnvironment.OAUTH_ISSUER_ENDPOINT;
}
return ManagedKafka.getDefault(appName, namespace, hostDomain, tlsCert, tlsKey, oauthClientId, oauthTlsCert, oauthClientSecret, oauthUserClaim, oauthFallbackUserClaim, oauthJwksEndpoint, oauthTokenEndpoint, oauthIssuerEndpoint, strimziVersion, kafkaVersion);
}
Aggregations