@eclipse-che/che-e2e 7.74.0-dev-41d1364 → 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.
Files changed (156) hide show
  1. package/.eslintrc.js +15 -1
  2. package/CODE_STYLE.md +144 -0
  3. package/configs/inversify.config.ts +26 -5
  4. package/configs/inversify.types.ts +17 -3
  5. package/constants/CHROME_DRIVER_CONSTANTS.ts +1 -13
  6. package/dist/configs/inversify.config.js +22 -1
  7. package/dist/configs/inversify.config.js.map +1 -1
  8. package/dist/configs/inversify.types.js +17 -3
  9. package/dist/configs/inversify.types.js.map +1 -1
  10. package/dist/constants/CHROME_DRIVER_CONSTANTS.js +1 -9
  11. package/dist/constants/CHROME_DRIVER_CONSTANTS.js.map +1 -1
  12. package/dist/driver/ChromeDriver.js +1 -7
  13. package/dist/driver/ChromeDriver.js.map +1 -1
  14. package/dist/index.js +9 -3
  15. package/dist/index.js.map +1 -1
  16. package/dist/pageobjects/dashboard/CreateWorkspace.js +5 -5
  17. package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
  18. package/dist/pageobjects/dashboard/Dashboard.js +5 -6
  19. package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
  20. package/dist/pageobjects/dashboard/Workspaces.js +34 -39
  21. package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
  22. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +27 -28
  23. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
  24. package/dist/pageobjects/git-providers/OauthPage.js +2 -2
  25. package/dist/pageobjects/git-providers/OauthPage.js.map +1 -1
  26. package/dist/pageobjects/ide/CheCodeLocatorLoader.js +18 -4
  27. package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -1
  28. package/dist/pageobjects/login/kubernetes/DexLoginPage.js +11 -11
  29. package/dist/pageobjects/login/kubernetes/DexLoginPage.js.map +1 -1
  30. package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js +2 -2
  31. package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js.map +1 -1
  32. package/dist/pageobjects/login/openshift/OcpLoginPage.js +20 -24
  33. package/dist/pageobjects/login/openshift/OcpLoginPage.js.map +1 -1
  34. package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js +10 -13
  35. package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js.map +1 -1
  36. package/dist/pageobjects/login/openshift/OcpUserLoginPage.js +3 -3
  37. package/dist/pageobjects/login/openshift/OcpUserLoginPage.js.map +1 -1
  38. package/dist/pageobjects/login/openshift/RedHatLoginPage.js +16 -20
  39. package/dist/pageobjects/login/openshift/RedHatLoginPage.js.map +1 -1
  40. package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js +16 -15
  41. package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js.map +1 -1
  42. package/dist/pageobjects/openshift/OcpApplicationPage.js +7 -7
  43. package/dist/pageobjects/openshift/OcpApplicationPage.js.map +1 -1
  44. package/dist/pageobjects/openshift/OcpImportFromGitPage.js +20 -20
  45. package/dist/pageobjects/openshift/OcpImportFromGitPage.js.map +1 -1
  46. package/dist/pageobjects/openshift/OcpMainPage.js +25 -25
  47. package/dist/pageobjects/openshift/OcpMainPage.js.map +1 -1
  48. package/dist/specs/MochaHooks.js +9 -6
  49. package/dist/specs/MochaHooks.js.map +1 -1
  50. package/dist/specs/SmokeTest.spec.js +6 -6
  51. package/dist/specs/SmokeTest.spec.js.map +1 -1
  52. package/dist/specs/api/ContainerOverridesAPI.spec.js +7 -14
  53. package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -1
  54. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +11 -19
  55. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -1
  56. package/dist/specs/api/EmptyWorkspaceAPI.spec.js +10 -16
  57. package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -1
  58. package/dist/specs/api/PodOverridesAPI.spec.js +7 -14
  59. package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -1
  60. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +5 -5
  61. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +1 -1
  62. package/dist/specs/dashboard-samples/Quarkus.spec.js +6 -6
  63. package/dist/specs/dashboard-samples/Quarkus.spec.js.map +1 -1
  64. package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js +11 -11
  65. package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js.map +1 -1
  66. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +11 -12
  67. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
  68. package/dist/specs/factory/Factory.spec.js +13 -16
  69. package/dist/specs/factory/Factory.spec.js.map +1 -1
  70. package/dist/specs/factory/NoSetupRepoFactory.spec.js +17 -18
  71. package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
  72. package/dist/specs/factory/RefusedOAuthFactory.spec.js +17 -19
  73. package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
  74. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +35 -41
  75. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -1
  76. package/dist/tests-library/LoginTests.js +8 -8
  77. package/dist/tests-library/LoginTests.js.map +1 -1
  78. package/dist/tests-library/ProjectAndFileTests.js +2 -2
  79. package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
  80. package/dist/tests-library/WorkspaceHandlingTests.js +8 -8
  81. package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
  82. package/dist/utils/BrowserTabsUtil.js +4 -9
  83. package/dist/utils/BrowserTabsUtil.js.map +1 -1
  84. package/dist/utils/CheReporter.js +49 -23
  85. package/dist/utils/CheReporter.js.map +1 -1
  86. package/dist/utils/DevWorkspaceConfigurationHelper.js +27 -17
  87. package/dist/utils/DevWorkspaceConfigurationHelper.js.map +1 -1
  88. package/dist/utils/DevfilesRegistryHelper.js +15 -5
  89. package/dist/utils/DevfilesRegistryHelper.js.map +1 -1
  90. package/dist/utils/DriverHelper.js +9 -2
  91. package/dist/utils/DriverHelper.js.map +1 -1
  92. package/dist/utils/IContextParams.js +12 -0
  93. package/dist/utils/IContextParams.js.map +1 -0
  94. package/dist/utils/IKubernetesCommandLineToolsExecutor.js +3 -0
  95. package/dist/utils/IKubernetesCommandLineToolsExecutor.js.map +1 -0
  96. package/dist/utils/KubernetesCommandLineToolsExecutor.js +133 -98
  97. package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
  98. package/dist/utils/ScreenCatcher.js +8 -4
  99. package/dist/utils/ScreenCatcher.js.map +1 -1
  100. package/dist/utils/ShellExecutor.js +20 -9
  101. package/dist/utils/ShellExecutor.js.map +1 -1
  102. package/dist/utils/StringUtil.js +4 -2
  103. package/dist/utils/StringUtil.js.map +1 -1
  104. package/dist/utils/request-handlers/CheApiRequestHandler.js +2 -2
  105. package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
  106. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js +2 -2
  107. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
  108. package/dist/utils/workspace/ApiUrlResolver.js +2 -2
  109. package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
  110. package/dist/utils/workspace/TestWorkspaceUtil.js +4 -4
  111. package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
  112. package/driver/ChromeDriver.ts +0 -7
  113. package/index.ts +2 -0
  114. package/package.json +3 -3
  115. package/pageobjects/dashboard/CreateWorkspace.ts +5 -4
  116. package/pageobjects/dashboard/Dashboard.ts +3 -4
  117. package/pageobjects/dashboard/Workspaces.ts +40 -48
  118. package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +23 -26
  119. package/pageobjects/ide/CheCodeLocatorLoader.ts +3 -1
  120. package/pageobjects/login/interfaces/ICheLoginPage.ts +1 -1
  121. package/pageobjects/login/interfaces/IOcpLoginPage.ts +1 -1
  122. package/pageobjects/login/kubernetes/DexLoginPage.ts +9 -9
  123. package/pageobjects/login/openshift/OcpLoginPage.ts +18 -30
  124. package/pageobjects/login/openshift/OcpRedHatLoginPage.ts +6 -11
  125. package/pageobjects/login/openshift/OcpUserLoginPage.ts +1 -1
  126. package/pageobjects/login/openshift/RedHatLoginPage.ts +17 -16
  127. package/pageobjects/login/openshift/RegularUserOcpCheLoginPage.ts +16 -11
  128. package/pageobjects/openshift/OcpApplicationPage.ts +5 -4
  129. package/pageobjects/openshift/OcpImportFromGitPage.ts +18 -20
  130. package/pageobjects/openshift/OcpMainPage.ts +24 -25
  131. package/specs/MochaHooks.ts +3 -5
  132. package/specs/SmokeTest.spec.ts +4 -5
  133. package/specs/api/ContainerOverridesAPI.spec.ts +8 -2
  134. package/specs/api/DevfileAcceptanceTestAPI.spec.ts +9 -7
  135. package/specs/api/EmptyWorkspaceAPI.spec.ts +8 -4
  136. package/specs/api/PodOverridesAPI.spec.ts +8 -3
  137. package/specs/dashboard-samples/EmptyWorkspace.spec.ts +5 -5
  138. package/specs/dashboard-samples/Quarkus.spec.ts +7 -6
  139. package/specs/dashboard-samples/RecommendedExtensions.spec.ts +8 -7
  140. package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +12 -11
  141. package/specs/factory/Factory.spec.ts +8 -12
  142. package/specs/factory/NoSetupRepoFactory.spec.ts +10 -11
  143. package/specs/factory/RefusedOAuthFactory.spec.ts +8 -10
  144. package/specs/miscellaneous/PredefinedNamespace.spec.ts +40 -44
  145. package/tests-library/LoginTests.ts +3 -3
  146. package/tests-library/WorkspaceHandlingTests.ts +2 -2
  147. package/utils/BrowserTabsUtil.ts +7 -9
  148. package/utils/CheReporter.ts +26 -20
  149. package/utils/DevWorkspaceConfigurationHelper.ts +9 -24
  150. package/utils/DevfilesRegistryHelper.ts +8 -3
  151. package/utils/DriverHelper.ts +14 -12
  152. package/utils/IContextParams.ts +26 -0
  153. package/utils/IKubernetesCommandLineToolsExecutor.ts +42 -0
  154. package/utils/KubernetesCommandLineToolsExecutor.ts +133 -101
  155. package/utils/ShellExecutor.ts +10 -7
  156. package/utils/StringUtil.ts +6 -1
