@eclipse-che/che-e2e 7.64.0-dev-20514b2 → 7.64.0-dev-db63138

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.
Files changed (150) hide show
  1. package/README.md +11 -37
  2. package/build/dockerfiles/entrypoint.sh +1 -1
  3. package/configs/inversify.config.ts +11 -26
  4. package/configs/inversify.types.ts +3 -33
  5. package/configs/mocharc.ts +9 -3
  6. package/configs/sh-scripts/initDefaultValues.sh +0 -5
  7. package/constants/TestConstants.ts +34 -96
  8. package/dist/configs/inversify.config.js +8 -23
  9. package/dist/configs/inversify.config.js.map +1 -1
  10. package/dist/configs/inversify.types.js +3 -33
  11. package/dist/configs/inversify.types.js.map +1 -1
  12. package/dist/configs/mocharc.js +11 -4
  13. package/dist/configs/mocharc.js.map +1 -1
  14. package/dist/constants/TestConstants.js +31 -86
  15. package/dist/constants/TestConstants.js.map +1 -1
  16. package/dist/driver/ChromeDriver.js +1 -1
  17. package/dist/driver/ChromeDriver.js.map +1 -1
  18. package/dist/index.js +63 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/pageobjects/dashboard/CreateWorkspace.js +3 -11
  21. package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
  22. package/dist/pageobjects/dashboard/Dashboard.js +16 -1
  23. package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
  24. package/dist/pageobjects/dashboard/Workspaces.js +1 -3
  25. package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
  26. package/dist/pageobjects/git-providers/OauthPage.js +150 -0
  27. package/dist/pageobjects/git-providers/OauthPage.js.map +1 -0
  28. package/dist/pageobjects/ide/CheCodeLocatorLoader.js +65 -0
  29. package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -0
  30. package/dist/pageobjects/login/OcpRedHatLoginPage.js +67 -0
  31. package/dist/pageobjects/login/OcpRedHatLoginPage.js.map +1 -0
  32. package/dist/pageobjects/login/RedHatLoginPage.js +78 -0
  33. package/dist/pageobjects/login/RedHatLoginPage.js.map +1 -0
  34. package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js +3 -21
  35. package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js.map +1 -1
  36. package/dist/pageobjects/openshift/CheLoginPage.js +0 -33
  37. package/dist/pageobjects/openshift/CheLoginPage.js.map +1 -1
  38. package/dist/pageobjects/openshift/OcpLoginPage.js +0 -14
  39. package/dist/pageobjects/openshift/OcpLoginPage.js.map +1 -1
  40. package/dist/specs/MochaHooks.js +2 -2
  41. package/dist/specs/MochaHooks.js.map +1 -1
  42. package/dist/specs/devfiles/EmptyWorkspace.spec.js +1 -0
  43. package/dist/specs/devfiles/EmptyWorkspace.spec.js.map +1 -1
  44. package/dist/specs/devfiles/Quarkus.spec.js +50 -0
  45. package/dist/specs/devfiles/Quarkus.spec.js.map +1 -0
  46. package/dist/specs/factory/Factory.spec.js +160 -0
  47. package/dist/specs/factory/Factory.spec.js.map +1 -0
  48. package/dist/specs/factory/NoSetupRepoFactory.spec.js +228 -0
  49. package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -0
  50. package/dist/specs/factory/RefusedOAuthFactory.spec.js +220 -0
  51. package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -0
  52. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +66 -0
  53. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -0
  54. package/dist/tests-library/LoginTests.js +10 -2
  55. package/dist/tests-library/LoginTests.js.map +1 -1
  56. package/dist/tests-library/WorkspaceHandlingTests.js +3 -6
  57. package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
  58. package/dist/utils/BrowserTabsUtil.js +2 -21
  59. package/dist/utils/BrowserTabsUtil.js.map +1 -1
  60. package/dist/utils/DriverHelper.js +11 -73
  61. package/dist/utils/DriverHelper.js.map +1 -1
  62. package/dist/utils/Logger.js +5 -0
  63. package/dist/utils/Logger.js.map +1 -1
  64. package/dist/utils/Sanitizer.js.map +1 -1
  65. package/dist/utils/request-handlers/CheApiRequestHandler.js +1 -1
  66. package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
  67. package/dist/utils/vsc/GitUtil.js +41 -0
  68. package/dist/utils/vsc/GitUtil.js.map +1 -0
  69. package/dist/utils/workspace/ApiUrlResolver.js +0 -3
  70. package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
  71. package/dist/utils/workspace/TestWorkspaceUtil.js +2 -192
  72. package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
  73. package/driver/ChromeDriver.ts +1 -1
  74. package/index.ts +37 -0
  75. package/package.json +9 -5
  76. package/pageobjects/dashboard/CreateWorkspace.ts +4 -15
  77. package/pageobjects/dashboard/Dashboard.ts +29 -4
  78. package/pageobjects/dashboard/Workspaces.ts +1 -3
  79. package/pageobjects/git-providers/OauthPage.ts +156 -0
  80. package/pageobjects/ide/CheCodeLocatorLoader.ts +69 -0
  81. package/pageobjects/login/OcpRedHatLoginPage.ts +49 -0
  82. package/pageobjects/login/RedHatLoginPage.ts +62 -0
  83. package/pageobjects/login/RegularUserOcpCheLoginPage.ts +1 -20
  84. package/pageobjects/openshift/CheLoginPage.ts +6 -55
  85. package/pageobjects/openshift/OcpLoginPage.ts +0 -21
  86. package/specs/MochaHooks.ts +2 -2
  87. package/specs/devfiles/EmptyWorkspace.spec.ts +1 -0
  88. package/specs/devfiles/Quarkus.spec.ts +52 -0
  89. package/specs/factory/Factory.spec.ts +199 -0
  90. package/specs/factory/NoSetupRepoFactory.spec.ts +272 -0
  91. package/specs/factory/RefusedOAuthFactory.spec.ts +260 -0
  92. package/specs/miscellaneous/PredefinedNamespace.spec.ts +74 -0
  93. package/tests-library/LoginTests.ts +9 -1
  94. package/tests-library/WorkspaceHandlingTests.ts +3 -7
  95. package/utils/BrowserTabsUtil.ts +2 -24
  96. package/utils/DriverHelper.ts +9 -84
  97. package/utils/Logger.ts +5 -0
  98. package/utils/Sanitizer.ts +0 -1
  99. package/utils/request-handlers/CheApiRequestHandler.ts +1 -1
  100. package/utils/vsc/GitUtil.ts +28 -0
  101. package/utils/workspace/ApiUrlResolver.ts +0 -4
  102. package/utils/workspace/ITestWorkspaceUtil.ts +1 -56
  103. package/utils/workspace/TestWorkspaceUtil.ts +2 -243
  104. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js +0 -97
  105. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js.map +0 -1
  106. package/dist/pageobjects/login/MultiUserLoginPage.js +0 -49
  107. package/dist/pageobjects/login/MultiUserLoginPage.js.map +0 -1
  108. package/dist/pageobjects/login/UpdateAccountInformationPage.js +0 -74
  109. package/dist/pageobjects/login/UpdateAccountInformationPage.js.map +0 -1
  110. package/dist/pageobjects/third-parties/GitLoginPage.js +0 -85
  111. package/dist/pageobjects/third-parties/GitLoginPage.js.map +0 -1
  112. package/dist/pageobjects/third-parties/GitOauthAppsSettings.js +0 -110
  113. package/dist/pageobjects/third-parties/GitOauthAppsSettings.js.map +0 -1
  114. package/dist/specs/login/LinkCheAndOcpUsers.spec.js +0 -40
  115. package/dist/specs/login/LinkCheAndOcpUsers.spec.js.map +0 -1
  116. package/dist/utils/WorkspaceNameHandler.js +0 -60
  117. package/dist/utils/WorkspaceNameHandler.js.map +0 -1
  118. package/dist/utils/request-handlers/tokens/CheMultiuserTokenHandler.js +0 -50
  119. package/dist/utils/request-handlers/tokens/CheMultiuserTokenHandler.js.map +0 -1
  120. package/dist/utils/request-handlers/tokens/ITokenHandler.js +0 -12
  121. package/dist/utils/request-handlers/tokens/ITokenHandler.js.map +0 -1
  122. package/dist/utils/vsc/CheGitApi.js +0 -42
  123. package/dist/utils/vsc/CheGitApi.js.map +0 -1
  124. package/dist/utils/vsc/github/GitHubUtil.js +0 -126
  125. package/dist/utils/vsc/github/GitHubUtil.js.map +0 -1
  126. package/files/devfiles/plugins/GitHubPullRequestPlugin.yaml +0 -11
  127. package/files/devfiles/plugins/InstallPluginUsingUI.yaml +0 -3
  128. package/files/devfiles/plugins/Java11PluginTest.yaml +0 -17
  129. package/files/devfiles/plugins/PhpPluginTest.yaml +0 -47
  130. package/files/devfiles/plugins/PythonPluginTest.yaml +0 -14
  131. package/files/devfiles/plugins/TypescriptNodeDebug2PluginTest.yaml +0 -49
  132. package/files/devfiles/plugins/VscodeKubernetesPlugin.yaml +0 -12
  133. package/files/devfiles/plugins/VscodeShellcheckPlugin.yaml +0 -12
  134. package/files/devfiles/plugins/VscodeValePlugin.yaml +0 -42
  135. package/files/devfiles/plugins/VscodeXmlPlugin.yaml +0 -12
  136. package/files/devfiles/plugins/VscodeYamlPlugin.yaml +0 -12
  137. package/files/happy-path/containers-happy-path.yaml +0 -127
  138. package/files/happy-path/happy-path-workspace.yaml +0 -95
  139. package/files/happy-path/petclinic-classpath.txt +0 -49
  140. package/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.ts +0 -95
  141. package/pageobjects/login/MultiUserLoginPage.ts +0 -33
  142. package/pageobjects/login/UpdateAccountInformationPage.ts +0 -70
  143. package/pageobjects/third-parties/GitLoginPage.ts +0 -81
  144. package/pageobjects/third-parties/GitOauthAppsSettings.ts +0 -110
  145. package/specs/login/LinkCheAndOcpUsers.spec.ts +0 -49
  146. package/utils/WorkspaceNameHandler.ts +0 -48
  147. package/utils/request-handlers/tokens/CheMultiuserTokenHandler.ts +0 -41
  148. package/utils/request-handlers/tokens/ITokenHandler.ts +0 -14
  149. package/utils/vsc/CheGitApi.ts +0 -22
  150. package/utils/vsc/github/GitHubUtil.ts +0 -110
