Skip to content

Commit 8760289

Browse files
authored
feat: Add sha_pinning_required to ActionsPermissions structs (#3807)
1 parent 943b801 commit 8760289

7 files changed

+60
-14
lines changed

github/actions_permissions_orgs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type ActionsPermissions struct {
1717
EnabledRepositories *string `json:"enabled_repositories,omitempty"`
1818
AllowedActions *string `json:"allowed_actions,omitempty"`
1919
SelectedActionsURL *string `json:"selected_actions_url,omitempty"`
20+
SHAPinningRequired *bool `json:"sha_pinning_required,omitempty"`
2021
}
2122

2223
func (a ActionsPermissions) String() string {

github/actions_permissions_orgs_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ func TestActionsService_GetActionsPermissions(t *testing.T) {
2020

2121
mux.HandleFunc("/orgs/o/actions/permissions", func(w http.ResponseWriter, r *http.Request) {
2222
testMethod(t, r, "GET")
23-
fmt.Fprint(w, `{"enabled_repositories": "all", "allowed_actions": "all"}`)
23+
fmt.Fprint(w, `{"enabled_repositories": "all", "allowed_actions": "all", "sha_pinning_required": true}`)
2424
})
2525

2626
ctx := t.Context()
2727
org, _, err := client.Actions.GetActionsPermissions(ctx, "o")
2828
if err != nil {
2929
t.Errorf("Actions.GetActionsPermissions returned error: %v", err)
3030
}
31-
want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("all")}
31+
want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("all"), SHAPinningRequired: Ptr(true)}
3232
if !cmp.Equal(org, want) {
3333
t.Errorf("Actions.GetActionsPermissions returned %+v, want %+v", org, want)
3434
}
@@ -52,7 +52,7 @@ func TestActionsService_UpdateActionsPermissions(t *testing.T) {
5252
t.Parallel()
5353
client, mux, _ := setup(t)
5454

55-
input := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected")}
55+
input := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)}
5656

5757
mux.HandleFunc("/orgs/o/actions/permissions", func(w http.ResponseWriter, r *http.Request) {
5858
v := new(ActionsPermissions)
@@ -63,7 +63,7 @@ func TestActionsService_UpdateActionsPermissions(t *testing.T) {
6363
t.Errorf("Request body = %+v, want %+v", v, input)
6464
}
6565

66-
fmt.Fprint(w, `{"enabled_repositories": "all", "allowed_actions": "selected"}`)
66+
fmt.Fprint(w, `{"enabled_repositories": "all", "allowed_actions": "selected", "sha_pinning_required": true}`)
6767
})
6868

6969
ctx := t.Context()
@@ -72,7 +72,7 @@ func TestActionsService_UpdateActionsPermissions(t *testing.T) {
7272
t.Errorf("Actions.UpdateActionsPermissions returned error: %v", err)
7373
}
7474

75-
want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected")}
75+
want := &ActionsPermissions{EnabledRepositories: Ptr("all"), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)}
7676
if !cmp.Equal(org, want) {
7777
t.Errorf("Actions.UpdateActionsPermissions returned %+v, want %+v", org, want)
7878
}
@@ -326,12 +326,14 @@ func TestActionsPermissions_Marshal(t *testing.T) {
326326
EnabledRepositories: Ptr("e"),
327327
AllowedActions: Ptr("a"),
328328
SelectedActionsURL: Ptr("sau"),
329+
SHAPinningRequired: Ptr(true),
329330
}
330331

331332
want := `{
332333
"enabled_repositories": "e",
333334
"allowed_actions": "a",
334-
"selected_actions_url": "sau"
335+
"selected_actions_url": "sau",
336+
"sha_pinning_required": true
335337
}`
336338

337339
testJSONMarshal(t, u, want)

github/github-accessors.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-stringify_test.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/repos_actions_permissions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type ActionsPermissionsRepository struct {
1717
Enabled *bool `json:"enabled,omitempty"`
1818
AllowedActions *string `json:"allowed_actions,omitempty"`
1919
SelectedActionsURL *string `json:"selected_actions_url,omitempty"`
20+
SHAPinningRequired *bool `json:"sha_pinning_required,omitempty"`
2021
}
2122

2223
func (a ActionsPermissionsRepository) String() string {

github/repos_actions_permissions_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ func TestRepositoriesService_GetActionsPermissions(t *testing.T) {
2020

2121
mux.HandleFunc("/repos/o/r/actions/permissions", func(w http.ResponseWriter, r *http.Request) {
2222
testMethod(t, r, "GET")
23-
fmt.Fprint(w, `{"enabled": true, "allowed_actions": "all"}`)
23+
fmt.Fprint(w, `{"enabled": true, "allowed_actions": "all", "sha_pinning_required": true}`)
2424
})
2525

2626
ctx := t.Context()
2727
org, _, err := client.Repositories.GetActionsPermissions(ctx, "o", "r")
2828
if err != nil {
2929
t.Errorf("Repositories.GetActionsPermissions returned error: %v", err)
3030
}
31-
want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("all")}
31+
want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("all"), SHAPinningRequired: Ptr(true)}
3232
if !cmp.Equal(org, want) {
3333
t.Errorf("Repositories.GetActionsPermissions returned %+v, want %+v", org, want)
3434
}
@@ -52,7 +52,7 @@ func TestRepositoriesService_UpdateActionsPermissions(t *testing.T) {
5252
t.Parallel()
5353
client, mux, _ := setup(t)
5454

55-
input := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected")}
55+
input := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)}
5656

5757
mux.HandleFunc("/repos/o/r/actions/permissions", func(w http.ResponseWriter, r *http.Request) {
5858
v := new(ActionsPermissionsRepository)
@@ -63,7 +63,7 @@ func TestRepositoriesService_UpdateActionsPermissions(t *testing.T) {
6363
t.Errorf("Request body = %+v, want %+v", v, input)
6464
}
6565

66-
fmt.Fprint(w, `{"enabled": true, "allowed_actions": "selected"}`)
66+
fmt.Fprint(w, `{"enabled": true, "allowed_actions": "selected", "sha_pinning_required": true}`)
6767
})
6868

6969
ctx := t.Context()
@@ -72,7 +72,7 @@ func TestRepositoriesService_UpdateActionsPermissions(t *testing.T) {
7272
t.Errorf("Repositories.UpdateActionsPermissions returned error: %v", err)
7373
}
7474

75-
want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected")}
75+
want := &ActionsPermissionsRepository{Enabled: Ptr(true), AllowedActions: Ptr("selected"), SHAPinningRequired: Ptr(true)}
7676
if !cmp.Equal(org, want) {
7777
t.Errorf("Repositories.UpdateActionsPermissions returned %+v, want %+v", org, want)
7878
}
@@ -100,12 +100,14 @@ func TestActionsPermissionsRepository_Marshal(t *testing.T) {
100100
Enabled: Ptr(true),
101101
AllowedActions: Ptr("all"),
102102
SelectedActionsURL: Ptr("someURL"),
103+
SHAPinningRequired: Ptr(true),
103104
}
104105

105106
want := `{
106107
"enabled": true,
107108
"allowed_actions": "all",
108-
"selected_actions_url": "someURL"
109+
"selected_actions_url": "someURL",
110+
"sha_pinning_required": true
109111
}`
110112

111113
testJSONMarshal(t, u, want)

0 commit comments

Comments
 (0)