@@ -14,76 +14,100 @@ import * as path from 'path';
14
14
  import { API_TEST_CONSTANTS, KubernetesCommandLineTool } from '../constants/API_TEST_CONSTANTS';
15
15
  import { BASE_TEST_CONSTANTS } from '../constants/BASE_TEST_CONSTANTS';
16
16
  import { OAUTH_CONSTANTS } from '../constants/OAUTH_CONSTANTS';
17
+ import { IKubernetesCommandLineToolsExecutor } from './IKubernetesCommandLineToolsExecutor';
18
+ import { inject, injectable } from 'inversify';
19
+ import { CLASSES } from '../configs/inversify.types';
17
20
 
18
- export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
21
+ @injectable()
22
+ export class KubernetesCommandLineToolsExecutor implements IKubernetesCommandLineToolsExecutor {
19
23
  private static container: string;
20
24
  private static pod: string;
21
- private readonly namespace: string;
22
- private readonly workspaceName: string | undefined;
23
- private readonly KUBERNETES_COMMAND_LINE_TOOL: string = API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL;
25
+ private readonly kubernetesCommandLineTool: string;
26
+ protected _namespace: string | undefined;
27
+ protected _workspaceName: string | undefined;
24
28
 
25
- constructor(_workspaceName?: string, _namespace?: string) {
26
- super();
27
- this.workspaceName = _workspaceName;
28
- this.namespace = this.setNamespace(_namespace);
29
+ constructor(
30
+ @inject(CLASSES.ShellExecutor)
31
+ protected readonly shellExecutor: ShellExecutor
32
+ ) {
33
+ this.kubernetesCommandLineTool = API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL;
29
34
  }
30
35
 
31
- get getWorkspaceName(): string {
32
- return <string>this.workspaceName;
36
+ set namespace(value: string | undefined) {
37
+ this._namespace = value;
33
38
  }
34
39
 
35
- get getNamespace(): string {
36
- return this.namespace;
40
+ set workspaceName(value: string | undefined) {
41
+ this._workspaceName = value;
42
+ }
43
+
44
+ get workspaceName(): string | undefined {
45
+ return this._workspaceName;
46
+ }
47
+
48
+ get namespace(): string | undefined {
49
+ this._namespace =
50
+ this._namespace !== undefined
51
+ ? this._namespace
52
+ : BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('devspaces')
53
+ ? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-devspaces'
54
+ : BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('che')
55
+ ? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-che'
56
+ : 'default';
57
+ return this._namespace;
37
58
  }
38
59
 
39
60
  // login to Openshift cluster with username and password
40
- loginToOcp(): void {
41
- if (this.KUBERNETES_COMMAND_LINE_TOOL === KubernetesCommandLineTool.OC) {
42
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - login to the "OC" client.`);
61
+ loginToOcp(user: string = OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME, password: string = OAUTH_CONSTANTS.TS_SELENIUM_OCP_PASSWORD): void {
62
+ if (this.kubernetesCommandLineTool === KubernetesCommandLineTool.OC) {
63
+ Logger.debug(`${this.kubernetesCommandLineTool} - login to the "OC" client.`);
43
64
  const url: string = this.getServerUrl();
44
- if (this.isUserLoggedIn()) {
45
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - user already logged`);
65
+ if (this.isUserLoggedIn(user)) {
66
+ Logger.debug(`${this.kubernetesCommandLineTool} - user already logged`);
46
67
  } else {
47
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - login ${url}, ${OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME}`);
48
- exec(
49
- `oc login --server=${url} -u=${OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME} -p=${OAUTH_CONSTANTS.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`
50
- );
68
+ Logger.debug(`${this.kubernetesCommandLineTool} - login ${url}, ${user}`);
69
+ exec(`oc login --server=${url} -u=${user} -p=${password} --insecure-skip-tls-verify`);
51
70
  }
52
71
  } else {
53
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - doesn't support login command`);
72
+ Logger.debug(`${this.kubernetesCommandLineTool} - doesn't support login command`);
54
73
  }
55
74
  }
56
75
 
57
76
  getContainerName(): string {
58
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get container name.`);
59
- const output: ShellString = ShellExecutor.execWithLog(
60
- `${this.KUBERNETES_COMMAND_LINE_TOOL} get ${KubernetesCommandLineToolsExecutor.pod} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`
77
+ Logger.debug(`${this.kubernetesCommandLineTool} - get container name.`);
78
+
79
+ const output: ShellString = this.shellExecutor.executeCommand(
80
+ `${this.kubernetesCommandLineTool} get ${KubernetesCommandLineToolsExecutor.pod} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`
61
81
  );
62
82
  echo('\n');
63
83
  return output.stderr ? output.stderr : output.stdout;
64
84
  }
65
85
 
66
86
  getWorkspacePodName(): string {
67
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get workspace pod name.`);
68
- const output: ShellString = ShellExecutor.execWithLog(
69
- `${this.KUBERNETES_COMMAND_LINE_TOOL} get pod -l controller.devfile.io/devworkspace_name=${this.workspaceName} -n ${this.namespace} -o name`
87
+ Logger.debug(`${this.kubernetesCommandLineTool} - get workspace pod name.`);
88
+
89
+ const output: ShellString = this.shellExecutor.executeCommand(
90
+ `${this.kubernetesCommandLineTool} get pod -l controller.devfile.io/devworkspace_name=${this.workspaceName} -n ${this.namespace} -o name`
70
91
  );
71
92
  return output.stderr ? output.stderr : output.stdout.replace('\n', '');
72
93
  }
73
94
 
74
95
  deleteDevWorkspace(): void {
75
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - delete '${this.workspaceName}' workspace`);
76
- ShellExecutor.execWithLog(
77
- `${this.KUBERNETES_COMMAND_LINE_TOOL} patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`
96
+ Logger.debug(`${this.kubernetesCommandLineTool} - delete '${this.workspaceName}' workspace`);
97
+
98
+ this.shellExecutor.executeCommand(
99
+ `${this.kubernetesCommandLineTool} patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`
78
100
  );
79
- ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete dw ${this.workspaceName} -n ${this.namespace} || true`);
80
- ShellExecutor.execWithLog(
81
- `${this.KUBERNETES_COMMAND_LINE_TOOL} delete dwt ${BASE_TEST_CONSTANTS.TS_SELENIUM_EDITOR}-${this.workspaceName} -n ${this.namespace} || true`
101
+ this.shellExecutor.executeCommand(`${this.kubernetesCommandLineTool} delete dw ${this.workspaceName} -n ${this.namespace} || true`);
102
+ this.shellExecutor.executeCommand(
103
+ `${this.kubernetesCommandLineTool} delete dwt ${BASE_TEST_CONSTANTS.TS_SELENIUM_EDITOR}-${this.workspaceName} -n ${this.namespace} || true`
82
104
  );
83
105
  }
84
106
 
85
107
  applyAndWaitDevWorkspace(yamlConfiguration: string): ShellString {
86
- if (this.KUBERNETES_COMMAND_LINE_TOOL === KubernetesCommandLineTool.KUBECTL) {
108
+ Logger.debug(`${this.kubernetesCommandLineTool}`);
109
+
110
+ if (this.kubernetesCommandLineTool === KubernetesCommandLineTool.KUBECTL) {
87
111
  this.createNamespace();
88
112
  }
89
113
  this.applyYamlConfigurationAsStringOutput(yamlConfiguration);
@@ -91,116 +115,124 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
91
115
  }
92
116
 
93
117
  executeCommand(commandToExecute: string, container: string = KubernetesCommandLineToolsExecutor.container): ShellString {
94
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
95
- return ShellExecutor.execWithLog(
96
- `${this.KUBERNETES_COMMAND_LINE_TOOL} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'`
118
+ Logger.debug(`${this.kubernetesCommandLineTool}`);
119
+
120
+ return this.shellExecutor.executeCommand(
121
+ `${this.kubernetesCommandLineTool} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'`
97
122
  );
98
123
  }
99
124
 
100
125
  applyYamlConfigurationAsStringOutput(yamlConfiguration: string): ShellString {
101
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
102
- return ShellExecutor.execWithLog(
103
- `cat <<EOF | ${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f - \n` + yamlConfiguration + '\n' + 'EOF'
126
+ Logger.debug(`${this.kubernetesCommandLineTool}`);
127
+
128
+ return this.shellExecutor.executeCommand(
129
+ `cat <<EOF | ${this.kubernetesCommandLineTool} apply -n ${this.namespace} -f - \n` + yamlConfiguration + '\n' + 'EOF'
130
+ );
131
+ }
132
+
133
+ applyWithoutNamespace(yamlConfiguration: string): ShellString {
134
+ Logger.debug(`${this.kubernetesCommandLineTool}`);
135
+
136
+ return this.shellExecutor.executeCommand(
137
+ `cat <<EOF | ${this.kubernetesCommandLineTool} apply -f - \n` + yamlConfiguration + '\n' + 'EOF'
104
138
  );
105
139
  }
106
140
 
107
141
  applyYamlConfigurationAsFile(pathToFile: string): void {
108
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
109
- ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f "${path.resolve(pathToFile)}"`);
142
+ Logger.debug(`${this.kubernetesCommandLineTool}`);
143
+
144
+ this.shellExecutor.executeCommand(`${this.kubernetesCommandLineTool} apply -n ${this.namespace} -f "${path.resolve(pathToFile)}"`);
110
145
  }
111
146
 
112
147
  getDevWorkspaceYamlConfiguration(): ShellString {
113
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
114
- return ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} get dw ${this.workspaceName} -n ${this.namespace} -o yaml`);
148
+ Logger.debug(`${this.kubernetesCommandLineTool}`);
149
+
150
+ return this.shellExecutor.executeCommand(
151
+ `${this.kubernetesCommandLineTool} get dw ${this.workspaceName} -n ${this.namespace} -o yaml`
152
+ );
115
153
  }
116
154
 
117
155
  waitDevWorkspace(timeout: number = 360): ShellString {
118
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - wait till workspace ready.`);
119
- const output: ShellString = ShellExecutor.execWithLog(
120
- `${this.KUBERNETES_COMMAND_LINE_TOOL} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`
156
+ Logger.debug(`${this.kubernetesCommandLineTool} - wait till workspace ready.`);
157
+
158
+ const output: ShellString = this.shellExecutor.executeCommand(
159
+ `${this.kubernetesCommandLineTool} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`
121
160
  );
122
161
  this.getPodAndContainerNames();
123
162
  return output;
124
163
  }
125
164
 
126
165
  createNamespace(): void {
127
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - create namespace "${this.namespace}".`);
128
- ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} create namespace ${this.namespace}`);
166
+ Logger.debug(`${this.kubernetesCommandLineTool} - create namespace "${this.namespace}".`);
167
+
168
+ this.shellExecutor.executeCommand(`${this.kubernetesCommandLineTool} create namespace ${this.namespace}`);
129
169
  }
130
170
 
131
171
  createProject(projectName: string): void {
132
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - create new project "${projectName}".`);
133
- ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} new-project ${projectName} -n ${this.namespace}`);
172
+ Logger.debug(`${this.kubernetesCommandLineTool} - create new project "${projectName}".`);
173
+
174
+ this.shellExecutor.executeCommand(`${this.kubernetesCommandLineTool} new-project ${projectName} -n ${this.namespace}`);
134
175
  }
135
176
 
136
177
  deleteProject(projectName: string): void {
137
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - delete "${projectName}".`);
138
- ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete project ${projectName} -n ${this.namespace}`);
178
+ Logger.debug(`${this.kubernetesCommandLineTool} - delete "${projectName}".`);
179
+
180
+ this.shellExecutor.executeCommand(`${this.kubernetesCommandLineTool} delete project ${projectName} -n ${this.namespace}`);
139
181
  }
140
182
 
141
- private getPodAndContainerNames(): void {
183
+ getPodAndContainerNames(): void {
184
+ Logger.debug(`${this.kubernetesCommandLineTool}`);
185
+
142
186
  KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
143
187
  KubernetesCommandLineToolsExecutor.container = this.getContainerName();
144
188
  }
145
189
 
146
- private isUserLoggedIn(): boolean {
147
- const whoamiCommandOutput: ShellString = ShellExecutor.execWithLog('oc whoami && oc whoami --show-server=true');
190
+ /**
191
+ * @param userName
192
+ */
193
+ isUserLoggedIn(userName: string): boolean {
194
+ Logger.debug(`${this.kubernetesCommandLineTool}`);
148
195
 
149
- return (
150
- whoamiCommandOutput.stdout.includes(OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME) &&
151
- whoamiCommandOutput.stdout.includes(this.getServerUrl())
152
- );
153
- }
196
+ const whoamiCommandOutput: ShellString = this.shellExecutor.executeCommand('oc whoami && oc whoami --show-server=true');
154
197
 
155
- private setNamespace(_namespace: string | undefined): string {
156
- _namespace =
157
- _namespace !== undefined
158
- ? _namespace
159
- : BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('devspaces')
160
- ? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-devspaces'
161
- : BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('che')
162
- ? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-che'
163
- : 'default';
164
- return _namespace;
198
+ return whoamiCommandOutput.stdout.includes(userName) && whoamiCommandOutput.stdout.includes(this.getServerUrl());
165
199
  }
166
200
 
167
- private getServerUrl(): string {
168
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get server api url.`);
201
+ getServerUrl(): string {
202
+ Logger.debug(`${this.kubernetesCommandLineTool} - get server api url.`);
203
+
169
204
  return BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
170
205
  }
171
206
  }
