+
Skip to content

feat: Add sorting list options for secret scanning #3481

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

Merged
merged 1 commit into from
Feb 17, 2025
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
6 changes: 6 additions & 0 deletions github/secret_scanning.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ type SecretScanningAlertListOptions struct {
// Valid resolutions are false_positive, wont_fix, revoked, pattern_edited, pattern_deleted or used_in_tests.
Resolution string `url:"resolution,omitempty"`

// The direction to sort the results by. Possible values are: asc, desc. Default: desc.
Direction string `url:"direction,omitempty"`

// The property by which to sort the results. Possible values are: created, updated. Default: created.
Sort string `url:"sort,omitempty"`

ListCursorOptions

// List options can vary on the Enterprise type.
Expand Down
16 changes: 8 additions & 8 deletions github/secret_scanning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestSecretScanningService_ListAlertsForEnterprise(t *testing.T) {

mux.HandleFunc("/enterprises/e/secret-scanning/alerts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"state": "open", "secret_type": "mailchimp_api_key"})
testFormValues(t, r, values{"state": "open", "secret_type": "mailchimp_api_key", "sort": "updated", "direction": "asc"})

fmt.Fprint(w, `[{
"number": 1,
Expand All @@ -45,7 +45,7 @@ func TestSecretScanningService_ListAlertsForEnterprise(t *testing.T) {
})

ctx := context.Background()
opts := &SecretScanningAlertListOptions{State: "open", SecretType: "mailchimp_api_key"}
opts := &SecretScanningAlertListOptions{State: "open", SecretType: "mailchimp_api_key", Direction: "asc", Sort: "updated"}

alerts, _, err := client.SecretScanning.ListAlertsForEnterprise(ctx, "e", opts)
if err != nil {
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestSecretScanningService_ListAlertsForOrg(t *testing.T) {

mux.HandleFunc("/orgs/o/secret-scanning/alerts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"state": "open", "secret_type": "mailchimp_api_key"})
testFormValues(t, r, values{"state": "open", "secret_type": "mailchimp_api_key", "sort": "updated", "direction": "asc"})

fmt.Fprint(w, `[{
"number": 1,
Expand All @@ -115,7 +115,7 @@ func TestSecretScanningService_ListAlertsForOrg(t *testing.T) {
})

ctx := context.Background()
opts := &SecretScanningAlertListOptions{State: "open", SecretType: "mailchimp_api_key"}
opts := &SecretScanningAlertListOptions{State: "open", SecretType: "mailchimp_api_key", Direction: "asc", Sort: "updated"}

alerts, _, err := client.SecretScanning.ListAlertsForOrg(ctx, "o", opts)
if err != nil {
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestSecretScanningService_ListAlertsForOrgListOptions(t *testing.T) {

mux.HandleFunc("/orgs/o/secret-scanning/alerts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"state": "open", "secret_type": "mailchimp_api_key", "per_page": "1", "page": "1"})
testFormValues(t, r, values{"state": "open", "secret_type": "mailchimp_api_key", "per_page": "1", "page": "1", "sort": "updated", "direction": "asc"})

fmt.Fprint(w, `[{
"number": 1,
Expand All @@ -182,7 +182,7 @@ func TestSecretScanningService_ListAlertsForOrgListOptions(t *testing.T) {
ctx := context.Background()

// Testing pagination by index
opts := &SecretScanningAlertListOptions{State: "open", SecretType: "mailchimp_api_key", ListOptions: ListOptions{Page: 1, PerPage: 1}}
opts := &SecretScanningAlertListOptions{State: "open", SecretType: "mailchimp_api_key", ListOptions: ListOptions{Page: 1, PerPage: 1}, Direction: "asc", Sort: "updated"}

alerts, _, err := client.SecretScanning.ListAlertsForOrg(ctx, "o", opts)
if err != nil {
Expand Down Expand Up @@ -229,7 +229,7 @@ func TestSecretScanningService_ListAlertsForRepo(t *testing.T) {

mux.HandleFunc("/repos/o/r/secret-scanning/alerts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"state": "open", "secret_type": "mailchimp_api_key"})
testFormValues(t, r, values{"state": "open", "secret_type": "mailchimp_api_key", "sort": "updated", "direction": "asc"})

fmt.Fprint(w, `[{
"number": 1,
Expand All @@ -247,7 +247,7 @@ func TestSecretScanningService_ListAlertsForRepo(t *testing.T) {
})

ctx := context.Background()
opts := &SecretScanningAlertListOptions{State: "open", SecretType: "mailchimp_api_key"}
opts := &SecretScanningAlertListOptions{State: "open", SecretType: "mailchimp_api_key", Direction: "asc", Sort: "updated"}

alerts, _, err := client.SecretScanning.ListAlertsForRepo(ctx, "o", "r", opts)
if err != nil {
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载