diff --git a/dashboard/src/app/diagnostics/test/diagnostics-workspace-check-workspace.factory.ts b/dashboard/src/app/diagnostics/test/diagnostics-workspace-check-workspace.factory.ts index 28fa1e91f1a..385a6144e27 100644 --- a/dashboard/src/app/diagnostics/test/diagnostics-workspace-check-workspace.factory.ts +++ b/dashboard/src/app/diagnostics/test/diagnostics-workspace-check-workspace.factory.ts @@ -157,6 +157,7 @@ export class DiagnosticsRunningWorkspaceCheck { */ checkWebSocketWsAgent(diagnosticCallback : DiagnosticCallback) : ng.IPromise { let workspace: che.IWorkspace = diagnosticCallback.getShared('workspace'); + let machineToken: string = diagnosticCallback.getShared('machineToken'); let wsAgentSocketWebLink = this.lodash.find(workspace.runtime.links, (link: any) => { return link.rel === 'wsagent.websocket'; @@ -166,6 +167,10 @@ export class DiagnosticsRunningWorkspaceCheck { } else { wsAgentSocketWebLink = wsAgentSocketWebLink.href; } + if (machineToken) { + wsAgentSocketWebLink += '?token=' + machineToken; + } + let wsAgentRemoteBus : MessageBus = this.cheWebsocket.getRemoteBus(wsAgentSocketWebLink); diagnosticCallback.setMessageBus(wsAgentRemoteBus); @@ -201,8 +206,15 @@ export class DiagnosticsRunningWorkspaceCheck { * @returns {Promise} */ callSCM(diagnosticCallback : DiagnosticCallback, wsAgentHRef : string, errorInsteadOfFailure : boolean) : ng.IPromise { + + let uriWsAgent : string = wsAgentHRef + '/'; + let machineToken: string = diagnosticCallback.getShared('machineToken'); + if (machineToken) { + uriWsAgent += '?token=' + machineToken; + } + // connect to the workspace agent - let resourceAPI : any = this.$resource(wsAgentHRef + '/', {}, { + let resourceAPI : any = this.$resource(uriWsAgent, {}, { getDetails: {method: 'OPTIONS', timeout : 15000} }, { stripTrailingSlashes: false diff --git a/dashboard/src/app/diagnostics/test/diagnostics-workspace-start-check.factory.ts b/dashboard/src/app/diagnostics/test/diagnostics-workspace-start-check.factory.ts index 714aaa98bea..9a8e2365290 100644 --- a/dashboard/src/app/diagnostics/test/diagnostics-workspace-start-check.factory.ts +++ b/dashboard/src/app/diagnostics/test/diagnostics-workspace-start-check.factory.ts @@ -206,8 +206,11 @@ export class DiagnosticsWorkspaceStartCheck { this.workspaceCallback.stateRunning('RUNNING'); this.cheWorkspace.fetchWorkspaces().then(() => { let workspace = diagnosticCallback.getShared('workspace'); + let workspaceId = workspace.id; this.cheWorkspace.fetchWorkspaceDetails(workspace.id).then(() => { - diagnosticCallback.shared('workspace', this.cheWorkspace.getWorkspaceById(workspace.id)); + let workspace = this.cheWorkspace.getWorkspaceById(workspaceId); + diagnosticCallback.shared('workspace', workspace); + diagnosticCallback.shared('machineToken', workspace.runtime.devMachine.runtime.envVariables['USER_TOKEN']); diagnosticCallback.success('Starting workspace OK'); }) }); @@ -248,8 +251,11 @@ export class DiagnosticsWorkspaceStartCheck { } hint += 'specific to your environment. See the `' + this.cheBranding.getCLI().configName + '` file for specifics.'; diagnosticCallback.notifyFailure('The workspace started, but ' + this.cheBranding.getName() + ' <--> Workspace connection not established', hint); + let workspaceId = workspace.id; this.cheWorkspace.fetchWorkspaceDetails(workspace.id).then(() => { - diagnosticCallback.shared('workspace', this.cheWorkspace.getWorkspaceById(workspace.id)); + let workspace = this.cheWorkspace.getWorkspaceById(workspaceId); + diagnosticCallback.shared('workspace', workspace); + diagnosticCallback.shared('machineToken', workspace.runtime.devMachine.runtime.envVariables['USER_TOKEN']); let newCallback : DiagnosticCallback = diagnosticCallback.newCallback('Test connection from browser to workspace agent by using Workspace Agent IP'); this.diagnosticsRunningWorkspaceCheck.checkWsAgent(newCallback, false); let websocketCallback : DiagnosticCallback = diagnosticCallback.newCallback('Test connection from browser to workspace agent with websocket');