@@ -117,7 +117,7 @@ func TestPermissions(t *testing.T) {
117117 ctx .ConfigureForTest (t )
118118
119119 onPermissionRequest := func (request copilot.PermissionRequest , invocation copilot.PermissionInvocation ) (copilot.PermissionRequestResult , error ) {
120- return copilot.PermissionRequestResult {Kind : "denied-interactively-by -user" }, nil
120+ return copilot.PermissionRequestResult {Kind : "denied-no-approval-rule-and-could-not-request-from -user" }, nil
121121 }
122122
123123 session , err := client .CreateSession (t .Context (), & copilot.SessionConfig {
@@ -157,10 +157,14 @@ func TestPermissions(t *testing.T) {
157157 }
158158 })
159159
160- t .Run ("should deny tool operations by default when no handler is provided " , func (t * testing.T ) {
160+ t .Run ("should deny tool operations when handler explicitly denies " , func (t * testing.T ) {
161161 ctx .ConfigureForTest (t )
162162
163- session , err := client .CreateSession (t .Context (), nil )
163+ session , err := client .CreateSession (t .Context (), & copilot.SessionConfig {
164+ OnPermissionRequest : func (request copilot.PermissionRequest , invocation copilot.ToolInvocation ) (copilot.PermissionRequestResult , error ) {
165+ return copilot.PermissionRequestResult {Kind : "denied-no-approval-rule-and-could-not-request-from-user" }, nil
166+ },
167+ })
164168 if err != nil {
165169 t .Fatalf ("Failed to create session: %v" , err )
166170 }
@@ -192,7 +196,7 @@ func TestPermissions(t *testing.T) {
192196 }
193197 })
194198
195- t .Run ("should deny tool operations by default when no handler is provided after resume" , func (t * testing.T ) {
199+ t .Run ("should deny tool operations when handler explicitly denies after resume" , func (t * testing.T ) {
196200 ctx .ConfigureForTest (t )
197201
198202 session1 , err := client .CreateSession (t .Context (), & copilot.SessionConfig {
@@ -206,7 +210,11 @@ func TestPermissions(t *testing.T) {
206210 t .Fatalf ("Failed to send message: %v" , err )
207211 }
208212
209- session2 , err := client .ResumeSession (t .Context (), sessionID )
213+ session2 , err := client .ResumeSession (t .Context (), sessionID , & copilot.ResumeSessionConfig {
214+ OnPermissionRequest : func (request copilot.PermissionRequest , invocation copilot.ToolInvocation ) (copilot.PermissionRequestResult , error ) {
215+ return copilot.PermissionRequestResult {Kind : "denied-no-approval-rule-and-could-not-request-from-user" }, nil
216+ },
217+ })
210218 if err != nil {
211219 t .Fatalf ("Failed to resume session: %v" , err )
212220 }
@@ -238,10 +246,12 @@ func TestPermissions(t *testing.T) {
238246 }
239247 })
240248
241- t .Run ("without permission handler" , func (t * testing.T ) {
249+ t .Run ("should work with approve-all permission handler" , func (t * testing.T ) {
242250 ctx .ConfigureForTest (t )
243251
244- session , err := client .CreateSession (t .Context (), nil )
252+ session , err := client .CreateSession (t .Context (), & copilot.SessionConfig {
253+ OnPermissionRequest : copilot .PermissionHandler .ApproveAll ,
254+ })
245255 if err != nil {
246256 t .Fatalf ("Failed to create session: %v" , err )
247257 }
0 commit comments