@eclipse-che/che-e2e 7.73.0-dev-11985ec → 7.73.0-dev-62c0c9d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configs/inversify.config.ts +6 -6
- package/configs/inversify.types.ts +27 -27
- package/configs/mocharc.ts +21 -21
- package/constants/APITestConstants.ts +39 -38
- package/constants/BaseTestConstants.ts +44 -43
- package/constants/ChromeDriverConstants.ts +29 -29
- package/constants/FactoryTestConstants.ts +30 -30
- package/constants/MonacoConstants.ts +10 -10
- package/constants/OAuthConstants.ts +46 -46
- package/constants/PluginsTestConstants.ts +1 -1
- package/constants/ReporterConstants.ts +28 -28
- package/constants/TimeoutConstants.ts +101 -101
- package/dist/configs/inversify.config.js.map +1 -1
- package/dist/configs/inversify.types.js.map +1 -1
- package/dist/configs/mocharc.js +1 -1
- package/dist/configs/mocharc.js.map +1 -1
- package/dist/constants/APITestConstants.js +2 -2
- package/dist/constants/APITestConstants.js.map +1 -1
- package/dist/constants/BaseTestConstants.js +1 -1
- package/dist/constants/BaseTestConstants.js.map +1 -1
- package/dist/constants/ChromeDriverConstants.js +1 -1
- package/dist/constants/ChromeDriverConstants.js.map +1 -1
- package/dist/constants/FactoryTestConstants.js +2 -2
- package/dist/constants/FactoryTestConstants.js.map +1 -1
- package/dist/constants/MonacoConstants.js +1 -1
- package/dist/constants/MonacoConstants.js.map +1 -1
- package/dist/constants/OAuthConstants.js +1 -1
- package/dist/constants/OAuthConstants.js.map +1 -1
- package/dist/constants/PluginsTestConstants.js +1 -1
- package/dist/constants/ReporterConstants.js +1 -1
- package/dist/constants/ReporterConstants.js.map +1 -1
- package/dist/constants/TimeoutConstants.js.map +1 -1
- package/dist/driver/ChromeDriver.js.map +1 -1
- package/dist/pageobjects/dashboard/CreateWorkspace.js +8 -8
- package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
- package/dist/pageobjects/dashboard/Dashboard.js +11 -11
- package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
- package/dist/pageobjects/dashboard/Workspaces.js +14 -14
- package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +8 -8
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
- package/dist/pageobjects/git-providers/OauthPage.js +21 -21
- package/dist/pageobjects/git-providers/OauthPage.js.map +1 -1
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js +1 -1
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -1
- package/dist/pageobjects/login/kubernetes/DexLoginPage.js +5 -5
- package/dist/pageobjects/login/kubernetes/DexLoginPage.js.map +1 -1
- package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js +1 -1
- package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpLoginPage.js +10 -10
- package/dist/pageobjects/login/openshift/OcpLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js +2 -2
- package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpUserLoginPage.js +1 -1
- package/dist/pageobjects/login/openshift/OcpUserLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/RedHatLoginPage.js +6 -6
- package/dist/pageobjects/login/openshift/RedHatLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js +2 -2
- package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpApplicationPage.js +2 -2
- package/dist/pageobjects/openshift/OcpApplicationPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpImportFromGitPage.js +5 -5
- package/dist/pageobjects/openshift/OcpImportFromGitPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpMainPage.js +11 -11
- package/dist/pageobjects/openshift/OcpMainPage.js.map +1 -1
- package/dist/specs/MochaHooks.js +1 -1
- package/dist/specs/MochaHooks.js.map +1 -1
- package/dist/specs/SmokeTest.spec.js +7 -3
- package/dist/specs/SmokeTest.spec.js.map +1 -1
- package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -1
- package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +7 -5
- package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -1
- package/dist/specs/api/EmptyWorkspaceAPI.spec.js +1 -1
- package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -1
- package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +9 -5
- package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/Quarkus.spec.js +7 -3
- package/dist/specs/dashboard-samples/Quarkus.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/{RecomendedExtentions.spec.js → RecommendedExtensions.spec.js} +7 -3
- package/dist/specs/dashboard-samples/{RecomendedExtentions.spec.js.map → RecommendedExtensions.spec.js.map} +1 -1
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +3 -1
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
- package/dist/specs/factory/Factory.spec.js +3 -1
- package/dist/specs/factory/Factory.spec.js.map +1 -1
- package/dist/specs/factory/NoSetupRepoFactory.spec.js +4 -2
- package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
- package/dist/specs/factory/RefusedOAuthFactory.spec.js +4 -2
- package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +6 -2
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -1
- package/dist/tests-library/LoginTests.js.map +1 -1
- package/dist/tests-library/ProjectAndFileTests.js +3 -3
- package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
- package/dist/tests-library/WorkspaceHandlingTests.js +54 -74
- package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
- package/dist/utils/BrowserTabsUtil.js +10 -10
- package/dist/utils/BrowserTabsUtil.js.map +1 -1
- package/dist/utils/CheReporter.js.map +1 -1
- package/dist/utils/DevWorkspaceConfigurationHelper.js +2 -2
- package/dist/utils/DevWorkspaceConfigurationHelper.js.map +1 -1
- package/dist/utils/DevfilesRegistryHelper.js +7 -7
- package/dist/utils/DevfilesRegistryHelper.js.map +1 -1
- package/dist/utils/DriverHelper.js +81 -81
- package/dist/utils/DriverHelper.js.map +1 -1
- package/dist/utils/KubernetesCommandLineToolsExecutor.js +38 -35
- package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
- package/dist/utils/Logger.js +19 -10
- package/dist/utils/Logger.js.map +1 -1
- package/dist/utils/ScreenCatcher.js.map +1 -1
- package/dist/utils/ShellExecutor.js.map +1 -1
- package/dist/utils/StringUtil.js +2 -2
- package/dist/utils/StringUtil.js.map +1 -1
- package/dist/utils/request-handlers/CheApiRequestHandler.js +13 -11
- package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
- package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js +1 -1
- package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
- package/dist/utils/workspace/ApiUrlResolver.js +3 -3
- package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
- package/dist/utils/workspace/TestWorkspaceUtil.js +20 -16
- package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
- package/dist/utils/workspace/WorkspaceStatus.js.map +1 -1
- package/driver/ChromeDriver.ts +44 -44
- package/driver/IDriver.ts +1 -1
- package/package.json +1 -1
- package/pageobjects/dashboard/CreateWorkspace.ts +52 -52
- package/pageobjects/dashboard/Dashboard.ts +72 -72
- package/pageobjects/dashboard/Workspaces.ts +138 -139
- package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +92 -93
- package/pageobjects/git-providers/OauthPage.ts +136 -136
- package/pageobjects/ide/CheCodeLocatorLoader.ts +40 -40
- package/pageobjects/login/interfaces/ICheLoginPage.ts +1 -1
- package/pageobjects/login/interfaces/IOcpLoginPage.ts +1 -1
- package/pageobjects/login/kubernetes/DexLoginPage.ts +27 -27
- package/pageobjects/login/kubernetes/KubernetesLoginPage.ts +11 -11
- package/pageobjects/login/openshift/OcpLoginPage.ts +50 -50
- package/pageobjects/login/openshift/OcpRedHatLoginPage.ts +21 -21
- package/pageobjects/login/openshift/OcpUserLoginPage.ts +14 -14
- package/pageobjects/login/openshift/RedHatLoginPage.ts +44 -41
- package/pageobjects/login/openshift/RegularUserOcpCheLoginPage.ts +23 -23
- package/pageobjects/openshift/OcpApplicationPage.ts +16 -16
- package/pageobjects/openshift/OcpImportFromGitPage.ts +54 -54
- package/pageobjects/openshift/OcpMainPage.ts +64 -64
- package/specs/MochaHooks.ts +44 -44
- package/specs/SmokeTest.spec.ts +35 -31
- package/specs/api/ContainerOverridesAPI.spec.ts +23 -23
- package/specs/api/DevfileAcceptanceTestAPI.spec.ts +93 -91
- package/specs/api/EmptyWorkspaceAPI.spec.ts +50 -50
- package/specs/api/PodOverridesAPI.spec.ts +29 -29
- package/specs/dashboard-samples/EmptyWorkspace.spec.ts +29 -25
- package/specs/dashboard-samples/Quarkus.spec.ts +31 -27
- package/specs/dashboard-samples/RecommendedExtensions.spec.ts +205 -0
- package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +62 -64
- package/specs/factory/Factory.spec.ts +149 -147
- package/specs/factory/NoSetupRepoFactory.spec.ts +188 -186
- package/specs/factory/RefusedOAuthFactory.spec.ts +182 -180
- package/specs/miscellaneous/PredefinedNamespace.spec.ts +52 -48
- package/tests-library/LoginTests.ts +29 -29
- package/tests-library/ProjectAndFileTests.ts +13 -13
- package/tests-library/WorkspaceHandlingTests.ts +84 -103
- package/utils/BrowserTabsUtil.ts +69 -69
- package/utils/CheReporter.ts +4 -6
- package/utils/DevWorkspaceConfigurationHelper.ts +58 -58
- package/utils/DevfilesRegistryHelper.ts +51 -51
- package/utils/DriverHelper.ts +599 -600
- package/utils/KubernetesCommandLineToolsExecutor.ts +166 -158
- package/utils/Logger.ts +98 -67
- package/utils/ScreenCatcher.ts +42 -42
- package/utils/ShellExecutor.ts +10 -10
- package/utils/StringUtil.ts +29 -30
- package/utils/request-handlers/CheApiRequestHandler.ts +84 -82
- package/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +18 -18
- package/utils/request-handlers/headers/IAuthorizationHeaderHandler.ts +1 -1
- package/utils/workspace/ApiUrlResolver.ts +23 -23
- package/utils/workspace/ITestWorkspaceUtil.ts +29 -29
- package/utils/workspace/TestWorkspaceUtil.ts +120 -116
- package/utils/workspace/WorkspaceStatus.ts +3 -3
- package/specs/dashboard-samples/RecomendedExtentions.spec.ts +0 -201
package/utils/ShellExecutor.ts
CHANGED
|
@@ -2,16 +2,16 @@ import { echo, exec, ShellString } from 'shelljs';
|
|
|
2
2
|
|
|
3
3
|
export class ShellExecutor {
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
static wait(seconds: number): void {
|
|
6
|
+
this.execWithLog(`sleep ${seconds}s`);
|
|
7
|
+
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
static curl(link: string): ShellString {
|
|
10
|
+
return this.execWithLog(`curl -k ${link}`);
|
|
11
|
+
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
protected static execWithLog(command: string): ShellString {
|
|
14
|
+
echo(command);
|
|
15
|
+
return exec(command);
|
|
16
|
+
}
|
|
17
17
|
}
|
package/utils/StringUtil.ts
CHANGED
|
@@ -10,41 +10,40 @@
|
|
|
10
10
|
|
|
11
11
|
import { injectable } from 'inversify';
|
|
12
12
|
import { Logger } from './Logger';
|
|
13
|
-
import { KubernetesCommandLineToolsExecutor } from './KubernetesCommandLineToolsExecutor';
|
|
14
13
|
|
|
15
14
|
@injectable()
|
|
16
15
|
export class StringUtil {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
if (url.includes('/tree/')) {
|
|
30
|
-
url = url.split('/').slice(0, -2).join('/');
|
|
31
|
-
}
|
|
32
|
-
const projectName: string = url.split(/[\/.]/).filter((e: string) => !['git', ''].includes(e)).reverse()[0];
|
|
33
|
-
Logger.debug(`${this.constructor.name}.${this.getProjectNameFromGitUrl.name} - ${projectName}`);
|
|
34
|
-
return projectName;
|
|
16
|
+
/**
|
|
17
|
+
* Method extracts a test repo name from git clone https url;
|
|
18
|
+
* it splits the url into string[] by "/" or ".", deletes empty elements and elements that contains just "git", "main" or "tree" word, than returns the last one;
|
|
19
|
+
* please, avoid to call the test repo as just "git" or to use dots in the name, like: github.com/user/git.git, github.com/user/name.with.dots.
|
|
20
|
+
* @param url git https url (which using for "git clone")
|
|
21
|
+
* @return project name
|
|
22
|
+
*/
|
|
23
|
+
static getProjectNameFromGitUrl(url: string): string {
|
|
24
|
+
Logger.debug(`${url}`);
|
|
25
|
+
if (url.includes('?')) {
|
|
26
|
+
url = url.substring(0, url.indexOf('?'));
|
|
35
27
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return arg.replace(/\//g, '+').replace(/,/g, '.').replace(/:/g, '-').replace(/['"]/g, '').replace(/[^a-z0-9+\-.()\[\]_]/gi, '_');
|
|
28
|
+
if (url.includes('/tree/')) {
|
|
29
|
+
url = url.split('/').slice(0, -2).join('/');
|
|
39
30
|
}
|
|
31
|
+
const projectName: string = url.split(/[\/.]/).filter((e: string) => !['git', ''].includes(e)).reverse()[0];
|
|
32
|
+
Logger.debug(`${projectName}`);
|
|
33
|
+
return projectName;
|
|
34
|
+
}
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* @return updated command with environmental variables in supported format
|
|
45
|
-
*/
|
|
36
|
+
static sanitizeTitle(arg: string): string {
|
|
37
|
+
return arg.replace(/\//g, '+').replace(/,/g, '.').replace(/:/g, '-').replace(/['"]/g, '').replace(/[^a-z0-9+\-.()\[\]_]/gi, '_');
|
|
38
|
+
}
|
|
46
39
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Replaces ${ENV}, $ENV to "$ENV"
|
|
42
|
+
* @param command string command with environmental variables in unsupported format
|
|
43
|
+
* @return updated command with environmental variables in supported format
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
static updateCommandEnvsToShStyle(command: string): string {
|
|
47
|
+
return command.replace(/[{}]/g, '').replace(/(?<!")\${?[a-zA-Z0-9_+\-\s]+\b}?/gm, `"\$&"`);
|
|
48
|
+
}
|
|
50
49
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
**********************************************************************/
|
|
10
10
|
|
|
11
|
-
import axios, {
|
|
11
|
+
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
12
12
|
import { TYPES } from '../../configs/inversify.types';
|
|
13
13
|
import { inject, injectable } from 'inversify';
|
|
14
14
|
import { IAuthorizationHeaderHandler } from './headers/IAuthorizationHeaderHandler';
|
|
@@ -18,93 +18,95 @@ import { BaseTestConstants } from '../../constants/BaseTestConstants';
|
|
|
18
18
|
@injectable()
|
|
19
19
|
export class CheApiRequestHandler {
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
21
|
+
/**
|
|
22
|
+
* This method adds a request interceptor into axios request interceptors list and returns an ID of the interceptor
|
|
23
|
+
*/
|
|
24
|
+
static enableRequestInterceptor(): number {
|
|
25
|
+
Logger.debug();
|
|
26
|
+
return axios.interceptors.request.use(request => {
|
|
27
|
+
try {
|
|
28
|
+
let request_censored: AxiosRequestConfig = JSON.parse(JSON.stringify(request));
|
|
29
|
+
if (request_censored === undefined) {
|
|
30
|
+
Logger.error('JSON.parse returned an undefined object, cannot process request');
|
|
31
|
+
return request;
|
|
32
|
+
}
|
|
33
|
+
if (request_censored.headers === undefined) {
|
|
34
|
+
Logger.warn('request does not contain any headers object');
|
|
35
|
+
return request;
|
|
36
|
+
}
|
|
37
|
+
request_censored.headers.Authorization = 'CENSORED';
|
|
38
|
+
request_censored.headers.Cookie = 'CENSORED';
|
|
39
|
+
Logger.info(`request:\n` + request_censored);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
Logger.error(`request: Failed to deep clone AxiosRequestConfig:` + err);
|
|
42
|
+
}
|
|
43
|
+
return request;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
47
|
+
/**
|
|
48
|
+
* This method adds a response interceptor into axios response interceptors list and returns an ID of the interceptor
|
|
49
|
+
*/
|
|
50
|
+
static enableResponseInterceptor(): number {
|
|
51
|
+
Logger.debug();
|
|
52
|
+
return axios.interceptors.response.use(response => {
|
|
53
|
+
try {
|
|
54
|
+
let response_censored: AxiosResponse = JSON.parse(JSON.stringify(response, (key, value) => {
|
|
55
|
+
switch (key) {
|
|
56
|
+
case 'request':
|
|
57
|
+
return 'CENSORED';
|
|
58
|
+
default:
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
if (response_censored === undefined) {
|
|
63
|
+
Logger.error('JSON.parse returned an undefined object, cannot process response');
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
if (response_censored.config === undefined) {
|
|
67
|
+
Logger.warn('response does not contain any config object');
|
|
68
|
+
return response;
|
|
69
|
+
}
|
|
70
|
+
if (response_censored.config.headers === undefined) {
|
|
71
|
+
Logger.warn('response does not contain any config.headers object');
|
|
72
|
+
return response;
|
|
73
|
+
}
|
|
74
|
+
response_censored.config.headers.Authorization = 'CENSORED';
|
|
75
|
+
response_censored.config.headers.Cookie = 'CENSORED';
|
|
76
|
+
if (response_censored.data.access_token !== null) {
|
|
77
|
+
response_censored.data.access_token = 'CENSORED';
|
|
78
|
+
}
|
|
79
|
+
if (response_censored.data.refresh_token !== null) {
|
|
80
|
+
response_censored.data.refresh_token = 'CENSORED';
|
|
81
|
+
}
|
|
82
|
+
Logger.info(`response:\n` + response_censored);
|
|
83
|
+
} catch (err) {
|
|
84
|
+
Logger.error(`response: Failed to deep clone AxiosResponse:` + err);
|
|
85
|
+
}
|
|
86
|
+
return response;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
87
89
|
|
|
88
|
-
|
|
90
|
+
constructor(@inject(TYPES.IAuthorizationHeaderHandler) private readonly headerHandler: IAuthorizationHeaderHandler) { }
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
async get(relativeUrl: string): Promise<AxiosResponse> {
|
|
93
|
+
return await axios.get(this.assembleUrl(relativeUrl), await this.headerHandler.get());
|
|
94
|
+
}
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
async post(relativeUrl: string, data?: string | any): Promise<AxiosResponse> {
|
|
97
|
+
return await axios.post(this.assembleUrl(relativeUrl), data, await this.headerHandler.get());
|
|
98
|
+
}
|
|
97
99
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
async delete(relativeUrl: string): Promise<AxiosResponse> {
|
|
101
|
+
return await axios.delete(this.assembleUrl(relativeUrl), await this.headerHandler.get());
|
|
102
|
+
}
|
|
101
103
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
async patch(relativeUrl: string, patchParams: object): Promise<AxiosResponse> {
|
|
105
|
+
return await axios.patch(this.assembleUrl(relativeUrl), patchParams, await this.headerHandler.get());
|
|
106
|
+
}
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
private assembleUrl(relativeUrl: string): string {
|
|
109
|
+
return `${BaseTestConstants.TS_SELENIUM_BASE_URL}/${relativeUrl}`;
|
|
110
|
+
}
|
|
109
111
|
|
|
110
112
|
}
|
|
@@ -18,25 +18,25 @@ import { BaseTestConstants, Platform } from '../../../constants/BaseTestConstant
|
|
|
18
18
|
|
|
19
19
|
@injectable()
|
|
20
20
|
export class CheMultiuserAuthorizationHeaderHandler implements IAuthorizationHeaderHandler {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
private authorizationToken: string = '';
|
|
22
|
+
private readonly cookiesType: string = BaseTestConstants.TS_PLATFORM === Platform.OPENSHIFT ? '_oauth_proxy' : '_oauth2_proxy';
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return { headers: { 'cookie': `${this.cookiesType}=${this.authorizationToken}` } };
|
|
26
|
+
async get(): Promise<AxiosRequestConfig> {
|
|
27
|
+
try {
|
|
28
|
+
let token: IWebDriverCookie = await this.driverHelper.getDriver().manage().getCookie(this.cookiesType);
|
|
29
|
+
if (this.authorizationToken !== token.value) {
|
|
30
|
+
this.authorizationToken = token.value;
|
|
31
|
+
}
|
|
32
|
+
} catch (err) {
|
|
33
|
+
if (this.authorizationToken.length > 0) {
|
|
34
|
+
Logger.warn(`could not obtain _oauth_proxy cookie from chromedriver, browser session may have been killed. Using stored value.`);
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error(`Could not obtain _oauth_proxy cookie from chromedriver, browser session may have been killed. No stored token present!`);
|
|
37
|
+
}
|
|
41
38
|
}
|
|
39
|
+
|
|
40
|
+
return { headers: { 'cookie': `${this.cookiesType}=${this.authorizationToken}` } };
|
|
41
|
+
}
|
|
42
42
|
}
|
|
@@ -15,33 +15,33 @@ import { AxiosResponse } from 'axios';
|
|
|
15
15
|
|
|
16
16
|
@injectable()
|
|
17
17
|
export class ApiUrlResolver {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
private static readonly DASHBOARD_API_URL: string = 'dashboard/api/namespace';
|
|
19
|
+
private static readonly KUBERNETES_API_URL: string = 'api/kubernetes/namespace';
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
private userNamespace: string = '';
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
constructor(@inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler) {}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
async getWorkspaceApiUrl(workspaceName: string): Promise<string> {
|
|
26
|
+
return `${await this.getWorkspacesApiUrl()}/${workspaceName}`;
|
|
27
|
+
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
async getWorkspacesApiUrl(): Promise<string> {
|
|
30
|
+
const namespace: string = await this.obtainUserNamespace();
|
|
31
|
+
return `${ApiUrlResolver.DASHBOARD_API_URL}/${namespace}/devworkspaces`;
|
|
32
|
+
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
return this.userNamespace;
|
|
34
|
+
private async obtainUserNamespace(): Promise<string> {
|
|
35
|
+
Logger.debug(`${this.userNamespace}`);
|
|
36
|
+
if (this.userNamespace.length === 0) {
|
|
37
|
+
Logger.trace(`USER_NAMESPACE.length = 0, calling kubernetes API`);
|
|
38
|
+
const kubernetesResponse: AxiosResponse = await this.processRequestHandler.get(ApiUrlResolver.KUBERNETES_API_URL);
|
|
39
|
+
if (kubernetesResponse.status !== 200) {
|
|
40
|
+
throw new Error(`Cannot get user namespace from kubernetes API. Code: ${kubernetesResponse.status} Data: ${kubernetesResponse.data}`);
|
|
41
|
+
}
|
|
42
|
+
this.userNamespace = kubernetesResponse.data[0].name;
|
|
43
|
+
Logger.debug(`kubeapi success: ${this.userNamespace}`);
|
|
46
44
|
}
|
|
45
|
+
return this.userNamespace;
|
|
46
|
+
}
|
|
47
47
|
}
|
|
@@ -11,33 +11,33 @@
|
|
|
11
11
|
import { WorkspaceStatus } from './WorkspaceStatus';
|
|
12
12
|
|
|
13
13
|
export interface ITestWorkspaceUtil {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
14
|
+
waitWorkspaceStatus(namespace: string, workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus): void;
|
|
15
|
+
|
|
16
|
+
stopWorkspaceByName(workspaceName: string): void;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Delete a workspace without stopping phase (similar with force deleting)
|
|
20
|
+
*/
|
|
21
|
+
deleteWorkspaceByName(workspaceName: string): void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Stop workspace before deleting with checking stopping phase
|
|
25
|
+
*/
|
|
26
|
+
stopAndDeleteWorkspaceByName(workspaceName: string): void;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Stop all run workspaces in the namespace
|
|
30
|
+
*/
|
|
31
|
+
stopAllRunningWorkspaces(namespace: string): void;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Stop all run workspaces, check statused and remove the workspaces
|
|
35
|
+
*/
|
|
36
|
+
stopAndDeleteAllRunningWorkspaces(namespace: string): void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Stop all run workspaces without stopping and waiting for of 'Stopped' phase
|
|
40
|
+
* Similar with 'force' deleting
|
|
41
|
+
*/
|
|
42
|
+
deleteAllWorkspaces(namespace: string): void;
|
|
43
43
|
}
|