Extract OpenShiftCliCommandExecutor in selenium tests (#10033)
Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>6.19.x
parent
ec4e4cd76f
commit
f5ce200109
|
|
@ -8,24 +8,23 @@
|
|||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.selenium.core.client.keycloak.executor;
|
||||
package org.eclipse.che.selenium.core.utils.executor;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.eclipse.che.selenium.core.utils.process.ProcessAgentException;
|
||||
|
||||
/**
|
||||
* Executor of command of 'keycloak/bin/kcadm.sh' command line application.
|
||||
* Executes commands of CLI application.
|
||||
*
|
||||
* @author Dmytro Nochevnov
|
||||
*/
|
||||
public interface KeycloakCommandExecutor {
|
||||
public interface CommandExecutor {
|
||||
|
||||
/**
|
||||
* Executes command-line interface command.
|
||||
* Executes CLI application command.
|
||||
*
|
||||
* @param command CLI command to execute
|
||||
* @return response of CLI command
|
||||
* @throws ProcessAgentException
|
||||
* @throws IOException if there is a problem with command execution.
|
||||
*/
|
||||
String execute(String command) throws IOException;
|
||||
}
|
||||
|
|
@ -52,10 +52,10 @@ Follow the guide: [https://github.com/eclipse/che](https://github.com/eclipse/ch
|
|||
|
||||
Simply launch `./selenium-tests.sh`
|
||||
|
||||
### How to run tests on Open Shift
|
||||
### How to run tests on OpenShift
|
||||
#### 1. Set workspace runtime infrastructure implementation
|
||||
export CHE_INFRASTRUCTURE=openshift
|
||||
#### 2. Run tests and specify host and port of Che deployed to Open Shift
|
||||
#### 2. Run tests and specify host and port of Che deployed to OpenShift
|
||||
Launch `./selenium-tests.sh --host=<Che host on openshift> --port=80`
|
||||
|
||||
Example: `./selenium-tests.sh --host=che-spi.192.168.99.100.nip.io --port=80`
|
||||
|
|
@ -68,7 +68,7 @@ export OPENSHIFT_TOKEN=<openshift_web_console_bearer_auth_token>
|
|||
export OPENSHIFT_CHE_NAMESPACE=<namespace_of_eclipse_che_deployed_on_openshift>
|
||||
export OPENSHIFT_URL=<url_of_openshift_web_console>
|
||||
```
|
||||
where `OPENSHIFT_TOKEN` is optional and is aimed to replace username/password when Open Shift is configured with oAuth.
|
||||
where `OPENSHIFT_TOKEN` is optional and is aimed to replace username/password when OpenShift is configured with oAuth.
|
||||
|
||||
|
||||
Default values:
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
package org.eclipse.che.selenium.core;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.executor.DockerKeycloakCommandExecutor;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.executor.KeycloakCommandExecutor;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.cli.DockerKeycloakCliCommandExecutor;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.cli.KeycloakCliCommandExecutor;
|
||||
import org.eclipse.che.selenium.core.workspace.CheTestDockerWorkspaceLogsReader;
|
||||
import org.eclipse.che.selenium.core.workspace.TestWorkspaceLogsReader;
|
||||
|
||||
|
|
@ -22,6 +22,6 @@ public class CheSeleniumDockerModule extends AbstractModule {
|
|||
@Override
|
||||
protected void configure() {
|
||||
bind(TestWorkspaceLogsReader.class).to(CheTestDockerWorkspaceLogsReader.class);
|
||||
bind(KeycloakCommandExecutor.class).to(DockerKeycloakCommandExecutor.class);
|
||||
bind(KeycloakCliCommandExecutor.class).to(DockerKeycloakCliCommandExecutor.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
package org.eclipse.che.selenium.core;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.executor.KeycloakCommandExecutor;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.executor.OpenShiftKeycloakCommandExecutor;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.cli.KeycloakCliCommandExecutor;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.cli.OpenShiftKeycloakCliCommandExecutor;
|
||||
import org.eclipse.che.selenium.core.workspace.CheTestOpenshiftWorkspaceLogsReader;
|
||||
import org.eclipse.che.selenium.core.workspace.TestWorkspaceLogsReader;
|
||||
|
||||
|
|
@ -22,6 +22,6 @@ public class CheSeleniumOpenshiftModule extends AbstractModule {
|
|||
@Override
|
||||
protected void configure() {
|
||||
bind(TestWorkspaceLogsReader.class).to(CheTestOpenshiftWorkspaceLogsReader.class);
|
||||
bind(KeycloakCommandExecutor.class).to(OpenShiftKeycloakCommandExecutor.class);
|
||||
bind(KeycloakCliCommandExecutor.class).to(OpenShiftKeycloakCliCommandExecutor.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,42 +8,39 @@
|
|||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.selenium.core.client.keycloak.executor;
|
||||
package org.eclipse.che.selenium.core.client.keycloak.cli;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import org.eclipse.che.selenium.core.executor.DockerCliCommandExecutor;
|
||||
import org.eclipse.che.selenium.core.utils.process.ProcessAgent;
|
||||
import org.eclipse.che.selenium.core.utils.process.ProcessAgentException;
|
||||
|
||||
/**
|
||||
* This class is aimed to call Keycloak admin CLI inside Docker container.
|
||||
* This class is aimed to call Keycloak CLI commands inside Docker container.
|
||||
*
|
||||
* @author Dmytro Nochevnov
|
||||
*/
|
||||
@Singleton
|
||||
public class DockerKeycloakCommandExecutor implements KeycloakCommandExecutor {
|
||||
public class DockerKeycloakCliCommandExecutor implements KeycloakCliCommandExecutor {
|
||||
@Inject private DockerCliCommandExecutor dockerCliCommandExecutor;
|
||||
|
||||
private final ProcessAgent processAgent;
|
||||
@Inject private ProcessAgent processAgent;
|
||||
|
||||
private String keycloakContainerId;
|
||||
|
||||
@Inject
|
||||
public DockerKeycloakCommandExecutor(ProcessAgent processAgent) {
|
||||
this.processAgent = processAgent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(String command) throws IOException {
|
||||
if (keycloakContainerId == null || keycloakContainerId.trim().isEmpty()) {
|
||||
obtainKeycloakContainerId();
|
||||
}
|
||||
|
||||
String dockerCommand =
|
||||
format("docker exec -i %s sh -c 'keycloak/bin/kcadm.sh %s'", keycloakContainerId, command);
|
||||
return processAgent.process(dockerCommand);
|
||||
String dockerKeycloakCliCommand =
|
||||
format("exec -i %s sh -c 'keycloak/bin/kcadm.sh %s'", keycloakContainerId, command);
|
||||
return dockerCliCommandExecutor.execute(dockerKeycloakCliCommand);
|
||||
}
|
||||
|
||||
private void obtainKeycloakContainerId() throws ProcessAgentException {
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.selenium.core.client.keycloak;
|
||||
package org.eclipse.che.selenium.core.client.keycloak.cli;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
|
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Singleton;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.executor.KeycloakCommandExecutor;
|
||||
import org.eclipse.che.selenium.core.provider.AdminTestUserProvider;
|
||||
import org.eclipse.che.selenium.core.provider.RemovableUserProvider;
|
||||
import org.eclipse.che.selenium.core.user.AdminTestUser;
|
||||
|
|
@ -34,8 +33,8 @@ import org.slf4j.LoggerFactory;
|
|||
* @author Dmytro Nochevnov
|
||||
*/
|
||||
@Singleton
|
||||
public class KeycloakAdminConsoleClient {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(KeycloakAdminConsoleClient.class);
|
||||
public class KeycloakCliClient {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(KeycloakCliClient.class);
|
||||
private static final Pattern EXTRACT_USER_ID_PATTERN =
|
||||
Pattern.compile("^.*Created new user with id '(.*)'.*$", Pattern.DOTALL);
|
||||
|
||||
|
|
@ -45,10 +44,10 @@ public class KeycloakAdminConsoleClient {
|
|||
private final TestUserFactory<DefaultTestUser> defaultTestUserFactory;
|
||||
private final TestUserFactory<TestUserImpl> testUserFactory;
|
||||
|
||||
@Inject private KeycloakCommandExecutor executor;
|
||||
@Inject private KeycloakCliCommandExecutor executor;
|
||||
|
||||
@Inject
|
||||
public KeycloakAdminConsoleClient(
|
||||
public KeycloakCliClient(
|
||||
TestUserFactory<TestUserImpl> testUserFactory,
|
||||
TestUserFactory<DefaultTestUser> defaultTestUserFactory) {
|
||||
this.testUserFactory = testUserFactory;
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2018 Red Hat, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.selenium.core.client.keycloak.cli;
|
||||
|
||||
import org.eclipse.che.selenium.core.utils.executor.CommandExecutor;
|
||||
|
||||
/**
|
||||
* Execute commands of Keycloak CLI application.
|
||||
*
|
||||
* @author Dmytro Nochevnov
|
||||
*/
|
||||
public interface KeycloakCliCommandExecutor extends CommandExecutor {}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2018 Red Hat, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.selenium.core.client.keycloak.cli;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.name.Named;
|
||||
import java.io.IOException;
|
||||
import org.eclipse.che.selenium.core.executor.OpenShiftCliCommandExecutor;
|
||||
|
||||
/**
|
||||
* This class is aimed to call Keycloak CLI commands inside OpenShift pod.
|
||||
*
|
||||
* @author Dmytro Nochevnov
|
||||
*/
|
||||
@Singleton
|
||||
public class OpenShiftKeycloakCliCommandExecutor implements KeycloakCliCommandExecutor {
|
||||
private static final String DEFAULT_OPENSHIFT_CHE_NAMESPACE = "eclipse-che";
|
||||
|
||||
private String keycloakPodName;
|
||||
|
||||
@Inject private OpenShiftCliCommandExecutor openShiftCliCommandExecutor;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named("env.openshift.che.namespace")
|
||||
private String openShiftCheNamespace;
|
||||
|
||||
@Override
|
||||
public String execute(String command) throws IOException {
|
||||
if (keycloakPodName == null || keycloakPodName.trim().isEmpty()) {
|
||||
obtainKeycloakPodName();
|
||||
}
|
||||
|
||||
String openShiftKeycloakCliCommand =
|
||||
format("exec %s -- /opt/jboss/keycloak/bin/kcadm.sh %s", keycloakPodName, command);
|
||||
|
||||
return openShiftCliCommandExecutor.execute(openShiftKeycloakCliCommand);
|
||||
}
|
||||
|
||||
private void obtainKeycloakPodName() throws IOException {
|
||||
openShiftCliCommandExecutor.login();
|
||||
|
||||
// obtain name of keycloak pod
|
||||
String getKeycloakPodNameCommand =
|
||||
format(
|
||||
"get pod --namespace=%s -l app=keycloak --no-headers | awk '{print $1}'",
|
||||
openShiftCheNamespace != null
|
||||
? openShiftCheNamespace
|
||||
: DEFAULT_OPENSHIFT_CHE_NAMESPACE);
|
||||
|
||||
keycloakPodName = openShiftCliCommandExecutor.execute(getKeycloakPodNameCommand);
|
||||
|
||||
if (keycloakPodName.trim().isEmpty()) {
|
||||
String errorMessage =
|
||||
format(
|
||||
"Keycloak pod is not found at namespace %s at OpenShift instance.",
|
||||
openShiftCheNamespace != null
|
||||
? openShiftCheNamespace
|
||||
: DEFAULT_OPENSHIFT_CHE_NAMESPACE);
|
||||
|
||||
throw new RuntimeException(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2018 Red Hat, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.selenium.core.executor;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import org.eclipse.che.selenium.core.utils.executor.CommandExecutor;
|
||||
import org.eclipse.che.selenium.core.utils.process.ProcessAgent;
|
||||
|
||||
/**
|
||||
* This class is aimed to call Docker CLI command.
|
||||
*
|
||||
* @author Dmytro Nochevnov
|
||||
*/
|
||||
@Singleton
|
||||
public class DockerCliCommandExecutor implements CommandExecutor {
|
||||
|
||||
private final ProcessAgent processAgent;
|
||||
|
||||
@Inject
|
||||
public DockerCliCommandExecutor(ProcessAgent processAgent) {
|
||||
this.processAgent = processAgent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(String command) throws IOException {
|
||||
String dockerCommand = format("docker %s", command);
|
||||
return processAgent.process(dockerCommand);
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Red Hat, Inc. - initial API and implementation
|
||||
*/
|
||||
package org.eclipse.che.selenium.core.client.keycloak.executor;
|
||||
package org.eclipse.che.selenium.core.executor;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static java.lang.System.getProperty;
|
||||
|
|
@ -24,32 +24,29 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.eclipse.che.selenium.core.provider.OpenShiftWebConsoleUrlProvider;
|
||||
import org.eclipse.che.selenium.core.utils.executor.CommandExecutor;
|
||||
import org.eclipse.che.selenium.core.utils.process.ProcessAgent;
|
||||
import org.eclipse.che.selenium.core.utils.process.ProcessAgentException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* This class is aimed to call Keycloak admin CLI inside Open Shift pod.
|
||||
* This class is aimed to call OpenShift CLI command.
|
||||
*
|
||||
* @author Dmytro Nochevnov
|
||||
*/
|
||||
@Singleton
|
||||
public class OpenShiftKeycloakCommandExecutor implements KeycloakCommandExecutor {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(OpenShiftKeycloakCommandExecutor.class);
|
||||
public class OpenShiftCliCommandExecutor implements CommandExecutor {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(OpenShiftCliCommandExecutor.class);
|
||||
|
||||
private static final boolean IS_MAC_OS = getProperty("os.name").toLowerCase().startsWith("mac");
|
||||
private static final String DEFAULT_OPENSHIFT_USERNAME = "developer";
|
||||
private static final String DEFAULT_OPENSHIFT_PASSWORD = "any";
|
||||
private static final String DEFAULT_OPENSHIFT_CHE_NAMESPACE = "eclipse-che";
|
||||
|
||||
private static final Path PATH_TO_OPENSHIFT_CLI_DIRECTORY =
|
||||
Paths.get(getProperty("java.io.tmpdir"));
|
||||
|
||||
private static final Path PATH_TO_OPENSHIFT_CLI = PATH_TO_OPENSHIFT_CLI_DIRECTORY.resolve("oc");
|
||||
|
||||
private String keycloakPodName;
|
||||
|
||||
@Inject private ProcessAgent processAgent;
|
||||
|
||||
@Inject(optional = true)
|
||||
|
|
@ -64,55 +61,40 @@ public class OpenShiftKeycloakCommandExecutor implements KeycloakCommandExecutor
|
|||
@Named("env.openshift.token")
|
||||
private String openShiftToken;
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named("env.openshift.che.namespace")
|
||||
private String openShiftCheNamespace;
|
||||
|
||||
@Inject private OpenShiftWebConsoleUrlProvider openShiftWebConsoleUrlProvider;
|
||||
|
||||
@Override
|
||||
public String execute(String command) throws IOException {
|
||||
if (keycloakPodName == null || keycloakPodName.trim().isEmpty()) {
|
||||
obtainKeycloakPodName();
|
||||
if (!PATH_TO_OPENSHIFT_CLI.toFile().exists()) {
|
||||
downloadOpenShiftCli();
|
||||
}
|
||||
|
||||
String openShiftCliCommand =
|
||||
format(
|
||||
"%s exec %s -- /opt/jboss/keycloak/bin/kcadm.sh %s",
|
||||
PATH_TO_OPENSHIFT_CLI, keycloakPodName, command);
|
||||
String openShiftCliCommand = format("%s %s", PATH_TO_OPENSHIFT_CLI, command);
|
||||
|
||||
return processAgent.process(openShiftCliCommand);
|
||||
}
|
||||
|
||||
private void obtainKeycloakPodName() throws IOException {
|
||||
if (Files.notExists(PATH_TO_OPENSHIFT_CLI)) {
|
||||
downloadOpenShiftCLI();
|
||||
}
|
||||
|
||||
loginToOpenShift();
|
||||
|
||||
// obtain name of keycloak pod
|
||||
keycloakPodName =
|
||||
processAgent.process(
|
||||
format(
|
||||
"%s get pod --namespace=%s -l app=keycloak --no-headers | awk '{print $1}'",
|
||||
PATH_TO_OPENSHIFT_CLI,
|
||||
openShiftCheNamespace != null
|
||||
? openShiftCheNamespace
|
||||
: DEFAULT_OPENSHIFT_CHE_NAMESPACE));
|
||||
|
||||
if (keycloakPodName.trim().isEmpty()) {
|
||||
throw new RuntimeException(
|
||||
/** Logs into OpensShift as a regular user */
|
||||
public void login() throws IOException {
|
||||
String loginToOpenShiftCliCommand;
|
||||
if (openShiftToken != null) {
|
||||
loginToOpenShiftCliCommand =
|
||||
format(
|
||||
"Keycloak pod is not found at namespace %s at Open Shift instance %s.",
|
||||
openShiftCheNamespace != null
|
||||
? openShiftCheNamespace
|
||||
: DEFAULT_OPENSHIFT_CHE_NAMESPACE,
|
||||
openShiftWebConsoleUrlProvider.get()));
|
||||
"login --server=%s --token=%s --insecure-skip-tls-verify",
|
||||
openShiftWebConsoleUrlProvider.get(), openShiftToken);
|
||||
} else {
|
||||
loginToOpenShiftCliCommand =
|
||||
format(
|
||||
"login --server=%s -u=%s -p=%s --insecure-skip-tls-verify",
|
||||
openShiftWebConsoleUrlProvider.get(),
|
||||
openShiftUsername != null ? openShiftUsername : DEFAULT_OPENSHIFT_USERNAME,
|
||||
openShiftPassword != null ? openShiftPassword : DEFAULT_OPENSHIFT_PASSWORD);
|
||||
}
|
||||
|
||||
execute(loginToOpenShiftCliCommand);
|
||||
}
|
||||
|
||||
private void downloadOpenShiftCLI() throws IOException {
|
||||
private void downloadOpenShiftCli() throws IOException {
|
||||
if (Files.notExists(PATH_TO_OPENSHIFT_CLI_DIRECTORY)) {
|
||||
Files.createDirectory(PATH_TO_OPENSHIFT_CLI_DIRECTORY);
|
||||
}
|
||||
|
|
@ -138,32 +120,12 @@ public class OpenShiftKeycloakCommandExecutor implements KeycloakCommandExecutor
|
|||
format("tar --strip 1 -xzf %s -C %s", packagePath, PATH_TO_OPENSHIFT_CLI_DIRECTORY);
|
||||
}
|
||||
|
||||
LOG.info("Downloading Open Shift CLI from {} ...", url);
|
||||
LOG.info("Downloading OpenShift CLI from {} ...", url);
|
||||
FileUtils.copyURLToFile(url, packagePath);
|
||||
LOG.info("Open Shift CLI has been downloaded.");
|
||||
LOG.info("OpenShift CLI has been downloaded.");
|
||||
|
||||
processAgent.process(commandToUnpackOpenShiftCli);
|
||||
|
||||
FileUtils.deleteQuietly(packagePath);
|
||||
}
|
||||
|
||||
private void loginToOpenShift() throws ProcessAgentException {
|
||||
String loginToOpenShiftCliCommand;
|
||||
if (openShiftToken != null) {
|
||||
loginToOpenShiftCliCommand =
|
||||
format(
|
||||
"%s login --server=%s --token=%s --insecure-skip-tls-verify",
|
||||
PATH_TO_OPENSHIFT_CLI, openShiftWebConsoleUrlProvider.get(), openShiftToken);
|
||||
} else {
|
||||
loginToOpenShiftCliCommand =
|
||||
format(
|
||||
"%s login --server=%s -u=%s -p=%s --insecure-skip-tls-verify",
|
||||
PATH_TO_OPENSHIFT_CLI,
|
||||
openShiftWebConsoleUrlProvider.get(),
|
||||
openShiftUsername != null ? openShiftUsername : DEFAULT_OPENSHIFT_USERNAME,
|
||||
openShiftPassword != null ? openShiftPassword : DEFAULT_OPENSHIFT_PASSWORD);
|
||||
}
|
||||
|
||||
processAgent.process(loginToOpenShiftCliCommand);
|
||||
}
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ public class OpenShiftWebConsoleUrlProvider implements Provider<URL> {
|
|||
if (!matcher.matches()) {
|
||||
throw new RuntimeException(
|
||||
format(
|
||||
"It's impossible to extract Open Shift host from Eclipse Che host '%s'. Make sure that correct value is set for `CHE_INFRASTRUCTURE`.",
|
||||
"It's impossible to extract OpenShift host from Eclipse Che host '%s'. Make sure that correct value is set for `CHE_INFRASTRUCTURE`.",
|
||||
cheHost));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.name.Named;
|
||||
import java.io.IOException;
|
||||
import javax.inject.Singleton;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.KeycloakAdminConsoleClient;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.cli.KeycloakCliClient;
|
||||
import org.eclipse.che.selenium.core.provider.AdminTestUserProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -34,7 +34,7 @@ public class MultiUserCheAdminTestUserProvider implements AdminTestUserProvider
|
|||
private AdminTestUser adminTestUser;
|
||||
|
||||
@Inject private TestUserFactory<AdminTestUser> adminTestUserFactory;
|
||||
@Inject private KeycloakAdminConsoleClient keycloakAdminConsoleClient;
|
||||
@Inject private KeycloakCliClient keycloakCliClient;
|
||||
|
||||
@Inject
|
||||
@Named("che.admin.name")
|
||||
|
|
@ -63,7 +63,7 @@ public class MultiUserCheAdminTestUserProvider implements AdminTestUserProvider
|
|||
}
|
||||
|
||||
adminTestUser = adminTestUserFactory.create(name, email, password, offlineToken, this);
|
||||
keycloakAdminConsoleClient.setupAdmin(adminTestUser);
|
||||
keycloakCliClient.setupAdmin(adminTestUser);
|
||||
|
||||
LOG.info("User name='{}', id='{}' is being used as admin", name, adminTestUser.getId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.name.Named;
|
||||
import java.io.IOException;
|
||||
import javax.inject.Singleton;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.KeycloakAdminConsoleClient;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.cli.KeycloakCliClient;
|
||||
import org.eclipse.che.selenium.core.provider.DefaultTestUserProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -33,23 +33,23 @@ public class MultiUserCheDefaultTestUserProvider implements DefaultTestUserProvi
|
|||
|
||||
private final DefaultTestUser defaultTestUser;
|
||||
private final boolean isNewUser;
|
||||
private final KeycloakAdminConsoleClient keycloakAdminConsoleClient;
|
||||
private final KeycloakCliClient keycloakCliClient;
|
||||
|
||||
@Inject
|
||||
public MultiUserCheDefaultTestUserProvider(
|
||||
TestUserFactory<DefaultTestUser> defaultTestUserFactory,
|
||||
KeycloakAdminConsoleClient keycloakAdminConsoleClient,
|
||||
KeycloakCliClient keycloakCliClient,
|
||||
MultiUserCheAdminTestUserProvider adminTestUserProvider,
|
||||
@Named("che.testuser.name") String name,
|
||||
@Named("che.testuser.email") String email,
|
||||
@Named("che.testuser.password") String password,
|
||||
@Named("che.testuser.offline_token") String offlineToken) {
|
||||
this.keycloakAdminConsoleClient = keycloakAdminConsoleClient;
|
||||
this.keycloakCliClient = keycloakCliClient;
|
||||
if (email == null || email.trim().isEmpty() || password == null || password.trim().isEmpty()) {
|
||||
DefaultTestUser testUser;
|
||||
Boolean isNewUser;
|
||||
try {
|
||||
testUser = keycloakAdminConsoleClient.createDefaultUser(this);
|
||||
testUser = keycloakCliClient.createDefaultUser(this);
|
||||
isNewUser = true;
|
||||
} catch (IOException e) {
|
||||
LOG.warn(
|
||||
|
|
@ -91,7 +91,7 @@ public class MultiUserCheDefaultTestUserProvider implements DefaultTestUserProvi
|
|||
@Override
|
||||
public void delete() throws IOException {
|
||||
if (isNewUser) {
|
||||
keycloakAdminConsoleClient.delete(defaultTestUser);
|
||||
keycloakCliClient.delete(defaultTestUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ package org.eclipse.che.selenium.core.user;
|
|||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import javax.annotation.PreDestroy;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.KeycloakAdminConsoleClient;
|
||||
import org.eclipse.che.selenium.core.client.keycloak.cli.KeycloakCliClient;
|
||||
import org.eclipse.che.selenium.core.provider.AdminTestUserProvider;
|
||||
import org.eclipse.che.selenium.core.provider.TestUserProvider;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -30,18 +30,18 @@ public class MultiUserCheTestUserProvider implements TestUserProvider {
|
|||
|
||||
private final TestUser testUser;
|
||||
private final boolean isNewUser;
|
||||
private final KeycloakAdminConsoleClient keycloakAdminConsoleClient;
|
||||
private final KeycloakCliClient keycloakCliClient;
|
||||
|
||||
@Inject
|
||||
public MultiUserCheTestUserProvider(
|
||||
TestUserFactory<TestUserImpl> testUserFactory,
|
||||
KeycloakAdminConsoleClient keycloakAdminConsoleClient,
|
||||
KeycloakCliClient keycloakCliClient,
|
||||
AdminTestUserProvider adminTestUserProvider) {
|
||||
this.keycloakAdminConsoleClient = keycloakAdminConsoleClient;
|
||||
this.keycloakCliClient = keycloakCliClient;
|
||||
TestUserImpl testUser;
|
||||
Boolean isNewUser;
|
||||
try {
|
||||
testUser = keycloakAdminConsoleClient.createUser(this);
|
||||
testUser = keycloakCliClient.createUser(this);
|
||||
isNewUser = true;
|
||||
} catch (IOException e) {
|
||||
LOG.warn(
|
||||
|
|
@ -79,7 +79,7 @@ public class MultiUserCheTestUserProvider implements TestUserProvider {
|
|||
@PreDestroy
|
||||
public void delete() throws IOException {
|
||||
if (isNewUser) {
|
||||
keycloakAdminConsoleClient.delete(testUser);
|
||||
keycloakCliClient.delete(testUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue