feat: add pagination to list GHAS alerts tools (#2451)
* feat(code_scanning): add pagination to list_code_scanning_alerts (#2363) * feat(dependabot): add pagination to list_dependabot_alerts (#2363) * feat(secret_scanning): add pagination to list_secret_scanning_alerts (#2363) * test(code_scanning): pagination expectations + new test case (#2363) * test(dependabot): pagination expectations + new test case (#2363) * test(secret_scanning): pagination expectations + new test case (#2363) * test(toolsnaps): refresh list_code_scanning_alerts with page/perPage (#2363) * test(toolsnaps): refresh list_dependabot_alerts with page/perPage (#2363) * test(toolsnaps): refresh list_secret_scanning_alerts with page/perPage (#2363) * docs: regenerate README for new pagination params Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Sam Morrow <info@sam-morrow.com> Co-authored-by: sammorrowdrums <sam.morrowdrums@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -649,6 +649,8 @@ The following sets of tools are available:
|
||||
- **Required OAuth Scopes**: `security_events`
|
||||
- **Accepted OAuth Scopes**: `repo`, `security_events`
|
||||
- `owner`: The owner of the repository. (string, required)
|
||||
- `page`: Page number for pagination (min 1) (number, optional)
|
||||
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
||||
- `ref`: The Git reference for the results you want to list. (string, optional)
|
||||
- `repo`: The name of the repository. (string, required)
|
||||
- `severity`: Filter code scanning alerts by severity (string, optional)
|
||||
@@ -712,6 +714,8 @@ The following sets of tools are available:
|
||||
- **Required OAuth Scopes**: `security_events`
|
||||
- **Accepted OAuth Scopes**: `repo`, `security_events`
|
||||
- `owner`: The owner of the repository. (string, required)
|
||||
- `page`: Page number for pagination (min 1) (number, optional)
|
||||
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
||||
- `repo`: The name of the repository. (string, required)
|
||||
- `severity`: Filter dependabot alerts by severity (string, optional)
|
||||
- `state`: Filter dependabot alerts by state. Defaults to open (string, optional)
|
||||
@@ -1324,6 +1328,8 @@ The following sets of tools are available:
|
||||
- **Required OAuth Scopes**: `security_events`
|
||||
- **Accepted OAuth Scopes**: `repo`, `security_events`
|
||||
- `owner`: The owner of the repository. (string, required)
|
||||
- `page`: Page number for pagination (min 1) (number, optional)
|
||||
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
|
||||
- `repo`: The name of the repository. (string, required)
|
||||
- `resolution`: Filter by resolution (string, optional)
|
||||
- `secret_type`: A comma-separated list of secret types to return. All default secret patterns are returned. To return generic patterns, pass the token name(s) in the parameter. (string, optional)
|
||||
|
||||
@@ -10,6 +10,17 @@
|
||||
"description": "The owner of the repository.",
|
||||
"type": "string"
|
||||
},
|
||||
"page": {
|
||||
"description": "Page number for pagination (min 1)",
|
||||
"minimum": 1,
|
||||
"type": "number"
|
||||
},
|
||||
"perPage": {
|
||||
"description": "Results per page for pagination (min 1, max 100)",
|
||||
"maximum": 100,
|
||||
"minimum": 1,
|
||||
"type": "number"
|
||||
},
|
||||
"ref": {
|
||||
"description": "The Git reference for the results you want to list.",
|
||||
"type": "string"
|
||||
|
||||
@@ -10,6 +10,17 @@
|
||||
"description": "The owner of the repository.",
|
||||
"type": "string"
|
||||
},
|
||||
"page": {
|
||||
"description": "Page number for pagination (min 1)",
|
||||
"minimum": 1,
|
||||
"type": "number"
|
||||
},
|
||||
"perPage": {
|
||||
"description": "Results per page for pagination (min 1, max 100)",
|
||||
"maximum": 100,
|
||||
"minimum": 1,
|
||||
"type": "number"
|
||||
},
|
||||
"repo": {
|
||||
"description": "The name of the repository.",
|
||||
"type": "string"
|
||||
|
||||
@@ -10,6 +10,17 @@
|
||||
"description": "The owner of the repository.",
|
||||
"type": "string"
|
||||
},
|
||||
"page": {
|
||||
"description": "Page number for pagination (min 1)",
|
||||
"minimum": 1,
|
||||
"type": "number"
|
||||
},
|
||||
"perPage": {
|
||||
"description": "Results per page for pagination (min 1, max 100)",
|
||||
"maximum": 100,
|
||||
"minimum": 1,
|
||||
"type": "number"
|
||||
},
|
||||
"repo": {
|
||||
"description": "The name of the repository.",
|
||||
"type": "string"
|
||||
|
||||
+51
-34
@@ -94,6 +94,41 @@ func GetCodeScanningAlert(t translations.TranslationHelperFunc) inventory.Server
|
||||
}
|
||||
|
||||
func ListCodeScanningAlerts(t translations.TranslationHelperFunc) inventory.ServerTool {
|
||||
schema := &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"owner": {
|
||||
Type: "string",
|
||||
Description: "The owner of the repository.",
|
||||
},
|
||||
"repo": {
|
||||
Type: "string",
|
||||
Description: "The name of the repository.",
|
||||
},
|
||||
"state": {
|
||||
Type: "string",
|
||||
Description: "Filter code scanning alerts by state. Defaults to open",
|
||||
Enum: []any{"open", "closed", "dismissed", "fixed"},
|
||||
Default: json.RawMessage(`"open"`),
|
||||
},
|
||||
"ref": {
|
||||
Type: "string",
|
||||
Description: "The Git reference for the results you want to list.",
|
||||
},
|
||||
"severity": {
|
||||
Type: "string",
|
||||
Description: "Filter code scanning alerts by severity",
|
||||
Enum: []any{"critical", "high", "medium", "low", "warning", "note", "error"},
|
||||
},
|
||||
"tool_name": {
|
||||
Type: "string",
|
||||
Description: "The name of the tool used for code scanning.",
|
||||
},
|
||||
},
|
||||
Required: []string{"owner", "repo"},
|
||||
}
|
||||
WithPagination(schema)
|
||||
|
||||
return NewTool(
|
||||
ToolsetMetadataCodeSecurity,
|
||||
mcp.Tool{
|
||||
@@ -103,39 +138,7 @@ func ListCodeScanningAlerts(t translations.TranslationHelperFunc) inventory.Serv
|
||||
Title: t("TOOL_LIST_CODE_SCANNING_ALERTS_USER_TITLE", "List code scanning alerts"),
|
||||
ReadOnlyHint: true,
|
||||
},
|
||||
InputSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"owner": {
|
||||
Type: "string",
|
||||
Description: "The owner of the repository.",
|
||||
},
|
||||
"repo": {
|
||||
Type: "string",
|
||||
Description: "The name of the repository.",
|
||||
},
|
||||
"state": {
|
||||
Type: "string",
|
||||
Description: "Filter code scanning alerts by state. Defaults to open",
|
||||
Enum: []any{"open", "closed", "dismissed", "fixed"},
|
||||
Default: json.RawMessage(`"open"`),
|
||||
},
|
||||
"ref": {
|
||||
Type: "string",
|
||||
Description: "The Git reference for the results you want to list.",
|
||||
},
|
||||
"severity": {
|
||||
Type: "string",
|
||||
Description: "Filter code scanning alerts by severity",
|
||||
Enum: []any{"critical", "high", "medium", "low", "warning", "note", "error"},
|
||||
},
|
||||
"tool_name": {
|
||||
Type: "string",
|
||||
Description: "The name of the tool used for code scanning.",
|
||||
},
|
||||
},
|
||||
Required: []string{"owner", "repo"},
|
||||
},
|
||||
InputSchema: schema,
|
||||
},
|
||||
[]scopes.Scope{scopes.SecurityEvents},
|
||||
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
|
||||
@@ -164,11 +167,25 @@ func ListCodeScanningAlerts(t translations.TranslationHelperFunc) inventory.Serv
|
||||
return utils.NewToolResultError(err.Error()), nil, nil
|
||||
}
|
||||
|
||||
pagination, err := OptionalPaginationParams(args)
|
||||
if err != nil {
|
||||
return utils.NewToolResultError(err.Error()), nil, nil
|
||||
}
|
||||
|
||||
client, err := deps.GetClient(ctx)
|
||||
if err != nil {
|
||||
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
|
||||
}
|
||||
alerts, resp, err := client.CodeScanning.ListAlertsForRepo(ctx, owner, repo, &github.AlertListOptions{Ref: ref, State: state, Severity: severity, ToolName: toolName})
|
||||
alerts, resp, err := client.CodeScanning.ListAlertsForRepo(ctx, owner, repo, &github.AlertListOptions{
|
||||
Ref: ref,
|
||||
State: state,
|
||||
Severity: severity,
|
||||
ToolName: toolName,
|
||||
ListOptions: github.ListOptions{
|
||||
Page: pagination.Page,
|
||||
PerPage: pagination.PerPage,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return ghErrors.NewGitHubAPIErrorResponse(ctx,
|
||||
"failed to list alerts",
|
||||
|
||||
@@ -137,6 +137,8 @@ func Test_ListCodeScanningAlerts(t *testing.T) {
|
||||
assert.Contains(t, schema.Properties, "state")
|
||||
assert.Contains(t, schema.Properties, "severity")
|
||||
assert.Contains(t, schema.Properties, "tool_name")
|
||||
assert.Contains(t, schema.Properties, "page")
|
||||
assert.Contains(t, schema.Properties, "perPage")
|
||||
assert.ElementsMatch(t, schema.Required, []string{"owner", "repo"})
|
||||
|
||||
// Setup mock alerts for success case
|
||||
@@ -171,6 +173,8 @@ func Test_ListCodeScanningAlerts(t *testing.T) {
|
||||
"state": "open",
|
||||
"severity": "high",
|
||||
"tool_name": "codeql",
|
||||
"page": "1",
|
||||
"per_page": "30",
|
||||
}).andThen(
|
||||
mockResponse(t, http.StatusOK, mockAlerts),
|
||||
),
|
||||
@@ -186,6 +190,25 @@ func Test_ListCodeScanningAlerts(t *testing.T) {
|
||||
expectError: false,
|
||||
expectedAlerts: mockAlerts,
|
||||
},
|
||||
{
|
||||
name: "successful alerts listing with custom pagination",
|
||||
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
|
||||
GetReposCodeScanningAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{
|
||||
"page": "2",
|
||||
"per_page": "50",
|
||||
}).andThen(
|
||||
mockResponse(t, http.StatusOK, mockAlerts),
|
||||
),
|
||||
}),
|
||||
requestArgs: map[string]any{
|
||||
"owner": "owner",
|
||||
"repo": "repo",
|
||||
"page": float64(2),
|
||||
"perPage": float64(50),
|
||||
},
|
||||
expectError: false,
|
||||
expectedAlerts: mockAlerts,
|
||||
},
|
||||
{
|
||||
name: "alerts listing fails",
|
||||
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
|
||||
|
||||
+37
-25
@@ -95,6 +95,33 @@ func GetDependabotAlert(t translations.TranslationHelperFunc) inventory.ServerTo
|
||||
}
|
||||
|
||||
func ListDependabotAlerts(t translations.TranslationHelperFunc) inventory.ServerTool {
|
||||
schema := &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"owner": {
|
||||
Type: "string",
|
||||
Description: "The owner of the repository.",
|
||||
},
|
||||
"repo": {
|
||||
Type: "string",
|
||||
Description: "The name of the repository.",
|
||||
},
|
||||
"state": {
|
||||
Type: "string",
|
||||
Description: "Filter dependabot alerts by state. Defaults to open",
|
||||
Enum: []any{"open", "fixed", "dismissed", "auto_dismissed"},
|
||||
Default: json.RawMessage(`"open"`),
|
||||
},
|
||||
"severity": {
|
||||
Type: "string",
|
||||
Description: "Filter dependabot alerts by severity",
|
||||
Enum: []any{"low", "medium", "high", "critical"},
|
||||
},
|
||||
},
|
||||
Required: []string{"owner", "repo"},
|
||||
}
|
||||
WithPagination(schema)
|
||||
|
||||
return NewTool(
|
||||
ToolsetMetadataDependabot,
|
||||
mcp.Tool{
|
||||
@@ -104,31 +131,7 @@ func ListDependabotAlerts(t translations.TranslationHelperFunc) inventory.Server
|
||||
Title: t("TOOL_LIST_DEPENDABOT_ALERTS_USER_TITLE", "List dependabot alerts"),
|
||||
ReadOnlyHint: true,
|
||||
},
|
||||
InputSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"owner": {
|
||||
Type: "string",
|
||||
Description: "The owner of the repository.",
|
||||
},
|
||||
"repo": {
|
||||
Type: "string",
|
||||
Description: "The name of the repository.",
|
||||
},
|
||||
"state": {
|
||||
Type: "string",
|
||||
Description: "Filter dependabot alerts by state. Defaults to open",
|
||||
Enum: []any{"open", "fixed", "dismissed", "auto_dismissed"},
|
||||
Default: json.RawMessage(`"open"`),
|
||||
},
|
||||
"severity": {
|
||||
Type: "string",
|
||||
Description: "Filter dependabot alerts by severity",
|
||||
Enum: []any{"low", "medium", "high", "critical"},
|
||||
},
|
||||
},
|
||||
Required: []string{"owner", "repo"},
|
||||
},
|
||||
InputSchema: schema,
|
||||
},
|
||||
[]scopes.Scope{scopes.SecurityEvents},
|
||||
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
|
||||
@@ -149,6 +152,11 @@ func ListDependabotAlerts(t translations.TranslationHelperFunc) inventory.Server
|
||||
return utils.NewToolResultError(err.Error()), nil, nil
|
||||
}
|
||||
|
||||
pagination, err := OptionalPaginationParams(args)
|
||||
if err != nil {
|
||||
return utils.NewToolResultError(err.Error()), nil, nil
|
||||
}
|
||||
|
||||
client, err := deps.GetClient(ctx)
|
||||
if err != nil {
|
||||
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, err
|
||||
@@ -157,6 +165,10 @@ func ListDependabotAlerts(t translations.TranslationHelperFunc) inventory.Server
|
||||
alerts, resp, err := client.Dependabot.ListRepoAlerts(ctx, owner, repo, &github.ListAlertsOptions{
|
||||
State: ToStringPtr(state),
|
||||
Severity: ToStringPtr(severity),
|
||||
ListOptions: github.ListOptions{
|
||||
Page: pagination.Page,
|
||||
PerPage: pagination.PerPage,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return ghErrors.NewGitHubAPIErrorResponse(ctx,
|
||||
|
||||
@@ -165,7 +165,9 @@ func Test_ListDependabotAlerts(t *testing.T) {
|
||||
name: "successful open alerts listing",
|
||||
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
|
||||
GetReposDependabotAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{
|
||||
"state": "open",
|
||||
"state": "open",
|
||||
"page": "1",
|
||||
"per_page": "30",
|
||||
}).andThen(
|
||||
mockResponse(t, http.StatusOK, []*github.DependabotAlert{&criticalAlert}),
|
||||
),
|
||||
@@ -183,6 +185,8 @@ func Test_ListDependabotAlerts(t *testing.T) {
|
||||
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
|
||||
GetReposDependabotAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{
|
||||
"severity": "high",
|
||||
"page": "1",
|
||||
"per_page": "30",
|
||||
}).andThen(
|
||||
mockResponse(t, http.StatusOK, []*github.DependabotAlert{&highSeverityAlert}),
|
||||
),
|
||||
@@ -198,7 +202,10 @@ func Test_ListDependabotAlerts(t *testing.T) {
|
||||
{
|
||||
name: "successful all alerts listing",
|
||||
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
|
||||
GetReposDependabotAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{}).andThen(
|
||||
GetReposDependabotAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{
|
||||
"page": "1",
|
||||
"per_page": "30",
|
||||
}).andThen(
|
||||
mockResponse(t, http.StatusOK, []*github.DependabotAlert{&criticalAlert, &highSeverityAlert}),
|
||||
),
|
||||
}),
|
||||
@@ -209,6 +216,25 @@ func Test_ListDependabotAlerts(t *testing.T) {
|
||||
expectError: false,
|
||||
expectedAlerts: []*github.DependabotAlert{&criticalAlert, &highSeverityAlert},
|
||||
},
|
||||
{
|
||||
name: "successful alerts listing with custom pagination",
|
||||
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
|
||||
GetReposDependabotAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{
|
||||
"page": "3",
|
||||
"per_page": "100",
|
||||
}).andThen(
|
||||
mockResponse(t, http.StatusOK, []*github.DependabotAlert{&criticalAlert}),
|
||||
),
|
||||
}),
|
||||
requestArgs: map[string]any{
|
||||
"owner": "owner",
|
||||
"repo": "repo",
|
||||
"page": float64(3),
|
||||
"perPage": float64(100),
|
||||
},
|
||||
expectError: false,
|
||||
expectedAlerts: []*github.DependabotAlert{&criticalAlert},
|
||||
},
|
||||
{
|
||||
name: "alerts listing fails",
|
||||
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
|
||||
|
||||
@@ -95,6 +95,36 @@ func GetSecretScanningAlert(t translations.TranslationHelperFunc) inventory.Serv
|
||||
}
|
||||
|
||||
func ListSecretScanningAlerts(t translations.TranslationHelperFunc) inventory.ServerTool {
|
||||
schema := &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"owner": {
|
||||
Type: "string",
|
||||
Description: "The owner of the repository.",
|
||||
},
|
||||
"repo": {
|
||||
Type: "string",
|
||||
Description: "The name of the repository.",
|
||||
},
|
||||
"state": {
|
||||
Type: "string",
|
||||
Description: "Filter by state",
|
||||
Enum: []any{"open", "resolved"},
|
||||
},
|
||||
"secret_type": {
|
||||
Type: "string",
|
||||
Description: "A comma-separated list of secret types to return. All default secret patterns are returned. To return generic patterns, pass the token name(s) in the parameter.",
|
||||
},
|
||||
"resolution": {
|
||||
Type: "string",
|
||||
Description: "Filter by resolution",
|
||||
Enum: []any{"false_positive", "wont_fix", "revoked", "pattern_edited", "pattern_deleted", "used_in_tests"},
|
||||
},
|
||||
},
|
||||
Required: []string{"owner", "repo"},
|
||||
}
|
||||
WithPagination(schema)
|
||||
|
||||
return NewTool(
|
||||
ToolsetMetadataSecretProtection,
|
||||
mcp.Tool{
|
||||
@@ -104,34 +134,7 @@ func ListSecretScanningAlerts(t translations.TranslationHelperFunc) inventory.Se
|
||||
Title: t("TOOL_LIST_SECRET_SCANNING_ALERTS_USER_TITLE", "List secret scanning alerts"),
|
||||
ReadOnlyHint: true,
|
||||
},
|
||||
InputSchema: &jsonschema.Schema{
|
||||
Type: "object",
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"owner": {
|
||||
Type: "string",
|
||||
Description: "The owner of the repository.",
|
||||
},
|
||||
"repo": {
|
||||
Type: "string",
|
||||
Description: "The name of the repository.",
|
||||
},
|
||||
"state": {
|
||||
Type: "string",
|
||||
Description: "Filter by state",
|
||||
Enum: []any{"open", "resolved"},
|
||||
},
|
||||
"secret_type": {
|
||||
Type: "string",
|
||||
Description: "A comma-separated list of secret types to return. All default secret patterns are returned. To return generic patterns, pass the token name(s) in the parameter.",
|
||||
},
|
||||
"resolution": {
|
||||
Type: "string",
|
||||
Description: "Filter by resolution",
|
||||
Enum: []any{"false_positive", "wont_fix", "revoked", "pattern_edited", "pattern_deleted", "used_in_tests"},
|
||||
},
|
||||
},
|
||||
Required: []string{"owner", "repo"},
|
||||
},
|
||||
InputSchema: schema,
|
||||
},
|
||||
[]scopes.Scope{scopes.SecurityEvents},
|
||||
func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
|
||||
@@ -156,11 +159,24 @@ func ListSecretScanningAlerts(t translations.TranslationHelperFunc) inventory.Se
|
||||
return utils.NewToolResultError(err.Error()), nil, nil
|
||||
}
|
||||
|
||||
pagination, err := OptionalPaginationParams(args)
|
||||
if err != nil {
|
||||
return utils.NewToolResultError(err.Error()), nil, nil
|
||||
}
|
||||
|
||||
client, err := deps.GetClient(ctx)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to get GitHub client: %w", err)
|
||||
}
|
||||
alerts, resp, err := client.SecretScanning.ListAlertsForRepo(ctx, owner, repo, &github.SecretScanningAlertListOptions{State: state, SecretType: secretType, Resolution: resolution})
|
||||
alerts, resp, err := client.SecretScanning.ListAlertsForRepo(ctx, owner, repo, &github.SecretScanningAlertListOptions{
|
||||
State: state,
|
||||
SecretType: secretType,
|
||||
Resolution: resolution,
|
||||
ListOptions: github.ListOptions{
|
||||
Page: pagination.Page,
|
||||
PerPage: pagination.PerPage,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return ghErrors.NewGitHubAPIErrorResponse(ctx,
|
||||
fmt.Sprintf("failed to list alerts for repository '%s/%s'", owner, repo),
|
||||
|
||||
@@ -165,7 +165,9 @@ func Test_ListSecretScanningAlerts(t *testing.T) {
|
||||
name: "successful resolved alerts listing",
|
||||
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
|
||||
GetReposSecretScanningAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{
|
||||
"state": "resolved",
|
||||
"state": "resolved",
|
||||
"page": "1",
|
||||
"per_page": "30",
|
||||
}).andThen(
|
||||
mockResponse(t, http.StatusOK, []*github.SecretScanningAlert{&resolvedAlert}),
|
||||
),
|
||||
@@ -181,7 +183,10 @@ func Test_ListSecretScanningAlerts(t *testing.T) {
|
||||
{
|
||||
name: "successful alerts listing",
|
||||
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
|
||||
GetReposSecretScanningAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{}).andThen(
|
||||
GetReposSecretScanningAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{
|
||||
"page": "1",
|
||||
"per_page": "30",
|
||||
}).andThen(
|
||||
mockResponse(t, http.StatusOK, []*github.SecretScanningAlert{&resolvedAlert, &openAlert}),
|
||||
),
|
||||
}),
|
||||
@@ -192,6 +197,25 @@ func Test_ListSecretScanningAlerts(t *testing.T) {
|
||||
expectError: false,
|
||||
expectedAlerts: []*github.SecretScanningAlert{&resolvedAlert, &openAlert},
|
||||
},
|
||||
{
|
||||
name: "successful alerts listing with custom pagination",
|
||||
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
|
||||
GetReposSecretScanningAlertsByOwnerByRepo: expectQueryParams(t, map[string]string{
|
||||
"page": "2",
|
||||
"per_page": "50",
|
||||
}).andThen(
|
||||
mockResponse(t, http.StatusOK, []*github.SecretScanningAlert{&openAlert}),
|
||||
),
|
||||
}),
|
||||
requestArgs: map[string]any{
|
||||
"owner": "owner",
|
||||
"repo": "repo",
|
||||
"page": float64(2),
|
||||
"perPage": float64(50),
|
||||
},
|
||||
expectError: false,
|
||||
expectedAlerts: []*github.SecretScanningAlert{&openAlert},
|
||||
},
|
||||
{
|
||||
name: "alerts listing fails",
|
||||
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
|
||||
|
||||
Reference in New Issue
Block a user