172
207
 
173
- // eslint-disable-next-line no-redeclare
174
- export namespace KubernetesCommandLineToolsExecutor {
175
- export class ContainerTerminal extends KubernetesCommandLineToolsExecutor {
176
- constructor(cluster: KubernetesCommandLineToolsExecutor) {
177
- super(cluster.getWorkspaceName, cluster.getNamespace);
178
- }
179
-
180
- ls(path: string = ''): ShellString {
181
- return this.executeCommand('ls ' + path);
182
- }
208
+ @injectable()
209
+ export class ContainerTerminal extends KubernetesCommandLineToolsExecutor {
210
+ constructor(
211
+ @inject(CLASSES.ShellExecutor)
212
+ readonly shellExecutor: ShellExecutor,
213
+ @inject(CLASSES.KubernetesCommandLineToolsExecutor)
214
+ readonly cluster: KubernetesCommandLineToolsExecutor
215
+ ) {
216
+ super(shellExecutor);
217
+ }
183
218
 
184
- pwd(): ShellString {
185
- return this.executeCommand('pwd');
186
- }
219
+ ls(path: string = ''): ShellString {
220
+ return this.shellExecutor.executeCommand('ls ' + path);
221
+ }
187
222
 
188
- cd(path: string): ShellString {
189
- return this.executeCommand('cd ' + path);
190
- }
223
+ pwd(): ShellString {
224
+ return this.shellExecutor.executeCommand('pwd');
225
+ }
191
226
 
192
- gitClone(repository: string): ShellString {
193
- return this.executeCommand('git clone ' + repository);
194
- }
227
+ cd(path: string): ShellString {
228
+ return this.shellExecutor.executeCommand('cd ' + path);
229
+ }
195
230
 
196
- removeFolder(path: string): ShellString {
197
- return this.executeCommand('rm -rf ' + path);
198
- }
231
+ gitClone(repository: string): ShellString {
232
+ return this.shellExecutor.executeCommand('git clone ' + repository);
233
+ }
199
234
 
200
- getEnvValue(envName: string): string {
201
- envName = envName.replace(/[${}]/g, '');
202
- const output: ShellString = this.executeCommand(`env | grep ${envName}`);
203
- return output.stderr ? output.stderr : output.stdout.substring(output.stdout.lastIndexOf('=') + 1).replace('\n', '');
204
- }
235
+ removeFolder(path: string): ShellString {
236
+ return this.shellExecutor.executeCommand('rm -rf ' + path);
205
237
  }
206
238
  }
@@ -7,19 +7,22 @@
7
7
  *
8
8
  * SPDX-License-Identifier: EPL-2.0
9
9
  **********************************************************************/
10
- import { echo, exec, ShellString } from 'shelljs';
10
+ import { exec, ShellString } from 'shelljs';
11
+ import { Logger } from './Logger';
12
+ import { injectable } from 'inversify';
11
13
 
14
+ @injectable()
12
15
  export class ShellExecutor {
13
- static wait(seconds: number): void {
14
- this.execWithLog(`sleep ${seconds}s`);
16
+ wait(seconds: number): void {
17
+ this.executeCommand(`sleep ${seconds}s`);
15
18
  }
16
19
 
17
- static curl(link: string): ShellString {
18
- return this.execWithLog(`curl -k ${link}`);
20
+ curl(link: string): ShellString {
21
+ return this.executeCommand(`curl -k ${link}`);
19
22
  }
20
23
 
21
- protected static execWithLog(command: string): ShellString {
22
- echo(command);
24
+ executeCommand(command: string): ShellString {
25
+ Logger.debug(command);
23
26
  return exec(command);
24
27
  }
25
28
  }
@@ -8,8 +8,8 @@
8
8
  * SPDX-License-Identifier: EPL-2.0
9
9
  **********************************************************************/
10
10
 
11
- import { injectable } from 'inversify';
12
11
  import { Logger } from './Logger';
12
+ import { injectable } from 'inversify';
13
13
 
14
14
  @injectable()
15
15
  export class StringUtil {
@@ -22,6 +22,7 @@ export class StringUtil {
22
22
  */
23
23
  static getProjectNameFromGitUrl(url: string): string {
24
24
  Logger.debug(`${url}`);
25
+
25
26
  if (url.includes('?')) {
26
27
  url = url.substring(0, url.indexOf('?'));
27
28
  }
@@ -37,6 +38,8 @@ export class StringUtil {
37
38
  }
38
39
 
39
40
  static sanitizeTitle(arg: string): string {
41
+ Logger.trace();
42
+
40
43
  return arg
41
44
  .replace(/\//g, '+')
42
45
  .replace(/,/g, '.')
@@ -52,6 +55,8 @@ export class StringUtil {
52
55
  */
53
56
 
54
57
  static updateCommandEnvsToShStyle(command: string): string {
58
+ Logger.trace();
59
+
55
60
  return command.replace(/[{}]/g, '').replace(/(?<!")\${?[a-zA-Z0-9_+\-\s]+\b}?/gm, '"$&"');
56
61
  }
57
62
  }