@@ -22,6 +22,7 @@ import {
2222import { StartDevEnvironmentSessionRequest } from 'aws-sdk/clients/codecatalyst'
2323import { mkdir , readFile , writeFile } from 'fs/promises'
2424import fs from '../../shared/fs/fs'
25+ import { globals } from '../../shared'
2526
2627class MockSshConfig extends SshConfig {
2728 // State variables to track logic flow.
@@ -181,22 +182,15 @@ describe('VscodeRemoteSshConfig', async function () {
181182} )
182183
183184describe ( 'CodeCatalyst Connect Script' , function ( ) {
184- let context : FakeExtensionContext
185-
186185 function isWithin ( path1 : string , path2 : string ) : boolean {
187186 const rel = path . relative ( path1 , path2 )
188187 return ! path . isAbsolute ( rel ) && ! rel . startsWith ( '..' ) && ! ! rel
189188 }
190189
191- beforeEach ( async function ( ) {
192- context = await FakeExtensionContext . create ( )
193- context . globalStorageUri = vscode . Uri . file ( await makeTemporaryToolkitFolder ( ) )
194- } )
195-
196190 it ( 'can get a connect script path, adding a copy to global storage' , async function ( ) {
197- const script = ( await ensureConnectScript ( connectScriptPrefix , context ) ) . unwrap ( ) . fsPath
191+ const script = ( await ensureConnectScript ( connectScriptPrefix , globals . context ) ) . unwrap ( ) . fsPath
198192 assert . ok ( await fileExists ( script ) )
199- assert . ok ( isWithin ( context . globalStorageUri . fsPath , script ) )
193+ assert . ok ( isWithin ( globals . context . globalStorageUri . fsPath , script ) )
200194 } )
201195
202196 function createFakeServer ( testDevEnv : DevEnvironmentId ) {
@@ -247,8 +241,8 @@ describe('CodeCatalyst Connect Script', function () {
247241 server . listen ( { host : 'localhost' , port : 28142 } , ( ) => resolve ( `http://localhost:28142` ) )
248242 } )
249243
250- await writeFile ( bearerTokenCacheLocation ( testDevEnv . id ) , 'token' )
251- const script = ( await ensureConnectScript ( connectScriptPrefix , context ) ) . unwrap ( ) . fsPath
244+ await fs . writeFile ( bearerTokenCacheLocation ( testDevEnv . id ) , 'token' )
245+ const script = ( await ensureConnectScript ( connectScriptPrefix , globals . context ) ) . unwrap ( ) . fsPath
252246 const env = getCodeCatalystSsmEnv ( 'us-weast-1' , 'echo' , testDevEnv )
253247 env . CODECATALYST_ENDPOINT = address
254248
@@ -280,12 +274,12 @@ describe('CodeCatalyst Connect Script', function () {
280274 } )
281275
282276 it ( 'works if the .ssh directory is missing' , async function ( ) {
283- ; ( await ensureConnectScript ( connectScriptPrefix , context ) ) . unwrap ( )
277+ ; ( await ensureConnectScript ( connectScriptPrefix , globals . context ) ) . unwrap ( )
284278 } )
285279
286280 it ( 'works if the .ssh directory exists but has different perms' , async function ( ) {
287281 await mkdir ( path . join ( tmpDir , '.ssh' ) , 0o777 )
288- ; ( await ensureConnectScript ( connectScriptPrefix , context ) ) . unwrap ( )
282+ ; ( await ensureConnectScript ( connectScriptPrefix , globals . context ) ) . unwrap ( )
289283 } )
290284 } )
291285} )
0 commit comments