@eclipse-che/che-e2e 7.46.1-dev-e59785f → 7.46.1-dev-c4fc12d
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/TestConstants.ts +6 -1
- package/dist/TestConstants.js +5 -1
- package/dist/TestConstants.js.map +1 -1
- package/dist/driver/CheReporter.js +7 -3
- package/dist/driver/CheReporter.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inversify.config.js +1 -1
- package/dist/inversify.config.js.map +1 -1
- package/dist/inversify.types.js +2 -3
- package/dist/inversify.types.js.map +1 -1
- package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +2 -4
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js +2 -4
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js.map +1 -1
- package/dist/tests/devfiles/CSlashCPlusPlus.spec.js +7 -0
- package/dist/tests/devfiles/CSlashCPlusPlus.spec.js.map +1 -1
- package/dist/tests/devfiles/DevfileSmoke.spec.js +7 -0
- package/dist/tests/devfiles/DevfileSmoke.spec.js.map +1 -1
- package/dist/tests/devfiles/DotNetCore.spec.js +7 -0
- package/dist/tests/devfiles/DotNetCore.spec.js.map +1 -1
- package/dist/tests/devfiles/Go.spec.js +7 -0
- package/dist/tests/devfiles/Go.spec.js.map +1 -1
- package/dist/tests/devfiles/JavaMaven.spec.js +7 -0
- package/dist/tests/devfiles/JavaMaven.spec.js.map +1 -1
- package/dist/tests/devfiles/JavaSpringBoot.spec.js +7 -0
- package/dist/tests/devfiles/JavaSpringBoot.spec.js.map +1 -1
- package/dist/tests/devfiles/JavaVertx.spec.js +7 -0
- package/dist/tests/devfiles/JavaVertx.spec.js.map +1 -1
- package/dist/tests/devfiles/NodeJS.spec.js +7 -0
- package/dist/tests/devfiles/NodeJS.spec.js.map +1 -1
- package/dist/tests/devfiles/PHPSimple.spec.js +7 -0
- package/dist/tests/devfiles/PHPSimple.spec.js.map +1 -1
- package/dist/tests/devfiles/Python.spec.js +7 -0
- package/dist/tests/devfiles/Python.spec.js.map +1 -1
- package/dist/tests/devfiles/PythonDjango.spec.js +7 -0
- package/dist/tests/devfiles/PythonDjango.spec.js.map +1 -1
- package/dist/tests/devfiles/Quarkus.spec.js +7 -0
- package/dist/tests/devfiles/Quarkus.spec.js.map +1 -1
- package/dist/tests/devfiles/Scala.spec.js +7 -0
- package/dist/tests/devfiles/Scala.spec.js.map +1 -1
- package/dist/tests/e2e/FactoryUrl.spec.js +1 -1
- package/dist/tests/e2e/FactoryUrl.spec.js.map +1 -1
- package/dist/tests/e2e/GitPublishBranch.spec.js +6 -1
- package/dist/tests/e2e/GitPublishBranch.spec.js.map +1 -1
- package/dist/tests/e2e/GitSelfSignCert.spec.js +6 -1
- package/dist/tests/e2e/GitSelfSignCert.spec.js.map +1 -1
- package/dist/tests/e2e/GitSsh.spec.js +7 -1
- package/dist/tests/e2e/GitSsh.spec.js.map +1 -1
- package/dist/tests/e2e/OpenshiftConnector.spec.js +6 -1
- package/dist/tests/e2e/OpenshiftConnector.spec.js.map +1 -1
- package/dist/tests/e2e_happy_path/DevWorkspaceHappyPath.spec.js +2 -0
- package/dist/tests/e2e_happy_path/DevWorkspaceHappyPath.spec.js.map +1 -1
- package/dist/tests/e2e_happy_path/HappyPath.spec.js +5 -0
- package/dist/tests/e2e_happy_path/HappyPath.spec.js.map +1 -1
- package/dist/tests/plugins/VscodeXmlPlugin.spec.js +4 -13
- package/dist/tests/plugins/VscodeXmlPlugin.spec.js.map +1 -1
- package/dist/tests/plugins/VscodeYamlPlugin.spec.js +3 -11
- package/dist/tests/plugins/VscodeYamlPlugin.spec.js.map +1 -1
- package/dist/testsLibrary/CodeExecutionTests.js.map +1 -1
- package/dist/testsLibrary/WorkspaceHandlingTests.js +13 -5
- package/dist/testsLibrary/WorkspaceHandlingTests.js.map +1 -1
- package/dist/utils/requestHandlers/CheApiRequestHandler.js.map +1 -1
- package/dist/utils/requestHandlers/headers/CheMultiuserAuthorizationHeaderHandler.js +17 -2
- package/dist/utils/requestHandlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
- package/dist/utils/workspace/ApiUrlResolver.js +41 -9
- package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
- package/dist/utils/workspace/{IApiUrlResolver.js → ITestWorkspaceUtil.js} +1 -1
- package/dist/utils/workspace/ITestWorkspaceUtil.js.map +1 -0
- package/dist/utils/workspace/TestWorkspaceUtil.js +29 -31
- package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
- package/dist/utils/workspace/WorkspaceStatus.js.map +1 -1
- package/driver/CheReporter.ts +10 -4
- package/index.ts +1 -1
- package/inversify.config.ts +4 -3
- package/inversify.types.ts +2 -3
- package/mocha-all-plugins.json +2 -1
- package/package.json +1 -1
- package/pageobjects/dashboard/Dashboard.ts +1 -1
- package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +3 -3
- package/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.ts +4 -4
- package/tests/devfiles/CSlashCPlusPlus.spec.ts +4 -0
- package/tests/devfiles/DevfileSmoke.spec.ts +4 -0
- package/tests/devfiles/DotNetCore.spec.ts +4 -0
- package/tests/devfiles/Go.spec.ts +4 -0
- package/tests/devfiles/JavaMaven.spec.ts +4 -0
- package/tests/devfiles/JavaSpringBoot.spec.ts +4 -0
- package/tests/devfiles/JavaVertx.spec.ts +4 -0
- package/tests/devfiles/NodeJS.spec.ts +4 -0
- package/tests/devfiles/PHPSimple.spec.ts +4 -0
- package/tests/devfiles/Python.spec.ts +4 -0
- package/tests/devfiles/PythonDjango.spec.ts +4 -0
- package/tests/devfiles/Quarkus.spec.ts +4 -0
- package/tests/devfiles/Scala.spec.ts +4 -0
- package/tests/e2e/FactoryUrl.spec.ts +2 -2
- package/tests/e2e/GitPublishBranch.spec.ts +4 -2
- package/tests/e2e/GitSelfSignCert.spec.ts +15 -13
- package/tests/e2e/GitSsh.spec.ts +5 -2
- package/tests/e2e/OpenshiftConnector.spec.ts +4 -2
- package/tests/e2e_happy_path/DevWorkspaceHappyPath.spec.ts +2 -0
- package/tests/e2e_happy_path/HappyPath.spec.ts +2 -0
- package/tests/load_test/LoadTest.spec.ts +0 -2
- package/tests/plugins/VscodeXmlPlugin.spec.ts +4 -18
- package/tests/plugins/VscodeYamlPlugin.spec.ts +4 -13
- package/testsLibrary/CodeExecutionTests.ts +1 -3
- package/testsLibrary/WorkspaceHandlingTests.ts +10 -4
- package/utils/requestHandlers/CheApiRequestHandler.ts +1 -1
- package/utils/requestHandlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +17 -2
- package/utils/workspace/ApiUrlResolver.ts +34 -11
- package/utils/workspace/ITestWorkspaceUtil.ts +98 -0
- package/utils/workspace/TestWorkspaceUtil.ts +34 -34
- package/utils/workspace/WorkspaceStatus.ts +1 -1
- package/dist/utils/workspace/IApiUrlResolver.js.map +0 -1
- package/utils/workspace/IApiUrlResolver.ts +0 -15
|
@@ -14,6 +14,7 @@ import { e2eContainer } from '../../inversify.config';
|
|
|
14
14
|
import { CodeExecutionTests } from '../../testsLibrary/CodeExecutionTests';
|
|
15
15
|
import { ProjectAndFileTests } from '../../testsLibrary/ProjectAndFileTests';
|
|
16
16
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
17
|
+
import CheReporter from '../../driver/CheReporter';
|
|
17
18
|
|
|
18
19
|
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
19
20
|
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
|
|
@@ -32,6 +33,9 @@ suite(`${workspaceStack} test`, async () => {
|
|
|
32
33
|
suite(`Create ${workspaceStack} workspace`, async () => {
|
|
33
34
|
workspaceHandlingTests.createAndOpenWorkspace(workspaceStack);
|
|
34
35
|
workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
|
|
36
|
+
test('Register running workspace', async () => {
|
|
37
|
+
CheReporter.registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName());
|
|
38
|
+
});
|
|
35
39
|
projectAndFileTests.waitWorkspaceReadinessNoSubfolder(workspaceSampleName, false);
|
|
36
40
|
});
|
|
37
41
|
|
|
@@ -13,6 +13,7 @@ import { CodeExecutionTests } from '../../testsLibrary/CodeExecutionTests';
|
|
|
13
13
|
import { e2eContainer } from '../../inversify.config';
|
|
14
14
|
import { ProjectAndFileTests } from '../../testsLibrary/ProjectAndFileTests';
|
|
15
15
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
16
|
+
import CheReporter from '../../driver/CheReporter';
|
|
16
17
|
|
|
17
18
|
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
18
19
|
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
|
|
@@ -34,6 +35,9 @@ suite(`${workspaceStack} test`, async () => {
|
|
|
34
35
|
suite(`Create ${workspaceStack} workspace`, async () => {
|
|
35
36
|
workspaceHandlingTests.createAndOpenWorkspace(workspaceStack);
|
|
36
37
|
workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
|
|
38
|
+
test('Register running workspace', async () => {
|
|
39
|
+
CheReporter.registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName());
|
|
40
|
+
});
|
|
37
41
|
projectAndFileTests.waitWorkspaceReadiness(workspaceSampleName, workspaceRootFolderName, false);
|
|
38
42
|
});
|
|
39
43
|
|
|
@@ -14,6 +14,7 @@ import { e2eContainer } from '../../inversify.config';
|
|
|
14
14
|
import { CodeExecutionTests } from '../../testsLibrary/CodeExecutionTests';
|
|
15
15
|
import { ProjectAndFileTests } from '../../testsLibrary/ProjectAndFileTests';
|
|
16
16
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
17
|
+
import CheReporter from '../../driver/CheReporter';
|
|
17
18
|
|
|
18
19
|
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
19
20
|
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
|
|
@@ -34,6 +35,9 @@ suite(`${workspaceStack} test`, async () => {
|
|
|
34
35
|
suite(`Create ${workspaceStack}`, async () => {
|
|
35
36
|
workspaceHandlingTests.createAndOpenWorkspace(workspaceStack);
|
|
36
37
|
workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
|
|
38
|
+
test('Register running workspace', async () => {
|
|
39
|
+
CheReporter.registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName());
|
|
40
|
+
});
|
|
37
41
|
projectAndFileTests.waitWorkspaceReadiness(workspaceSampleName, workspaceRootFolderName, false);
|
|
38
42
|
});
|
|
39
43
|
|
|
@@ -14,6 +14,7 @@ import { e2eContainer } from '../../inversify.config';
|
|
|
14
14
|
import { CodeExecutionTests } from '../../testsLibrary/CodeExecutionTests';
|
|
15
15
|
import { ProjectAndFileTests } from '../../testsLibrary/ProjectAndFileTests';
|
|
16
16
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
17
|
+
import CheReporter from '../../driver/CheReporter';
|
|
17
18
|
|
|
18
19
|
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
19
20
|
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
|
|
@@ -34,6 +35,9 @@ suite.skip(`${stack} test`, async () => {
|
|
|
34
35
|
suite (`Create ${stack} workspace`, async () => {
|
|
35
36
|
workspaceHandlingTests.createAndOpenWorkspace(stack);
|
|
36
37
|
workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
|
|
38
|
+
test('Register running workspace', async () => {
|
|
39
|
+
CheReporter.registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName());
|
|
40
|
+
});
|
|
37
41
|
projectAndFileTests.waitWorkspaceReadiness(workspaceSampleName, workspaceRootFolderName, false);
|
|
38
42
|
});
|
|
39
43
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// **********************************************************************/
|
|
10
10
|
|
|
11
11
|
import { e2eContainer } from '../../inversify.config';
|
|
12
|
-
import { CLASSES } from '../../inversify.types';
|
|
12
|
+
import { CLASSES, TYPES } from '../../inversify.types';
|
|
13
13
|
import { TestConstants } from '../../TestConstants';
|
|
14
14
|
import { ProjectAndFileTests } from '../../testsLibrary/ProjectAndFileTests';
|
|
15
15
|
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
|
|
@@ -18,7 +18,7 @@ import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTest
|
|
|
18
18
|
|
|
19
19
|
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
|
|
20
20
|
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
|
|
21
|
-
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(
|
|
21
|
+
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(TYPES.WorkspaceUtil);
|
|
22
22
|
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get<WorkspaceHandlingTests>(CLASSES.WorkspaceHandlingTests);
|
|
23
23
|
|
|
24
24
|
const factoryUrl : string = `${TestConstants.TS_SELENIUM_BASE_URL}/f?url=https://raw.githubusercontent.com/eclipse/che-devfile-registry/master/devfiles/java-maven/devfile.yaml`;
|
|
@@ -18,12 +18,13 @@ import { QuickOpenContainer } from '../../pageobjects/ide/QuickOpenContainer';
|
|
|
18
18
|
import { ICheLoginPage } from '../../pageobjects/login/ICheLoginPage';
|
|
19
19
|
import { TestConstants } from '../../TestConstants';
|
|
20
20
|
import { DriverHelper } from '../../utils/DriverHelper';
|
|
21
|
-
import { TestWorkspaceUtil } from '../../utils/workspace/TestWorkspaceUtil';
|
|
22
21
|
import { TopMenu } from '../../pageobjects/ide/TopMenu';
|
|
23
22
|
import { WorkspaceNameHandler } from '../../utils/WorkspaceNameHandler';
|
|
24
23
|
import { By } from 'selenium-webdriver';
|
|
25
24
|
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
|
|
26
25
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
26
|
+
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
|
|
27
|
+
import CheReporter from '../../driver/CheReporter';
|
|
27
28
|
|
|
28
29
|
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
|
|
29
30
|
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
|
|
@@ -34,7 +35,7 @@ const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu);
|
|
|
34
35
|
const loginPage: ICheLoginPage = e2eContainer.get<ICheLoginPage>(TYPES.CheLogin);
|
|
35
36
|
const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree);
|
|
36
37
|
const gitPlugin: GitPlugin = e2eContainer.get(CLASSES.GitPlugin);
|
|
37
|
-
const testWorkspaceUtils:
|
|
38
|
+
const testWorkspaceUtils: ITestWorkspaceUtil = e2eContainer.get<ITestWorkspaceUtil>(TYPES.WorkspaceUtil);
|
|
38
39
|
const workspaceNameHandler: WorkspaceNameHandler = e2eContainer.get(CLASSES.WorkspaceNameHandler);
|
|
39
40
|
|
|
40
41
|
const workspacePrefixUrl: string = `${TestConstants.TS_SELENIUM_BASE_URL}/dashboard/#/ide/${TestConstants.TS_SELENIUM_USERNAME}/`;
|
|
@@ -54,6 +55,7 @@ suite('Publish branch in git extension', async () => {
|
|
|
54
55
|
await browserTabsUtil.navigateTo(workspacePrefixUrl + wsNameGitPublishBranch);
|
|
55
56
|
await loginPage.login();
|
|
56
57
|
WorkspaceHandlingTests.setWorkspaceName(wsNameGitPublishBranch);
|
|
58
|
+
CheReporter.registerRunningWorkspace(wsNameGitPublishBranch);
|
|
57
59
|
await ide.waitWorkspaceAndIde();
|
|
58
60
|
await projectTree.openProjectTreeContainer();
|
|
59
61
|
await driverHelper.wait(15000);
|
|
@@ -17,26 +17,27 @@ import { QuickOpenContainer } from '../../pageobjects/ide/QuickOpenContainer';
|
|
|
17
17
|
import { ICheLoginPage } from '../../pageobjects/login/ICheLoginPage';
|
|
18
18
|
import { TestConstants } from '../../TestConstants';
|
|
19
19
|
import { DriverHelper } from '../../utils/DriverHelper';
|
|
20
|
-
import { TestWorkspaceUtil } from '../../utils/workspace/TestWorkspaceUtil';
|
|
21
20
|
import { TopMenu } from '../../pageobjects/ide/TopMenu';
|
|
22
21
|
import { TimeoutConstants } from '../../TimeoutConstants';
|
|
23
22
|
import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
|
|
24
23
|
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
|
|
25
24
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
26
25
|
import { Editor } from '../../pageobjects/ide/Editor';
|
|
26
|
+
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
|
|
27
|
+
import CheReporter from '../../driver/CheReporter';
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
30
|
+
const ide: Ide = e2eContainer.get(CLASSES.Ide);
|
|
31
|
+
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
|
|
32
|
+
const quickOpenContainer: QuickOpenContainer = e2eContainer.get(CLASSES.QuickOpenContainer);
|
|
33
|
+
const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu);
|
|
34
|
+
const loginPage: ICheLoginPage = e2eContainer.get<ICheLoginPage>(TYPES.CheLogin);
|
|
35
|
+
const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree);
|
|
36
|
+
const gitPlugin: GitPlugin = e2eContainer.get(CLASSES.GitPlugin);
|
|
37
|
+
const testWorkspaceUtils: ITestWorkspaceUtil = e2eContainer.get<ITestWorkspaceUtil>(TYPES.WorkspaceUtil);
|
|
38
|
+
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
|
|
39
|
+
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
|
|
40
|
+
const editor: Editor = e2eContainer.get(CLASSES.Editor);
|
|
40
41
|
|
|
41
42
|
const workspaceName = 'gitSelfSignCert';
|
|
42
43
|
|
|
@@ -49,6 +50,7 @@ suite('Checking git + self sign cert', async () => {
|
|
|
49
50
|
const wsConfig = await testWorkspaceUtils.getBaseDevfile();
|
|
50
51
|
wsConfig.metadata!.name = workspaceName;
|
|
51
52
|
WorkspaceHandlingTests.setWorkspaceName(workspaceName);
|
|
53
|
+
CheReporter.registerRunningWorkspace(workspaceName);
|
|
52
54
|
await browserTabsUtil.navigateTo(TestConstants.TS_SELENIUM_BASE_URL);
|
|
53
55
|
await loginPage.login();
|
|
54
56
|
await testWorkspaceUtils.createWsFromDevFile(wsConfig);
|
package/tests/e2e/GitSsh.spec.ts
CHANGED
|
@@ -22,12 +22,13 @@ import { DriverHelper } from '../../utils/DriverHelper';
|
|
|
22
22
|
import { WorkspaceNameHandler } from '../../utils/WorkspaceNameHandler';
|
|
23
23
|
import { CheGitApi } from '../../utils/VCS/CheGitApi';
|
|
24
24
|
import { GitHubUtil } from '../../utils/VCS/github/GitHubUtil';
|
|
25
|
-
import { TestWorkspaceUtil } from '../../utils/workspace/TestWorkspaceUtil';
|
|
26
25
|
import { TopMenu } from '../../pageobjects/ide/TopMenu';
|
|
27
26
|
import { TimeoutConstants } from '../../TimeoutConstants';
|
|
28
27
|
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
|
|
29
28
|
import { Dashboard } from '../..';
|
|
30
29
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
30
|
+
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
|
|
31
|
+
import CheReporter from '../../driver/CheReporter';
|
|
31
32
|
|
|
32
33
|
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
|
|
33
34
|
const ide: Ide = e2eContainer.get(CLASSES.Ide);
|
|
@@ -39,7 +40,7 @@ const gitHubUtils: GitHubUtil = e2eContainer.get<GitHubUtil>(CLASSES.GitHubUtil)
|
|
|
39
40
|
const cheGitAPI: CheGitApi = e2eContainer.get(CLASSES.CheGitApi);
|
|
40
41
|
const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree);
|
|
41
42
|
const gitPlugin: GitPlugin = e2eContainer.get(CLASSES.GitPlugin);
|
|
42
|
-
const testWorkspaceUtils:
|
|
43
|
+
const testWorkspaceUtils: ITestWorkspaceUtil = e2eContainer.get<ITestWorkspaceUtil>(TYPES.WorkspaceUtil);
|
|
43
44
|
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
|
|
44
45
|
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
|
|
45
46
|
const workspaceNameHandler: WorkspaceNameHandler = e2eContainer.get(CLASSES.WorkspaceNameHandler);
|
|
@@ -62,6 +63,7 @@ suite('Git with ssh workflow', async () => {
|
|
|
62
63
|
await dashboard.openDashboard();
|
|
63
64
|
await browserTabsUtil.navigateTo(workspacePrefixUrl + wsNameCheckGeneratingKeys);
|
|
64
65
|
WorkspaceHandlingTests.setWorkspaceName(wsNameCheckGeneratingKeys);
|
|
66
|
+
CheReporter.registerRunningWorkspace(wsNameCheckGeneratingKeys);
|
|
65
67
|
await ide.waitWorkspaceAndIde();
|
|
66
68
|
await projectTree.openProjectTreeContainer();
|
|
67
69
|
await driverHelper.wait(TimeoutConstants.TS_PROJECT_TREE_TIMEOUT);
|
|
@@ -112,6 +114,7 @@ suite('Git with ssh workflow', async () => {
|
|
|
112
114
|
await dashboard.openDashboard();
|
|
113
115
|
await browserTabsUtil.navigateTo(workspacePrefixUrl + wsNameCheckPropagatingKeys);
|
|
114
116
|
WorkspaceHandlingTests.setWorkspaceName(wsNameCheckPropagatingKeys);
|
|
117
|
+
CheReporter.registerRunningWorkspace(wsNameCheckGeneratingKeys);
|
|
115
118
|
await ide.waitWorkspaceAndIde();
|
|
116
119
|
await projectTree.openProjectTreeContainer();
|
|
117
120
|
await driverHelper.wait(TimeoutConstants.TS_PROJECT_TREE_TIMEOUT);
|
|
@@ -23,15 +23,16 @@ import { ICheLoginPage } from '../../pageobjects/login/ICheLoginPage';
|
|
|
23
23
|
import { TestConstants } from '../../TestConstants';
|
|
24
24
|
import { DriverHelper } from '../../utils/DriverHelper';
|
|
25
25
|
import { PreferencesHandler, TerminalRendererType } from '../../utils/PreferencesHandler';
|
|
26
|
-
import { TestWorkspaceUtil } from '../../utils/workspace/TestWorkspaceUtil';
|
|
27
26
|
import { TimeoutConstants } from '../../TimeoutConstants';
|
|
28
27
|
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
|
|
29
28
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
29
|
+
import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
|
|
30
|
+
import CheReporter from '../../driver/CheReporter';
|
|
30
31
|
|
|
31
32
|
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
|
|
32
33
|
const ide: Ide = e2eContainer.get(CLASSES.Ide);
|
|
33
34
|
const loginPage: ICheLoginPage = e2eContainer.get<ICheLoginPage>(TYPES.CheLogin);
|
|
34
|
-
const testWorkspaceUtils:
|
|
35
|
+
const testWorkspaceUtils: ITestWorkspaceUtil = e2eContainer.get<ITestWorkspaceUtil>(TYPES.WorkspaceUtil);
|
|
35
36
|
const openshiftPlugin: OpenshiftPlugin = e2eContainer.get(CLASSES.OpenshiftPlugin);
|
|
36
37
|
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
|
|
37
38
|
const quickOpenContainer: QuickOpenContainer = e2eContainer.get(CLASSES.QuickOpenContainer);
|
|
@@ -78,6 +79,7 @@ suite('Openshift connector user story', async () => {
|
|
|
78
79
|
await dashboard.openDashboard();
|
|
79
80
|
await browserTabsUtil.navigateTo(workspacePrefixUrl + wsName);
|
|
80
81
|
WorkspaceHandlingTests.setWorkspaceName(wsName);
|
|
82
|
+
CheReporter.registerRunningWorkspace(wsName);
|
|
81
83
|
await ide.waitWorkspaceAndIde();
|
|
82
84
|
await projectTree.openProjectTreeContainer();
|
|
83
85
|
await projectTree.waitProjectImported(projectName, 'index.js');
|
|
@@ -25,6 +25,7 @@ import { TopMenu } from '../../pageobjects/ide/TopMenu';
|
|
|
25
25
|
import * as fs from 'fs';
|
|
26
26
|
import axios from 'axios';
|
|
27
27
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
28
|
+
import CheReporter from '../../driver/CheReporter';
|
|
28
29
|
|
|
29
30
|
const ide: Ide = e2eContainer.get(CLASSES.Ide);
|
|
30
31
|
const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree);
|
|
@@ -66,6 +67,7 @@ suite('Workspace creation via factory url', async () => {
|
|
|
66
67
|
|
|
67
68
|
test('Register running workspace', async () => {
|
|
68
69
|
WorkspaceHandlingTests.setWorkspaceName(projectName);
|
|
70
|
+
CheReporter.registerRunningWorkspace(projectName);
|
|
69
71
|
});
|
|
70
72
|
|
|
71
73
|
test('Register running workspace', async () => {
|
|
@@ -29,6 +29,7 @@ import { Logger } from '../../utils/Logger';
|
|
|
29
29
|
import { RightToolBar } from '../../pageobjects/ide/RightToolBar';
|
|
30
30
|
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
|
|
31
31
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
32
|
+
import CheReporter from '../../driver/CheReporter';
|
|
32
33
|
|
|
33
34
|
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
|
|
34
35
|
const ide: Ide = e2eContainer.get(CLASSES.Ide);
|
|
@@ -76,6 +77,7 @@ suite('Validation of workspace start', async () => {
|
|
|
76
77
|
|
|
77
78
|
test('Register running workspace', async () => {
|
|
78
79
|
WorkspaceHandlingTests.setWorkspaceName(workspaceName);
|
|
80
|
+
CheReporter.registerRunningWorkspace(workspaceName);
|
|
79
81
|
});
|
|
80
82
|
|
|
81
83
|
test('Wait for workspace readiness', async () => {
|
|
@@ -14,11 +14,8 @@ import { CLASSES } from '../../inversify.types';
|
|
|
14
14
|
import { ProjectTree } from '../../pageobjects/ide/ProjectTree';
|
|
15
15
|
import { Editor } from '../../pageobjects/ide/Editor';
|
|
16
16
|
import { TestConstants } from '../../TestConstants';
|
|
17
|
-
import { Logger } from '../../utils/Logger';
|
|
18
17
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
19
|
-
|
|
20
18
|
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
|
|
21
|
-
import { PreferencesHandler } from '../../utils/PreferencesHandler';
|
|
22
19
|
import { ProjectAndFileTests } from '../../testsLibrary/ProjectAndFileTests';
|
|
23
20
|
|
|
24
21
|
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
|
|
@@ -26,15 +23,12 @@ const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree);
|
|
|
26
23
|
const editor: Editor = e2eContainer.get(CLASSES.Editor);
|
|
27
24
|
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
|
|
28
25
|
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const devfileUrl: string = 'https://github.com/che-samples/web-nodejs-sample/tree/xml-plugin';
|
|
26
|
+
const devfileUrl: string = TestConstants.TS_TEST_WORKSPACE_DEVFILE_REPO || 'https://github.com/che-samples/web-nodejs-sample/tree/xml-plugin';
|
|
32
27
|
const factoryUrl: string = `${TestConstants.TS_SELENIUM_BASE_URL}/f?url=${devfileUrl}`;
|
|
33
28
|
const projectName: string = 'web-nodejs-sample';
|
|
34
29
|
const pathToFile: string = `${projectName}`;
|
|
35
30
|
const xmlFileName: string = 'hello.xml';
|
|
36
31
|
const subRootFolder: string = 'app';
|
|
37
|
-
let workspaceName: string = 'xml-plugin';
|
|
38
32
|
|
|
39
33
|
suite('The "VscodeXmlPlugin" userstory', async () => {
|
|
40
34
|
suite('Create workspace', async () => {
|
|
@@ -45,10 +39,6 @@ suite('The "VscodeXmlPlugin" userstory', async () => {
|
|
|
45
39
|
workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
|
|
46
40
|
|
|
47
41
|
projectAndFileTests.waitWorkspaceReadiness(projectName, subRootFolder);
|
|
48
|
-
|
|
49
|
-
test('Set confirmExit preference to never', async () => {
|
|
50
|
-
await preferencesHandler.setPreferenceUsingUI('application.confirmExit', 'never');
|
|
51
|
-
});
|
|
52
42
|
});
|
|
53
43
|
|
|
54
44
|
suite('Check the "vscode-xml" plugin', async () => {
|
|
@@ -98,14 +88,10 @@ suite('The "VscodeXmlPlugin" userstory', async () => {
|
|
|
98
88
|
|
|
99
89
|
});
|
|
100
90
|
|
|
101
|
-
suite('
|
|
91
|
+
suite ('Stopping and deleting the workspace', async () => {
|
|
102
92
|
test('Stop and remove workspace', async () => {
|
|
103
|
-
|
|
104
|
-
await workspaceHandlingTests.stopAndRemoveWorkspace(workspaceName);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`);
|
|
93
|
+
await workspaceHandlingTests.stopAndRemoveWorkspace(WorkspaceHandlingTests.getWorkspaceName());
|
|
109
94
|
});
|
|
110
95
|
});
|
|
96
|
+
|
|
111
97
|
});
|
|
@@ -14,7 +14,6 @@ import { CLASSES } from '../../inversify.types';
|
|
|
14
14
|
import { ProjectTree } from '../../pageobjects/ide/ProjectTree';
|
|
15
15
|
import { Editor } from '../../pageobjects/ide/Editor';
|
|
16
16
|
import { TestConstants } from '../../TestConstants';
|
|
17
|
-
import { Logger } from '../../utils/Logger';
|
|
18
17
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
19
18
|
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
|
|
20
19
|
import { PreferencesHandler } from '../../utils/PreferencesHandler';
|
|
@@ -27,7 +26,7 @@ const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUti
|
|
|
27
26
|
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
28
27
|
const preferencesHandler: PreferencesHandler = e2eContainer.get(CLASSES.PreferencesHandler);
|
|
29
28
|
|
|
30
|
-
const devfileUrl: string = 'https://github.com/che-samples/web-nodejs-sample/tree/yaml-plugin';
|
|
29
|
+
const devfileUrl: string = TestConstants.TS_TEST_WORKSPACE_DEVFILE_REPO || 'https://github.com/che-samples/web-nodejs-sample/tree/yaml-plugin';
|
|
31
30
|
const factoryUrl: string = `${TestConstants.TS_SELENIUM_BASE_URL}/f?url=${devfileUrl}`;
|
|
32
31
|
const projectName: string = 'web-nodejs-sample';
|
|
33
32
|
const subRootFolder: string = 'app';
|
|
@@ -44,10 +43,6 @@ suite('The "VscodeYamlPlugin" userstory', async () => {
|
|
|
44
43
|
workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
|
|
45
44
|
|
|
46
45
|
projectAndFileTests.waitWorkspaceReadiness(projectName, subRootFolder);
|
|
47
|
-
|
|
48
|
-
test('Set confirmExit preference to never', async () => {
|
|
49
|
-
await preferencesHandler.setPreferenceUsingUI('application.confirmExit', 'never');
|
|
50
|
-
});
|
|
51
46
|
});
|
|
52
47
|
|
|
53
48
|
suite('Check the "vscode-yaml" plugin', async () => {
|
|
@@ -91,14 +86,10 @@ suite('The "VscodeYamlPlugin" userstory', async () => {
|
|
|
91
86
|
|
|
92
87
|
});
|
|
93
88
|
|
|
94
|
-
suite('
|
|
89
|
+
suite ('Stopping and deleting the workspace', async () => {
|
|
95
90
|
test('Stop and remove workspace', async () => {
|
|
96
|
-
|
|
97
|
-
await workspaceHandlingTests.stopAndRemoveWorkspace(WorkspaceHandlingTests.getWorkspaceName());
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
Logger.info(`As far as the "TS_DELETE_PLUGINS_TEST_WORKSPACE" value is "false the workspace deletion is skipped"`);
|
|
91
|
+
await workspaceHandlingTests.stopAndRemoveWorkspace(WorkspaceHandlingTests.getWorkspaceName());
|
|
102
92
|
});
|
|
103
93
|
});
|
|
94
|
+
|
|
104
95
|
});
|
|
@@ -36,9 +36,7 @@ export class CodeExecutionTests {
|
|
|
36
36
|
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
|
|
37
37
|
@inject(CLASSES.QuickOpenContainer) private readonly quickOpenContainer: QuickOpenContainer,
|
|
38
38
|
@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil,
|
|
39
|
-
@inject(CLASSES.WorkspaceHandlingTests) private readonly workspaceHandlingTests: WorkspaceHandlingTests
|
|
40
|
-
|
|
41
|
-
) {}
|
|
39
|
+
@inject(CLASSES.WorkspaceHandlingTests) private readonly workspaceHandlingTests: WorkspaceHandlingTests) {}
|
|
42
40
|
|
|
43
41
|
public runTask(taskName: string, timeout: number) {
|
|
44
42
|
test(`Run command '${taskName}'`, async () => {
|
|
@@ -16,9 +16,10 @@ import { CreateWorkspace } from '../pageobjects/dashboard/CreateWorkspace';
|
|
|
16
16
|
import { Workspaces } from '../pageobjects/dashboard/Workspaces';
|
|
17
17
|
import { BrowserTabsUtil } from '../utils/BrowserTabsUtil';
|
|
18
18
|
import { Logger } from '../utils/Logger';
|
|
19
|
-
import {
|
|
19
|
+
import { ApiUrlResolver } from '../utils/workspace/ApiUrlResolver';
|
|
20
20
|
import { DriverHelper } from '../utils/DriverHelper';
|
|
21
21
|
import { Ide } from '../pageobjects/ide/Ide';
|
|
22
|
+
import { TimeoutConstants } from '../TimeoutConstants';
|
|
22
23
|
import { By, error } from 'selenium-webdriver';
|
|
23
24
|
|
|
24
25
|
@injectable()
|
|
@@ -50,11 +51,14 @@ export class WorkspaceHandlingTests {
|
|
|
50
51
|
@inject(CLASSES.Workspaces) private readonly workspaces: Workspaces,
|
|
51
52
|
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
|
|
52
53
|
@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil,
|
|
53
|
-
@inject(CLASSES.Ide) private readonly ide: Ide
|
|
54
|
+
@inject(CLASSES.Ide) private readonly ide: Ide,
|
|
55
|
+
@inject(CLASSES.ApiUrlResolver) private readonly apiUrlResolver: ApiUrlResolver) {}
|
|
54
56
|
|
|
55
57
|
public createAndOpenWorkspace(stack: string) {
|
|
56
58
|
test(`Create and open new workspace, stack:${stack}`, async () => {
|
|
57
59
|
await this.dashboard.waitPage();
|
|
60
|
+
Logger.debug(`Fetching user kubernetes namespace, storing auth token by getting workspaces API URL.`);
|
|
61
|
+
await this.apiUrlResolver.getWorkspacesApiUrl();
|
|
58
62
|
await this.dashboard.clickCreateWorkspaceButton();
|
|
59
63
|
await this.createWorkspace.waitPage();
|
|
60
64
|
WorkspaceHandlingTests.parentGUID = await this.browserTabsUtil.getCurrentWindowHandle();
|
|
@@ -66,6 +70,8 @@ export class WorkspaceHandlingTests {
|
|
|
66
70
|
public openExistingWorkspace(workspaceName: string) {
|
|
67
71
|
test('Open and start existing workspace', async () => {
|
|
68
72
|
await this.dashboard.waitPage();
|
|
73
|
+
Logger.debug(`Fetching user kubernetes namespace, storing auth token by getting workspaces API URL.`);
|
|
74
|
+
await this.apiUrlResolver.getWorkspacesApiUrl();
|
|
69
75
|
await this.dashboard.clickWorkspacesButton();
|
|
70
76
|
await this.workspaces.waitPage();
|
|
71
77
|
await this.workspaces.clickOpenButton(workspaceName);
|
|
@@ -77,7 +83,7 @@ export class WorkspaceHandlingTests {
|
|
|
77
83
|
try {
|
|
78
84
|
await this.driverHelper.waitVisibility(WorkspaceHandlingTests.START_WORKSPACE_PAGE_NAME_LOCATOR, TimeoutConstants.TS_WAIT_LOADER_PRESENCE_TIMEOUT);
|
|
79
85
|
// it takes a while to update the element with the workspace name
|
|
80
|
-
await this.driverHelper.wait(
|
|
86
|
+
await this.driverHelper.wait(TimeoutConstants.TS_IDE_LOAD_TIMEOUT);
|
|
81
87
|
let startingWorkspaceLineContent = await this.driverHelper.getDriver().findElement(WorkspaceHandlingTests.START_WORKSPACE_PAGE_NAME_LOCATOR).getAttribute('innerHTML');
|
|
82
88
|
// cutting away leading text
|
|
83
89
|
WorkspaceHandlingTests.workspaceName = startingWorkspaceLineContent.substring('Starting workspace '.length).trim();
|
|
@@ -97,7 +103,7 @@ export class WorkspaceHandlingTests {
|
|
|
97
103
|
await this.browserTabsUtil.switchToWindow(tabs[i]);
|
|
98
104
|
try {
|
|
99
105
|
await this.ide.waitIde(TimeoutConstants.TS_IDE_LOAD_TIMEOUT);
|
|
100
|
-
Logger.
|
|
106
|
+
Logger.debug(`WorkspaceHandlingTests.switchBackToIdeTab located and switched to IDE tab`);
|
|
101
107
|
return;
|
|
102
108
|
} catch (err) {
|
|
103
109
|
if (err instanceof error.TimeoutError) {
|
|
@@ -100,7 +100,7 @@ export class CheApiRequestHandler {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
async patch(relativeUrl: string, patchParams: object): Promise<AxiosResponse> {
|
|
103
|
-
|
|
103
|
+
return await axios.patch(this.assembleUrl(relativeUrl), patchParams, await this.headerHandler.get());
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
private assembleUrl(relativeUrl: string): string {
|
|
@@ -12,13 +12,28 @@ import { IAuthorizationHeaderHandler } from './IAuthorizationHeaderHandler';
|
|
|
12
12
|
import { inject, injectable } from 'inversify';
|
|
13
13
|
import { DriverHelper } from '../../DriverHelper';
|
|
14
14
|
import { CLASSES } from '../../../inversify.types';
|
|
15
|
+
import { Logger } from '../../Logger';
|
|
15
16
|
|
|
16
17
|
@injectable()
|
|
17
18
|
export class CheMultiuserAuthorizationHeaderHandler implements IAuthorizationHeaderHandler {
|
|
19
|
+
private authorizationToken: string = '';
|
|
20
|
+
|
|
18
21
|
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }
|
|
19
22
|
|
|
20
23
|
async get(): Promise<AxiosRequestConfig> {
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
try {
|
|
25
|
+
let token = await this.driverHelper.getDriver().manage().getCookie('_oauth_proxy');
|
|
26
|
+
if (this.authorizationToken !== token.value) {
|
|
27
|
+
this.authorizationToken = token.value;
|
|
28
|
+
}
|
|
29
|
+
} catch (err) {
|
|
30
|
+
if (this.authorizationToken.length > 0) {
|
|
31
|
+
Logger.warn(`Could not obtain _oauth_proxy cookie from chromedriver, browser session may have been killed. Using stored value.`);
|
|
32
|
+
} else {
|
|
33
|
+
throw new Error(`Could not obtain _oauth_proxy cookie from chromedriver, browser session may have been killed. No stored token present!`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return { headers: { 'cookie': `_oauth_proxy=${this.authorizationToken}` } };
|
|
23
38
|
}
|
|
24
39
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { IApiUrlResolver } from './IApiUrlResolver';
|
|
2
|
-
|
|
3
1
|
/*********************************************************************
|
|
4
2
|
* Copyright (c) 2019 Red Hat, Inc.
|
|
5
3
|
*
|
|
@@ -9,19 +7,44 @@ import { IApiUrlResolver } from './IApiUrlResolver';
|
|
|
9
7
|
*
|
|
10
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
11
9
|
**********************************************************************/
|
|
12
|
-
import { injectable } from 'inversify';
|
|
13
|
-
|
|
10
|
+
import { inject, injectable } from 'inversify';
|
|
11
|
+
import { CLASSES } from '../../inversify.types';
|
|
12
|
+
import { Logger } from '../Logger';
|
|
13
|
+
import { CheApiRequestHandler } from '../requestHandlers/CheApiRequestHandler';
|
|
14
14
|
|
|
15
15
|
@injectable()
|
|
16
|
-
export class ApiUrlResolver
|
|
17
|
-
private
|
|
16
|
+
export class ApiUrlResolver {
|
|
17
|
+
private static readonly DASHBOARD_API_URL: string = 'dashboard/api/namespace';
|
|
18
|
+
private static readonly KUBERNETES_API_URL: string = 'api/kubernetes/namespace';
|
|
19
|
+
|
|
20
|
+
private userNamespace: string = '';
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
constructor(@inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler) {}
|
|
23
|
+
|
|
24
|
+
public async getWorkspaceApiUrl(workspaceName: string): Promise<string> {
|
|
25
|
+
return `${await this.getWorkspacesApiUrl()}/${workspaceName}`;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
public getWorkspacesApiUrl(
|
|
24
|
-
|
|
28
|
+
public async getWorkspacesApiUrl(): Promise<string> {
|
|
29
|
+
const namespace = await this.obtainUserNamespace();
|
|
30
|
+
return `${ApiUrlResolver.DASHBOARD_API_URL}/${namespace}/devworkspaces`;
|
|
25
31
|
}
|
|
26
|
-
}
|
|
27
32
|
|
|
33
|
+
public getKubernetesApiUrl(): string {
|
|
34
|
+
return ApiUrlResolver.KUBERNETES_API_URL;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private async obtainUserNamespace() : Promise<string> {
|
|
38
|
+
Logger.debug(`ApiUrlResolver.obtainUserNamespace ${this.userNamespace}`);
|
|
39
|
+
if (this.userNamespace.length === 0) {
|
|
40
|
+
Logger.trace(`ApiUrlResolver.obtainUserNamespace USER_NAMESPACE.length = 0, calling kubernetes API`);
|
|
41
|
+
const kubernetesResponse = await this.processRequestHandler.get(ApiUrlResolver.KUBERNETES_API_URL);
|
|
42
|
+
if (kubernetesResponse.status !== 200) {
|
|
43
|
+
throw new Error(`Cannot get user namespace from kubernetes API. Code: ${kubernetesResponse.status} Data: ${kubernetesResponse.data}`);
|
|
44
|
+
}
|
|
45
|
+
this.userNamespace = kubernetesResponse.data[0].name;
|
|
46
|
+
Logger.debug(`ApiUrlResolver.obtainUserNamespace kubeapi success: ${this.userNamespace}`);
|
|
47
|
+
}
|
|
48
|
+
return this.userNamespace;
|
|
49
|
+
}
|
|
50
|
+
}
|