|
|
@ -49,6 +49,7 @@ import org.springframework.boot.testsupport.gradle.testkit.GradleBuildExtension;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.entry;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Integration tests for the Paketo builder and buildpacks.
|
|
|
|
* Integration tests for the Paketo builder and buildpacks.
|
|
|
@ -80,14 +81,16 @@ class PaketoBuilderTests {
|
|
|
|
container.waitingFor(Wait.forHttp("/test")).start();
|
|
|
|
container.waitingFor(Wait.forHttp("/test")).start();
|
|
|
|
ContainerConfig config = container.getContainerInfo().getConfig();
|
|
|
|
ContainerConfig config = container.getContainerInfo().getConfig();
|
|
|
|
assertLabelsMatchManifestAttributes(config);
|
|
|
|
assertLabelsMatchManifestAttributes(config);
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().buildpacks().contains(
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
|
|
|
|
"paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica",
|
|
|
|
metadata.buildpacks().contains("paketo-buildpacks/ca-certificates",
|
|
|
|
"paketo-buildpacks/executable-jar", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
|
|
|
|
"paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/executable-jar",
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().processOfType("web").extracting("command", "args")
|
|
|
|
"paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
|
|
|
|
.containsExactly("java", Collections.singletonList("org.springframework.boot.loader.JarLauncher"));
|
|
|
|
metadata.processOfType("web").extracting("command", "args").containsExactly("java",
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().processOfType("executable-jar")
|
|
|
|
Collections.singletonList("org.springframework.boot.loader.JarLauncher"));
|
|
|
|
.extracting("command", "args")
|
|
|
|
metadata.processOfType("executable-jar").extracting("command", "args").containsExactly("java",
|
|
|
|
.containsExactly("java", Collections.singletonList("org.springframework.boot.loader.JarLauncher"));
|
|
|
|
Collections.singletonList("org.springframework.boot.loader.JarLauncher"));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
assertImageHasSbomLayer(imageReference, config, "executable-jar");
|
|
|
|
assertImageLayersMatchLayersIndex(imageReference, config);
|
|
|
|
assertImageLayersMatchLayersIndex(imageReference, config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
finally {
|
|
|
@ -143,17 +146,22 @@ class PaketoBuilderTests {
|
|
|
|
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
|
|
|
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
|
|
|
container.waitingFor(Wait.forHttp("/test")).start();
|
|
|
|
container.waitingFor(Wait.forHttp("/test")).start();
|
|
|
|
ContainerConfig config = container.getContainerInfo().getConfig();
|
|
|
|
ContainerConfig config = container.getContainerInfo().getConfig();
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().buildpacks().contains(
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
|
|
|
|
"paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica",
|
|
|
|
metadata.buildpacks().contains("paketo-buildpacks/ca-certificates",
|
|
|
|
"paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
|
|
|
|
"paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/dist-zip",
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().processOfType("web").extracting("command", "args")
|
|
|
|
"paketo-buildpacks/spring-boot");
|
|
|
|
.containsExactly("/workspace/" + projectName + "-boot/bin/" + projectName, Collections.emptyList());
|
|
|
|
metadata.processOfType("web").extracting("command", "args").containsExactly(
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().processOfType("dist-zip").extracting("command", "args")
|
|
|
|
"/workspace/" + projectName + "-boot/bin/" + projectName, Collections.emptyList());
|
|
|
|
.containsExactly("/workspace/" + projectName + "-boot/bin/" + projectName, Collections.emptyList());
|
|
|
|
metadata.processOfType("dist-zip").extracting("command", "args").containsExactly(
|
|
|
|
DigestCapturingCondition digests = new DigestCapturingCondition();
|
|
|
|
"/workspace/" + projectName + "-boot/bin/" + projectName, Collections.emptyList());
|
|
|
|
ImageAssertions.assertThat(config).lifecycleMetadata().appLayerShas().haveExactly(1, digests);
|
|
|
|
});
|
|
|
|
ImageAssertions.assertThat(imageReference).hasLayer(digests.getDigest(0)).entries().contains(
|
|
|
|
assertImageHasSbomLayer(imageReference, config, "dist-zip");
|
|
|
|
projectName + "-boot/bin/" + projectName, projectName + "-boot/lib/" + projectName + ".jar");
|
|
|
|
DigestCapturingCondition digest = new DigestCapturingCondition();
|
|
|
|
|
|
|
|
ImageAssertions.assertThat(config)
|
|
|
|
|
|
|
|
.lifecycleMetadata((metadata) -> metadata.appLayerShas().haveExactly(1, digest));
|
|
|
|
|
|
|
|
ImageAssertions.assertThat(imageReference).layer(digest.getDigest(),
|
|
|
|
|
|
|
|
(layer) -> layer.entries().contains(projectName + "-boot/bin/" + projectName,
|
|
|
|
|
|
|
|
projectName + "-boot/lib/" + projectName + ".jar"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
finally {
|
|
|
|
removeImage(imageReference);
|
|
|
|
removeImage(imageReference);
|
|
|
@ -171,20 +179,24 @@ class PaketoBuilderTests {
|
|
|
|
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
|
|
|
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
|
|
|
container.waitingFor(Wait.forHttp("/test")).start();
|
|
|
|
container.waitingFor(Wait.forHttp("/test")).start();
|
|
|
|
ContainerConfig config = container.getContainerInfo().getConfig();
|
|
|
|
ContainerConfig config = container.getContainerInfo().getConfig();
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().buildpacks().contains(
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
|
|
|
|
"paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica",
|
|
|
|
metadata.buildpacks().contains("paketo-buildpacks/ca-certificates",
|
|
|
|
"paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
|
|
|
|
"paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/dist-zip",
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().processOfType("web").extracting("command", "args")
|
|
|
|
"paketo-buildpacks/spring-boot");
|
|
|
|
.containsExactly("/workspace/" + projectName + "/bin/" + projectName, Collections.emptyList());
|
|
|
|
metadata.processOfType("web").extracting("command", "args")
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().processOfType("dist-zip").extracting("command", "args")
|
|
|
|
.containsExactly("/workspace/" + projectName + "/bin/" + projectName, Collections.emptyList());
|
|
|
|
.containsExactly("/workspace/" + projectName + "/bin/" + projectName, Collections.emptyList());
|
|
|
|
metadata.processOfType("dist-zip").extracting("command", "args")
|
|
|
|
DigestCapturingCondition digests = new DigestCapturingCondition();
|
|
|
|
.containsExactly("/workspace/" + projectName + "/bin/" + projectName, Collections.emptyList());
|
|
|
|
ImageAssertions.assertThat(config).lifecycleMetadata().appLayerShas().haveExactly(1, digests);
|
|
|
|
});
|
|
|
|
ImageAssertions.assertThat(imageReference).hasLayer(digests.getDigest(0)).entries()
|
|
|
|
assertImageHasSbomLayer(imageReference, config, "dist-zip");
|
|
|
|
|
|
|
|
DigestCapturingCondition digest = new DigestCapturingCondition();
|
|
|
|
|
|
|
|
ImageAssertions.assertThat(config)
|
|
|
|
|
|
|
|
.lifecycleMetadata((metadata) -> metadata.appLayerShas().haveExactly(1, digest));
|
|
|
|
|
|
|
|
ImageAssertions.assertThat(imageReference).layer(digest.getDigest(), (layer) -> layer.entries()
|
|
|
|
.contains(projectName + "/bin/" + projectName, projectName + "/lib/" + projectName + "-plain.jar")
|
|
|
|
.contains(projectName + "/bin/" + projectName, projectName + "/lib/" + projectName + "-plain.jar")
|
|
|
|
.anyMatch((s) -> s.startsWith(projectName + "/lib/spring-boot-"))
|
|
|
|
.anyMatch((s) -> s.startsWith(projectName + "/lib/spring-boot-"))
|
|
|
|
.anyMatch((s) -> s.startsWith(projectName + "/lib/spring-core-"))
|
|
|
|
.anyMatch((s) -> s.startsWith(projectName + "/lib/spring-core-"))
|
|
|
|
.anyMatch((s) -> s.startsWith(projectName + "/lib/spring-web-"));
|
|
|
|
.anyMatch((s) -> s.startsWith(projectName + "/lib/spring-web-")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
finally {
|
|
|
|
removeImage(imageReference);
|
|
|
|
removeImage(imageReference);
|
|
|
@ -203,14 +215,16 @@ class PaketoBuilderTests {
|
|
|
|
container.waitingFor(Wait.forHttp("/test")).start();
|
|
|
|
container.waitingFor(Wait.forHttp("/test")).start();
|
|
|
|
ContainerConfig config = container.getContainerInfo().getConfig();
|
|
|
|
ContainerConfig config = container.getContainerInfo().getConfig();
|
|
|
|
assertLabelsMatchManifestAttributes(config);
|
|
|
|
assertLabelsMatchManifestAttributes(config);
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().buildpacks().contains(
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
|
|
|
|
"paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica",
|
|
|
|
metadata.buildpacks().contains("paketo-buildpacks/ca-certificates",
|
|
|
|
"paketo-buildpacks/executable-jar", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
|
|
|
|
"paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/executable-jar",
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().processOfType("web").extracting("command", "args")
|
|
|
|
"paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
|
|
|
|
.containsExactly("java", Collections.singletonList("org.springframework.boot.loader.WarLauncher"));
|
|
|
|
metadata.processOfType("web").extracting("command", "args").containsExactly("java",
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().processOfType("executable-jar")
|
|
|
|
Collections.singletonList("org.springframework.boot.loader.WarLauncher"));
|
|
|
|
.extracting("command", "args")
|
|
|
|
metadata.processOfType("executable-jar").extracting("command", "args").containsExactly("java",
|
|
|
|
.containsExactly("java", Collections.singletonList("org.springframework.boot.loader.WarLauncher"));
|
|
|
|
Collections.singletonList("org.springframework.boot.loader.WarLauncher"));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
assertImageHasSbomLayer(imageReference, config, "executable-jar");
|
|
|
|
assertImageLayersMatchLayersIndex(imageReference, config);
|
|
|
|
assertImageLayersMatchLayersIndex(imageReference, config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
finally {
|
|
|
@ -229,21 +243,26 @@ class PaketoBuilderTests {
|
|
|
|
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
|
|
|
try (GenericContainer<?> container = new GenericContainer<>(imageName).withExposedPorts(8080)) {
|
|
|
|
container.waitingFor(Wait.forHttp("/test")).start();
|
|
|
|
container.waitingFor(Wait.forHttp("/test")).start();
|
|
|
|
ContainerConfig config = container.getContainerInfo().getConfig();
|
|
|
|
ContainerConfig config = container.getContainerInfo().getConfig();
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().buildpacks().contains(
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
|
|
|
|
"paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica",
|
|
|
|
metadata.buildpacks().contains("paketo-buildpacks/ca-certificates",
|
|
|
|
"paketo-buildpacks/apache-tomcat", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
|
|
|
|
"paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/apache-tomcat",
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().processOfType("web").extracting("command", "args")
|
|
|
|
"paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot");
|
|
|
|
.containsExactly("bash", Arrays.asList("catalina.sh", "run"));
|
|
|
|
metadata.processOfType("web").extracting("command", "args").containsExactly("bash",
|
|
|
|
ImageAssertions.assertThat(config).buildMetadata().processOfType("tomcat").extracting("command", "args")
|
|
|
|
Arrays.asList("catalina.sh", "run"));
|
|
|
|
.containsExactly("bash", Arrays.asList("catalina.sh", "run"));
|
|
|
|
metadata.processOfType("tomcat").extracting("command", "args").containsExactly("bash",
|
|
|
|
DigestCapturingCondition digests = new DigestCapturingCondition();
|
|
|
|
Arrays.asList("catalina.sh", "run"));
|
|
|
|
ImageAssertions.assertThat(config).lifecycleMetadata().appLayerShas().haveExactly(1, digests);
|
|
|
|
});
|
|
|
|
ImageAssertions.assertThat(imageReference).hasLayer(digests.getDigest(0)).entries()
|
|
|
|
assertImageHasSbomLayer(imageReference, config, "apache-tomcat");
|
|
|
|
.contains("WEB-INF/classes/example/ExampleApplication.class",
|
|
|
|
DigestCapturingCondition digest = new DigestCapturingCondition();
|
|
|
|
"WEB-INF/classes/example/HelloController.class", "META-INF/MANIFEST.MF")
|
|
|
|
ImageAssertions.assertThat(config)
|
|
|
|
.anyMatch((s) -> s.startsWith("WEB-INF/lib/spring-boot-"))
|
|
|
|
.lifecycleMetadata((metadata) -> metadata.appLayerShas().haveExactly(1, digest));
|
|
|
|
.anyMatch((s) -> s.startsWith("WEB-INF/lib/spring-core-"))
|
|
|
|
ImageAssertions.assertThat(imageReference).layer(digest.getDigest(),
|
|
|
|
.anyMatch((s) -> s.startsWith("WEB-INF/lib/spring-web-"));
|
|
|
|
(layer) -> layer.entries()
|
|
|
|
|
|
|
|
.contains("WEB-INF/classes/example/ExampleApplication.class",
|
|
|
|
|
|
|
|
"WEB-INF/classes/example/HelloController.class", "META-INF/MANIFEST.MF")
|
|
|
|
|
|
|
|
.anyMatch((s) -> s.startsWith("WEB-INF/lib/spring-boot-"))
|
|
|
|
|
|
|
|
.anyMatch((s) -> s.startsWith("WEB-INF/lib/spring-core-"))
|
|
|
|
|
|
|
|
.anyMatch((s) -> s.startsWith("WEB-INF/lib/spring-web-")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
finally {
|
|
|
|
removeImage(imageReference);
|
|
|
|
removeImage(imageReference);
|
|
|
@ -318,29 +337,54 @@ class PaketoBuilderTests {
|
|
|
|
private void assertLabelsMatchManifestAttributes(ContainerConfig config) throws IOException {
|
|
|
|
private void assertLabelsMatchManifestAttributes(ContainerConfig config) throws IOException {
|
|
|
|
JarFile jarFile = new JarFile(projectArchiveFile());
|
|
|
|
JarFile jarFile = new JarFile(projectArchiveFile());
|
|
|
|
Attributes attributes = jarFile.getManifest().getMainAttributes();
|
|
|
|
Attributes attributes = jarFile.getManifest().getMainAttributes();
|
|
|
|
ImageAssertions.assertThat(config).label("org.springframework.boot.version")
|
|
|
|
ImageAssertions.assertThat(config).labels((labels) -> {
|
|
|
|
.isEqualTo(attributes.getValue("Spring-Boot-Version"));
|
|
|
|
labels.contains(entry("org.springframework.boot.version", attributes.getValue("Spring-Boot-Version")));
|
|
|
|
ImageAssertions.assertThat(config).label("org.opencontainers.image.title")
|
|
|
|
labels.contains(
|
|
|
|
.isEqualTo(attributes.getValue(Attributes.Name.IMPLEMENTATION_TITLE));
|
|
|
|
entry("org.opencontainers.image.title", attributes.getValue(Attributes.Name.IMPLEMENTATION_TITLE)));
|
|
|
|
ImageAssertions.assertThat(config).label("org.opencontainers.image.version")
|
|
|
|
labels.contains(entry("org.opencontainers.image.version",
|
|
|
|
.isEqualTo(attributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION));
|
|
|
|
attributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION)));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void assertImageHasSbomLayer(ImageReference imageReference, ContainerConfig config, String buildpack)
|
|
|
|
|
|
|
|
throws IOException {
|
|
|
|
|
|
|
|
DigestCapturingCondition digest = new DigestCapturingCondition();
|
|
|
|
|
|
|
|
ImageAssertions.assertThat(config).lifecycleMetadata((metadata) -> metadata.sbomLayerSha().has(digest));
|
|
|
|
|
|
|
|
ImageAssertions.assertThat(imageReference).layer(digest.getDigest(), (layer) -> {
|
|
|
|
|
|
|
|
layer.entries().contains("/layers/sbom/launch/paketo-buildpacks_bellsoft-liberica/jre/sbom.syft.json",
|
|
|
|
|
|
|
|
"/layers/sbom/launch/paketo-buildpacks_" + buildpack + "/sbom.syft.json",
|
|
|
|
|
|
|
|
"/layers/sbom/launch/paketo-buildpacks_" + buildpack + "/sbom.cdx.json");
|
|
|
|
|
|
|
|
layer.jsonEntry("/layers/sbom/launch/paketo-buildpacks_bellsoft-liberica/jre/sbom.syft.json", (json) -> {
|
|
|
|
|
|
|
|
json.extractingJsonPathStringValue("$.Artifacts[0].Name").isEqualTo("BellSoft Liberica JRE");
|
|
|
|
|
|
|
|
json.extractingJsonPathStringValue("$.Artifacts[0].Version").startsWith(javaMajorVersion());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
layer.jsonEntry("/layers/sbom/launch/paketo-buildpacks_" + buildpack + "/sbom.syft.json",
|
|
|
|
|
|
|
|
(json) -> json.extractingJsonPathArrayValue("$.artifacts.[*].name").contains("spring-beans",
|
|
|
|
|
|
|
|
"spring-boot", "spring-boot-autoconfigure", "spring-context", "spring-core",
|
|
|
|
|
|
|
|
"spring-expression", "spring-jcl", "spring-web", "spring-webmvc"));
|
|
|
|
|
|
|
|
layer.jsonEntry("/layers/sbom/launch/paketo-buildpacks_" + buildpack + "/sbom.cdx.json",
|
|
|
|
|
|
|
|
(json) -> json.extractingJsonPathArrayValue("$.components.[*].name").contains("spring-beans",
|
|
|
|
|
|
|
|
"spring-boot", "spring-boot-autoconfigure", "spring-context", "spring-core",
|
|
|
|
|
|
|
|
"spring-expression", "spring-jcl", "spring-web", "spring-webmvc"));
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void assertImageLayersMatchLayersIndex(ImageReference imageReference, ContainerConfig config)
|
|
|
|
private void assertImageLayersMatchLayersIndex(ImageReference imageReference, ContainerConfig config)
|
|
|
|
throws IOException {
|
|
|
|
throws IOException {
|
|
|
|
DigestCapturingCondition digests = new DigestCapturingCondition();
|
|
|
|
DigestsCapturingCondition digests = new DigestsCapturingCondition();
|
|
|
|
ImageAssertions.assertThat(config).lifecycleMetadata().appLayerShas().haveExactly(5, digests);
|
|
|
|
ImageAssertions.assertThat(config)
|
|
|
|
|
|
|
|
.lifecycleMetadata((metadata) -> metadata.appLayerShas().haveExactly(5, digests));
|
|
|
|
LayersIndex layersIndex = LayersIndex.fromArchiveFile(projectArchiveFile());
|
|
|
|
LayersIndex layersIndex = LayersIndex.fromArchiveFile(projectArchiveFile());
|
|
|
|
ImageAssertions.assertThat(imageReference).hasLayer(digests.getDigest(0)).entries()
|
|
|
|
ImageAssertions.assertThat(imageReference).layer(digests.getDigest(0), (layer) -> layer.entries()
|
|
|
|
.allMatch((entry) -> startsWithOneOf(entry, layersIndex.getLayer("dependencies")));
|
|
|
|
.allMatch((entry) -> startsWithOneOf(entry, layersIndex.getLayer("dependencies"))));
|
|
|
|
ImageAssertions.assertThat(imageReference).hasLayer(digests.getDigest(1)).entries()
|
|
|
|
ImageAssertions.assertThat(imageReference).layer(digests.getDigest(1), (layer) -> layer.entries()
|
|
|
|
.allMatch((entry) -> startsWithOneOf(entry, layersIndex.getLayer("spring-boot-loader")));
|
|
|
|
.allMatch((entry) -> startsWithOneOf(entry, layersIndex.getLayer("spring-boot-loader"))));
|
|
|
|
ImageAssertions.assertThat(imageReference).hasLayer(digests.getDigest(2)).entries()
|
|
|
|
ImageAssertions.assertThat(imageReference).layer(digests.getDigest(2), (layer) -> layer.entries()
|
|
|
|
.allMatch((entry) -> startsWithOneOf(entry, layersIndex.getLayer("snapshot-dependencies")));
|
|
|
|
.allMatch((entry) -> startsWithOneOf(entry, layersIndex.getLayer("snapshot-dependencies"))));
|
|
|
|
ImageAssertions.assertThat(imageReference).hasLayer(digests.getDigest(3)).entries()
|
|
|
|
ImageAssertions.assertThat(imageReference).layer(digests.getDigest(3), (layer) -> layer.entries()
|
|
|
|
.allMatch((entry) -> startsWithOneOf(entry, layersIndex.getLayer("application")));
|
|
|
|
.allMatch((entry) -> startsWithOneOf(entry, layersIndex.getLayer("application"))));
|
|
|
|
ImageAssertions.assertThat(imageReference).hasLayer(digests.getDigest(4)).entries()
|
|
|
|
ImageAssertions.assertThat(imageReference).layer(digests.getDigest(4),
|
|
|
|
.allMatch((entry) -> entry.contains("lib/spring-cloud-bindings-"));
|
|
|
|
(layer) -> layer.entries().allMatch((entry) -> entry.contains("lib/spring-cloud-bindings-")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private File projectArchiveFile() {
|
|
|
|
private File projectArchiveFile() {
|
|
|
@ -376,12 +420,33 @@ class PaketoBuilderTests {
|
|
|
|
|
|
|
|
|
|
|
|
private static class DigestCapturingCondition extends Condition<Object> {
|
|
|
|
private static class DigestCapturingCondition extends Condition<Object> {
|
|
|
|
|
|
|
|
|
|
|
|
private static List<String> digests;
|
|
|
|
private static String digest = null;
|
|
|
|
|
|
|
|
|
|
|
|
DigestCapturingCondition() {
|
|
|
|
DigestCapturingCondition() {
|
|
|
|
super(predicate(), "a value starting with 'sha256:'");
|
|
|
|
super(predicate(), "a value starting with 'sha256:'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Predicate<Object> predicate() {
|
|
|
|
|
|
|
|
return (sha) -> {
|
|
|
|
|
|
|
|
digest = sha.toString();
|
|
|
|
|
|
|
|
return sha.toString().startsWith("sha256:");
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String getDigest() {
|
|
|
|
|
|
|
|
return digest;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class DigestsCapturingCondition extends Condition<Object> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<String> digests;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DigestsCapturingCondition() {
|
|
|
|
|
|
|
|
super(predicate(), "a value starting with 'sha256:'");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static Predicate<Object> predicate() {
|
|
|
|
private static Predicate<Object> predicate() {
|
|
|
|
digests = new ArrayList<>();
|
|
|
|
digests = new ArrayList<>();
|
|
|
|
return (sha) -> {
|
|
|
|
return (sha) -> {
|
|
|
|