@@ -6,6 +6,7 @@ import { MementoManager } from "@/core/mementoManager";
66import { PathResolver } from "@/core/pathResolver" ;
77import { SecretsManager } from "@/core/secretsManager" ;
88import { Remote , workspaceLabelSuffix } from "@/remote/remote" ;
9+ import { escapeCommandArg } from "@/util" ;
910
1011import { createTestTelemetryService } from "../../mocks/telemetry" ;
1112import {
@@ -50,13 +51,20 @@ const CLI_AUTH: CliAuth = {
5051 allowRedirects : false ,
5152} ;
5253
54+ const PATH_RESOLVER = new PathResolver ( "/mock/global" , "/mock/log" ) ;
55+ // Paths are separated and quoted per platform, so build them the same way.
56+ const NETWORK_INFO_DIR = escapeCommandArg ( PATH_RESOLVER . getNetworkInfoPath ( ) ) ;
57+ const SESSION_TOKEN_FILE = escapeCommandArg (
58+ PATH_RESOLVER . getSessionTokenPath ( SAFE_HOSTNAME ) ,
59+ ) ;
60+ const URL_FILE = escapeCommandArg ( PATH_RESOLVER . getUrlPath ( SAFE_HOSTNAME ) ) ;
61+
5362function createRemote ( logger : Logger = createMockLogger ( ) ) {
5463 new MockConfigurationProvider ( ) ;
5564 const userInteraction = new MockUserInteraction ( ) ;
56- const pathResolver = new PathResolver ( "/mock/global" , "/mock/log" ) ;
5765 vol . fromJSON ( {
58- [ pathResolver . getUrlPath ( SAFE_HOSTNAME ) ] : MISMATCHED_URL ,
59- [ pathResolver . getSessionTokenPath ( SAFE_HOSTNAME ) ] : SESSION_TOKEN ,
66+ [ PATH_RESOLVER . getUrlPath ( SAFE_HOSTNAME ) ] : MISMATCHED_URL ,
67+ [ PATH_RESOLVER . getSessionTokenPath ( SAFE_HOSTNAME ) ] : SESSION_TOKEN ,
6068 } ) ;
6169 const secretsManager = new SecretsManager (
6270 new InMemorySecretStorage ( ) ,
@@ -69,7 +77,7 @@ function createRemote(logger: Logger = createMockLogger()) {
6977 const mementoManager = new MementoManager ( new InMemoryMemento ( ) ) ;
7078 const serviceContainer = createMockServiceContainer ( {
7179 logger,
72- pathResolver,
80+ pathResolver : PATH_RESOLVER ,
7381 mementoManager,
7482 cliManager : { } as CliManager ,
7583 contextManager : {
@@ -246,15 +254,13 @@ describe("ProxyCommand", () => {
246254 name : "appends disable-autostart after user SSH flags" ,
247255 wildcard : true ,
248256 flags : [ "--disable-autostart=false" , "--wait=yes" ] ,
249- expected :
250- "/mock/coder --global-config /mock/global --url https://coder.example.com ssh --disable-autostart=false --wait=yes --disable-autostart --stdio --usage-app=vscode --network-info-dir /mock/global/net --ssh-host-prefix coder-vscode.coder.example.com-- %h" ,
257+ expected : `/mock/coder --global-config /mock/global --url https://coder.example.com ssh --disable-autostart=false --wait=yes --disable-autostart --stdio --usage-app=vscode --network-info-dir ${ NETWORK_INFO_DIR } --ssh-host-prefix coder-vscode.coder.example.com-- %h` ,
251258 } ,
252259 {
253260 name : "keeps disable-autostart out of the legacy vscodessh command" ,
254261 wildcard : false ,
255262 flags : [ "--disable-autostart" , "--wait=yes" ] ,
256- expected :
257- "/mock/coder --global-config /mock/global --url https://coder.example.com vscodessh --network-info-dir /mock/global/net --session-token-file /mock/global/coder.example.com/session --url-file /mock/global/coder.example.com/url %h" ,
263+ expected : `/mock/coder --global-config /mock/global --url https://coder.example.com vscodessh --network-info-dir ${ NETWORK_INFO_DIR } --session-token-file ${ SESSION_TOKEN_FILE } --url-file ${ URL_FILE } %h` ,
258264 } ,
259265 ] ) ( "$name" , async ( { wildcard, flags, expected } ) => {
260266 const { remote } = createRemote ( ) ;
0 commit comments