@@ -1,81 +0,0 @@
1
- /*********************************************************************
2
- * Copyright (c) 2021-2023 Red Hat, Inc.
3
- *
4
- * This program and the accompanying materials are made
5
- * available under the terms of the Eclipse Public License 2.0
6
- * which is available at https://www.eclipse.org/legal/epl-2.0/
7
- *
8
- * SPDX-License-Identifier: EPL-2.0
9
- **********************************************************************/
10
-
11
- import 'reflect-metadata';
12
- import { injectable, inject } from 'inversify';
13
- import { CLASSES } from '../../configs/inversify.types';
14
- import { DriverHelper } from '../../utils/DriverHelper';
15
- import { TimeoutConstants } from '../../constants/TimeoutConstants';
16
- import { Logger } from '../../utils/Logger';
17
- import { By } from 'selenium-webdriver';
18
- import { TestConstants } from '../../constants/TestConstants';
19
-
20
- @injectable()
21
- export class GitLoginPage {
22
- private static readonly USERNAME_FIELD_LOCATOR = By.xpath(`//input[@id='login_field']`);
23
- private static readonly PASSWORD_FIELD_LOCATOR = By.xpath(`//input[@id='password']`);
24
- private static readonly SIGN_IN_BUTTON_LOCATOR = By.xpath(`//input[@value='Sign in']`);
25
-
26
- constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }
27
-
28
- async login(timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
29
- Logger.debug('GitLoginPage.login');
30
-
31
- await this.waitPage(timeout);
32
- await this.typeUsername(TestConstants.TS_GITHUB_USERNAME, timeout);
33
- await this.typePassword(TestConstants.TS_GITHUB_PASSWORD, timeout);
34
- await this.clickSignInButton(timeout);
35
- }
36
-
37
- async waitPage(timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
38
- Logger.debug('GitLoginPage.waitPage');
39
-
40
- await this.waitUsernameField(timeout);
41
- await this.waitPasswordField(timeout);
42
- await this.waitSignInButton(timeout);
43
- }
44
-
45
- async waitUsernameField(timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
46
- Logger.debug('GitLoginPage.waitUsernameField');
47
-
48
- await this.driverHelper.waitVisibility(GitLoginPage.USERNAME_FIELD_LOCATOR, timeout);
49
- }
50
-
51
- async waitPasswordField(timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
52
- Logger.debug('GitLoginPage.waitPasswordField');
53
-
54
- await this.driverHelper.waitVisibility(GitLoginPage.PASSWORD_FIELD_LOCATOR, timeout);
55
- }
56
-
57
- async waitSignInButton(timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
58
- Logger.debug('GitLoginPage.waitSignInbutton');
59
-
60
- await this.driverHelper.waitVisibility(GitLoginPage.SIGN_IN_BUTTON_LOCATOR, timeout);
61
- }
62
-
63
- async typeUsername(username: string, timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
64
- Logger.debug('GitLoginPage.typeUsername');
65
-
66
- await this.driverHelper.type(GitLoginPage.USERNAME_FIELD_LOCATOR, username, timeout);
67
- }
68
-
69
- async typePassword(password: string, timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
70
- Logger.debug('GitLoginPage.typePassword');
71
-
72
- await this.driverHelper.type(GitLoginPage.PASSWORD_FIELD_LOCATOR, password, timeout);
73
- }
74
-
75
- async clickSignInButton(timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
76
- Logger.debug('GitLoginPage.clickSignInButton');
77
-
78
- await this.driverHelper.waitAndClick(GitLoginPage.SIGN_IN_BUTTON_LOCATOR, timeout);
79
- }
80
-
81
- }
@@ -1,110 +0,0 @@
1
- /*********************************************************************
2
- * Copyright (c) 2021-2023 Red Hat, Inc.
3
- *
4
- * This program and the accompanying materials are made
5
- * available under the terms of the Eclipse Public License 2.0
6
- * which is available at https://www.eclipse.org/legal/epl-2.0/
7
- *
8
- * SPDX-License-Identifier: EPL-2.0
9
- **********************************************************************/
10
-
11
- import 'reflect-metadata';
12
- import { injectable, inject } from 'inversify';
13
- import { CLASSES } from '../../configs/inversify.types';
14
- import { DriverHelper } from '../../utils/DriverHelper';
15
- import { TimeoutConstants } from '../../constants/TimeoutConstants';
16
- import { Logger } from '../../utils/Logger';
17
- import { By, error, Key } from 'selenium-webdriver';
18
- import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
19
-
20
- @injectable()
21
- export class GitOauthAppsSettings {
22
- private static readonly GITHUB_OAUTH_APPS_SETTINGS_URL = 'https://github.com/settings/developers';
23
- private static readonly HOME_PAGE_FIELD_LOCATOR: By = By.xpath(`//input[@id='oauth_application_url']`);
24
- private static readonly CALLBACK_URL_FIELD_LOCATOR: By = By.xpath(`//input[@id='oauth_application_callback_url']`);
25
- private static readonly UPDATE_APPLICATION_BUTTON_LOCATOR: By = By.xpath(`//form[@class='edit_oauth_application']//button[@type='submit']`);
26
-
27
- constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
28
- @inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil) { }
29
-
30
- async openPage(timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
31
- Logger.debug('GitOauthAppsSettings.openPage');
32
-
33
- await this.browserTabsUtil.navigateTo(GitOauthAppsSettings.GITHUB_OAUTH_APPS_SETTINGS_URL);
34
- }
35
-
36
- async waitTitle(title: string, timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
37
- Logger.debug('GitOauthAppsSettings.waitTitle');
38
-
39
- await this.driverHelper.waitVisibility(this.getTitleLocator(title), timeout);
40
- }
41
-
42
- async waitOauthApp(applicationTitle: string, timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
43
- Logger.debug('GitOauthAppsSettings.waitOauthApp');
44
-
45
- await this.driverHelper.waitVisibility(this.getOauthAppLocator(applicationTitle), timeout);
46
- }
47
-
48
- async clickOauthApp(applicationTitle: string, timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
49
- Logger.debug('GitOauthAppsSettings.clickOauthApp');
50
-
51
- await this.driverHelper.waitAndClick(this.getOauthAppLocator(applicationTitle), timeout);
52
- }
53
-
54
- async openOauthApp(title: string, timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
55
- Logger.debug('GitOauthAppsSettings.openOauthApp');
56
-
57
- await this.driverHelper.waitUntilTrue(async () => {
58
- await this.clickOauthApp(title);
59
-
60
- try {
61
- await this.waitTitle(title, timeout / 3);
62
- return true;
63
- } catch (err) {
64
- if (!(err instanceof error.TimeoutError)) {
65
- throw err;
66
- }
67
-
68
- Logger.debug(`The ${title} oAuth app is not opened, next try.`);
69
- }
70
-
71
- }, timeout);
72
- }
73
-
74
- async scrollToUpdateApplicationButton(timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
75
- Logger.debug('GitOauthAppsSettings.scrollToUpdateApplicationButton');
76
-
77
- await this.driverHelper.scrollTo(GitOauthAppsSettings.UPDATE_APPLICATION_BUTTON_LOCATOR, timeout);
78
- }
79
-
80
- async typeHomePageUrl(homePageUrl: string, timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
81
- Logger.debug('GitOauthAppsSettings.typeHomePageUrl');
82
-
83
- await this.driverHelper.type(GitOauthAppsSettings.HOME_PAGE_FIELD_LOCATOR, Key.chord(Key.CONTROL, 'a'), timeout);
84
- await this.driverHelper.type(GitOauthAppsSettings.HOME_PAGE_FIELD_LOCATOR, Key.DELETE, timeout);
85
- await this.driverHelper.type(GitOauthAppsSettings.HOME_PAGE_FIELD_LOCATOR, homePageUrl, timeout);
86
- }
87
-
88
- async typeCallbackUrl(callbackUrl: string, timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
89
- Logger.debug('GitOauthAppsSettings.typeCallbackUrl');
90
-
91
- await this.driverHelper.type(GitOauthAppsSettings.CALLBACK_URL_FIELD_LOCATOR, Key.chord(Key.CONTROL, 'a'), timeout);
92
- await this.driverHelper.type(GitOauthAppsSettings.CALLBACK_URL_FIELD_LOCATOR, Key.DELETE, timeout);
93
- await this.driverHelper.type(GitOauthAppsSettings.CALLBACK_URL_FIELD_LOCATOR, callbackUrl, timeout);
94
- }
95
-
96
- async clickUpdateApplicationButton(timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
97
- Logger.debug('GitOauthAppsSettings.clickUpdateApplicationButton');
98
-
99
- await this.driverHelper.waitAndClick(GitOauthAppsSettings.UPDATE_APPLICATION_BUTTON_LOCATOR, timeout);
100
- }
101
-
102
- private getOauthAppLocator(applicationTitle: string, timeout: number = TimeoutConstants.TS_COMMON_PLUGIN_TEST_TIMEOUT) {
103
- return By.xpath(`//div[@class='TableObject']//a[text()='${applicationTitle}']`);
104
- }
105
-
106
- private getTitleLocator(title: string): By {
107
- return By.xpath(`//main[@id='js-pjax-container']//h2[text()='${title}']`);
108
- }
109
-
110
- }
@@ -1,49 +0,0 @@
1
- /*********************************************************************
2
- * Copyright (c) 2019-2023 Red Hat, Inc.
3
- *
4
- * This program and the accompanying materials are made
5
- * available under the terms of the Eclipse Public License 2.0
6
- * which is available at https://www.eclipse.org/legal/epl-2.0/
7
- *
8
- * SPDX-License-Identifier: EPL-2.0
9
- **********************************************************************/
10
-
11
- import { CLASSES, TYPES } from '../../configs/inversify.types';
12
- import { e2eContainer } from '../../configs/inversify.config';
13
- import { IOcpLoginPage } from '../../pageobjects/login/IOcpLoginPage';
14
- import { UpdateAccountInformationPage } from '../../pageobjects/login/UpdateAccountInformationPage';
15
- import { TimeoutConstants } from '../../constants/TimeoutConstants';
16
- import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
17
- import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
18
- import { TestConstants } from '../../constants/TestConstants';
19
-
20
- const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
21
- const ocpLogin: IOcpLoginPage = e2eContainer.get<IOcpLoginPage>(TYPES.OcpLogin);
22
- const updateAccountInformation: UpdateAccountInformationPage = e2eContainer.get(CLASSES.UpdateAccountInformationPage);
23
- const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
24
-
25
- const commonTimeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT * 2;
26
-
27
- suite('Link users', async () => {
28
- test('Login to OCP', async () => {
29
- await browserTabsUtil.navigateTo(TestConstants.TS_SELENIUM_BASE_URL);
30
-
31
- await ocpLogin.login();
32
- await updateAccountInformation.clickToAllowSelectedPermissionsButton(commonTimeout);
33
- });
34
-
35
- test('Update account information', async () => {
36
- await updateAccountInformation.enterEmail('admin@admin.com', commonTimeout);
37
- await updateAccountInformation.enterFirstName(TestConstants.TS_SELENIUM_USERNAME, commonTimeout);
38
- await updateAccountInformation.enterLastName(TestConstants.TS_SELENIUM_USERNAME, commonTimeout);
39
- await updateAccountInformation.clickConfirmButton(commonTimeout);
40
- await updateAccountInformation.clickAddToExistingAccountButton(commonTimeout);
41
- });
42
-
43
- test('Login to Che', async () => {
44
- await updateAccountInformation.enterPassword(TestConstants.TS_SELENIUM_PASSWORD, commonTimeout);
45
- await updateAccountInformation.clickLogInButton(commonTimeout);
46
- await dashboard.waitPage(commonTimeout);
47
- });
48
-
49
- });
@@ -1,48 +0,0 @@
1
- /*********************************************************************
2
- * Copyright (c) 2019-2023 Red Hat, Inc.
3
- *
4
- * This program and the accompanying materials are made
5
- * available under the terms of the Eclipse Public License 2.0
6
- * which is available at https://www.eclipse.org/legal/epl-2.0/
7
- *
8
- * SPDX-License-Identifier: EPL-2.0
9
- **********************************************************************/
10
-
11
- import { CLASSES } from '../configs/inversify.types';
12
- import { inject, injectable } from 'inversify';
13
- import { BrowserTabsUtil } from './BrowserTabsUtil';
14
- import { Logger } from './Logger';
15
-
16
- @injectable()
17
- export class WorkspaceNameHandler {
18
-
19
- constructor(@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil) {}
20
-
21
- public generateWorkspaceName(prefix: string, randomLength: number): string {
22
- const possibleCharacters: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
23
- const possibleCharactersLength: number = possibleCharacters.length;
24
- let randomPart: string = '';
25
- Logger.debug('WorkspaceNameHandler.generateWorkspaceName');
26
-
27
- for (let i = 0; i < randomLength; i++) {
28
- let currentRandomIndex: number = Math.floor(Math.random() * Math.floor(possibleCharactersLength));
29
-
30
- randomPart += possibleCharacters[currentRandomIndex];
31
- }
32
-
33
- return prefix + randomPart;
34
- }
35
-
36
- public async getNameFromUrl(): Promise<string> {
37
- let workspaceUrl: string = await this.browserTabsUtil.getCurrentUrl();
38
- Logger.debug(`WorkspaceNameHandler.fromWorkspaceUrl workspaceUrl: ${workspaceUrl}`);
39
-
40
- const workspaceUrlParts: string[] = workspaceUrl.split('/');
41
- const workspaceNameQueryString: string = workspaceUrlParts[workspaceUrlParts.length - 1];
42
- const workspaceName: string = workspaceNameQueryString.split('?')[0];
43
-
44
- Logger.debug(`workspaceName: ${workspaceName}`);
45
-
46
- return workspaceName;
47
- }
48
- }
@@ -1,41 +0,0 @@
1
- /*********************************************************************
2
- * Copyright (c) 2019-2023 Red Hat, Inc.
3
- *
4
- * This program and the accompanying materials are made
5
- * available under the terms of the Eclipse Public License 2.0
6
- * which is available at https://www.eclipse.org/legal/epl-2.0/
7
- *
8
- * SPDX-License-Identifier: EPL-2.0
9
- **********************************************************************/
10
- import axios from 'axios';
11
- import querystring from 'querystring';
12
- import { injectable } from 'inversify';
13
- import { TestConstants } from '../../../constants/TestConstants';
14
- import { ITokenHandler } from './ITokenHandler';
15
-
16
-
17
- @injectable()
18
- export class CheMultiuserTokenHandler implements ITokenHandler {
19
- async get(): Promise<string> {
20
- // to-do: Login to the che-dashboard and fetch the authorization related info
21
- const keycloakUrl = '';
22
-
23
- const params = {
24
- client_id: 'che-public',
25
- username: TestConstants.TS_SELENIUM_USERNAME,
26
- password: TestConstants.TS_SELENIUM_PASSWORD,
27
- grant_type: 'password',
28
- };
29
-
30
- try {
31
- const responseToObtainBearerToken = await axios.post(
32
- keycloakUrl,
33
- querystring.stringify(params)
34
- );
35
- return responseToObtainBearerToken.data.access_token;
36
- } catch (err) {
37
- console.log(`Can not get bearer token. URL used: ${keycloakUrl}`);
38
- throw err;
39
- }
40
- }
41
- }
@@ -1,14 +0,0 @@
1
- /*********************************************************************
2
- * Copyright (c) 2019-2023 Red Hat, Inc.
3
- *
4
- * This program and the accompanying materials are made
5
- * available under the terms of the Eclipse Public License 2.0
6
- * which is available at https://www.eclipse.org/legal/epl-2.0/
7
- *
8
- * SPDX-License-Identifier: EPL-2.0
9
- **********************************************************************/
10
-
11
-
12
- export interface ITokenHandler {
13
- get(): Promise<string>;
14
- }
@@ -1,22 +0,0 @@
1
- import { injectable, inject } from 'inversify';
2
- import { CLASSES } from '../../configs/inversify.types';
3
- import { CheApiRequestHandler } from '../request-handlers/CheApiRequestHandler';
4
-
5
-
6
- @injectable()
7
- export class CheGitApi {
8
- static readonly GIT_API_ENTRIPOINT_URL = 'api/ssh/vcs';
9
-
10
- constructor(@inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler) { }
11
-
12
- public async getPublicSSHKey(): Promise<string> {
13
-
14
- try {
15
- const responce = await this.processRequestHandler.get(CheGitApi.GIT_API_ENTRIPOINT_URL);
16
- return responce.data[0].publicKey;
17
- } catch (error) {
18
- console.error('Cannot get public ssh key with API \n' + error);
19
- throw error;
20
- }
21
- }
22
- }
@@ -1,110 +0,0 @@
1
- import { injectable } from 'inversify';
2
- import axios from 'axios';
3
-
4
- @injectable()
5
- export class GitHubUtil {
6
- private static readonly GITHUB_API_ENTRIPOINT_URL = 'https://api.github.com/';
7
- /**
8
- * add public part of ssh key to the defied github account
9
- * @param authToken
10
- * @param title
11
- * @param key
12
- */
13
- async addPublicSshKeyToUserAccount(authToken: string, title: string, key: string) {
14
- const gitHubApiSshURL: string = GitHubUtil.GITHUB_API_ENTRIPOINT_URL + 'user/keys';
15
- const authHeader = { headers: { 'Authorization': 'token ' + authToken, 'Content-Type': 'application/json' } };
16
-
17
- const data = {
18
- title: `${title}`,
19
- key: `${key}`
20
- };
21
-
22
- try { await axios.post(gitHubApiSshURL, JSON.stringify(data), authHeader); } catch (error) {
23
- console.error('Cannot add the public key to the GitHub account: ');
24
- console.error(error);
25
- throw error;
26
- }
27
- }
28
-
29
- async getRawContentFromFile(pathToFile: string): Promise<string> {
30
- const gitHubContentEntryPointUrl: string = 'https://raw.githubusercontent.com/';
31
- const pathToRawContent: string = `${gitHubContentEntryPointUrl}${pathToFile}`;
32
- const authorization: string = 'Authorization';
33
- const contentType: string = 'Content-Type';
34
-
35
- try {
36
- delete axios.defaults.headers.common[authorization];
37
- delete axios.defaults.headers.common[contentType];
38
- const response = await axios.get(`${gitHubContentEntryPointUrl}${pathToFile}`);
39
- return response.data;
40
- } catch (error) {
41
- console.error('Cannot get content form the raw github content: ' + pathToRawContent);
42
- console.error(error);
43
- throw error;
44
- }
45
- }
46
-
47
- async getPublicSshKeys(authToken: string): Promise<Array<string>> {
48
- const gitHubApiSshURL: string = GitHubUtil.GITHUB_API_ENTRIPOINT_URL + 'user/keys';
49
- const authHeader = { headers: { 'Authorization': 'token ' + authToken, 'Content-Type': 'application/json' } };
50
- try {
51
- const response = await axios.get(gitHubApiSshURL, authHeader);
52
- const stringified = JSON.stringify(response.data);
53
- const arrayOfWorkspaces = JSON.parse(stringified);
54
- const idOfRunningWorkspace: Array<string> = new Array();
55
- for (let entry of arrayOfWorkspaces) {
56
- idOfRunningWorkspace.push(entry.id);
57
- }
58
- return idOfRunningWorkspace;
59
- } catch (error) {
60
- console.error('Cannot get public Keys from github: ' + gitHubApiSshURL);
61
- console.error(error);
62
- throw error;
63
- }
64
- }
65
-
66
- async removePublicSshKey(authToken: string, keyId: string) {
67
- const gitHubApiSshURL: string = GitHubUtil.GITHUB_API_ENTRIPOINT_URL + 'user/keys/' + keyId;
68
- const authHeader = { headers: { 'Authorization': 'token ' + authToken, 'Content-Type': 'application/json' } };
69
- try { await axios.delete(gitHubApiSshURL, authHeader); } catch (error) {
70
- console.error('Cannot delete the public key from the GitHub account: ');
71
- console.error(error);
72
- throw error;
73
- }
74
- }
75
-
76
- async deletePublicSshKeyByName(authToken: string, keyName: string) {
77
- const gitHubApiSshURL: string = GitHubUtil.GITHUB_API_ENTRIPOINT_URL + 'user/keys';
78
- const authHeader = { headers: { 'Authorization': 'token ' + authToken, 'Content-Type': 'application/json' } };
79
- try {
80
- const response = await axios.get(gitHubApiSshURL, authHeader);
81
- const stringified = JSON.stringify(response.data);
82
- const arrayOfPublicKeys = JSON.parse(stringified);
83
- for (let entry of arrayOfPublicKeys) {
84
- if (entry.title === keyName) {
85
- await this.removePublicSshKey(authToken, entry.id);
86
- break;
87
- }
88
- }
89
- } catch (error) {
90
- console.error('Cannot delete the ' + keyName + ' public key from the GitHub account');
91
- console.error(error);
92
- throw error;
93
- }
94
- }
95
-
96
- async removeAllPublicSshKeys(authToken: string) {
97
- try {
98
- const idList: string[] = await this.getPublicSshKeys(authToken);
99
- for (let id of idList) {
100
- await this.removePublicSshKey(authToken, id);
101
- }
102
-
103
- } catch (error) {
104
- console.error('Cannot delete the public key from the GitHub account: ');
105
- console.error(error);
106
- throw error;
107
- }
108
- }
109
-
110
- }