From 1d8a033aa260903936e7e088a80f0b4675c9e688 Mon Sep 17 00:00:00 2001 From: Leonard Sheng Sheng Lee Date: Thu, 6 Nov 2025 16:21:33 +0100 Subject: [PATCH 1/2] feat(actions_permissions): sha_pinning_required Signed-off-by: Leonard Sheng Sheng Lee --- github/actions_permissions_orgs.go | 1 + github/actions_permissions_orgs_test.go | 14 ++++++++------ github/repos_actions_permissions.go | 1 + github/repos_actions_permissions_test.go | 14 ++++++++------ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/github/actions_permissions_orgs.go b/github/actions_permissions_orgs.go index 64e692d70a3..d6d49fbc042 100644 --- a/github/actions_permissions_orgs.go +++ b/github/actions_permissions_orgs.go @@ -17,6 +17,7 @@ type ActionsPermissions struct { EnabledRepositories *string `json:"enabled_repositories,omitempty"` AllowedActions *string `json:"allowed_actions,omitempty"` SelectedActionsURL *string `json:"selected_actions_url,omitempty"` + ShaPinningRequired *bool `json:"sha_pinning_required,omitempty"` } func (a ActionsPermissions) String() string { diff --git a/github/actions_permissions_orgs_test.go b/github/actions_permissions_orgs_test.go index 9d213423b9a..42efecd40c3 100644 --- a/github/actions_permissions_orgs_test.go +++ b/github/actions_permissions_orgs_test.go @@ -20,7 +20,7 @@ func TestActionsService_GetActionsPermissions(t *testing.T) { mux.HandleFunc("/orgs/o/actions/permissions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"enabled_repositories": "all", "allowed_actions": "all"}`) + fmt.Fprint(w, `{"enabled_repositories": "all", "allowed_actions": "all", "sha_pinning_required": true}`) }) ctx := t.Context() @@ -28,7 +28,7 @@ func TestActionsService_GetActionsPermissions(t *testing.T) { if err != nil { t.Errorf("Actions.GetActionsPermissions returned error: %v", err) } - want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("all")} + want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("all"), ShaPinningRequired: Ptr(true)} if !cmp.Equal(org, want) { t.Errorf("Actions.GetActionsPermissions returned %+v, want %+v", org, want) } @@ -52,7 +52,7 @@ func TestActionsService_UpdateActionsPermissions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected")} + input := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected"), ShaPinningRequired: Ptr(true)} mux.HandleFunc("/orgs/o/actions/permissions", func(w http.ResponseWriter, r *http.Request) { v := new(ActionsPermissions) @@ -63,7 +63,7 @@ func TestActionsService_UpdateActionsPermissions(t *testing.T) { t.Errorf("Request body = %+v, want %+v", v, input) } - fmt.Fprint(w, `{"enabled_repositories": "all", "allowed_actions": "selected"}`) + fmt.Fprint(w, `{"enabled_repositories": "all", "allowed_actions": "selected", "sha_pinning_required": true}`) }) ctx := t.Context() @@ -72,7 +72,7 @@ func TestActionsService_UpdateActionsPermissions(t *testing.T) { t.Errorf("Actions.UpdateActionsPermissions returned error: %v", err) } - want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected")} + want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected"), ShaPinningRequired: Ptr(true)} if !cmp.Equal(org, want) { t.Errorf("Actions.UpdateActionsPermissions returned %+v, want %+v", org, want) } @@ -326,12 +326,14 @@ func TestActionsPermissions_Marshal(t *testing.T) { EnabledRepositories: Ptr("e"), AllowedActions: Ptr("a"), SelectedActionsURL: Ptr("sau"), + ShaPinningRequired: Ptr(true), } want := `{ "enabled_repositories": "e", "allowed_actions": "a", - "selected_actions_url": "sau" + "selected_actions_url": "sau", + "sha_pinning_required": true }` testJSONMarshal(t, u, want) diff --git a/github/repos_actions_permissions.go b/github/repos_actions_permissions.go index 751fd79a894..2232a90c989 100644 --- a/github/repos_actions_permissions.go +++ b/github/repos_actions_permissions.go @@ -17,6 +17,7 @@ type ActionsPermissionsRepository struct { Enabled *bool `json:"enabled,omitempty"` AllowedActions *string `json:"allowed_actions,omitempty"` SelectedActionsURL *string `json:"selected_actions_url,omitempty"` + ShaPinningRequired *bool `json:"sha_pinning_required,omitempty"` } func (a ActionsPermissionsRepository) String() string { diff --git a/github/repos_actions_permissions_test.go b/github/repos_actions_permissions_test.go index 8d07eb7a676..b750d390b8f 100644 --- a/github/repos_actions_permissions_test.go +++ b/github/repos_actions_permissions_test.go @@ -20,7 +20,7 @@ func TestRepositoriesService_GetActionsPermissions(t *testing.T) { mux.HandleFunc("/repos/o/r/actions/permissions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") - fmt.Fprint(w, `{"enabled": true, "allowed_actions": "all"}`) + fmt.Fprint(w, `{"enabled": true, "allowed_actions": "all", "sha_pinning_required": true}`) }) ctx := t.Context() @@ -28,7 +28,7 @@ func TestRepositoriesService_GetActionsPermissions(t *testing.T) { if err != nil { t.Errorf("Repositories.GetActionsPermissions returned error: %v", err) } - want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("all")} + want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("all"), ShaPinningRequired: Ptr(true)} if !cmp.Equal(org, want) { t.Errorf("Repositories.GetActionsPermissions returned %+v, want %+v", org, want) } @@ -52,7 +52,7 @@ func TestRepositoriesService_UpdateActionsPermissions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected")} + input := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected"), ShaPinningRequired: Ptr(true)} mux.HandleFunc("/repos/o/r/actions/permissions", func(w http.ResponseWriter, r *http.Request) { v := new(ActionsPermissionsRepository) @@ -63,7 +63,7 @@ func TestRepositoriesService_UpdateActionsPermissions(t *testing.T) { t.Errorf("Request body = %+v, want %+v", v, input) } - fmt.Fprint(w, `{"enabled": true, "allowed_actions": "selected"}`) + fmt.Fprint(w, `{"enabled": true, "allowed_actions": "selected", "sha_pinning_required": true}`) }) ctx := t.Context() @@ -72,7 +72,7 @@ func TestRepositoriesService_UpdateActionsPermissions(t *testing.T) { t.Errorf("Repositories.UpdateActionsPermissions returned error: %v", err) } - want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected")} + want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected"), ShaPinningRequired: Ptr(true)} if !cmp.Equal(org, want) { t.Errorf("Repositories.UpdateActionsPermissions returned %+v, want %+v", org, want) } @@ -100,12 +100,14 @@ func TestActionsPermissionsRepository_Marshal(t *testing.T) { Enabled: Ptr(true), AllowedActions: Ptr("all"), SelectedActionsURL: Ptr("someURL"), + ShaPinningRequired: Ptr(true), } want := `{ "enabled": true, "allowed_actions": "all", - "selected_actions_url": "someURL" + "selected_actions_url": "someURL", + "sha_pinning_required": true }` testJSONMarshal(t, u, want) From cb55bd57dae27a5f9f51e3882ba2f023b3a7eaed Mon Sep 17 00:00:00 2001 From: Leonard Sheng Sheng Lee Date: Thu, 6 Nov 2025 17:08:56 +0100 Subject: [PATCH 2/2] fix(actions_permissions): sha_pinning_required Signed-off-by: Leonard Sheng Sheng Lee --- github/actions_permissions_orgs.go | 2 +- github/actions_permissions_orgs_test.go | 8 ++++---- github/github-accessors.go | 16 ++++++++++++++++ github/github-accessors_test.go | 22 ++++++++++++++++++++++ github/github-stringify_test.go | 6 ++++-- github/repos_actions_permissions.go | 2 +- github/repos_actions_permissions_test.go | 8 ++++---- 7 files changed, 52 insertions(+), 12 deletions(-) diff --git a/github/actions_permissions_orgs.go b/github/actions_permissions_orgs.go index d6d49fbc042..626e3998303 100644 --- a/github/actions_permissions_orgs.go +++ b/github/actions_permissions_orgs.go @@ -17,7 +17,7 @@ type ActionsPermissions struct { EnabledRepositories *string `json:"enabled_repositories,omitempty"` AllowedActions *string `json:"allowed_actions,omitempty"` SelectedActionsURL *string `json:"selected_actions_url,omitempty"` - ShaPinningRequired *bool `json:"sha_pinning_required,omitempty"` + SHAPinningRequired *bool `json:"sha_pinning_required,omitempty"` } func (a ActionsPermissions) String() string { diff --git a/github/actions_permissions_orgs_test.go b/github/actions_permissions_orgs_test.go index 42efecd40c3..c42405795df 100644 --- a/github/actions_permissions_orgs_test.go +++ b/github/actions_permissions_orgs_test.go @@ -28,7 +28,7 @@ func TestActionsService_GetActionsPermissions(t *testing.T) { if err != nil { t.Errorf("Actions.GetActionsPermissions returned error: %v", err) } - want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("all"), ShaPinningRequired: Ptr(true)} + want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("all"), SHAPinningRequired: Ptr(true)} if !cmp.Equal(org, want) { t.Errorf("Actions.GetActionsPermissions returned %+v, want %+v", org, want) } @@ -52,7 +52,7 @@ func TestActionsService_UpdateActionsPermissions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected"), ShaPinningRequired: Ptr(true)} + input := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)} mux.HandleFunc("/orgs/o/actions/permissions", func(w http.ResponseWriter, r *http.Request) { v := new(ActionsPermissions) @@ -72,7 +72,7 @@ func TestActionsService_UpdateActionsPermissions(t *testing.T) { t.Errorf("Actions.UpdateActionsPermissions returned error: %v", err) } - want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected"), ShaPinningRequired: Ptr(true)} + want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)} if !cmp.Equal(org, want) { t.Errorf("Actions.UpdateActionsPermissions returned %+v, want %+v", org, want) } @@ -326,7 +326,7 @@ func TestActionsPermissions_Marshal(t *testing.T) { EnabledRepositories: Ptr("e"), AllowedActions: Ptr("a"), SelectedActionsURL: Ptr("sau"), - ShaPinningRequired: Ptr(true), + SHAPinningRequired: Ptr(true), } want := `{ diff --git a/github/github-accessors.go b/github/github-accessors.go index c32e2159611..6a6ef9c9599 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -206,6 +206,14 @@ func (a *ActionsPermissions) GetSelectedActionsURL() string { return *a.SelectedActionsURL } +// GetSHAPinningRequired returns the SHAPinningRequired field if it's non-nil, zero value otherwise. +func (a *ActionsPermissions) GetSHAPinningRequired() bool { + if a == nil || a.SHAPinningRequired == nil { + return false + } + return *a.SHAPinningRequired +} + // GetAllowedActions returns the AllowedActions field if it's non-nil, zero value otherwise. func (a *ActionsPermissionsEnterprise) GetAllowedActions() string { if a == nil || a.AllowedActions == nil { @@ -254,6 +262,14 @@ func (a *ActionsPermissionsRepository) GetSelectedActionsURL() string { return *a.SelectedActionsURL } +// GetSHAPinningRequired returns the SHAPinningRequired field if it's non-nil, zero value otherwise. +func (a *ActionsPermissionsRepository) GetSHAPinningRequired() bool { + if a == nil || a.SHAPinningRequired == nil { + return false + } + return *a.SHAPinningRequired +} + // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. func (a *ActionsVariable) GetCreatedAt() Timestamp { if a == nil || a.CreatedAt == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index d3bef6e4a9d..33f25e90ee3 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -273,6 +273,17 @@ func TestActionsPermissions_GetSelectedActionsURL(tt *testing.T) { a.GetSelectedActionsURL() } +func TestActionsPermissions_GetSHAPinningRequired(tt *testing.T) { + tt.Parallel() + var zeroValue bool + a := &ActionsPermissions{SHAPinningRequired: &zeroValue} + a.GetSHAPinningRequired() + a = &ActionsPermissions{} + a.GetSHAPinningRequired() + a = nil + a.GetSHAPinningRequired() +} + func TestActionsPermissionsEnterprise_GetAllowedActions(tt *testing.T) { tt.Parallel() var zeroValue string @@ -339,6 +350,17 @@ func TestActionsPermissionsRepository_GetSelectedActionsURL(tt *testing.T) { a.GetSelectedActionsURL() } +func TestActionsPermissionsRepository_GetSHAPinningRequired(tt *testing.T) { + tt.Parallel() + var zeroValue bool + a := &ActionsPermissionsRepository{SHAPinningRequired: &zeroValue} + a.GetSHAPinningRequired() + a = &ActionsPermissionsRepository{} + a.GetSHAPinningRequired() + a = nil + a.GetSHAPinningRequired() +} + func TestActionsVariable_GetCreatedAt(tt *testing.T) { tt.Parallel() var zeroValue Timestamp diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index c068952d51c..6f0cdbeb8f1 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -49,8 +49,9 @@ func TestActionsPermissions_String(t *testing.T) { EnabledRepositories: Ptr(""), AllowedActions: Ptr(""), SelectedActionsURL: Ptr(""), + SHAPinningRequired: Ptr(false), } - want := `github.ActionsPermissions{EnabledRepositories:"", AllowedActions:"", SelectedActionsURL:""}` + want := `github.ActionsPermissions{EnabledRepositories:"", AllowedActions:"", SelectedActionsURL:"", SHAPinningRequired:false}` if got := v.String(); got != want { t.Errorf("ActionsPermissions.String = %v, want %v", got, want) } @@ -75,8 +76,9 @@ func TestActionsPermissionsRepository_String(t *testing.T) { Enabled: Ptr(false), AllowedActions: Ptr(""), SelectedActionsURL: Ptr(""), + SHAPinningRequired: Ptr(false), } - want := `github.ActionsPermissionsRepository{Enabled:false, AllowedActions:"", SelectedActionsURL:""}` + want := `github.ActionsPermissionsRepository{Enabled:false, AllowedActions:"", SelectedActionsURL:"", SHAPinningRequired:false}` if got := v.String(); got != want { t.Errorf("ActionsPermissionsRepository.String = %v, want %v", got, want) } diff --git a/github/repos_actions_permissions.go b/github/repos_actions_permissions.go index 2232a90c989..7e56c3f3965 100644 --- a/github/repos_actions_permissions.go +++ b/github/repos_actions_permissions.go @@ -17,7 +17,7 @@ type ActionsPermissionsRepository struct { Enabled *bool `json:"enabled,omitempty"` AllowedActions *string `json:"allowed_actions,omitempty"` SelectedActionsURL *string `json:"selected_actions_url,omitempty"` - ShaPinningRequired *bool `json:"sha_pinning_required,omitempty"` + SHAPinningRequired *bool `json:"sha_pinning_required,omitempty"` } func (a ActionsPermissionsRepository) String() string { diff --git a/github/repos_actions_permissions_test.go b/github/repos_actions_permissions_test.go index b750d390b8f..aad947f9dc7 100644 --- a/github/repos_actions_permissions_test.go +++ b/github/repos_actions_permissions_test.go @@ -28,7 +28,7 @@ func TestRepositoriesService_GetActionsPermissions(t *testing.T) { if err != nil { t.Errorf("Repositories.GetActionsPermissions returned error: %v", err) } - want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("all"), ShaPinningRequired: Ptr(true)} + want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("all"), SHAPinningRequired: Ptr(true)} if !cmp.Equal(org, want) { t.Errorf("Repositories.GetActionsPermissions returned %+v, want %+v", org, want) } @@ -52,7 +52,7 @@ func TestRepositoriesService_UpdateActionsPermissions(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected"), ShaPinningRequired: Ptr(true)} + input := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)} mux.HandleFunc("/repos/o/r/actions/permissions", func(w http.ResponseWriter, r *http.Request) { v := new(ActionsPermissionsRepository) @@ -72,7 +72,7 @@ func TestRepositoriesService_UpdateActionsPermissions(t *testing.T) { t.Errorf("Repositories.UpdateActionsPermissions returned error: %v", err) } - want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected"), ShaPinningRequired: Ptr(true)} + want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)} if !cmp.Equal(org, want) { t.Errorf("Repositories.UpdateActionsPermissions returned %+v, want %+v", org, want) } @@ -100,7 +100,7 @@ func TestActionsPermissionsRepository_Marshal(t *testing.T) { Enabled: Ptr(true), AllowedActions: Ptr("all"), SelectedActionsURL: Ptr("someURL"), - ShaPinningRequired: Ptr(true), + SHAPinningRequired: Ptr(true), } want := `{