Skip to content

Commit

Permalink
updated loginToOcp() method
Browse files Browse the repository at this point in the history
Signed-off-by: mdolhalo <[email protected]>
  • Loading branch information
mdolhalo committed Apr 26, 2023
1 parent a9314eb commit 4867754
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
// login to Openshift cluster with username and password
loginToOcp(): void {
if (this.KUBERNETES_COMMAND_LINE_TOOL === KubernetesCommandLineTool.OC) {
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: Login to the "OC" client`);
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: Login to the "OC" client.`);
const url: string = this.getServerUrl();
Logger.debug(url, TestConstants.TS_SELENIUM_OCP_USERNAME);
exec(`sleep 5
oc login --server=${url} -u=${TestConstants.TS_SELENIUM_OCP_USERNAME} -p=${TestConstants.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`);
const isUserLoggedIn: ShellString = this.execWithLog('oc whoami && oc whoami --show-server=true');
if (isUserLoggedIn.stdout.includes(TestConstants.TS_SELENIUM_OCP_USERNAME) && isUserLoggedIn.stdout.includes(url)) {
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: User already logged`);
} else {
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: Login ${url}, ${TestConstants.TS_SELENIUM_OCP_USERNAME}`);
exec(`oc login --server=${url} -u=${TestConstants.TS_SELENIUM_OCP_USERNAME} -p=${TestConstants.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`);
}
} else {
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: doesn't support login command`);
}
Expand Down

0 comments on commit 4867754

Please sign in to comment.