@@ -252,6 +252,40 @@ func TestActionsService_GetActionsAllowed(t *testing.T) {
252252 })
253253}
254254
255+ func TestActionsService_GetActionsAllowed_emptyPatterns (t * testing.T ) {
256+ t .Parallel ()
257+ client , mux , _ := setup (t )
258+
259+ mux .HandleFunc ("/orgs/o/actions/permissions/selected-actions" , func (w http.ResponseWriter , r * http.Request ) {
260+ testMethod (t , r , "GET" )
261+ fmt .Fprint (w , `{"github_owned_allowed":true, "verified_allowed":false, "patterns_allowed":[]}` )
262+ })
263+
264+ ctx := t .Context ()
265+ org , _ , err := client .Actions .GetActionsAllowed (ctx , "o" )
266+ if err != nil {
267+ t .Errorf ("Actions.GetActionsAllowed returned error: %v" , err )
268+ }
269+ want := & ActionsAllowed {GithubOwnedAllowed : Ptr (true ), VerifiedAllowed : Ptr (false ), PatternsAllowed : []string {}}
270+ if ! cmp .Equal (org , want ) {
271+ t .Errorf ("Actions.GetActionsAllowed returned %+v, want %+v" , org , want )
272+ }
273+
274+ const methodName = "GetActionsAllowed"
275+ testBadOptions (t , methodName , func () (err error ) {
276+ _ , _ , err = client .Actions .GetActionsAllowed (ctx , "\n " )
277+ return err
278+ })
279+
280+ testNewRequestAndDoFailure (t , methodName , client , func () (* Response , error ) {
281+ got , resp , err := client .Actions .GetActionsAllowed (ctx , "o" )
282+ if got != nil {
283+ t .Errorf ("testNewRequestAndDoFailure %v = %#v, want nil" , methodName , got )
284+ }
285+ return resp , err
286+ })
287+ }
288+
255289func TestActionsService_UpdateActionsAllowed (t * testing.T ) {
256290 t .Parallel ()
257291 client , mux , _ := setup (t )
@@ -290,6 +324,78 @@ func TestActionsService_UpdateActionsAllowed(t *testing.T) {
290324 })
291325}
292326
327+ func TestActionsService_UpdateActionsAllowed_emptyPatterns (t * testing.T ) {
328+ t .Parallel ()
329+ client , mux , _ := setup (t )
330+
331+ input := & ActionsAllowed {GithubOwnedAllowed : Ptr (true ), VerifiedAllowed : Ptr (false ), PatternsAllowed : []string {}}
332+
333+ mux .HandleFunc ("/orgs/o/actions/permissions/selected-actions" , func (w http.ResponseWriter , r * http.Request ) {
334+ testMethod (t , r , "PUT" )
335+ testJSONBody (t , r , input )
336+ fmt .Fprint (w , `{"github_owned_allowed":true, "verified_allowed":false, "patterns_allowed":[]}` )
337+ })
338+
339+ ctx := t .Context ()
340+ org , _ , err := client .Actions .UpdateActionsAllowed (ctx , "o" , * input )
341+ if err != nil {
342+ t .Errorf ("Actions.UpdateActionsAllowed returned error: %v" , err )
343+ }
344+
345+ want := & ActionsAllowed {GithubOwnedAllowed : Ptr (true ), VerifiedAllowed : Ptr (false ), PatternsAllowed : []string {}}
346+ if ! cmp .Equal (org , want ) {
347+ t .Errorf ("Actions.UpdateActionsAllowed returned %+v, want %+v" , org , want )
348+ }
349+ }
350+
351+ func TestActionsService_UpdateActionsAllowed_nilPatterns (t * testing.T ) {
352+ t .Parallel ()
353+ client , mux , _ := setup (t )
354+
355+ input := & ActionsAllowed {GithubOwnedAllowed : Ptr (true ), VerifiedAllowed : Ptr (false ), PatternsAllowed : nil }
356+
357+ mux .HandleFunc ("/orgs/o/actions/permissions/selected-actions" , func (w http.ResponseWriter , r * http.Request ) {
358+ testMethod (t , r , "PUT" )
359+ testJSONBody (t , r , input )
360+ fmt .Fprint (w , `{"github_owned_allowed":true, "verified_allowed":false, "patterns_allowed":["a/b"]}` )
361+ })
362+
363+ ctx := t .Context ()
364+ org , _ , err := client .Actions .UpdateActionsAllowed (ctx , "o" , * input )
365+ if err != nil {
366+ t .Errorf ("Actions.UpdateActionsAllowed returned error: %v" , err )
367+ }
368+
369+ want := & ActionsAllowed {GithubOwnedAllowed : Ptr (true ), VerifiedAllowed : Ptr (false ), PatternsAllowed : []string {"a/b" }}
370+ if ! cmp .Equal (org , want ) {
371+ t .Errorf ("Actions.UpdateActionsAllowed returned %+v, want %+v" , org , want )
372+ }
373+ }
374+
375+ func TestActionsService_UpdateActionsAllowed_omittedPatterns (t * testing.T ) {
376+ t .Parallel ()
377+ client , mux , _ := setup (t )
378+
379+ input := & ActionsAllowed {GithubOwnedAllowed : Ptr (true ), VerifiedAllowed : Ptr (false )}
380+
381+ mux .HandleFunc ("/orgs/o/actions/permissions/selected-actions" , func (w http.ResponseWriter , r * http.Request ) {
382+ testMethod (t , r , "PUT" )
383+ testJSONBody (t , r , input )
384+ fmt .Fprint (w , `{"github_owned_allowed":true, "verified_allowed":false, "patterns_allowed":["a/b"]}` )
385+ })
386+
387+ ctx := t .Context ()
388+ org , _ , err := client .Actions .UpdateActionsAllowed (ctx , "o" , * input )
389+ if err != nil {
390+ t .Errorf ("Actions.UpdateActionsAllowed returned error: %v" , err )
391+ }
392+
393+ want := & ActionsAllowed {GithubOwnedAllowed : Ptr (true ), VerifiedAllowed : Ptr (false ), PatternsAllowed : []string {"a/b" }}
394+ if ! cmp .Equal (org , want ) {
395+ t .Errorf ("Actions.UpdateActionsAllowed returned %+v, want %+v" , org , want )
396+ }
397+ }
398+
293399func TestActionsService_GetDefaultWorkflowPermissionsInOrganization (t * testing.T ) {
294400 t .Parallel ()
295401 client , mux , _ := setup (t )
0 commit comments