Skip to content

Commit

Permalink
Extract configuration to HydraIdentityProvider
Browse files Browse the repository at this point in the history
This allows us to reuse to HydraIdentityProvider across various
environment.
  • Loading branch information
Praveen2112 committed Nov 26, 2021
1 parent b11a241 commit 040fa59
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.containers.wait.strategy.WaitAllStrategy;

import static io.trino.tests.product.launcher.env.EnvironmentContainers.TESTS;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.isPrestoContainer;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_PRESTO_ETC;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_TEMPTO_PROFILE_CONFIG;
import static java.util.Objects.requireNonNull;
import static org.testcontainers.utility.MountableFile.forHostPath;

Expand Down Expand Up @@ -88,6 +92,19 @@ public void extendEnvironment(Environment.Builder builder)
builder.containerDependsOn(hydra.getLogicalName(), hydraConsent.getLogicalName());
builder.containerDependsOn(hydra.getLogicalName(), migrationContainer.getLogicalName());
builder.containerDependsOn(hydra.getLogicalName(), databaseContainer.getLogicalName());

builder.configureContainers(dockerContainer -> {
if (isPrestoContainer(dockerContainer.getLogicalName())) {
dockerContainer
.withCopyFileToContainer(
forHostPath(configDir.getPath("cert")),
CONTAINER_PRESTO_ETC + "/hydra/cert");
}
});

builder.configureContainer(TESTS, dockerContainer -> dockerContainer.withCopyFileToContainer(
forHostPath(configDir.getPath("tempto-configuration-for-docker-oauth2.yaml")),
CONTAINER_TEMPTO_PROFILE_CONFIG));
}

public DockerContainer createClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.google.common.collect.ImmutableList;
import io.trino.tests.product.launcher.docker.DockerFiles;
import io.trino.tests.product.launcher.docker.DockerFiles.ResourceProvider;
import io.trino.tests.product.launcher.env.DockerContainer;
import io.trino.tests.product.launcher.env.Environment;
import io.trino.tests.product.launcher.env.EnvironmentProvider;
Expand All @@ -30,10 +31,7 @@
import java.util.List;

import static io.trino.tests.product.launcher.env.EnvironmentContainers.COORDINATOR;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.TESTS;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_PRESTO_CONFIG_PROPERTIES;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_PRESTO_ETC;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_TEMPTO_PROFILE_CONFIG;
import static java.util.Objects.requireNonNull;
import static org.testcontainers.utility.MountableFile.forHostPath;

Expand All @@ -43,7 +41,7 @@ public class EnvSinglenodeOauth2
{
private final PortBinder binder;
private final HydraIdentityProvider hydraIdentityProvider;
private final DockerFiles dockerFiles;
private final ResourceProvider configDir;

@Inject
public EnvSinglenodeOauth2(DockerFiles dockerFiles, PortBinder binder, Standard standard, HydraIdentityProvider hydraIdentityProvider, SeleniumChrome seleniumChrome)
Expand All @@ -52,7 +50,8 @@ public EnvSinglenodeOauth2(DockerFiles dockerFiles, PortBinder binder, Standard

this.binder = requireNonNull(binder, "binder is null");
this.hydraIdentityProvider = requireNonNull(hydraIdentityProvider, "hydraIdentityProvider is null");
this.dockerFiles = requireNonNull(dockerFiles, "dockerFiles is null");
requireNonNull(dockerFiles, "dockerFiles is null");
this.configDir = dockerFiles.getDockerFilesHostDirectory("conf/environment/singlenode-oauth2/");
}

@Override
Expand All @@ -61,21 +60,12 @@ public void extendEnvironment(Environment.Builder builder)
builder.configureContainer(COORDINATOR, dockerContainer -> {
dockerContainer
.withCopyFileToContainer(
forHostPath(dockerFiles.getDockerFilesHostPath("conf/environment/singlenode-oauth2/config.properties")),
CONTAINER_PRESTO_CONFIG_PROPERTIES)
.withCopyFileToContainer(
forHostPath(dockerFiles.getDockerFilesHostPath("common/hydra-identity-provider/cert")),
CONTAINER_PRESTO_ETC + "/hydra/cert");
forHostPath(configDir.getPath("config.properties")),
CONTAINER_PRESTO_CONFIG_PROPERTIES);

binder.exposePort(dockerContainer, 7778);
});

builder.configureContainer(TESTS, dockerContainer -> {
dockerContainer.withCopyFileToContainer(
forHostPath(dockerFiles.getDockerFilesHostPath("conf/tempto/tempto-configuration-for-docker-oauth2.yaml")),
CONTAINER_TEMPTO_PROFILE_CONFIG);
});

DockerContainer hydraClientConfig = hydraIdentityProvider.createClient(
builder,
"trinodb_client_id",
Expand Down

0 comments on commit 040fa59

Please sign in to comment.