Skip to content

Commit

Permalink
tests: run spoon with depscan (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
algomaster99 authored Aug 28, 2023
1 parent d6c8db9 commit fae647b
Show file tree
Hide file tree
Showing 3 changed files with 14,759 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ private void processAllComponents(Bom14Schema sbom) {
try {
File jarFile = JarDownloader.getMavenJarFile(
component.getGroup(), component.getName(), component.getVersion());
if (jarFile == null) {
LOGGER.warn(
"Could not find jar for {}:{}:{}",
component.getGroup(),
component.getName(),
component.getVersion());
continue;
}
goInsideJarAndUpdateFingerprints(
jarFile,
fingerprints,
Expand Down
10 changes: 8 additions & 2 deletions watchdog-agent/src/test/java/AgentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,24 @@ class Level1_FatJar {
private final Path project = Paths.get("src/test/resources/spoon-10.4.0");

@Test
void spoon_10_4_0_correctSbom() throws IOException, InterruptedException {
void spoon_10_4_0_cyclonedx_2_7_4_correctSbom() throws IOException, InterruptedException {
// contract: spoon 10.4.0 CLI should be self-contained in a fat jar and its execution should not load any
// classes outside SBOM
assertThat(runSpoonWithSbom(project.resolve("bom.json"))).isEqualTo(0);
}

@Test
void spoon_10_4_0_wrongSbom() throws IOException, InterruptedException {
void spoon_10_4_0_cyclonedx_2_7_4_wrongSbom() throws IOException, InterruptedException {
// contract: spoon should not execute as the incorrect SBOM is passed (spoon-core is changed to 10.3.0)
assertThat(runSpoonWithSbom(project.resolve("wrong-bom.json"))).isEqualTo(1);
}

@Test
void spoon_10_4_0_depscan_4_2_2() throws IOException, InterruptedException {
// contract: spoon should execute as the root component is within component list
assertThat(runSpoonWithSbom(project.resolve("sbom-universal.json"))).isEqualTo(0);
}

private int runSpoonWithSbom(Path sbom) throws IOException, InterruptedException {
Path spoonExecutable = project.resolve("spoon-core-10.4.0-jar-with-dependencies.jar");
Path workload = project.resolve("Main.java").toAbsolutePath();
Expand Down
Loading

0 comments on commit fae647b

Please sign in to comment.