Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SecretScanning API by switching arguments from url to json #2934

Merged
merged 2 commits into from
Sep 19, 2023
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
16 changes: 0 additions & 16 deletions github/github-accessors.go

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

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

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

18 changes: 8 additions & 10 deletions github/secret_scanning.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,14 @@ type SecretScanningAlertListOptions struct {

// SecretScanningAlertUpdateOptions specifies optional parameters to the SecretScanningService.UpdateAlert method.
type SecretScanningAlertUpdateOptions struct {
// Required. Sets the state of the secret scanning alert. Can be either open or resolved.
// You must provide resolution when you set the state to resolved.
State *string `url:"state,omitempty"`

// A comma-separated list of secret types to return. By default all secret types are returned.
SecretType *string `url:"secret_type,omitempty"`

// Required when the state is resolved. The reason for resolving the alert. Can be one of false_positive,
// wont_fix, revoked, or used_in_tests.
Resolution *string `url:"resolution,omitempty"`
// State is required and sets the state of the secret scanning alert.
// Can be either "open" or "resolved".
// You must provide resolution when you set the state to "resolved".
State string `json:"state"`

// Required when the state is "resolved" and represents the reason for resolving the alert.
// Can be one of: "false_positive", "wont_fix", "revoked", or "used_in_tests".
Resolution *string `json:"resolution,omitempty"`
}

// Lists secret scanning alerts for eligible repositories in an enterprise, from newest to oldest.
Expand Down
4 changes: 2 additions & 2 deletions github/secret_scanning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func TestSecretScanningService_UpdateAlert(t *testing.T) {
v := new(SecretScanningAlertUpdateOptions)
assertNilError(t, json.NewDecoder(r.Body).Decode(v))

want := &SecretScanningAlertUpdateOptions{State: String("resolved"), Resolution: String("used_in_tests")}
want := &SecretScanningAlertUpdateOptions{State: "resolved", Resolution: String("used_in_tests")}

if !cmp.Equal(v, want) {
t.Errorf("Request body = %+v, want %+v", v, want)
Expand All @@ -381,7 +381,7 @@ func TestSecretScanningService_UpdateAlert(t *testing.T) {
})

ctx := context.Background()
opts := &SecretScanningAlertUpdateOptions{State: String("resolved"), Resolution: String("used_in_tests")}
opts := &SecretScanningAlertUpdateOptions{State: "resolved", Resolution: String("used_in_tests")}

alert, _, err := client.SecretScanning.UpdateAlert(ctx, "o", "r", 1, opts)
if err != nil {
Expand Down
Loading