-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88918f3
commit 893dcc8
Showing
14 changed files
with
278 additions
and
3,341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
operator/controller/src/test/java/io/apicurio/registry/operator/it/KeycloakTLSITTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package io.apicurio.registry.operator.it; | ||
|
||
import io.apicurio.registry.operator.EnvironmentVariables; | ||
import io.apicurio.registry.operator.api.v1.ApicurioRegistry3; | ||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.client.utils.Serialization; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import org.awaitility.Awaitility; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.time.Duration; | ||
import java.util.List; | ||
|
||
import static io.apicurio.registry.operator.api.v1.ContainerNames.REGISTRY_APP_CONTAINER_NAME; | ||
import static io.apicurio.registry.operator.resource.ResourceFactory.COMPONENT_APP; | ||
import static io.apicurio.registry.operator.resource.ResourceFactory.COMPONENT_UI; | ||
import static io.apicurio.registry.operator.resource.ResourceFactory.deserialize; | ||
import static io.apicurio.registry.operator.resource.app.AppDeploymentResource.getContainerFromDeployment; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.awaitility.Awaitility.await; | ||
|
||
@QuarkusTest | ||
public class KeycloakTLSITTest extends ITBase { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(KeycloakTLSITTest.class); | ||
|
||
@BeforeAll | ||
public static void init() { | ||
Awaitility.setDefaultTimeout(Duration.ofSeconds(60)); | ||
} | ||
|
||
@Test | ||
void testKeycloakPlain() { | ||
// Preparation, deploy Keycloak | ||
List<HasMetadata> resources = Serialization | ||
.unmarshal(KeycloakTLSITTest.class.getResourceAsStream("/k8s/examples/auth/keycloak.yaml")); | ||
|
||
createResources(resources, "Keycloak"); | ||
|
||
await().ignoreExceptions().untilAsserted(() -> { | ||
assertThat(client.apps().deployments().withName("keycloak").get().getStatus().getReadyReplicas()) | ||
.isEqualTo(1); | ||
}); | ||
|
||
// Deploy Registry | ||
var registry = deserialize("k8s/examples/auth/tls/simple-with_keycloak.apicurioregistry3.yaml", | ||
ApicurioRegistry3.class); | ||
|
||
registry.getMetadata().setNamespace(namespace); | ||
|
||
var appAuthSpec = registry.getSpec().getApp().getAuth(); | ||
|
||
Assertions.assertEquals("registry-api", appAuthSpec.getAppClientId()); | ||
Assertions.assertEquals("apicurio-registry", appAuthSpec.getUiClientId()); | ||
Assertions.assertEquals(true, appAuthSpec.getEnabled()); | ||
Assertions.assertEquals("https://simple-keycloak.apps.cluster.example/realms/registry", | ||
appAuthSpec.getAuthServerUrl()); | ||
Assertions.assertEquals("https://simple-ui.apps.cluster.example", appAuthSpec.getRedirectURI()); | ||
Assertions.assertEquals("https://simple-ui.apps.cluster.example", appAuthSpec.getLogoutURL()); | ||
|
||
// We must change the auth url of the backend to use the service. | ||
appAuthSpec.setAuthServerUrl("https://keycloak." + namespace + ".svc.cluster.local/realms/registry"); | ||
|
||
client.resource(registry).create(); | ||
|
||
// Assertions, checks registry deployments exist | ||
checkDeploymentExists(registry, COMPONENT_APP, 1); | ||
checkDeploymentExists(registry, COMPONENT_UI, 1); | ||
|
||
// App deployment auth related assertions | ||
var appEnv = getContainerFromDeployment( | ||
client.apps().deployments().inNamespace(namespace) | ||
.withName(registry.getMetadata().getName() + "-app-deployment").get(), | ||
REGISTRY_APP_CONTAINER_NAME).getEnv(); | ||
|
||
assertThat(appEnv).map(ev -> ev.getName() + "=" + ev.getValue()) | ||
.contains(EnvironmentVariables.APICURIO_REGISTRY_AUTH_ENABLED + "=" + "true"); | ||
assertThat(appEnv).map(ev -> ev.getName() + "=" + ev.getValue()) | ||
.contains(EnvironmentVariables.OIDC_TLS_VERIFICATION + "=" + "required"); | ||
assertThat(appEnv).map(ev -> ev.getName() + "=" + ev.getValue()) | ||
.contains(EnvironmentVariables.APICURIO_REGISTRY_APP_CLIENT_ID + "=" + "registry-api"); | ||
assertThat(appEnv).map(ev -> ev.getName() + "=" + ev.getValue()) | ||
.contains(EnvironmentVariables.APICURIO_REGISTRY_UI_CLIENT_ID + "=" + "apicurio-registry"); | ||
assertThat(appEnv).map(ev -> ev.getName() + "=" + ev.getValue()) | ||
.contains(EnvironmentVariables.APICURIO_REGISTRY_AUTH_SERVER_URL + "=" + "https://keycloak." | ||
+ namespace + ".svc.cluster.local/realms/registry"); | ||
assertThat(appEnv).map(ev -> ev.getName() + "=" + ev.getValue()) | ||
.contains(EnvironmentVariables.APICURIO_UI_AUTH_OIDC_REDIRECT_URI + "=" | ||
+ "https://simple-ui.apps.cluster.example"); | ||
assertThat(appEnv).map(ev -> ev.getName() + "=" + ev.getValue()) | ||
.contains(EnvironmentVariables.APICURIO_UI_AUTH_OIDC_LOGOUT_URL + "=" | ||
+ "https://simple-ui.apps.cluster.example"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.