Skip to content

Commit

Permalink
Update VulnerabilityResourceTest.java
Browse files Browse the repository at this point in the history
  • Loading branch information
sahibamittal committed Sep 18, 2024
1 parent 6711c97 commit 5b3d909
Showing 1 changed file with 0 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -657,30 +657,6 @@ public void createVulnerabilityWithBadOwaspVectorTest() {
Assert.assertEquals("Provided vector SL:1/M:1/O:a/S:2/ED:1/EE:1/A:1/ID:1/LC:2/LI:1/LAV:1/LAC:1/FD:1/RD:1/NC:2/PV:3 does not match OWASP RR Vector pattern SL:\\d/M:\\d/O:\\d/S:\\d/ED:\\d/EE:\\d/A:\\d/ID:\\d/LC:\\d/LI:\\d/LAV:\\d/LAC:\\d/FD:\\d/RD:\\d/NC:\\d/PV:\\d", body);
}

/**
* Ensure that pre-v4.5.0 behavior of setting CWE via a single object
* still works, and both "cwe" and "cwes" fields are returned in the response.
*/
@Test
public void createVulnerabilityCwePreV450CompatTest() {
JsonObject payload = Json.createObjectBuilder()
.add("vulnId", "ACME-1")
.add("cwes", Json.createArrayBuilder().add(Json.createObjectBuilder().add("cweId", 80)))
.build();
Response response = jersey.target(V1_VULNERABILITY).request()
.header(X_API_KEY, apiKey)
.put(Entity.json(payload.toString()));
Assert.assertEquals(201, response.getStatus(), 0);
JsonObject json = parseJsonObject(response);
Assert.assertNotNull(json);
Assert.assertEquals("ACME-1", json.getString("vulnId"));
Assert.assertEquals("INTERNAL", json.getString("source"));
Assert.assertEquals(1, json.getJsonArray("cwes").size());
Assert.assertEquals(80, json.getJsonArray("cwes").getJsonObject(0).getInt("cweId"));
Assert.assertEquals("Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)", json.getJsonArray("cwes").getJsonObject(0).getString("name"));
Assert.assertTrue(UuidUtil.isValidUUID(json.getString("uuid")));
}

@Test
public void createVulnerabilityDuplicateTest() {
Vulnerability vuln = new Vulnerability();
Expand Down

0 comments on commit 5b3d909

Please sign in to comment.