@eclipse-che/che-e2e 7.74.0-dev-1d09cb7 → 7.74.0-dev-aace77a
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/.eslintignore +10 -0
- package/.eslintrc.js +197 -0
- package/.prettierignore +10 -0
- package/.prettierrc.json +10 -0
- package/CODE_STYLE.md +144 -0
- package/README.md +47 -47
- package/configs/inversify.config.ts +39 -14
- package/configs/inversify.types.ts +44 -30
- package/configs/mocharc.ts +21 -24
- package/constants/API_TEST_CONSTANTS.ts +67 -0
- package/constants/BASE_TEST_CONSTANTS.ts +80 -0
- package/constants/CHROME_DRIVER_CONSTANTS.ts +42 -0
- package/constants/FACTORY_TEST_CONSTANTS.ts +61 -0
- package/constants/MONACO_CONSTANTS.ts +25 -0
- package/constants/OAUTH_CONSTANTS.ts +67 -0
- package/constants/PLUGIN_TEST_CONSTANTS.ts +15 -0
- package/constants/REPORTER_CONSTANTS.ts +53 -0
- package/constants/TIMEOUT_CONSTANTS.ts +131 -0
- package/dist/configs/inversify.config.js +36 -9
- package/dist/configs/inversify.config.js.map +1 -1
- package/dist/configs/inversify.types.js +19 -5
- package/dist/configs/inversify.types.js.map +1 -1
- package/dist/configs/mocharc.js +13 -16
- package/dist/configs/mocharc.js.map +1 -1
- package/dist/constants/{APITestConstants.js → API_TEST_CONSTANTS.js} +12 -12
- package/dist/constants/API_TEST_CONSTANTS.js.map +1 -0
- package/dist/constants/{BaseTestConstants.js → BASE_TEST_CONSTANTS.js} +16 -16
- package/dist/constants/BASE_TEST_CONSTANTS.js.map +1 -0
- package/dist/constants/CHROME_DRIVER_CONSTANTS.js +36 -0
- package/dist/constants/CHROME_DRIVER_CONSTANTS.js.map +1 -0
- package/dist/constants/{FactoryTestConstants.js → FACTORY_TEST_CONSTANTS.js} +14 -13
- package/dist/constants/FACTORY_TEST_CONSTANTS.js.map +1 -0
- package/dist/constants/{MonacoConstants.js → MONACO_CONSTANTS.js} +7 -7
- package/dist/constants/MONACO_CONSTANTS.js.map +1 -0
- package/dist/constants/{OAuthConstants.js → OAUTH_CONSTANTS.js} +14 -14
- package/dist/constants/OAUTH_CONSTANTS.js.map +1 -0
- package/dist/constants/{PluginsTestConstants.js → PLUGIN_TEST_CONSTANTS.js} +7 -7
- package/dist/constants/PLUGIN_TEST_CONSTANTS.js.map +1 -0
- package/dist/constants/{ReporterConstants.js → REPORTER_CONSTANTS.js} +12 -12
- package/dist/constants/REPORTER_CONSTANTS.js.map +1 -0
- package/dist/constants/{TimeoutConstants.js → TIMEOUT_CONSTANTS.js} +24 -24
- package/dist/constants/TIMEOUT_CONSTANTS.js.map +1 -0
- package/dist/driver/ChromeDriver.js +12 -22
- package/dist/driver/ChromeDriver.js.map +1 -1
- package/dist/index.js +18 -12
- package/dist/index.js.map +1 -1
- package/dist/pageobjects/dashboard/CreateWorkspace.js +15 -15
- package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
- package/dist/pageobjects/dashboard/Dashboard.js +20 -21
- package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
- package/dist/pageobjects/dashboard/Workspaces.js +55 -60
- package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +58 -48
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
- package/dist/pageobjects/git-providers/OauthPage.js +22 -20
- package/dist/pageobjects/git-providers/OauthPage.js.map +1 -1
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js +26 -12
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -1
- package/dist/pageobjects/login/interfaces/ICheLoginPage.js +2 -2
- package/dist/pageobjects/login/interfaces/IOcpLoginPage.js +2 -2
- package/dist/pageobjects/login/kubernetes/DexLoginPage.js +14 -14
- package/dist/pageobjects/login/kubernetes/DexLoginPage.js.map +1 -1
- package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js +7 -7
- package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpLoginPage.js +24 -28
- package/dist/pageobjects/login/openshift/OcpLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js +13 -16
- package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpUserLoginPage.js +9 -9
- package/dist/pageobjects/login/openshift/OcpUserLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/RedHatLoginPage.js +19 -23
- package/dist/pageobjects/login/openshift/RedHatLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js +20 -19
- package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpApplicationPage.js +11 -11
- package/dist/pageobjects/openshift/OcpApplicationPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpImportFromGitPage.js +24 -24
- package/dist/pageobjects/openshift/OcpImportFromGitPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpMainPage.js +30 -30
- package/dist/pageobjects/openshift/OcpMainPage.js.map +1 -1
- package/dist/specs/MochaHooks.js +33 -27
- package/dist/specs/MochaHooks.js.map +1 -1
- package/dist/specs/SmokeTest.spec.js +17 -17
- package/dist/specs/SmokeTest.spec.js.map +1 -1
- package/dist/specs/api/ContainerOverridesAPI.spec.js +8 -6
- package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -1
- package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +27 -24
- package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -1
- package/dist/specs/api/EmptyWorkspaceAPI.spec.js +17 -17
- package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -1
- package/dist/specs/api/PodOverridesAPI.spec.js +10 -8
- package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +10 -10
- package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/Quarkus.spec.js +13 -13
- package/dist/specs/dashboard-samples/Quarkus.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js +52 -52
- package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js.map +1 -1
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +23 -19
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
- package/dist/specs/factory/Factory.spec.js +38 -41
- package/dist/specs/factory/Factory.spec.js.map +1 -1
- package/dist/specs/factory/NoSetupRepoFactory.spec.js +52 -50
- package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
- package/dist/specs/factory/RefusedOAuthFactory.spec.js +49 -51
- package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +45 -42
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -1
- package/dist/tests-library/LoginTests.js +13 -13
- package/dist/tests-library/LoginTests.js.map +1 -1
- package/dist/tests-library/ProjectAndFileTests.js +9 -7
- package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
- package/dist/tests-library/WorkspaceHandlingTests.js +22 -19
- package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
- package/dist/utils/BrowserTabsUtil.js +21 -21
- package/dist/utils/BrowserTabsUtil.js.map +1 -1
- package/dist/utils/CheReporter.js +91 -65
- package/dist/utils/CheReporter.js.map +1 -1
- package/dist/utils/DevWorkspaceConfigurationHelper.js +34 -15
- package/dist/utils/DevWorkspaceConfigurationHelper.js.map +1 -1
- package/dist/utils/DevfilesRegistryHelper.js +34 -18
- package/dist/utils/DevfilesRegistryHelper.js.map +1 -1
- package/dist/utils/DriverHelper.js +73 -68
- package/dist/utils/DriverHelper.js.map +1 -1
- package/dist/utils/IContextParams.js +12 -0
- package/dist/utils/IContextParams.js.map +1 -0
- package/dist/utils/IKubernetesCommandLineToolsExecutor.js +3 -0
- package/dist/utils/IKubernetesCommandLineToolsExecutor.js.map +1 -0
- package/dist/utils/KubernetesCommandLineToolsExecutor.js +146 -107
- package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
- package/dist/utils/Logger.js +18 -19
- package/dist/utils/Logger.js.map +1 -1
- package/dist/utils/ScreenCatcher.js +26 -16
- package/dist/utils/ScreenCatcher.js.map +1 -1
- package/dist/utils/ShellExecutor.js +29 -9
- package/dist/utils/ShellExecutor.js.map +1 -1
- package/dist/utils/StringUtil.js +19 -9
- package/dist/utils/StringUtil.js.map +1 -1
- package/dist/utils/request-handlers/CheApiRequestHandler.js +29 -29
- package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
- package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js +12 -8
- package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
- package/dist/utils/request-handlers/headers/IAuthorizationHeaderHandler.js +2 -2
- package/dist/utils/workspace/ApiUrlResolver.js +5 -5
- package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
- package/dist/utils/workspace/ITestWorkspaceUtil.js +2 -2
- package/dist/utils/workspace/TestWorkspaceUtil.js +25 -23
- package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
- package/dist/utils/workspace/WorkspaceStatus.js +2 -2
- package/dist/utils/workspace/WorkspaceStatus.js.map +1 -1
- package/driver/ChromeDriver.ts +45 -58
- package/driver/IDriver.ts +3 -3
- package/index.ts +11 -9
- package/package.json +59 -49
- package/pageobjects/dashboard/CreateWorkspace.ts +65 -55
- package/pageobjects/dashboard/Dashboard.ts +100 -100
- package/pageobjects/dashboard/Workspaces.ts +210 -186
- package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +153 -131
- package/pageobjects/git-providers/OauthPage.ts +177 -166
- package/pageobjects/ide/CheCodeLocatorLoader.ts +51 -46
- package/pageobjects/login/interfaces/ICheLoginPage.ts +3 -3
- package/pageobjects/login/interfaces/IOcpLoginPage.ts +3 -3
- package/pageobjects/login/kubernetes/DexLoginPage.ts +31 -30
- package/pageobjects/login/kubernetes/KubernetesLoginPage.ts +15 -14
- package/pageobjects/login/openshift/OcpLoginPage.ts +51 -56
- package/pageobjects/login/openshift/OcpRedHatLoginPage.ts +27 -27
- package/pageobjects/login/openshift/OcpUserLoginPage.ts +15 -18
- package/pageobjects/login/openshift/RedHatLoginPage.ts +49 -46
- package/pageobjects/login/openshift/RegularUserOcpCheLoginPage.ts +43 -34
- package/pageobjects/openshift/OcpApplicationPage.ts +21 -19
- package/pageobjects/openshift/OcpImportFromGitPage.ts +68 -68
- package/pageobjects/openshift/OcpMainPage.ts +69 -69
- package/specs/MochaHooks.ts +59 -52
- package/specs/SmokeTest.spec.ts +47 -45
- package/specs/api/ContainerOverridesAPI.spec.ts +39 -26
- package/specs/api/DevfileAcceptanceTestAPI.spec.ts +110 -97
- package/specs/api/EmptyWorkspaceAPI.spec.ts +67 -58
- package/specs/api/PodOverridesAPI.spec.ts +48 -34
- package/specs/dashboard-samples/EmptyWorkspace.spec.ts +36 -36
- package/specs/dashboard-samples/Quarkus.spec.ts +41 -40
- package/specs/dashboard-samples/RecommendedExtensions.spec.ts +202 -183
- package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +85 -75
- package/specs/factory/Factory.spec.ts +184 -178
- package/specs/factory/NoSetupRepoFactory.spec.ts +233 -219
- package/specs/factory/RefusedOAuthFactory.spec.ts +223 -211
- package/specs/miscellaneous/PredefinedNamespace.spec.ts +70 -64
- package/tests-library/LoginTests.ts +34 -32
- package/tests-library/ProjectAndFileTests.ts +21 -18
- package/tests-library/WorkspaceHandlingTests.ts +98 -89
- package/tsconfig.json +15 -15
- package/utils/BrowserTabsUtil.ts +78 -74
- package/utils/CheReporter.ts +159 -157
- package/utils/DevWorkspaceConfigurationHelper.ts +63 -69
- package/utils/DevfilesRegistryHelper.ts +71 -57
- package/utils/DriverHelper.ts +728 -700
- package/utils/IContextParams.ts +26 -0
- package/utils/IKubernetesCommandLineToolsExecutor.ts +42 -0
- package/utils/KubernetesCommandLineToolsExecutor.ts +231 -183
- package/utils/Logger.ts +102 -125
- package/utils/ScreenCatcher.ts +57 -46
- package/utils/ShellExecutor.ts +23 -12
- package/utils/StringUtil.ts +49 -36
- package/utils/request-handlers/CheApiRequestHandler.ts +91 -88
- package/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +32 -21
- package/utils/request-handlers/headers/IAuthorizationHeaderHandler.ts +3 -3
- package/utils/workspace/ApiUrlResolver.ts +31 -26
- package/utils/workspace/ITestWorkspaceUtil.ts +31 -31
- package/utils/workspace/TestWorkspaceUtil.ts +152 -145
- package/utils/workspace/WorkspaceStatus.ts +5 -5
- package/constants/APITestConstants.ts +0 -57
- package/constants/BaseTestConstants.ts +0 -68
- package/constants/ChromeDriverConstants.ts +0 -46
- package/constants/FactoryTestConstants.ts +0 -51
- package/constants/MonacoConstants.ts +0 -22
- package/constants/OAuthConstants.ts +0 -57
- package/constants/PluginsTestConstants.ts +0 -15
- package/constants/ReporterConstants.ts +0 -45
- package/constants/TimeoutConstants.ts +0 -113
- package/dist/constants/APITestConstants.js.map +0 -1
- package/dist/constants/BaseTestConstants.js.map +0 -1
- package/dist/constants/ChromeDriverConstants.js +0 -44
- package/dist/constants/ChromeDriverConstants.js.map +0 -1
- package/dist/constants/FactoryTestConstants.js.map +0 -1
- package/dist/constants/MonacoConstants.js.map +0 -1
- package/dist/constants/OAuthConstants.js.map +0 -1
- package/dist/constants/PluginsTestConstants.js.map +0 -1
- package/dist/constants/ReporterConstants.js.map +0 -1
- package/dist/constants/TimeoutConstants.js.map +0 -1
- package/tslint.json +0 -126
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
1
|
+
/** *******************************************************************
|
|
2
|
+
* copyright (c) 2019-2023 Red Hat, Inc.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made
|
|
5
5
|
* available under the terms of the Eclipse Public License 2.0
|
|
@@ -13,100 +13,103 @@ import { TYPES } from '../../configs/inversify.types';
|
|
|
13
13
|
import { inject, injectable } from 'inversify';
|
|
14
14
|
import { IAuthorizationHeaderHandler } from './headers/IAuthorizationHeaderHandler';
|
|
15
15
|
import { Logger } from '../Logger';
|
|
16
|
-
import {
|
|
16
|
+
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
|
|
17
17
|
|
|
18
18
|
@injectable()
|
|
19
19
|
export class CheApiRequestHandler {
|
|
20
|
+
constructor(
|
|
21
|
+
@inject(TYPES.IAuthorizationHeaderHandler)
|
|
22
|
+
private readonly headerHandler: IAuthorizationHeaderHandler
|
|
23
|
+
) {}
|
|
20
24
|
|
|
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
|
-
|
|
25
|
+
/**
|
|
26
|
+
* this method adds a request interceptor into axios request interceptors list and returns an ID of the interceptor
|
|
27
|
+
*/
|
|
28
|
+
static enableRequestInterceptor(): number {
|
|
29
|
+
Logger.debug();
|
|
30
|
+
return axios.interceptors.request.use((request: AxiosRequestConfig): AxiosRequestConfig => {
|
|
31
|
+
try {
|
|
32
|
+
const REQUEST_CENSORED: AxiosRequestConfig = JSON.parse(JSON.stringify(request));
|
|
33
|
+
if (REQUEST_CENSORED === undefined) {
|
|
34
|
+
Logger.error('JSON.parse returned an undefined object, cannot process request');
|
|
35
|
+
return request;
|
|
36
|
+
}
|
|
37
|
+
if (REQUEST_CENSORED.headers === undefined) {
|
|
38
|
+
Logger.warn('request does not contain any headers object');
|
|
39
|
+
return request;
|
|
40
|
+
}
|
|
41
|
+
REQUEST_CENSORED.headers.Authorization = 'CENSORED';
|
|
42
|
+
REQUEST_CENSORED.headers.Cookie = 'CENSORED';
|
|
43
|
+
Logger.info('request:\n' + JSON.stringify(REQUEST_CENSORED));
|
|
44
|
+
} catch (err) {
|
|
45
|
+
Logger.error('request: Failed to deep clone AxiosRequestConfig:' + err);
|
|
46
|
+
}
|
|
47
|
+
return request;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
46
50
|
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
51
|
+
/**
|
|
52
|
+
* this method adds a response interceptor into axios response interceptors list and returns an ID of the interceptor
|
|
53
|
+
*/
|
|
54
|
+
static enableResponseInterceptor(): number {
|
|
55
|
+
Logger.debug();
|
|
56
|
+
return axios.interceptors.response.use((response: AxiosResponse): AxiosResponse => {
|
|
57
|
+
try {
|
|
58
|
+
const RESPONSE_CENSORED: AxiosResponse = JSON.parse(
|
|
59
|
+
JSON.stringify(response, (key, value: string): string => {
|
|
60
|
+
switch (key) {
|
|
61
|
+
case 'request':
|
|
62
|
+
return 'CENSORED';
|
|
63
|
+
default:
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
if (RESPONSE_CENSORED === undefined) {
|
|
69
|
+
Logger.error('JSON.parse returned an undefined object, cannot process response');
|
|
70
|
+
return response;
|
|
71
|
+
}
|
|
72
|
+
if (RESPONSE_CENSORED.config === undefined) {
|
|
73
|
+
Logger.warn('response does not contain any config object');
|
|
74
|
+
return response;
|
|
75
|
+
}
|
|
76
|
+
if (RESPONSE_CENSORED.config.headers === undefined) {
|
|
77
|
+
Logger.warn('response does not contain any config.headers object');
|
|
78
|
+
return response;
|
|
79
|
+
}
|
|
80
|
+
RESPONSE_CENSORED.config.headers.Authorization = 'CENSORED';
|
|
81
|
+
RESPONSE_CENSORED.config.headers.Cookie = 'CENSORED';
|
|
82
|
+
if (RESPONSE_CENSORED.data.access_token !== null) {
|
|
83
|
+
RESPONSE_CENSORED.data.access_token = 'CENSORED';
|
|
84
|
+
}
|
|
85
|
+
if (RESPONSE_CENSORED.data.refresh_token !== null) {
|
|
86
|
+
RESPONSE_CENSORED.data.refresh_token = 'CENSORED';
|
|
87
|
+
}
|
|
88
|
+
Logger.info('response:\n' + JSON.stringify(RESPONSE_CENSORED));
|
|
89
|
+
} catch (err) {
|
|
90
|
+
Logger.error('response: Failed to deep clone AxiosResponse:' + err);
|
|
91
|
+
}
|
|
92
|
+
return response;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
89
95
|
|
|
90
|
-
|
|
96
|
+
async get(relativeUrl: string): Promise<AxiosResponse> {
|
|
97
|
+
return await axios.get(this.assembleUrl(relativeUrl), await this.headerHandler.get());
|
|
98
|
+
}
|
|
91
99
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
async post(relativeUrl: string, data?: string): Promise<AxiosResponse> {
|
|
101
|
+
return await axios.post(this.assembleUrl(relativeUrl), data, await this.headerHandler.get());
|
|
102
|
+
}
|
|
95
103
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
104
|
+
async delete(relativeUrl: string): Promise<AxiosResponse> {
|
|
105
|
+
return await axios.delete(this.assembleUrl(relativeUrl), await this.headerHandler.get());
|
|
106
|
+
}
|
|
99
107
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
async patch(relativeUrl: string, patchParams: object): Promise<AxiosResponse> {
|
|
105
|
-
return await axios.patch(this.assembleUrl(relativeUrl), patchParams, await this.headerHandler.get());
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
private assembleUrl(relativeUrl: string): string {
|
|
109
|
-
return `${BaseTestConstants.TS_SELENIUM_BASE_URL}/${relativeUrl}`;
|
|
110
|
-
}
|
|
108
|
+
async patch(relativeUrl: string, patchParams: object): Promise<AxiosResponse> {
|
|
109
|
+
return await axios.patch(this.assembleUrl(relativeUrl), patchParams, await this.headerHandler.get());
|
|
110
|
+
}
|
|
111
111
|
|
|
112
|
+
private assembleUrl(relativeUrl: string): string {
|
|
113
|
+
return `${BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL}/${relativeUrl}`;
|
|
114
|
+
}
|
|
112
115
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
1
|
+
/** *******************************************************************
|
|
2
|
+
* copyright (c) 2019-2023 Red Hat, Inc.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made
|
|
5
5
|
* available under the terms of the Eclipse Public License 2.0
|
|
@@ -14,29 +14,40 @@ import { DriverHelper } from '../../DriverHelper';
|
|
|
14
14
|
import { CLASSES } from '../../../configs/inversify.types';
|
|
15
15
|
import { Logger } from '../../Logger';
|
|
16
16
|
import { IWebDriverCookie } from 'selenium-webdriver';
|
|
17
|
-
import {
|
|
17
|
+
import { BASE_TEST_CONSTANTS, Platform } from '../../../constants/BASE_TEST_CONSTANTS';
|
|
18
18
|
|
|
19
19
|
@injectable()
|
|
20
20
|
export class CheMultiuserAuthorizationHeaderHandler implements IAuthorizationHeaderHandler {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
private authorizationToken: string = '';
|
|
22
|
+
private readonly cookiesType: string = BASE_TEST_CONSTANTS.TS_PLATFORM === Platform.OPENSHIFT ? '_oauth_proxy' : '_oauth2_proxy';
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
constructor(
|
|
25
|
+
@inject(CLASSES.DriverHelper)
|
|
26
|
+
private readonly driverHelper: DriverHelper
|
|
27
|
+
) {}
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
async get(): Promise<AxiosRequestConfig> {
|
|
30
|
+
try {
|
|
31
|
+
const token: IWebDriverCookie = await this.driverHelper.getDriver().manage().getCookie(this.cookiesType);
|
|
32
|
+
if (this.authorizationToken !== token.value) {
|
|
33
|
+
this.authorizationToken = token.value;
|
|
34
|
+
}
|
|
35
|
+
} catch (err) {
|
|
36
|
+
if (this.authorizationToken.length > 0) {
|
|
37
|
+
Logger.warn(
|
|
38
|
+
'could not obtain _oauth_proxy cookie from chromedriver, browser session may have been killed. Using stored value.'
|
|
39
|
+
);
|
|
40
|
+
} else {
|
|
41
|
+
throw new Error(
|
|
42
|
+
'Could not obtain _oauth_proxy cookie from chromedriver, browser session may have been killed. No stored token present!'
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
return {
|
|
48
|
+
headers: {
|
|
49
|
+
cookie: `${this.cookiesType}=${this.authorizationToken}`
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
42
53
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
1
|
+
/** *******************************************************************
|
|
2
|
+
* copyright (c) 2019-2023 Red Hat, Inc.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made
|
|
5
5
|
* available under the terms of the Eclipse Public License 2.0
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
import { AxiosRequestConfig } from 'axios';
|
|
12
12
|
|
|
13
13
|
export interface IAuthorizationHeaderHandler {
|
|
14
|
-
|
|
14
|
+
get(): Promise<AxiosRequestConfig>;
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
1
|
+
/** *******************************************************************
|
|
2
|
+
* copyright (c) 2019-2023 Red Hat, Inc.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made
|
|
5
5
|
* available under the terms of the Eclipse Public License 2.0
|
|
@@ -15,33 +15,38 @@ 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(
|
|
24
|
+
@inject(CLASSES.CheApiRequestHandler)
|
|
25
|
+
private readonly processRequestHandler: CheApiRequestHandler
|
|
26
|
+
) {}
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
async getWorkspaceApiUrl(workspaceName: string): Promise<string> {
|
|
29
|
+
return `${await this.getWorkspacesApiUrl()}/${workspaceName}`;
|
|
30
|
+
}
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
async getWorkspacesApiUrl(): Promise<string> {
|
|
33
|
+
const namespace: string = await this.obtainUserNamespace();
|
|
34
|
+
return `${ApiUrlResolver.DASHBOARD_API_URL}/${namespace}/devworkspaces`;
|
|
35
|
+
}
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
private async obtainUserNamespace(): Promise<string> {
|
|
38
|
+
Logger.debug(`${this.userNamespace}`);
|
|
39
|
+
if (this.userNamespace.length === 0) {
|
|
40
|
+
Logger.trace('USER_NAMESPACE.length = 0, calling kubernetes API');
|
|
41
|
+
const kubernetesResponse: AxiosResponse = await this.processRequestHandler.get(ApiUrlResolver.KUBERNETES_API_URL);
|
|
42
|
+
if (kubernetesResponse.status !== 200) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
`Cannot get user namespace from kubernetes API. Code: ${kubernetesResponse.status} Data: ${kubernetesResponse.data}`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
this.userNamespace = kubernetesResponse.data[0].name;
|
|
48
|
+
Logger.debug(`kubeapi success: ${this.userNamespace}`);
|
|
49
|
+
}
|
|
50
|
+
return this.userNamespace;
|
|
51
|
+
}
|
|
47
52
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
1
|
+
/** *******************************************************************
|
|
2
|
+
* copyright (c) 2019-2023 Red Hat, Inc.
|
|
3
3
|
*
|
|
4
4
|
* This program and the accompanying materials are made
|
|
5
5
|
* available under the terms of the Eclipse Public License 2.0
|
|
@@ -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
|
}
|