Skip to content

Commit

Permalink
refactor(test): getServerUrl to handle different base URL formats
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Szuc <[email protected]>
  • Loading branch information
martinszuc committed Oct 30, 2024
1 parent 43a07b9 commit 5cabc58
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,20 @@ export class KubernetesCommandLineToolsExecutor implements IKubernetesCommandLin

getServerUrl(): string {
Logger.debug(`${this.kubernetesCommandLineTool} - get server api url.`);
const baseUrl = new URL(BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL);
let apiHostname: string;

return BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
if (baseUrl.hostname.includes('devspaces.apps')) {
apiHostname = baseUrl.hostname.replace('devspaces.apps', 'api');
} else if (baseUrl.hostname.includes('console-openshift-console.apps')) {
apiHostname = baseUrl.hostname.replace('console-openshift-console.apps', 'api');
} else {
throw new Error(`Unexpected base URL hostname format: ${baseUrl.hostname}`);
}

const apiUrl = `https://${apiHostname}:6443`;
Logger.debug(`Generated API server URL: ${apiUrl}`);
return apiUrl;
}
}

Expand Down

0 comments on commit 5cabc58

Please sign in to comment.