Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@
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"`

Check failure on line 20 in github/actions_permissions_orgs.go

View workflow job for this annotation

GitHub Actions / lint

change Go field name "ShaPinningRequired" to "SHAPinningRequired" for JSON tag "sha_pinning_required" in struct "ActionsPermissions" (jsonfieldname)
}

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
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 @@
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"`

Check failure on line 20 in github/repos_actions_permissions.go

View workflow job for this annotation

GitHub Actions / lint

change Go field name "ShaPinningRequired" to "SHAPinningRequired" for JSON tag "sha_pinning_required" in struct "ActionsPermissionsRepository" (jsonfieldname)
}

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