@@ -17,8 +17,6 @@ import { approveAll, defineTool, createAttributedPermissionResult } from "../../
1717import { createSdkTestContext , isInProcessTransport } from "./harness/sdkTestContext.js" ;
1818import { getFinalAssistantMessage , getNextEventOfType } from "./harness/sdkTestHelper.js" ;
1919
20- const isWindows = process . platform === "win32" ;
21-
2220describe ( "Permission callbacks" , async ( ) => {
2321 const { copilotClient : client , workDir } = await createSdkTestContext ( ) ;
2422
@@ -632,76 +630,67 @@ describe("Permission callbacks", async () => {
632630 }
633631 } ) ;
634632
635- // TODO(cli-1.0.81-2): CLI 1.0.81-2 no longer matches the location key returned by
636- // permissions.locations.resolve when permissions.locations.apply re-resolves it on Windows,
637- // so appliedRuleCount comes back as 0. Still covered on Linux and macOS.
638- it . skipIf ( isWindows ) (
639- "should invoke permission location and folder trust rpc apis" ,
640- async ( ) => {
641- const session = await client . createSession ( { onPermissionRequest : approveAll } ) ;
642- const locationDirectory = await createUniqueWorkDirectory (
643- workDir ,
644- "permission-location"
645- ) ;
646- const trustedDirectory = await createUniqueWorkDirectory ( workDir , "folder-trust" ) ;
647- const commandIdentifier = `node-permission-location-${ Date . now ( ) } ` ;
648- try {
649- const resolved = await session . rpc . permissions . locations . resolve ( {
650- workingDirectory : locationDirectory ,
651- } ) ;
652- expect ( resolved . locationType ) . toBe ( "dir" ) ;
653- expectPathEqual ( resolved . locationKey , locationDirectory ) ;
654-
655- expect (
656- (
657- await session . rpc . permissions . locations . addToolApproval ( {
658- locationKey : resolved . locationKey ,
659- approval : {
660- kind : "commands" ,
661- commandIdentifiers : [ commandIdentifier ] ,
662- } ,
663- } )
664- ) . success
665- ) . toBe ( true ) ;
666-
667- const applied = await session . rpc . permissions . locations . apply ( {
668- workingDirectory : locationDirectory ,
669- } ) ;
670- expect ( applied . locationType ) . toBe ( resolved . locationType ) ;
671- expectPathEqual ( applied . locationKey , resolved . locationKey ) ;
672- expect ( applied . appliedRuleCount ) . toBeGreaterThanOrEqual ( 1 ) ;
673- expect (
674- applied . appliedRules . some (
675- ( rule ) => rule . kind === "shell" && rule . argument === commandIdentifier
676- )
677- ) . toBe ( true ) ;
678-
679- expect (
680- (
681- await session . rpc . permissions . folderTrust . isTrusted ( {
682- path : trustedDirectory ,
683- } )
684- ) . trusted
685- ) . toBe ( false ) ;
686- expect (
687- (
688- await session . rpc . permissions . folderTrust . addTrusted ( {
689- path : trustedDirectory ,
690- } )
691- ) . success
692- ) . toBe ( true ) ;
693- expect (
694- (
695- await session . rpc . permissions . folderTrust . isTrusted ( {
696- path : trustedDirectory ,
697- } )
698- ) . trusted
699- ) . toBe ( true ) ;
700- } finally {
701- await session . disconnect ( ) ;
702- }
633+ it ( "should invoke permission location and folder trust rpc apis" , async ( ) => {
634+ const session = await client . createSession ( { onPermissionRequest : approveAll } ) ;
635+ const locationDirectory = await createUniqueWorkDirectory ( workDir , "permission-location" ) ;
636+ const trustedDirectory = await createUniqueWorkDirectory ( workDir , "folder-trust" ) ;
637+ const commandIdentifier = `node-permission-location-${ Date . now ( ) } ` ;
638+ try {
639+ const resolved = await session . rpc . permissions . locations . resolve ( {
640+ workingDirectory : locationDirectory ,
641+ } ) ;
642+ expect ( resolved . locationType ) . toBe ( "dir" ) ;
643+ expectPathEqual ( resolved . locationKey , locationDirectory ) ;
644+
645+ expect (
646+ (
647+ await session . rpc . permissions . locations . addToolApproval ( {
648+ locationKey : resolved . locationKey ,
649+ approval : {
650+ kind : "commands" ,
651+ commandIdentifiers : [ commandIdentifier ] ,
652+ } ,
653+ } )
654+ ) . success
655+ ) . toBe ( true ) ;
656+
657+ const applied = await session . rpc . permissions . locations . apply ( {
658+ workingDirectory : locationDirectory ,
659+ } ) ;
660+ expect ( applied . locationType ) . toBe ( resolved . locationType ) ;
661+ expectPathEqual ( applied . locationKey , resolved . locationKey ) ;
662+ expect ( applied . appliedRuleCount ) . toBeGreaterThanOrEqual ( 1 ) ;
663+ expect (
664+ applied . appliedRules . some (
665+ ( rule ) => rule . kind === "shell" && rule . argument === commandIdentifier
666+ )
667+ ) . toBe ( true ) ;
668+
669+ expect (
670+ (
671+ await session . rpc . permissions . folderTrust . isTrusted ( {
672+ path : trustedDirectory ,
673+ } )
674+ ) . trusted
675+ ) . toBe ( false ) ;
676+ expect (
677+ (
678+ await session . rpc . permissions . folderTrust . addTrusted ( {
679+ path : trustedDirectory ,
680+ } )
681+ ) . success
682+ ) . toBe ( true ) ;
683+ expect (
684+ (
685+ await session . rpc . permissions . folderTrust . isTrusted ( {
686+ path : trustedDirectory ,
687+ } )
688+ ) . trusted
689+ ) . toBe ( true ) ;
690+ } finally {
691+ await session . disconnect ( ) ;
703692 }
704- ) ;
693+ } ) ;
705694} ) ;
706695
707696async function createUniqueWorkDirectory ( baseDir : string , prefix : string ) : Promise < string > {
0 commit comments