Skip to content

Commit 6f477b4

Browse files
Array Fleetcursoragent
andcommitted
test: reject null cweIds on advisory create handler
Mirror the existing null credits guard test on the create path so null optional array fields are validated consistently at handler level. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent fabcc52 commit 6f477b4

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

pkg/github/security_advisories_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,23 @@ func Test_CreateRepositorySecurityAdvisory(t *testing.T) {
801801
expectError: true,
802802
expectedErrMsg: "invalid credits: value must not be null",
803803
},
804+
{
805+
name: "reject null cweIds",
806+
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
807+
PostReposSecurityAdvisoriesByOwnerByRepo: mockResponse(t, http.StatusCreated, mockAdvisory),
808+
}),
809+
requestArgs: map[string]any{
810+
"owner": "octo",
811+
"repo": "hello-world",
812+
"summary": "Stored XSS in Core",
813+
"description": "A stored XSS vulnerability in Core.",
814+
"severity": "high",
815+
"vulnerabilities": sampleAdvisoryVulnerabilities(),
816+
"cweIds": nil,
817+
},
818+
expectError: true,
819+
expectedErrMsg: "invalid cweIds: value must not be null",
820+
},
804821
{
805822
name: "API error handling",
806823
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{

0 commit comments

Comments
 (0)