diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/executor/KeycloakCommandExecutor.java b/selenium/che-selenium-core/src/main/java/org/eclipse/che/selenium/core/utils/executor/CommandExecutor.java similarity index 63% rename from selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/executor/KeycloakCommandExecutor.java rename to selenium/che-selenium-core/src/main/java/org/eclipse/che/selenium/core/utils/executor/CommandExecutor.java index f10447dbb7..70d0cae899 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/executor/KeycloakCommandExecutor.java +++ b/selenium/che-selenium-core/src/main/java/org/eclipse/che/selenium/core/utils/executor/CommandExecutor.java @@ -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; } diff --git a/selenium/che-selenium-test/README.md b/selenium/che-selenium-test/README.md index 596c020a2e..91908b8b87 100644 --- a/selenium/che-selenium-test/README.md +++ b/selenium/che-selenium-test/README.md @@ -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= --port=80` Example: `./selenium-tests.sh --host=che-spi.192.168.99.100.nip.io --port=80` @@ -68,7 +68,7 @@ export OPENSHIFT_TOKEN= export OPENSHIFT_CHE_NAMESPACE= export OPENSHIFT_URL= ``` -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: diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/CheSeleniumDockerModule.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/CheSeleniumDockerModule.java index 63e6b27c0b..9eb2122d89 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/CheSeleniumDockerModule.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/CheSeleniumDockerModule.java @@ -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); } } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/CheSeleniumOpenshiftModule.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/CheSeleniumOpenshiftModule.java index 725d71f60f..31fc8d8cce 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/CheSeleniumOpenshiftModule.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/CheSeleniumOpenshiftModule.java @@ -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); } } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/executor/DockerKeycloakCommandExecutor.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/DockerKeycloakCliCommandExecutor.java similarity index 69% rename from selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/executor/DockerKeycloakCommandExecutor.java rename to selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/DockerKeycloakCliCommandExecutor.java index 761c1dd43c..6b529d8333 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/executor/DockerKeycloakCommandExecutor.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/DockerKeycloakCliCommandExecutor.java @@ -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 { diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/KeycloakAdminConsoleClient.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/KeycloakCliClient.java similarity index 95% rename from selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/KeycloakAdminConsoleClient.java rename to selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/KeycloakCliClient.java index 1f203a625c..488f4b5c34 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/KeycloakAdminConsoleClient.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/KeycloakCliClient.java @@ -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 defaultTestUserFactory; private final TestUserFactory testUserFactory; - @Inject private KeycloakCommandExecutor executor; + @Inject private KeycloakCliCommandExecutor executor; @Inject - public KeycloakAdminConsoleClient( + public KeycloakCliClient( TestUserFactory testUserFactory, TestUserFactory defaultTestUserFactory) { this.testUserFactory = testUserFactory; diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/KeycloakCliCommandExecutor.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/KeycloakCliCommandExecutor.java new file mode 100644 index 0000000000..3cc66d4851 --- /dev/null +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/KeycloakCliCommandExecutor.java @@ -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 {} diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/OpenShiftKeycloakCliCommandExecutor.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/OpenShiftKeycloakCliCommandExecutor.java new file mode 100644 index 0000000000..bb39a06414 --- /dev/null +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/OpenShiftKeycloakCliCommandExecutor.java @@ -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); + } + } +} diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/executor/DockerCliCommandExecutor.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/executor/DockerCliCommandExecutor.java new file mode 100644 index 0000000000..40765f4d07 --- /dev/null +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/executor/DockerCliCommandExecutor.java @@ -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); + } +} diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/executor/OpenShiftKeycloakCommandExecutor.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/executor/OpenShiftCliCommandExecutor.java similarity index 61% rename from selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/executor/OpenShiftKeycloakCommandExecutor.java rename to selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/executor/OpenShiftCliCommandExecutor.java index 35f5c93d7c..fd4ec1d0a6 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/executor/OpenShiftKeycloakCommandExecutor.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/executor/OpenShiftCliCommandExecutor.java @@ -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); - } } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/provider/OpenShiftWebConsoleUrlProvider.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/provider/OpenShiftWebConsoleUrlProvider.java index 79ecbe9691..2d860d80e6 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/provider/OpenShiftWebConsoleUrlProvider.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/provider/OpenShiftWebConsoleUrlProvider.java @@ -64,7 +64,7 @@ public class OpenShiftWebConsoleUrlProvider implements Provider { 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)); } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheAdminTestUserProvider.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheAdminTestUserProvider.java index 75759933f2..9e5475714d 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheAdminTestUserProvider.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheAdminTestUserProvider.java @@ -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 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()); } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheDefaultTestUserProvider.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheDefaultTestUserProvider.java index 56ee1f2c4b..b44198f6e5 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheDefaultTestUserProvider.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheDefaultTestUserProvider.java @@ -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 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); } } } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheTestUserProvider.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheTestUserProvider.java index dbe3809bed..87021c3b7b 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheTestUserProvider.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/user/MultiUserCheTestUserProvider.java @@ -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 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); } } }