Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions github/actions_permissions_orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 8 additions & 6 deletions github/actions_permissions_orgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ 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()
org, _, err := client.Actions.GetActionsPermissions(ctx, "o")
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)
}
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions github/github-stringify_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions github/repos_actions_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 8 additions & 6 deletions github/repos_actions_permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ 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()
org, _, err := client.Repositories.GetActionsPermissions(ctx, "o", "r")
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)
}
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
Loading