-
-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert Kiss
committed
Jan 18, 2024
1 parent
5435656
commit c2c52a3
Showing
3 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/test/java/org/dependencytrack/parser/github/GitHubSecurityAdvisoryParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.dependencytrack.parser.github; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
|
||
import org.dependencytrack.parser.github.graphql.GitHubSecurityAdvisoryParser; | ||
import org.dependencytrack.parser.github.graphql.model.GitHubSecurityAdvisory; | ||
import org.json.JSONObject; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class GitHubSecurityAdvisoryParserTest { | ||
|
||
GitHubSecurityAdvisoryParser parser = new GitHubSecurityAdvisoryParser(); | ||
|
||
@Test | ||
public void testWithdrawnAdvisory() throws IOException { | ||
|
||
String jsonFile = "src/test/resources/unit/github.jsons/GHSA-8v27-2fg9-7h62.json"; | ||
String jsonString = new String(Files.readAllBytes(Paths.get(jsonFile))); | ||
JSONObject jsonObject = new JSONObject(jsonString); | ||
List<GitHubSecurityAdvisory> advisories = parser.parse(jsonObject).getAdvisories(); | ||
Assert.assertEquals(0, advisories.size()); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/test/resources/unit/github.jsons/GHSA-8v27-2fg9-7h62.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"data": { | ||
"securityAdvisories": { | ||
"pageInfo": {}, | ||
"nodes": [ | ||
{ | ||
"id": "GHSA-8v27-2fg9-7h62", | ||
"withdrawnAt": "2021-05-04T20:26:20Z" | ||
} | ||
] | ||
} | ||
} | ||
} |