From ae7cd6bbb7866f55ec4c5030a2c94a0239d4ca68 Mon Sep 17 00:00:00 2001 From: Dan Luhring Date: Wed, 27 Jan 2021 10:07:54 -0500 Subject: [PATCH] Add test for Java cataloging with no main package Signed-off-by: Dan Luhring --- test/integration/java_no_main_package_test.go | 20 ++++++++++++++++ .../image-java-no-main-package/Dockerfile | 23 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/integration/java_no_main_package_test.go create mode 100644 test/integration/test-fixtures/image-java-no-main-package/Dockerfile diff --git a/test/integration/java_no_main_package_test.go b/test/integration/java_no_main_package_test.go new file mode 100644 index 000000000..e330a78fb --- /dev/null +++ b/test/integration/java_no_main_package_test.go @@ -0,0 +1,20 @@ +package integration + +import ( + "github.com/anchore/stereoscope/pkg/imagetest" + "github.com/anchore/syft/syft" + "github.com/anchore/syft/syft/source" + "testing" +) + +func TestJavaNoMainPackage(t *testing.T) { // Regression: https://github.com/anchore/syft/issues/252 + fixtureImageName := "image-java-no-main-package" + _, cleanup := imagetest.GetFixtureImage(t, "docker-archive", fixtureImageName) + tarPath := imagetest.GetFixtureImageTarPath(t, fixtureImageName) + defer cleanup() + + _, _, _, err := syft.Catalog("docker-archive:"+tarPath, source.SquashedScope) + if err != nil { + t.Fatalf("failed to catalog image: %+v", err) + } +} diff --git a/test/integration/test-fixtures/image-java-no-main-package/Dockerfile b/test/integration/test-fixtures/image-java-no-main-package/Dockerfile new file mode 100644 index 000000000..c6100ae44 --- /dev/null +++ b/test/integration/test-fixtures/image-java-no-main-package/Dockerfile @@ -0,0 +1,23 @@ +FROM jenkins:2.60.3 + +USER root + +WORKDIR /usr/share/jenkins + +RUN mkdir tmp + +WORKDIR /usr/share/jenkins/tmp + +RUN apt-get update 2>&1 > /dev/null && apt-get install -y less zip 2>&1 > /dev/null + +RUN unzip ../jenkins.war 2>&1 > /dev/null + +RUN rm -f ./META-INF/MANIFEST.MF + +WORKDIR /usr/share/jenkins + +RUN rm -rf jenkins.war + +RUN cd ./tmp && zip -r ../jenkins.war . && cd .. + +RUN rm -rf ./tmp