Merge branch '2.7.x' into 3.0.x
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,7 +62,7 @@ class BuilderBuildpack implements Buildpack {
|
||||
static Buildpack resolve(BuildpackResolverContext context, BuildpackReference reference) {
|
||||
boolean unambiguous = reference.hasPrefix(PREFIX);
|
||||
BuilderReference builderReference = BuilderReference
|
||||
.of(unambiguous ? reference.getSubReference(PREFIX) : reference.toString());
|
||||
.of(unambiguous ? reference.getSubReference(PREFIX) : reference.toString());
|
||||
BuildpackMetadata buildpackMetadata = findBuildpackMetadata(context, builderReference);
|
||||
if (unambiguous) {
|
||||
Assert.isTrue(buildpackMetadata != null, () -> "Buildpack '" + reference + "' not found in builder");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -118,8 +118,9 @@ final class BuildpackLayersMetadata extends MappedObject {
|
||||
|
||||
private static Buildpacks fromJson(JsonNode node) {
|
||||
Buildpacks buildpacks = new Buildpacks();
|
||||
node.fields().forEachRemaining((field) -> buildpacks.addBuildpackVersions(field.getKey(),
|
||||
BuildpackVersions.fromJson(field.getValue())));
|
||||
node.fields()
|
||||
.forEachRemaining((field) -> buildpacks.addBuildpackVersions(field.getKey(),
|
||||
BuildpackVersions.fromJson(field.getValue())));
|
||||
return buildpacks;
|
||||
}
|
||||
|
||||
@@ -139,8 +140,9 @@ final class BuildpackLayersMetadata extends MappedObject {
|
||||
|
||||
private static BuildpackVersions fromJson(JsonNode node) {
|
||||
BuildpackVersions versions = new BuildpackVersions();
|
||||
node.fields().forEachRemaining((field) -> versions.addBuildpackVersion(field.getKey(),
|
||||
BuildpackLayerDetails.fromJson(field.getValue())));
|
||||
node.fields()
|
||||
.forEachRemaining((field) -> versions.addBuildpackVersion(field.getKey(),
|
||||
BuildpackLayerDetails.fromJson(field.getValue())));
|
||||
return versions;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -71,7 +71,7 @@ final class ImageBuildpack implements Buildpack {
|
||||
|
||||
private boolean buildpackExistsInBuilder(BuildpackResolverContext context, List<LayerId> imageLayers) {
|
||||
BuildpackLayerDetails buildpackLayerDetails = context.getBuildpackLayersMetadata()
|
||||
.getBuildpack(this.coordinates.getId(), this.coordinates.getVersion());
|
||||
.getBuildpack(this.coordinates.getId(), this.coordinates.getVersion());
|
||||
String layerDiffId = (buildpackLayerDetails != null) ? buildpackLayerDetails.getLayerDiffId() : null;
|
||||
return (layerDiffId != null) && imageLayers.stream().map(LayerId::toString).anyMatch(layerDiffId::equals);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ final class ImageBuildpack implements Buildpack {
|
||||
boolean unambiguous = reference.hasPrefix(PREFIX);
|
||||
try {
|
||||
ImageReference imageReference = ImageReference
|
||||
.of((unambiguous) ? reference.getSubReference(PREFIX) : reference.toString());
|
||||
.of((unambiguous) ? reference.getSubReference(PREFIX) : reference.toString());
|
||||
return new ImageBuildpack(context, imageReference);
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -239,8 +239,8 @@ class Lifecycle implements Closeable {
|
||||
}
|
||||
try {
|
||||
TarArchive applicationContent = this.request.getApplicationContent(this.builder.getBuildOwner());
|
||||
return this.docker.container().create(config,
|
||||
ContainerContent.of(applicationContent, Directory.APPLICATION));
|
||||
return this.docker.container()
|
||||
.create(config, ContainerContent.of(applicationContent, Directory.APPLICATION));
|
||||
}
|
||||
finally {
|
||||
this.applicationVolumePopulated = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,8 @@ import org.springframework.util.Assert;
|
||||
class LifecycleVersion implements Comparable<LifecycleVersion> {
|
||||
|
||||
private static final Comparator<LifecycleVersion> COMPARATOR = Comparator.comparingInt(LifecycleVersion::getMajor)
|
||||
.thenComparingInt(LifecycleVersion::getMinor).thenComparing(LifecycleVersion::getPatch);
|
||||
.thenComparingInt(LifecycleVersion::getMinor)
|
||||
.thenComparing(LifecycleVersion::getPatch);
|
||||
|
||||
private final int major;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -339,7 +339,7 @@ public class DockerApi {
|
||||
URI createUri = buildUrl("/containers/create");
|
||||
try (Response response = http().post(createUri, "application/json", config::writeTo)) {
|
||||
return ContainerReference
|
||||
.of(SharedObjectMapper.get().readTree(response.getContent()).at("/Id").asText());
|
||||
.of(SharedObjectMapper.get().readTree(response.getContent()).at("/Id").asText());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,10 +56,10 @@ import org.springframework.util.Assert;
|
||||
public class ImageArchive implements TarArchive {
|
||||
|
||||
private static final Instant WINDOWS_EPOCH_PLUS_SECOND = OffsetDateTime.of(1980, 1, 1, 0, 0, 1, 0, ZoneOffset.UTC)
|
||||
.toInstant();
|
||||
.toInstant();
|
||||
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ISO_ZONED_DATE_TIME
|
||||
.withZone(ZoneOffset.UTC);
|
||||
.withZone(ZoneOffset.UTC);
|
||||
|
||||
private static final String EMPTY_LAYER_NAME_PREFIX = "blank_";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -66,7 +66,7 @@ final class Regex implements CharSequence {
|
||||
static final Pattern TAG = Regex.of("^[\\w][\\w.-]{0,127}").compile();
|
||||
|
||||
static final Pattern DIGEST = Regex.of("^[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[A-Fa-f0-9]]{32,}")
|
||||
.compile();
|
||||
.compile();
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
@@ -35,19 +35,19 @@ class ApiVersionTests {
|
||||
@Test
|
||||
void parseWhenVersionIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ApiVersion.parse(null))
|
||||
.withMessage("Value must not be empty");
|
||||
.withMessage("Value must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseWhenVersionIsEmptyThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ApiVersion.parse(""))
|
||||
.withMessage("Value must not be empty");
|
||||
.withMessage("Value must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseWhenVersionDoesNotMatchPatternThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ApiVersion.parse("bad"))
|
||||
.withMessage("Malformed version number 'bad'");
|
||||
.withMessage("Malformed version number 'bad'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,8 +65,8 @@ class ApiVersionTests {
|
||||
@Test
|
||||
void assertSupportsWhenDoesNotSupportThrowsException() {
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> ApiVersion.parse("1.2").assertSupports(ApiVersion.parse("1.3")))
|
||||
.withMessage("Detected platform API version '1.3' does not match supported version '1.2'");
|
||||
.isThrownBy(() -> ApiVersion.parse("1.2").assertSupports(ApiVersion.parse("1.3")))
|
||||
.withMessage("Detected platform API version '1.3' does not match supported version '1.2'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,7 +129,7 @@ class ApiVersionTests {
|
||||
|
||||
private boolean supportsAny(String v1, String... others) {
|
||||
return ApiVersion.parse(v1)
|
||||
.supportsAny(Arrays.stream(others).map(ApiVersion::parse).toArray(ApiVersion[]::new));
|
||||
.supportsAny(Arrays.stream(others).map(ApiVersion::parse).toArray(ApiVersion[]::new));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ class ApiVersionsTests {
|
||||
@Test
|
||||
void findLatestWhenNoneSupportedThrowsException() {
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> ApiVersions.parse("1.1", "1.2").findLatestSupported("1.3", "1.4")).withMessage(
|
||||
"Detected platform API versions '1.3,1.4' are not included in supported versions '1.1,1.2'");
|
||||
.isThrownBy(() -> ApiVersions.parse("1.1", "1.2").findLatestSupported("1.3", "1.4"))
|
||||
.withMessage("Detected platform API versions '1.3,1.4' are not included in supported versions '1.1,1.2'");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -47,7 +47,7 @@ class BuildOwnerTests {
|
||||
@Test
|
||||
void fromEnvWhenEnvIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildOwner.fromEnv(null))
|
||||
.withMessage("Env must not be null");
|
||||
.withMessage("Env must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,7 +55,7 @@ class BuildOwnerTests {
|
||||
Map<String, String> env = new LinkedHashMap<>();
|
||||
env.put("CNB_GROUP_ID", "456");
|
||||
assertThatIllegalStateException().isThrownBy(() -> BuildOwner.fromEnv(env))
|
||||
.withMessage("Missing 'CNB_USER_ID' value from the builder environment '" + env + "'");
|
||||
.withMessage("Missing 'CNB_USER_ID' value from the builder environment '" + env + "'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,7 +63,7 @@ class BuildOwnerTests {
|
||||
Map<String, String> env = new LinkedHashMap<>();
|
||||
env.put("CNB_USER_ID", "123");
|
||||
assertThatIllegalStateException().isThrownBy(() -> BuildOwner.fromEnv(env))
|
||||
.withMessage("Missing 'CNB_GROUP_ID' value from the builder environment '" + env + "'");
|
||||
.withMessage("Missing 'CNB_GROUP_ID' value from the builder environment '" + env + "'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -72,7 +72,7 @@ class BuildOwnerTests {
|
||||
env.put("CNB_USER_ID", "nope");
|
||||
env.put("CNB_GROUP_ID", "456");
|
||||
assertThatIllegalStateException().isThrownBy(() -> BuildOwner.fromEnv(env))
|
||||
.withMessage("Malformed 'CNB_USER_ID' value 'nope' in the builder environment '" + env + "'");
|
||||
.withMessage("Malformed 'CNB_USER_ID' value 'nope' in the builder environment '" + env + "'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +81,7 @@ class BuildOwnerTests {
|
||||
env.put("CNB_USER_ID", "123");
|
||||
env.put("CNB_GROUP_ID", "nope");
|
||||
assertThatIllegalStateException().isThrownBy(() -> BuildOwner.fromEnv(env))
|
||||
.withMessage("Malformed 'CNB_GROUP_ID' value 'nope' in the builder environment '" + env + "'");
|
||||
.withMessage("Malformed 'CNB_GROUP_ID' value 'nope' in the builder environment '" + env + "'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,32 +78,33 @@ class BuildRequestTests {
|
||||
@Test
|
||||
void forJarFileWhenJarFileIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildRequest.forJarFile(null))
|
||||
.withMessage("JarFile must not be null");
|
||||
.withMessage("JarFile must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void forJarFileWhenJarFileIsMissingThrowsException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> BuildRequest.forJarFile(new File(this.tempDir, "missing.jar")))
|
||||
.withMessage("JarFile must exist");
|
||||
.isThrownBy(() -> BuildRequest.forJarFile(new File(this.tempDir, "missing.jar")))
|
||||
.withMessage("JarFile must exist");
|
||||
}
|
||||
|
||||
@Test
|
||||
void forJarFileWhenJarFileIsDirectoryThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildRequest.forJarFile(this.tempDir))
|
||||
.withMessage("JarFile must be a file");
|
||||
.withMessage("JarFile must be a file");
|
||||
}
|
||||
|
||||
@Test
|
||||
void withBuilderUpdatesBuilder() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"))
|
||||
.withBuilder(ImageReference.of("spring/builder"));
|
||||
.withBuilder(ImageReference.of("spring/builder"));
|
||||
assertThat(request.getBuilder()).hasToString("docker.io/spring/builder:latest");
|
||||
}
|
||||
|
||||
@Test
|
||||
void withBuilderWhenHasDigestUpdatesBuilder() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar")).withBuilder(ImageReference
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"))
|
||||
.withBuilder(ImageReference
|
||||
.of("spring/builder@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d"));
|
||||
assertThat(request.getBuilder()).hasToString(
|
||||
"docker.io/spring/builder@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
@@ -112,13 +113,14 @@ class BuildRequestTests {
|
||||
@Test
|
||||
void withRunImageUpdatesRunImage() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"))
|
||||
.withRunImage(ImageReference.of("example.com/custom/run-image:latest"));
|
||||
.withRunImage(ImageReference.of("example.com/custom/run-image:latest"));
|
||||
assertThat(request.getRunImage()).hasToString("example.com/custom/run-image:latest");
|
||||
}
|
||||
|
||||
@Test
|
||||
void withRunImageWhenHasDigestUpdatesRunImage() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar")).withRunImage(ImageReference
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"))
|
||||
.withRunImage(ImageReference
|
||||
.of("example.com/custom/run-image@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d"));
|
||||
assertThat(request.getRunImage()).hasToString(
|
||||
"example.com/custom/run-image@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
@@ -157,14 +159,14 @@ class BuildRequestTests {
|
||||
void withEnvWhenKeyIsNullThrowsException() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> request.withEnv(null, "test"))
|
||||
.withMessage("Name must not be empty");
|
||||
.withMessage("Name must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void withEnvWhenValueIsNullThrowsException() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> request.withEnv("test", null))
|
||||
.withMessage("Value must not be empty");
|
||||
.withMessage("Value must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -181,7 +183,7 @@ class BuildRequestTests {
|
||||
void withBuildpacksWhenBuildpacksIsNullThrowsException() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> request.withBuildpacks((List<BuildpackReference>) null))
|
||||
.withMessage("Buildpacks must not be null");
|
||||
.withMessage("Buildpacks must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -198,7 +200,7 @@ class BuildRequestTests {
|
||||
void withBindingsWhenBindingsIsNullThrowsException() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> request.withBindings((List<Binding>) null))
|
||||
.withMessage("Bindings must not be null");
|
||||
.withMessage("Bindings must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -223,7 +225,7 @@ class BuildRequestTests {
|
||||
void withTagsWhenTagsIsNullThrowsException() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> request.withTags((List<ImageReference>) null))
|
||||
.withMessage("Tags must not be null");
|
||||
.withMessage("Tags must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -238,7 +240,7 @@ class BuildRequestTests {
|
||||
void withBuildVolumeCacheWhenCacheIsNullThrowsException() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> request.withBuildCache(null))
|
||||
.withMessage("BuildCache must not be null");
|
||||
.withMessage("BuildCache must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -253,7 +255,7 @@ class BuildRequestTests {
|
||||
void withLaunchVolumeCacheWhenCacheIsNullThrowsException() throws IOException {
|
||||
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> request.withLaunchCache(null))
|
||||
.withMessage("LaunchCache must not be null");
|
||||
.withMessage("LaunchCache must not be null");
|
||||
}
|
||||
|
||||
private void hasExpectedJarContent(TarArchive archive) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,7 +52,7 @@ class BuilderBuildpackTests extends AbstractJsonTests {
|
||||
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:paketo-buildpacks/spring-boot@3.5.0");
|
||||
Buildpack buildpack = BuilderBuildpack.resolve(this.resolverContext, reference);
|
||||
assertThat(buildpack.getCoordinates())
|
||||
.isEqualTo(BuildpackCoordinates.of("paketo-buildpacks/spring-boot", "3.5.0"));
|
||||
.isEqualTo(BuildpackCoordinates.of("paketo-buildpacks/spring-boot", "3.5.0"));
|
||||
assertThatNoLayersAreAdded(buildpack);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class BuilderBuildpackTests extends AbstractJsonTests {
|
||||
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:paketo-buildpacks/spring-boot");
|
||||
Buildpack buildpack = BuilderBuildpack.resolve(this.resolverContext, reference);
|
||||
assertThat(buildpack.getCoordinates())
|
||||
.isEqualTo(BuildpackCoordinates.of("paketo-buildpacks/spring-boot", "3.5.0"));
|
||||
.isEqualTo(BuildpackCoordinates.of("paketo-buildpacks/spring-boot", "3.5.0"));
|
||||
assertThatNoLayersAreAdded(buildpack);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class BuilderBuildpackTests extends AbstractJsonTests {
|
||||
BuildpackReference reference = BuildpackReference.of("paketo-buildpacks/spring-boot@3.5.0");
|
||||
Buildpack buildpack = BuilderBuildpack.resolve(this.resolverContext, reference);
|
||||
assertThat(buildpack.getCoordinates())
|
||||
.isEqualTo(BuildpackCoordinates.of("paketo-buildpacks/spring-boot", "3.5.0"));
|
||||
.isEqualTo(BuildpackCoordinates.of("paketo-buildpacks/spring-boot", "3.5.0"));
|
||||
assertThatNoLayersAreAdded(buildpack);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class BuilderBuildpackTests extends AbstractJsonTests {
|
||||
BuildpackReference reference = BuildpackReference.of("paketo-buildpacks/spring-boot");
|
||||
Buildpack buildpack = BuilderBuildpack.resolve(this.resolverContext, reference);
|
||||
assertThat(buildpack.getCoordinates())
|
||||
.isEqualTo(BuildpackCoordinates.of("paketo-buildpacks/spring-boot", "3.5.0"));
|
||||
.isEqualTo(BuildpackCoordinates.of("paketo-buildpacks/spring-boot", "3.5.0"));
|
||||
assertThatNoLayersAreAdded(buildpack);
|
||||
}
|
||||
|
||||
@@ -87,16 +87,16 @@ class BuilderBuildpackTests extends AbstractJsonTests {
|
||||
void resolveWhenFullyQualifiedBuildpackWithVersionNotInBuilderThrowsException() {
|
||||
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:example/buildpack1@1.2.3");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuilderBuildpack.resolve(this.resolverContext, reference))
|
||||
.withMessageContaining("'urn:cnb:builder:example/buildpack1@1.2.3'")
|
||||
.withMessageContaining("not found in builder");
|
||||
.withMessageContaining("'urn:cnb:builder:example/buildpack1@1.2.3'")
|
||||
.withMessageContaining("not found in builder");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveWhenFullyQualifiedBuildpackWithoutVersionNotInBuilderThrowsException() {
|
||||
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:example/buildpack1");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuilderBuildpack.resolve(this.resolverContext, reference))
|
||||
.withMessageContaining("'urn:cnb:builder:example/buildpack1'")
|
||||
.withMessageContaining("not found in builder");
|
||||
.withMessageContaining("'urn:cnb:builder:example/buildpack1'")
|
||||
.withMessageContaining("not found in builder");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,28 +51,28 @@ class BuilderMetadataTests extends AbstractJsonTests {
|
||||
assertThat(metadata.getLifecycle().getApi().getPlatform()).isEqualTo("0.3");
|
||||
assertThat(metadata.getCreatedBy().getName()).isEqualTo("Pack CLI");
|
||||
assertThat(metadata.getCreatedBy().getVersion())
|
||||
.isEqualTo("v0.9.0 (git sha: d42c384a39f367588f2653f2a99702db910e5ad7)");
|
||||
.isEqualTo("v0.9.0 (git sha: d42c384a39f367588f2653f2a99702db910e5ad7)");
|
||||
assertThat(metadata.getBuildpacks()).extracting(BuildpackMetadata::getId, BuildpackMetadata::getVersion)
|
||||
.contains(tuple("paketo-buildpacks/java", "4.10.0"))
|
||||
.contains(tuple("paketo-buildpacks/spring-boot", "3.5.0"))
|
||||
.contains(tuple("paketo-buildpacks/executable-jar", "3.1.3"))
|
||||
.contains(tuple("paketo-buildpacks/graalvm", "4.1.0"))
|
||||
.contains(tuple("paketo-buildpacks/java-native-image", "4.7.0"))
|
||||
.contains(tuple("paketo-buildpacks/spring-boot-native-image", "2.0.1"))
|
||||
.contains(tuple("paketo-buildpacks/bellsoft-liberica", "6.2.0"));
|
||||
.contains(tuple("paketo-buildpacks/java", "4.10.0"))
|
||||
.contains(tuple("paketo-buildpacks/spring-boot", "3.5.0"))
|
||||
.contains(tuple("paketo-buildpacks/executable-jar", "3.1.3"))
|
||||
.contains(tuple("paketo-buildpacks/graalvm", "4.1.0"))
|
||||
.contains(tuple("paketo-buildpacks/java-native-image", "4.7.0"))
|
||||
.contains(tuple("paketo-buildpacks/spring-boot-native-image", "2.0.1"))
|
||||
.contains(tuple("paketo-buildpacks/bellsoft-liberica", "6.2.0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromImageWhenImageIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuilderMetadata.fromImage(null))
|
||||
.withMessage("Image must not be null");
|
||||
.withMessage("Image must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromImageWhenImageConfigIsNullThrowsException() {
|
||||
Image image = mock(Image.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuilderMetadata.fromImage(image))
|
||||
.withMessage("ImageConfig must not be null");
|
||||
.withMessage("ImageConfig must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,7 +82,7 @@ class BuilderMetadataTests extends AbstractJsonTests {
|
||||
given(image.getConfig()).willReturn(imageConfig);
|
||||
given(imageConfig.getLabels()).willReturn(Collections.singletonMap("alpha", "a"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuilderMetadata.fromImage(image))
|
||||
.withMessage("No 'io.buildpacks.builder.metadata' label found in image config labels 'alpha'");
|
||||
.withMessage("No 'io.buildpacks.builder.metadata' label found in image config labels 'alpha'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,7 +127,7 @@ class BuilderMetadataTests extends AbstractJsonTests {
|
||||
String label = imageConfigCopy.getLabels().get("io.buildpacks.builder.metadata");
|
||||
BuilderMetadata metadataCopy = BuilderMetadata.fromJson(label);
|
||||
assertThat(metadataCopy.getStack().getRunImage().getImage())
|
||||
.isEqualTo(metadata.getStack().getRunImage().getImage());
|
||||
.isEqualTo(metadata.getStack().getRunImage().getImage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -64,7 +64,7 @@ class BuilderTests {
|
||||
@Test
|
||||
void createWhenLogIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Builder((BuildLog) null))
|
||||
.withMessage("Log must not be null");
|
||||
.withMessage("Log must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,7 +77,7 @@ class BuilderTests {
|
||||
void buildWhenRequestIsNullThrowsException() {
|
||||
Builder builder = new Builder();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> builder.build(null))
|
||||
.withMessage("Request must not be null");
|
||||
.withMessage("Request must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,19 +87,19 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), isNull()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||
BuildRequest request = getTestRequest();
|
||||
builder.build(request);
|
||||
assertThat(out.toString()).contains("Running creator");
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
then(docker.image()).should().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
isNull());
|
||||
then(docker.image()).should().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
isNull());
|
||||
then(docker.image()).should()
|
||||
.pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull());
|
||||
then(docker.image()).should()
|
||||
.pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), isNull());
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).shouldHaveNoMoreInteractions();
|
||||
@@ -112,26 +112,31 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
DockerConfiguration dockerConfiguration = new DockerConfiguration()
|
||||
.withBuilderRegistryTokenAuthentication("builder token")
|
||||
.withPublishRegistryTokenAuthentication("publish token");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
.withBuilderRegistryTokenAuthentication("builder token")
|
||||
.withPublishRegistryTokenAuthentication("publish token");
|
||||
given(docker.image()
|
||||
.pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image()
|
||||
.pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, dockerConfiguration);
|
||||
BuildRequest request = getTestRequest().withPublish(true);
|
||||
builder.build(request);
|
||||
assertThat(out.toString()).contains("Running creator");
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
then(docker.image()).should().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should().push(eq(request.getName()), any(),
|
||||
eq(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should()
|
||||
.pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should()
|
||||
.pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should()
|
||||
.push(eq(request.getName()), any(),
|
||||
eq(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
then(docker.image()).shouldHaveNoMoreInteractions();
|
||||
@@ -144,9 +149,9 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image-with-no-run-image-tag.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of("gcr.io/paketo-buildpacks/builder:latest")), any(), isNull()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:latest")), any(), isNull()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||
BuildRequest request = getTestRequest().withBuilder(ImageReference.of("gcr.io/paketo-buildpacks/builder"));
|
||||
builder.build(request);
|
||||
@@ -164,10 +169,12 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image-with-run-image-digest.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of(
|
||||
"docker.io/cloudfoundry/run@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d")),
|
||||
any(), isNull())).willAnswer(withPulledImage(runImage));
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image()
|
||||
.pull(eq(ImageReference
|
||||
.of("docker.io/cloudfoundry/run@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d")),
|
||||
any(), isNull()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||
BuildRequest request = getTestRequest();
|
||||
builder.build(request);
|
||||
@@ -185,9 +192,9 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("example.com/custom/run:latest")), any(), isNull()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||
BuildRequest request = getTestRequest().withRunImage(ImageReference.of("example.com/custom/run:latest"));
|
||||
builder.build(request);
|
||||
@@ -205,13 +212,13 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), isNull()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
given(docker.image().inspect(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME))))
|
||||
.willReturn(builderImage);
|
||||
.willReturn(builderImage);
|
||||
given(docker.image().inspect(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb"))))
|
||||
.willReturn(runImage);
|
||||
.willReturn(runImage);
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||
BuildRequest request = getTestRequest().withPullPolicy(PullPolicy.NEVER);
|
||||
builder.build(request);
|
||||
@@ -231,13 +238,13 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), isNull()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
given(docker.image().inspect(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME))))
|
||||
.willReturn(builderImage);
|
||||
.willReturn(builderImage);
|
||||
given(docker.image().inspect(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb"))))
|
||||
.willReturn(runImage);
|
||||
.willReturn(runImage);
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||
BuildRequest request = getTestRequest().withPullPolicy(PullPolicy.ALWAYS);
|
||||
builder.build(request);
|
||||
@@ -257,15 +264,17 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), isNull()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
given(docker.image().inspect(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)))).willThrow(
|
||||
new DockerEngineException("docker://localhost/", new URI("example"), 404, "NOT FOUND", null, null))
|
||||
.willReturn(builderImage);
|
||||
given(docker.image().inspect(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")))).willThrow(
|
||||
new DockerEngineException("docker://localhost/", new URI("example"), 404, "NOT FOUND", null, null))
|
||||
.willReturn(runImage);
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
given(docker.image().inspect(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME))))
|
||||
.willThrow(
|
||||
new DockerEngineException("docker://localhost/", new URI("example"), 404, "NOT FOUND", null, null))
|
||||
.willReturn(builderImage);
|
||||
given(docker.image().inspect(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb"))))
|
||||
.willThrow(
|
||||
new DockerEngineException("docker://localhost/", new URI("example"), 404, "NOT FOUND", null, null))
|
||||
.willReturn(runImage);
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||
BuildRequest request = getTestRequest().withPullPolicy(PullPolicy.IF_NOT_PRESENT);
|
||||
builder.build(request);
|
||||
@@ -285,9 +294,9 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), isNull()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||
BuildRequest request = getTestRequest().withTags(ImageReference.of("my-application:1.2.3"));
|
||||
builder.build(request);
|
||||
@@ -307,14 +316,16 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
DockerConfiguration dockerConfiguration = new DockerConfiguration()
|
||||
.withBuilderRegistryTokenAuthentication("builder token")
|
||||
.withPublishRegistryTokenAuthentication("publish token");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
.withBuilderRegistryTokenAuthentication("builder token")
|
||||
.withPublishRegistryTokenAuthentication("publish token");
|
||||
given(docker.image()
|
||||
.pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image()
|
||||
.pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, dockerConfiguration);
|
||||
BuildRequest request = getTestRequest().withPublish(true).withTags(ImageReference.of("my-application:1.2.3"));
|
||||
builder.build(request);
|
||||
@@ -322,15 +333,19 @@ class BuilderTests {
|
||||
assertThat(out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
assertThat(out.toString()).contains("Successfully created image tag 'docker.io/library/my-application:1.2.3'");
|
||||
|
||||
then(docker.image()).should().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should().push(eq(request.getName()), any(),
|
||||
eq(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should()
|
||||
.pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should()
|
||||
.pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should()
|
||||
.push(eq(request.getName()), any(),
|
||||
eq(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should().tag(eq(request.getName()), eq(ImageReference.of("my-application:1.2.3")));
|
||||
then(docker.image()).should().push(eq(ImageReference.of("my-application:1.2.3")), any(),
|
||||
eq(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()));
|
||||
then(docker.image()).should()
|
||||
.push(eq(ImageReference.of("my-application:1.2.3")), any(),
|
||||
eq(dockerConfiguration.getPublishRegistryAuthentication().getAuthHeader()));
|
||||
ArgumentCaptor<ImageArchive> archive = ArgumentCaptor.forClass(ImageArchive.class);
|
||||
then(docker.image()).should().load(archive.capture(), any());
|
||||
then(docker.image()).should().remove(archive.getValue().getTag(), true);
|
||||
@@ -344,13 +359,14 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image-with-bad-stack.json");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), isNull()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||
BuildRequest request = getTestRequest();
|
||||
assertThatIllegalStateException().isThrownBy(() -> builder.build(request)).withMessage(
|
||||
"Run image stack 'org.cloudfoundry.stacks.cfwindowsfs3' does not match builder stack 'io.buildpacks.stacks.bionic'");
|
||||
assertThatIllegalStateException().isThrownBy(() -> builder.build(request))
|
||||
.withMessage(
|
||||
"Run image stack 'org.cloudfoundry.stacks.cfwindowsfs3' does not match builder stack 'io.buildpacks.stacks.bionic'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -360,13 +376,13 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), isNull()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||
BuildRequest request = getTestRequest();
|
||||
assertThatExceptionOfType(BuilderException.class).isThrownBy(() -> builder.build(request))
|
||||
.withMessage("Builder lifecycle 'creator' failed with status code 9");
|
||||
.withMessage("Builder lifecycle 'creator' failed with status code 9");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -375,14 +391,16 @@ class BuilderTests {
|
||||
DockerApi docker = mockDockerApi();
|
||||
Image builderImage = loadImage("image-with-run-image-different-registry.json");
|
||||
DockerConfiguration dockerConfiguration = new DockerConfiguration()
|
||||
.withBuilderRegistryTokenAuthentication("builder token");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.withBuilderRegistryTokenAuthentication("builder token");
|
||||
given(docker.image()
|
||||
.pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, dockerConfiguration);
|
||||
BuildRequest request = getTestRequest();
|
||||
assertThatIllegalStateException().isThrownBy(() -> builder.build(request)).withMessage(
|
||||
"Run image 'example.com/custom/run:latest' must be pulled from the 'docker.io' authenticated registry");
|
||||
assertThatIllegalStateException().isThrownBy(() -> builder.build(request))
|
||||
.withMessage(
|
||||
"Run image 'example.com/custom/run:latest' must be pulled from the 'docker.io' authenticated registry");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -391,14 +409,16 @@ class BuilderTests {
|
||||
DockerApi docker = mockDockerApi();
|
||||
Image builderImage = loadImage("image.json");
|
||||
DockerConfiguration dockerConfiguration = new DockerConfiguration()
|
||||
.withBuilderRegistryTokenAuthentication("builder token");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.withBuilderRegistryTokenAuthentication("builder token");
|
||||
given(docker.image()
|
||||
.pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(),
|
||||
eq(dockerConfiguration.getBuilderRegistryAuthentication().getAuthHeader())))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, dockerConfiguration);
|
||||
BuildRequest request = getTestRequest().withRunImage(ImageReference.of("example.com/custom/run:latest"));
|
||||
assertThatIllegalStateException().isThrownBy(() -> builder.build(request)).withMessage(
|
||||
"Run image 'example.com/custom/run:latest' must be pulled from the 'docker.io' authenticated registry");
|
||||
assertThatIllegalStateException().isThrownBy(() -> builder.build(request))
|
||||
.withMessage(
|
||||
"Run image 'example.com/custom/run:latest' must be pulled from the 'docker.io' authenticated registry");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -408,15 +428,15 @@ class BuilderTests {
|
||||
Image builderImage = loadImage("image.json");
|
||||
Image runImage = loadImage("run-image.json");
|
||||
given(docker.image().pull(eq(ImageReference.of(BuildRequest.DEFAULT_BUILDER_IMAGE_NAME)), any(), isNull()))
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
.willAnswer(withPulledImage(builderImage));
|
||||
given(docker.image().pull(eq(ImageReference.of("docker.io/cloudfoundry/run:base-cnb")), any(), isNull()))
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
.willAnswer(withPulledImage(runImage));
|
||||
Builder builder = new Builder(BuildLog.to(out), docker, null);
|
||||
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:example/buildpack@1.2.3");
|
||||
BuildRequest request = getTestRequest().withBuildpacks(reference);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> builder.build(request))
|
||||
.withMessageContaining("'urn:cnb:builder:example/buildpack@1.2.3'")
|
||||
.withMessageContaining("not found in builder");
|
||||
.withMessageContaining("'urn:cnb:builder:example/buildpack@1.2.3'")
|
||||
.withMessageContaining("not found in builder");
|
||||
}
|
||||
|
||||
private DockerApi mockDockerApi() throws IOException {
|
||||
|
||||
@@ -43,7 +43,7 @@ class BuildpackCoordinatesTests extends AbstractJsonTests {
|
||||
@Test
|
||||
void fromToml() throws IOException {
|
||||
BuildpackCoordinates coordinates = BuildpackCoordinates
|
||||
.fromToml(createTomlStream("example/buildpack1", "0.0.1", true, false), this.archive);
|
||||
.fromToml(createTomlStream("example/buildpack1", "0.0.1", true, false), this.archive);
|
||||
assertThat(coordinates.getId()).isEqualTo("example/buildpack1");
|
||||
assertThat(coordinates.getVersion()).isEqualTo("0.0.1");
|
||||
}
|
||||
@@ -52,17 +52,17 @@ class BuildpackCoordinatesTests extends AbstractJsonTests {
|
||||
void fromTomlWhenMissingDescriptorThrowsException() {
|
||||
ByteArrayInputStream coordinates = new ByteArrayInputStream("".getBytes());
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
|
||||
.withMessageContaining("Buildpack descriptor 'buildpack.toml' is required")
|
||||
.withMessageContaining(this.archive.toString());
|
||||
.withMessageContaining("Buildpack descriptor 'buildpack.toml' is required")
|
||||
.withMessageContaining(this.archive.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromTomlWhenMissingIDThrowsException() throws IOException {
|
||||
try (InputStream coordinates = createTomlStream(null, null, true, false)) {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
|
||||
.withMessageContaining("Buildpack descriptor must contain ID")
|
||||
.withMessageContaining(this.archive.toString());
|
||||
.isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
|
||||
.withMessageContaining("Buildpack descriptor must contain ID")
|
||||
.withMessageContaining(this.archive.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,9 +70,9 @@ class BuildpackCoordinatesTests extends AbstractJsonTests {
|
||||
void fromTomlWhenMissingVersionThrowsException() throws IOException {
|
||||
try (InputStream coordinates = createTomlStream("example/buildpack1", null, true, false)) {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
|
||||
.withMessageContaining("Buildpack descriptor must contain version")
|
||||
.withMessageContaining(this.archive.toString());
|
||||
.isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
|
||||
.withMessageContaining("Buildpack descriptor must contain version")
|
||||
.withMessageContaining(this.archive.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ class BuildpackCoordinatesTests extends AbstractJsonTests {
|
||||
void fromTomlWhenMissingStacksAndOrderThrowsException() throws IOException {
|
||||
try (InputStream coordinates = createTomlStream("example/buildpack1", "0.0.1", false, false)) {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
|
||||
.withMessageContaining("Buildpack descriptor must contain either 'stacks' or 'order'")
|
||||
.withMessageContaining(this.archive.toString());
|
||||
.isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
|
||||
.withMessageContaining("Buildpack descriptor must contain either 'stacks' or 'order'")
|
||||
.withMessageContaining(this.archive.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,16 +90,16 @@ class BuildpackCoordinatesTests extends AbstractJsonTests {
|
||||
void fromTomlWhenContainsBothStacksAndOrderThrowsException() throws IOException {
|
||||
try (InputStream coordinates = createTomlStream("example/buildpack1", "0.0.1", true, true)) {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
|
||||
.withMessageContaining("Buildpack descriptor must not contain both 'stacks' and 'order'")
|
||||
.withMessageContaining(this.archive.toString());
|
||||
.isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
|
||||
.withMessageContaining("Buildpack descriptor must not contain both 'stacks' and 'order'")
|
||||
.withMessageContaining(this.archive.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromBuildpackMetadataWhenMetadataIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromBuildpackMetadata(null))
|
||||
.withMessage("BuildpackMetadata must not be null");
|
||||
.withMessage("BuildpackMetadata must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,7 +113,7 @@ class BuildpackCoordinatesTests extends AbstractJsonTests {
|
||||
@Test
|
||||
void ofWhenIdIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.of(null, null))
|
||||
.withMessage("ID must not be empty");
|
||||
.withMessage("ID must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,11 +42,11 @@ class BuildpackLayersMetadataTests extends AbstractJsonTests {
|
||||
Image image = Image.of(getContent("buildpack-image.json"));
|
||||
BuildpackLayersMetadata metadata = BuildpackLayersMetadata.fromImage(image);
|
||||
assertThat(metadata.getBuildpack("example/hello-moon", "0.0.3")).extracting("homepage", "layerDiffId")
|
||||
.containsExactly("https://github.com/example/tree/main/buildpacks/hello-moon",
|
||||
"sha256:4bfdc8714aee68da6662c43bc28d3b41202c88e915641c356523dabe729814c2");
|
||||
.containsExactly("https://github.com/example/tree/main/buildpacks/hello-moon",
|
||||
"sha256:4bfdc8714aee68da6662c43bc28d3b41202c88e915641c356523dabe729814c2");
|
||||
assertThat(metadata.getBuildpack("example/hello-world", "0.0.2")).extracting("homepage", "layerDiffId")
|
||||
.containsExactly("https://github.com/example/tree/main/buildpacks/hello-world",
|
||||
"sha256:f752fe099c846e501bdc991d1a22f98c055ddc62f01cfc0495fff2c69f8eb940");
|
||||
.containsExactly("https://github.com/example/tree/main/buildpacks/hello-world",
|
||||
"sha256:f752fe099c846e501bdc991d1a22f98c055ddc62f01cfc0495fff2c69f8eb940");
|
||||
assertThat(metadata.getBuildpack("example/hello-world", "version-does-not-exist")).isNull();
|
||||
assertThat(metadata.getBuildpack("id-does-not-exist", "9.9.9")).isNull();
|
||||
}
|
||||
@@ -54,14 +54,14 @@ class BuildpackLayersMetadataTests extends AbstractJsonTests {
|
||||
@Test
|
||||
void fromImageWhenImageIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackLayersMetadata.fromImage(null))
|
||||
.withMessage("Image must not be null");
|
||||
.withMessage("Image must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromImageWhenImageConfigIsNullThrowsException() {
|
||||
Image image = mock(Image.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackLayersMetadata.fromImage(image))
|
||||
.withMessage("ImageConfig must not be null");
|
||||
.withMessage("ImageConfig must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,25 +71,25 @@ class BuildpackLayersMetadataTests extends AbstractJsonTests {
|
||||
given(image.getConfig()).willReturn(imageConfig);
|
||||
given(imageConfig.getLabels()).willReturn(Collections.singletonMap("alpha", "a"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackLayersMetadata.fromImage(image))
|
||||
.withMessage("No 'io.buildpacks.buildpack.layers' label found in image config labels 'alpha'");
|
||||
.withMessage("No 'io.buildpacks.buildpack.layers' label found in image config labels 'alpha'");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromJsonLoadsMetadata() throws IOException {
|
||||
BuildpackLayersMetadata metadata = BuildpackLayersMetadata
|
||||
.fromJson(getContentAsString("buildpack-layers-metadata.json"));
|
||||
.fromJson(getContentAsString("buildpack-layers-metadata.json"));
|
||||
assertThat(metadata.getBuildpack("example/hello-moon", "0.0.3")).extracting("name", "homepage", "layerDiffId")
|
||||
.containsExactly("Example hello-moon buildpack",
|
||||
"https://github.com/example/tree/main/buildpacks/hello-moon",
|
||||
"sha256:4bfdc8714aee68da6662c43bc28d3b41202c88e915641c356523dabe729814c2");
|
||||
.containsExactly("Example hello-moon buildpack",
|
||||
"https://github.com/example/tree/main/buildpacks/hello-moon",
|
||||
"sha256:4bfdc8714aee68da6662c43bc28d3b41202c88e915641c356523dabe729814c2");
|
||||
assertThat(metadata.getBuildpack("example/hello-world", "0.0.1")).extracting("name", "homepage", "layerDiffId")
|
||||
.containsExactly("Example hello-world buildpack",
|
||||
"https://github.com/example/tree/main/buildpacks/hello-world",
|
||||
"sha256:1c90e0b80d92555a0523c9ee6500845328fc39ba9dca9d30a877ff759ffbff28");
|
||||
.containsExactly("Example hello-world buildpack",
|
||||
"https://github.com/example/tree/main/buildpacks/hello-world",
|
||||
"sha256:1c90e0b80d92555a0523c9ee6500845328fc39ba9dca9d30a877ff759ffbff28");
|
||||
assertThat(metadata.getBuildpack("example/hello-world", "0.0.2")).extracting("name", "homepage", "layerDiffId")
|
||||
.containsExactly("Example hello-world buildpack",
|
||||
"https://github.com/example/tree/main/buildpacks/hello-world",
|
||||
"sha256:f752fe099c846e501bdc991d1a22f98c055ddc62f01cfc0495fff2c69f8eb940");
|
||||
.containsExactly("Example hello-world buildpack",
|
||||
"https://github.com/example/tree/main/buildpacks/hello-world",
|
||||
"sha256:f752fe099c846e501bdc991d1a22f98c055ddc62f01cfc0495fff2c69f8eb940");
|
||||
assertThat(metadata.getBuildpack("example/hello-world", "version-does-not-exist")).isNull();
|
||||
assertThat(metadata.getBuildpack("id-does-not-exist", "9.9.9")).isNull();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,14 +48,14 @@ class BuildpackMetadataTests extends AbstractJsonTests {
|
||||
@Test
|
||||
void fromImageWhenImageIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackMetadata.fromImage(null))
|
||||
.withMessage("Image must not be null");
|
||||
.withMessage("Image must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromImageWhenImageConfigIsNullThrowsException() {
|
||||
Image image = mock(Image.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackMetadata.fromImage(image))
|
||||
.withMessage("ImageConfig must not be null");
|
||||
.withMessage("ImageConfig must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,7 +65,7 @@ class BuildpackMetadataTests extends AbstractJsonTests {
|
||||
given(image.getConfig()).willReturn(imageConfig);
|
||||
given(imageConfig.getLabels()).willReturn(Collections.singletonMap("alpha", "a"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackMetadata.fromImage(image))
|
||||
.withMessage("No 'io.buildpacks.buildpackage.metadata' label found in image config labels 'alpha'");
|
||||
.withMessage("No 'io.buildpacks.buildpackage.metadata' label found in image config labels 'alpha'");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -33,7 +33,7 @@ class BuildpackReferenceTests {
|
||||
@Test
|
||||
void ofWhenValueIsEmptyThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackReference.of(""))
|
||||
.withMessage("Value must not be empty");
|
||||
.withMessage("Value must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -96,9 +96,9 @@ class BuildpackResolversTests extends AbstractJsonTests {
|
||||
void resolveAllWithInvalidLocatorThrowsException() {
|
||||
BuildpackReference reference = BuildpackReference.of("unknown-buildpack@0.0.1");
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> BuildpackResolvers.resolveAll(this.resolverContext, Collections.singleton(reference)))
|
||||
.withMessageContaining("Invalid buildpack reference")
|
||||
.withMessageContaining("'unknown-buildpack@0.0.1'");
|
||||
.isThrownBy(() -> BuildpackResolvers.resolveAll(this.resolverContext, Collections.singleton(reference)))
|
||||
.withMessageContaining("Invalid buildpack reference")
|
||||
.withMessageContaining("'unknown-buildpack@0.0.1'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -90,9 +90,9 @@ class DirectoryBuildpackTests {
|
||||
Files.createDirectories(this.buildpackDir.toPath());
|
||||
BuildpackReference reference = BuildpackReference.of(this.buildpackDir.toString());
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> DirectoryBuildpack.resolve(this.resolverContext, reference))
|
||||
.withMessageContaining("Buildpack descriptor 'buildpack.toml' is required")
|
||||
.withMessageContaining(this.buildpackDir.getAbsolutePath());
|
||||
.isThrownBy(() -> DirectoryBuildpack.resolve(this.resolverContext, reference))
|
||||
.withMessageContaining("Buildpack descriptor 'buildpack.toml' is required")
|
||||
.withMessageContaining(this.buildpackDir.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,13 +133,14 @@ class DirectoryBuildpackTests {
|
||||
entries.add(entry);
|
||||
entry = tar.getNextTarEntry();
|
||||
}
|
||||
assertThat(entries).extracting("name", "mode").containsExactlyInAnyOrder(tuple("/cnb/", 0755),
|
||||
tuple("/cnb/buildpacks/", 0755), tuple("/cnb/buildpacks/example_buildpack1/", 0755),
|
||||
tuple("/cnb/buildpacks/example_buildpack1/0.0.1/", 0755),
|
||||
tuple("/cnb/buildpacks/example_buildpack1/0.0.1/buildpack.toml", 0644),
|
||||
tuple("/cnb/buildpacks/example_buildpack1/0.0.1/bin/", 0755),
|
||||
tuple("/cnb/buildpacks/example_buildpack1/0.0.1/bin/detect", 0744),
|
||||
tuple("/cnb/buildpacks/example_buildpack1/0.0.1/bin/build", 0744));
|
||||
assertThat(entries).extracting("name", "mode")
|
||||
.containsExactlyInAnyOrder(tuple("/cnb/", 0755), tuple("/cnb/buildpacks/", 0755),
|
||||
tuple("/cnb/buildpacks/example_buildpack1/", 0755),
|
||||
tuple("/cnb/buildpacks/example_buildpack1/0.0.1/", 0755),
|
||||
tuple("/cnb/buildpacks/example_buildpack1/0.0.1/buildpack.toml", 0644),
|
||||
tuple("/cnb/buildpacks/example_buildpack1/0.0.1/bin/", 0755),
|
||||
tuple("/cnb/buildpacks/example_buildpack1/0.0.1/bin/detect", 0744),
|
||||
tuple("/cnb/buildpacks/example_buildpack1/0.0.1/bin/build", 0744));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ class EphemeralBuilderTests extends AbstractJsonTests {
|
||||
this.creator, this.env, this.buildpacks);
|
||||
ImageConfig config = builder.getArchive().getImageConfig();
|
||||
assertThat(config.getLabels())
|
||||
.contains(entry(EphemeralBuilder.BUILDER_FOR_LABEL_NAME, this.targetImage.toString()));
|
||||
.contains(entry(EphemeralBuilder.BUILDER_FOR_LABEL_NAME, this.targetImage.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -164,7 +164,7 @@ class EphemeralBuilderTests extends AbstractJsonTests {
|
||||
"/cnb/buildpacks/example_buildpack3/0.0.3/buildpack.toml");
|
||||
File orderDirectory = unpack(getLayer(builder.getArchive(), EXISTING_IMAGE_LAYER_COUNT + 3), "order");
|
||||
assertThat(new File(orderDirectory, "cnb/order.toml")).usingCharset(StandardCharsets.UTF_8)
|
||||
.hasContent(content("order.toml"));
|
||||
.hasContent(content("order.toml"));
|
||||
}
|
||||
|
||||
private void assertBuildpackLayerContent(EphemeralBuilder builder, int index, String s) throws Exception {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -126,7 +126,7 @@ class ImageBuildpackTests extends AbstractJsonTests {
|
||||
ImageReference imageReference = ImageReference.of("example/buildpack1:1.0.0");
|
||||
BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class);
|
||||
given(resolverContext.getBuildpackLayersMetadata())
|
||||
.willReturn(BuildpackLayersMetadata.fromJson(getContentAsString("buildpack-layers-metadata.json")));
|
||||
.willReturn(BuildpackLayersMetadata.fromJson(getContentAsString("buildpack-layers-metadata.json")));
|
||||
given(resolverContext.fetchImage(eq(imageReference), eq(ImageType.BUILDPACK))).willReturn(image);
|
||||
willAnswer(this::withMockLayers).given(resolverContext).exportImageLayers(eq(imageReference), any());
|
||||
BuildpackReference reference = BuildpackReference.of("docker://example/buildpack1:1.0.0");
|
||||
@@ -141,8 +141,8 @@ class ImageBuildpackTests extends AbstractJsonTests {
|
||||
given(resolverContext.fetchImage(any(), any())).willThrow(IOException.class);
|
||||
BuildpackReference reference = BuildpackReference.of("docker://example/buildpack1");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ImageBuildpack.resolve(resolverContext, reference))
|
||||
.withMessageContaining("Error pulling buildpack image")
|
||||
.withMessageContaining("example/buildpack1:latest");
|
||||
.withMessageContaining("Error pulling buildpack image")
|
||||
.withMessageContaining("example/buildpack1:latest");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,7 +152,7 @@ class ImageBuildpackTests extends AbstractJsonTests {
|
||||
given(resolverContext.fetchImage(any(), any())).willReturn(image);
|
||||
BuildpackReference reference = BuildpackReference.of("docker://example/buildpack1:latest");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ImageBuildpack.resolve(resolverContext, reference))
|
||||
.withMessageContaining("No 'io.buildpacks.buildpackage.metadata' label found");
|
||||
.withMessageContaining("No 'io.buildpacks.buildpackage.metadata' label found");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -160,7 +160,7 @@ class ImageBuildpackTests extends AbstractJsonTests {
|
||||
BuildpackReference reference = BuildpackReference.of("docker://buildpack@0.0.1");
|
||||
BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ImageBuildpack.resolve(resolverContext, reference))
|
||||
.withMessageContaining("Unable to parse image reference \"buildpack@0.0.1\"");
|
||||
.withMessageContaining("Unable to parse image reference \"buildpack@0.0.1\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -217,14 +217,14 @@ class ImageBuildpackTests extends AbstractJsonTests {
|
||||
entry = tar.getNextTarEntry();
|
||||
}
|
||||
}
|
||||
assertThat(entries).extracting("name", "mode").containsExactlyInAnyOrder(
|
||||
tuple("cnb/", TarArchiveEntry.DEFAULT_DIR_MODE),
|
||||
tuple("cnb/buildpacks/", TarArchiveEntry.DEFAULT_DIR_MODE),
|
||||
tuple("cnb/buildpacks/example_buildpack/", TarArchiveEntry.DEFAULT_DIR_MODE),
|
||||
tuple("cnb/buildpacks/example_buildpack/0.0.1/", TarArchiveEntry.DEFAULT_DIR_MODE),
|
||||
tuple("cnb/buildpacks/example_buildpack/0.0.1/buildpack.toml", TarArchiveEntry.DEFAULT_FILE_MODE),
|
||||
tuple("cnb/buildpacks/example_buildpack/0.0.1/" + this.longFilePath,
|
||||
TarArchiveEntry.DEFAULT_FILE_MODE));
|
||||
assertThat(entries).extracting("name", "mode")
|
||||
.containsExactlyInAnyOrder(tuple("cnb/", TarArchiveEntry.DEFAULT_DIR_MODE),
|
||||
tuple("cnb/buildpacks/", TarArchiveEntry.DEFAULT_DIR_MODE),
|
||||
tuple("cnb/buildpacks/example_buildpack/", TarArchiveEntry.DEFAULT_DIR_MODE),
|
||||
tuple("cnb/buildpacks/example_buildpack/0.0.1/", TarArchiveEntry.DEFAULT_DIR_MODE),
|
||||
tuple("cnb/buildpacks/example_buildpack/0.0.1/buildpack.toml", TarArchiveEntry.DEFAULT_FILE_MODE),
|
||||
tuple("cnb/buildpacks/example_buildpack/0.0.1/" + this.longFilePath,
|
||||
TarArchiveEntry.DEFAULT_FILE_MODE));
|
||||
}
|
||||
|
||||
private void assertAppliesNoLayers(Buildpack buildpack) throws IOException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -135,7 +135,7 @@ class LifecycleTests {
|
||||
Lifecycle lifecycle = createLifecycle();
|
||||
lifecycle.execute();
|
||||
assertThatIllegalStateException().isThrownBy(lifecycle::execute)
|
||||
.withMessage("Lifecycle has already been executed");
|
||||
.withMessage("Lifecycle has already been executed");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,7 +144,7 @@ class LifecycleTests {
|
||||
given(this.docker.container().create(any(), any())).willAnswer(answerWithGeneratedContainerId());
|
||||
given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(9, null));
|
||||
assertThatExceptionOfType(BuilderException.class).isThrownBy(() -> createLifecycle().execute())
|
||||
.withMessage("Builder lifecycle 'creator' failed with status code 9");
|
||||
.withMessage("Builder lifecycle 'creator' failed with status code 9");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -165,8 +165,8 @@ class LifecycleTests {
|
||||
given(this.docker.container().create(any(), any())).willAnswer(answerWithGeneratedContainerId());
|
||||
given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(0, null));
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> createLifecycle("builder-metadata-unsupported-api.json").execute())
|
||||
.withMessageContaining("Detected platform API versions '0.2' are not included in supported versions");
|
||||
.isThrownBy(() -> createLifecycle("builder-metadata-unsupported-api.json").execute())
|
||||
.withMessageContaining("Detected platform API versions '0.2' are not included in supported versions");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -175,9 +175,8 @@ class LifecycleTests {
|
||||
given(this.docker.container().create(any(), any())).willAnswer(answerWithGeneratedContainerId());
|
||||
given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(0, null));
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> createLifecycle("builder-metadata-unsupported-apis.json").execute())
|
||||
.withMessageContaining(
|
||||
"Detected platform API versions '0.1,0.2' are not included in supported versions");
|
||||
.isThrownBy(() -> createLifecycle("builder-metadata-unsupported-apis.json").execute())
|
||||
.withMessageContaining("Detected platform API versions '0.1,0.2' are not included in supported versions");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -213,7 +212,7 @@ class LifecycleTests {
|
||||
given(this.docker.container().create(any(), any())).willAnswer(answerWithGeneratedContainerId());
|
||||
given(this.docker.container().wait(any())).willReturn(ContainerStatus.of(0, null));
|
||||
BuildRequest request = getTestRequest().withBuildCache(Cache.volume("build-volume"))
|
||||
.withLaunchCache(Cache.volume("launch-volume"));
|
||||
.withLaunchCache(Cache.volume("launch-volume"));
|
||||
createLifecycle(request).execute();
|
||||
assertPhaseWasRun("creator", withExpectedConfig("lifecycle-creator-cache-volumes.json"));
|
||||
assertThat(this.out.toString()).contains("Successfully built image 'docker.io/library/my-application:latest'");
|
||||
|
||||
@@ -31,19 +31,19 @@ class LifecycleVersionTests {
|
||||
@Test
|
||||
void parseWhenValueIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> LifecycleVersion.parse(null))
|
||||
.withMessage("Value must not be empty");
|
||||
.withMessage("Value must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseWhenTooLongThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> LifecycleVersion.parse("v1.2.3.4"))
|
||||
.withMessage("Malformed version number '1.2.3.4'");
|
||||
.withMessage("Malformed version number '1.2.3.4'");
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseWhenNonNumericThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> LifecycleVersion.parse("v1.2.3a"))
|
||||
.withMessage("Malformed version number '1.2.3a'");
|
||||
.withMessage("Malformed version number '1.2.3a'");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -39,7 +39,7 @@ class StackIdTests {
|
||||
@Test
|
||||
void fromImageWhenImageIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> StackId.fromImage(null))
|
||||
.withMessage("Image must not be null");
|
||||
.withMessage("Image must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,7 +48,7 @@ class StackIdTests {
|
||||
ImageConfig imageConfig = mock(ImageConfig.class);
|
||||
given(image.getConfig()).willReturn(imageConfig);
|
||||
assertThatIllegalStateException().isThrownBy(() -> StackId.fromImage(image))
|
||||
.withMessage("Missing 'io.buildpacks.stack.id' stack label");
|
||||
.withMessage("Missing 'io.buildpacks.stack.id' stack label");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -73,8 +73,8 @@ class TarGzipBuildpackTests {
|
||||
Path compressedArchive = this.testTarGzip.createEmptyArchive();
|
||||
BuildpackReference reference = BuildpackReference.of(compressedArchive.toString());
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> TarGzipBuildpack.resolve(this.resolverContext, reference))
|
||||
.withMessageContaining("Buildpack descriptor 'buildpack.toml' is required")
|
||||
.withMessageContaining(compressedArchive.toString());
|
||||
.withMessageContaining("Buildpack descriptor 'buildpack.toml' is required")
|
||||
.withMessageContaining(compressedArchive.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -129,7 +129,7 @@ class TestTarGzip {
|
||||
assertThat(tar.getNextEntry().getName()).isEqualTo("cnb/buildpacks/example_buildpack1/");
|
||||
assertThat(tar.getNextEntry().getName()).isEqualTo("cnb/buildpacks/example_buildpack1/0.0.1/");
|
||||
assertThat(tar.getNextEntry().getName())
|
||||
.isEqualTo("cnb/buildpacks/example_buildpack1/0.0.1/buildpack.toml");
|
||||
.isEqualTo("cnb/buildpacks/example_buildpack1/0.0.1/buildpack.toml");
|
||||
assertThat(tar.getNextEntry().getName()).isEqualTo("cnb/buildpacks/example_buildpack1/0.0.1/bin/");
|
||||
assertThat(tar.getNextEntry().getName()).isEqualTo("cnb/buildpacks/example_buildpack1/0.0.1/bin/detect");
|
||||
assertThat(tar.getNextEntry().getName()).isEqualTo("cnb/buildpacks/example_buildpack1/0.0.1/bin/build");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,8 +35,9 @@ class DockerApiIntegrationTests {
|
||||
|
||||
@Test
|
||||
void pullImage() throws IOException {
|
||||
this.docker.image().pull(ImageReference.of("gcr.io/paketo-buildpacks/builder:base"),
|
||||
new TotalProgressPullListener(new TotalProgressBar("Pulling: ")));
|
||||
this.docker.image()
|
||||
.pull(ImageReference.of("gcr.io/paketo-buildpacks/builder:base"),
|
||||
new TotalProgressPullListener(new TotalProgressBar("Pulling: ")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -151,13 +151,13 @@ class DockerApiTests {
|
||||
@Test
|
||||
void pullWhenReferenceIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.pull(null, this.pullListener))
|
||||
.withMessage("Reference must not be null");
|
||||
.withMessage("Reference must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void pullWhenListenerIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.pull(ImageReference.of("ubuntu"), null))
|
||||
.withMessage("Listener must not be null");
|
||||
.withMessage("Listener must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -193,14 +193,14 @@ class DockerApiTests {
|
||||
@Test
|
||||
void pushWhenReferenceIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.push(null, this.pushListener, null))
|
||||
.withMessage("Reference must not be null");
|
||||
.withMessage("Reference must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void pushWhenListenerIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.api.push(ImageReference.of("ubuntu"), null, null))
|
||||
.withMessage("Listener must not be null");
|
||||
.isThrownBy(() -> this.api.push(ImageReference.of("ubuntu"), null, null))
|
||||
.withMessage("Listener must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -221,21 +221,21 @@ class DockerApiTests {
|
||||
URI pushUri = new URI(IMAGES_URL + "/localhost:5000/ubuntu/push");
|
||||
given(http().post(pushUri, "auth token")).willReturn(responseOf("push-stream-with-error.json"));
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> this.api.push(reference, this.pushListener, "auth token"))
|
||||
.withMessageContaining("test message");
|
||||
.isThrownBy(() -> this.api.push(reference, this.pushListener, "auth token"))
|
||||
.withMessageContaining("test message");
|
||||
}
|
||||
|
||||
@Test
|
||||
void loadWhenArchiveIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.load(null, UpdateListener.none()))
|
||||
.withMessage("Archive must not be null");
|
||||
.withMessage("Archive must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void loadWhenListenerIsNullThrowsException() {
|
||||
ImageArchive archive = mock(ImageArchive.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.load(archive, null))
|
||||
.withMessage("Listener must not be null");
|
||||
.withMessage("Listener must not be null");
|
||||
}
|
||||
|
||||
@Test // gh-23130
|
||||
@@ -245,7 +245,7 @@ class DockerApiTests {
|
||||
URI loadUri = new URI(IMAGES_URL + "/load");
|
||||
given(http().post(eq(loadUri), eq("application/x-tar"), any())).willReturn(emptyResponse());
|
||||
assertThatIllegalStateException().isThrownBy(() -> this.api.load(archive, this.loadListener))
|
||||
.withMessageContaining("Invalid response received");
|
||||
.withMessageContaining("Invalid response received");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -268,13 +268,13 @@ class DockerApiTests {
|
||||
@Test
|
||||
void removeWhenReferenceIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.remove(null, true))
|
||||
.withMessage("Reference must not be null");
|
||||
.withMessage("Reference must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void removeRemovesContainer() throws Exception {
|
||||
ImageReference reference = ImageReference
|
||||
.of("ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
.of("ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
URI removeUri = new URI(IMAGES_URL
|
||||
+ "/docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
given(http().delete(removeUri)).willReturn(emptyResponse());
|
||||
@@ -285,7 +285,7 @@ class DockerApiTests {
|
||||
@Test
|
||||
void removeWhenForceIsTrueRemovesContainer() throws Exception {
|
||||
ImageReference reference = ImageReference
|
||||
.of("ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
.of("ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
URI removeUri = new URI(IMAGES_URL
|
||||
+ "/docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d?force=1");
|
||||
given(http().delete(removeUri)).willReturn(emptyResponse());
|
||||
@@ -296,7 +296,7 @@ class DockerApiTests {
|
||||
@Test
|
||||
void inspectWhenReferenceIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.inspect(null))
|
||||
.withMessage("Reference must not be null");
|
||||
.withMessage("Reference must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -318,7 +318,7 @@ class DockerApiTests {
|
||||
void exportLayersWhenExportsIsNullThrowsException() {
|
||||
ImageReference reference = ImageReference.of("gcr.io/paketo-buildpacks/builder:base");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.exportLayers(reference, null))
|
||||
.withMessage("Exports must not be null");
|
||||
.withMessage("Exports must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -339,26 +339,26 @@ class DockerApiTests {
|
||||
}
|
||||
}
|
||||
});
|
||||
assertThat(contents).hasSize(3).containsKeys(
|
||||
"1bf6c63a1e9ed1dd7cb961273bf60b8e0f440361faf273baf866f408e4910601/layer.tar",
|
||||
"8fdfb915302159a842cbfae6faec5311b00c071ebf14e12da7116ae7532e9319/layer.tar",
|
||||
"93cd584bb189bfca4f51744bd19d836fd36da70710395af5a1523ee88f208c6a/layer.tar");
|
||||
assertThat(contents).hasSize(3)
|
||||
.containsKeys("1bf6c63a1e9ed1dd7cb961273bf60b8e0f440361faf273baf866f408e4910601/layer.tar",
|
||||
"8fdfb915302159a842cbfae6faec5311b00c071ebf14e12da7116ae7532e9319/layer.tar",
|
||||
"93cd584bb189bfca4f51744bd19d836fd36da70710395af5a1523ee88f208c6a/layer.tar");
|
||||
assertThat(contents.get("1bf6c63a1e9ed1dd7cb961273bf60b8e0f440361faf273baf866f408e4910601/layer.tar"))
|
||||
.containsExactly("etc/", "etc/apt/", "etc/apt/sources.list");
|
||||
.containsExactly("etc/", "etc/apt/", "etc/apt/sources.list");
|
||||
}
|
||||
|
||||
@Test
|
||||
void tagWhenReferenceIsNullThrowsException() {
|
||||
ImageReference tag = ImageReference.of("localhost:5000/ubuntu");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.tag(null, tag))
|
||||
.withMessage("SourceReference must not be null");
|
||||
.withMessage("SourceReference must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void tagWhenTargetIsNullThrowsException() {
|
||||
ImageReference reference = ImageReference.of("localhost:5000/ubuntu");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.tag(reference, null))
|
||||
.withMessage("TargetReference must not be null");
|
||||
.withMessage("TargetReference must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -392,7 +392,7 @@ class DockerApiTests {
|
||||
@Test
|
||||
void createWhenConfigIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.create(null))
|
||||
.withMessage("Config must not be null");
|
||||
.withMessage("Config must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -401,7 +401,7 @@ class DockerApiTests {
|
||||
ContainerConfig config = ContainerConfig.of(imageReference, (update) -> update.withCommand("/bin/bash"));
|
||||
URI createUri = new URI(CONTAINERS_URL + "/create");
|
||||
given(http().post(eq(createUri), eq("application/json"), any()))
|
||||
.willReturn(responseOf("create-container-response.json"));
|
||||
.willReturn(responseOf("create-container-response.json"));
|
||||
ContainerReference containerReference = this.api.create(config);
|
||||
assertThat(containerReference).hasToString("e90e34656806");
|
||||
then(http()).should().post(any(), any(), this.writer.capture());
|
||||
@@ -421,7 +421,7 @@ class DockerApiTests {
|
||||
ContainerContent content = ContainerContent.of(archive);
|
||||
URI createUri = new URI(CONTAINERS_URL + "/create");
|
||||
given(http().post(eq(createUri), eq("application/json"), any()))
|
||||
.willReturn(responseOf("create-container-response.json"));
|
||||
.willReturn(responseOf("create-container-response.json"));
|
||||
URI uploadUri = new URI(CONTAINERS_URL + "/e90e34656806/archive?path=%2F");
|
||||
given(http().put(eq(uploadUri), eq("application/x-tar"), any())).willReturn(emptyResponse());
|
||||
ContainerReference containerReference = this.api.create(config, content);
|
||||
@@ -438,7 +438,7 @@ class DockerApiTests {
|
||||
@Test
|
||||
void startWhenReferenceIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.start(null))
|
||||
.withMessage("Reference must not be null");
|
||||
.withMessage("Reference must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -453,14 +453,14 @@ class DockerApiTests {
|
||||
@Test
|
||||
void logsWhenReferenceIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.logs(null, UpdateListener.none()))
|
||||
.withMessage("Reference must not be null");
|
||||
.withMessage("Reference must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void logsWhenListenerIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.api.logs(ContainerReference.of("e90e34656806"), null))
|
||||
.withMessage("Listener must not be null");
|
||||
.isThrownBy(() -> this.api.logs(ContainerReference.of("e90e34656806"), null))
|
||||
.withMessage("Listener must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -478,7 +478,7 @@ class DockerApiTests {
|
||||
@Test
|
||||
void waitWhenReferenceIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.wait(null))
|
||||
.withMessage("Reference must not be null");
|
||||
.withMessage("Reference must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -493,7 +493,7 @@ class DockerApiTests {
|
||||
@Test
|
||||
void removeWhenReferenceIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.remove(null, true))
|
||||
.withMessage("Reference must not be null");
|
||||
.withMessage("Reference must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -529,7 +529,7 @@ class DockerApiTests {
|
||||
@Test
|
||||
void deleteWhenNameIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.api.delete(null, false))
|
||||
.withMessage("Name must not be null");
|
||||
.withMessage("Name must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -37,11 +37,11 @@ class LogUpdateEventTests {
|
||||
List<LogUpdateEvent> events = readAll("log-update-event.stream");
|
||||
assertThat(events).hasSize(7);
|
||||
assertThat(events.get(0))
|
||||
.hasToString("Analyzing image '307c032c4ceaa6330b6c02af945a1fe56a8c3c27c28268574b217c1d38b093cf'");
|
||||
.hasToString("Analyzing image '307c032c4ceaa6330b6c02af945a1fe56a8c3c27c28268574b217c1d38b093cf'");
|
||||
assertThat(events.get(1))
|
||||
.hasToString("Writing metadata for uncached layer 'org.cloudfoundry.openjdk:openjdk-jre'");
|
||||
.hasToString("Writing metadata for uncached layer 'org.cloudfoundry.openjdk:openjdk-jre'");
|
||||
assertThat(events.get(2))
|
||||
.hasToString("Using cached launch layer 'org.cloudfoundry.jvmapplication:executable-jar'");
|
||||
.hasToString("Using cached launch layer 'org.cloudfoundry.jvmapplication:executable-jar'");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -38,13 +38,13 @@ class TotalProgressEventTests {
|
||||
@Test
|
||||
void createWhenPercentLessThanZeroThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new TotalProgressEvent(-1))
|
||||
.withMessage("Percent must be in the range 0 to 100");
|
||||
.withMessage("Percent must be in the range 0 to 100");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenEventMoreThanOneHundredThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new TotalProgressEvent(101))
|
||||
.withMessage("Percent must be in the range 0 to 100");
|
||||
.withMessage("Percent must be in the range 0 to 100");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class CertificateParserTests {
|
||||
void parseWithInvalidPathWillThrowException() throws URISyntaxException {
|
||||
Path path = Paths.get(new URI("file:///bad/path/cert.pem"));
|
||||
assertThatIllegalStateException().isThrownBy(() -> CertificateParser.parse(path))
|
||||
.withMessageContaining(path.toString());
|
||||
.withMessageContaining(path.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -87,7 +87,7 @@ class PrivateKeyParserTests {
|
||||
void parseWithNonKeyFileWillThrowException() throws IOException {
|
||||
Path path = this.fileWriter.writeFile("text.pem", "plain text");
|
||||
assertThatIllegalStateException().isThrownBy(() -> PrivateKeyParser.parse(path))
|
||||
.withMessageContaining(path.toString());
|
||||
.withMessageContaining(path.toString());
|
||||
Files.delete(path);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ class PrivateKeyParserTests {
|
||||
void parseWithInvalidPathWillThrowException() throws URISyntaxException {
|
||||
Path path = Paths.get(new URI("file:///bad/path/key.pem"));
|
||||
assertThatIllegalStateException().isThrownBy(() -> PrivateKeyParser.parse(path))
|
||||
.withMessageContaining(path.toString());
|
||||
.withMessageContaining(path.toString());
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,20 +35,20 @@ class DockerConnectionExceptionTests {
|
||||
@Test
|
||||
void createWhenHostIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new DockerConnectionException(null, null))
|
||||
.withMessage("Host must not be null");
|
||||
.withMessage("Host must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenCauseIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new DockerConnectionException(HOST, null))
|
||||
.withMessage("Cause must not be null");
|
||||
.withMessage("Cause must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWithIOException() {
|
||||
DockerConnectionException exception = new DockerConnectionException(HOST, new IOException("error"));
|
||||
assertThat(exception.getMessage())
|
||||
.contains("Connection to the Docker daemon at 'docker://localhost/' failed with error \"error\"");
|
||||
.contains("Connection to the Docker daemon at 'docker://localhost/' failed with error \"error\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,7 +56,7 @@ class DockerConnectionExceptionTests {
|
||||
DockerConnectionException exception = new DockerConnectionException(HOST,
|
||||
new IOException(new com.sun.jna.LastErrorException("root cause")));
|
||||
assertThat(exception.getMessage())
|
||||
.contains("Connection to the Docker daemon at 'docker://localhost/' failed with error \"root cause\"");
|
||||
.contains("Connection to the Docker daemon at 'docker://localhost/' failed with error \"root cause\"");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,15 +56,15 @@ class DockerEngineExceptionTests {
|
||||
@Test
|
||||
void createWhenHostIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new DockerEngineException(null, null, 404, null, NO_ERRORS, NO_MESSAGE))
|
||||
.withMessage("Host must not be null");
|
||||
.isThrownBy(() -> new DockerEngineException(null, null, 404, null, NO_ERRORS, NO_MESSAGE))
|
||||
.withMessage("Host must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenUriIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> new DockerEngineException(HOST, null, 404, null, NO_ERRORS, NO_MESSAGE))
|
||||
.withMessage("URI must not be null");
|
||||
.isThrownBy(() -> new DockerEngineException(HOST, null, 404, null, NO_ERRORS, NO_MESSAGE))
|
||||
.withMessage("URI must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -264,10 +264,10 @@ class HttpClientTransportTests {
|
||||
given(this.entity.getContent()).willReturn(getClass().getResourceAsStream("errors.json"));
|
||||
given(this.statusLine.getStatusCode()).willReturn(404);
|
||||
assertThatExceptionOfType(DockerEngineException.class).isThrownBy(() -> this.http.get(this.uri))
|
||||
.satisfies((ex) -> {
|
||||
assertThat(ex.getErrors()).hasSize(2);
|
||||
assertThat(ex.getResponseMessage()).isNull();
|
||||
});
|
||||
.satisfies((ex) -> {
|
||||
assertThat(ex.getErrors()).hasSize(2);
|
||||
assertThat(ex.getResponseMessage()).isNull();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -275,10 +275,10 @@ class HttpClientTransportTests {
|
||||
givenClientWillReturnResponse();
|
||||
given(this.statusLine.getStatusCode()).willReturn(500);
|
||||
assertThatExceptionOfType(DockerEngineException.class).isThrownBy(() -> this.http.get(this.uri))
|
||||
.satisfies((ex) -> {
|
||||
assertThat(ex.getErrors()).isNull();
|
||||
assertThat(ex.getResponseMessage()).isNull();
|
||||
});
|
||||
.satisfies((ex) -> {
|
||||
assertThat(ex.getErrors()).isNull();
|
||||
assertThat(ex.getResponseMessage()).isNull();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -287,10 +287,10 @@ class HttpClientTransportTests {
|
||||
given(this.entity.getContent()).willReturn(getClass().getResourceAsStream("message.json"));
|
||||
given(this.statusLine.getStatusCode()).willReturn(500);
|
||||
assertThatExceptionOfType(DockerEngineException.class).isThrownBy(() -> this.http.get(this.uri))
|
||||
.satisfies((ex) -> {
|
||||
assertThat(ex.getErrors()).isNull();
|
||||
assertThat(ex.getResponseMessage().getMessage()).contains("test message");
|
||||
});
|
||||
.satisfies((ex) -> {
|
||||
assertThat(ex.getErrors()).isNull();
|
||||
assertThat(ex.getResponseMessage().getMessage()).contains("test message");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -299,18 +299,18 @@ class HttpClientTransportTests {
|
||||
given(this.entity.getContent()).willReturn(this.content);
|
||||
given(this.statusLine.getStatusCode()).willReturn(500);
|
||||
assertThatExceptionOfType(DockerEngineException.class).isThrownBy(() -> this.http.get(this.uri))
|
||||
.satisfies((ex) -> {
|
||||
assertThat(ex.getErrors()).isNull();
|
||||
assertThat(ex.getResponseMessage()).isNull();
|
||||
});
|
||||
.satisfies((ex) -> {
|
||||
assertThat(ex.getErrors()).isNull();
|
||||
assertThat(ex.getResponseMessage()).isNull();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void executeWhenClientThrowsIOExceptionRethrowsAsDockerException() throws IOException {
|
||||
given(this.client.execute(any(HttpHost.class), any(HttpRequest.class)))
|
||||
.willThrow(new IOException("test IO exception"));
|
||||
.willThrow(new IOException("test IO exception"));
|
||||
assertThatExceptionOfType(DockerConnectionException.class).isThrownBy(() -> this.http.get(this.uri))
|
||||
.satisfies((ex) -> assertThat(ex.getMessage()).contains("test IO exception"));
|
||||
.satisfies((ex) -> assertThat(ex.getMessage()).contains("test IO exception"));
|
||||
}
|
||||
|
||||
private String writeToString(HttpEntity entity) throws IOException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -80,7 +80,7 @@ class RemoteHttpClientTransportTests {
|
||||
SslContextFactory sslContextFactory = mock(SslContextFactory.class);
|
||||
given(sslContextFactory.forDirectory("/test-cert-path")).willReturn(SSLContext.getDefault());
|
||||
ResolvedDockerHost dockerHost = ResolvedDockerHost
|
||||
.from(new DockerHost("tcp://192.168.1.2:2376", true, "/test-cert-path"));
|
||||
.from(new DockerHost("tcp://192.168.1.2:2376", true, "/test-cert-path"));
|
||||
RemoteHttpClientTransport transport = RemoteHttpClientTransport.createIfPossible(dockerHost, sslContextFactory);
|
||||
assertThat(transport.getHost()).satisfies(hostOf("https", "192.168.1.2", 2376));
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class RemoteHttpClientTransportTests {
|
||||
void createIfPossibleWhenTlsVerifyWithMissingCertPathThrowsException() {
|
||||
ResolvedDockerHost dockerHost = ResolvedDockerHost.from(new DockerHost("tcp://192.168.1.2:2376", true, null));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> RemoteHttpClientTransport.createIfPossible(dockerHost))
|
||||
.withMessageContaining("Docker host TLS verification requires trust material");
|
||||
.withMessageContaining("Docker host TLS verification requires trust material");
|
||||
}
|
||||
|
||||
private Consumer<HttpHost> hostOf(String scheme, String hostName, int port) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ class BindingTests {
|
||||
@Test
|
||||
void ofWithNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Binding.of(null))
|
||||
.withMessageContaining("Value must not be null");
|
||||
.withMessageContaining("Value must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -49,13 +49,13 @@ class BindingTests {
|
||||
@Test
|
||||
void fromWithNullSourceThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Binding.from((String) null, "container-dest"))
|
||||
.withMessageContaining("Source must not be null");
|
||||
.withMessageContaining("Source must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromWithNullDestinationThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Binding.from("host-src", null))
|
||||
.withMessageContaining("Destination must not be null");
|
||||
.withMessageContaining("Destination must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,7 +67,7 @@ class BindingTests {
|
||||
@Test
|
||||
void fromVolumeNameSourceWithNullSourceThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Binding.from((VolumeName) null, "container-dest"))
|
||||
.withMessageContaining("SourceVolume must not be null");
|
||||
.withMessageContaining("SourceVolume must not be null");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ class ContainerConfigTests extends AbstractJsonTests {
|
||||
void ofWhenUpdateIsNullThrowsException() {
|
||||
ImageReference imageReference = ImageReference.of("ubuntu:bionic");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ContainerConfig.of(imageReference, null))
|
||||
.withMessage("Update must not be null");
|
||||
.withMessage("Update must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,21 +34,21 @@ class ContainerContentTests {
|
||||
@Test
|
||||
void ofWhenArchiveIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ContainerContent.of(null))
|
||||
.withMessage("Archive must not be null");
|
||||
.withMessage("Archive must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenDestinationPathIsNullThrowsException() {
|
||||
TarArchive archive = mock(TarArchive.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ContainerContent.of(archive, null))
|
||||
.withMessage("DestinationPath must not be empty");
|
||||
.withMessage("DestinationPath must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenDestinationPathIsEmptyThrowsException() {
|
||||
TarArchive archive = mock(TarArchive.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ContainerContent.of(archive, ""))
|
||||
.withMessage("DestinationPath must not be empty");
|
||||
.withMessage("DestinationPath must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -31,30 +31,30 @@ class ContainerReferenceTests {
|
||||
@Test
|
||||
void ofCreatesInstance() {
|
||||
ContainerReference reference = ContainerReference
|
||||
.of("92691aec176333f7ae890de9aaeeafef11166efcaa3908edf83eb44a5c943781");
|
||||
.of("92691aec176333f7ae890de9aaeeafef11166efcaa3908edf83eb44a5c943781");
|
||||
assertThat(reference).hasToString("92691aec176333f7ae890de9aaeeafef11166efcaa3908edf83eb44a5c943781");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ContainerReference.of(null))
|
||||
.withMessage("Value must not be empty");
|
||||
.withMessage("Value must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenEmptyThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ContainerReference.of(""))
|
||||
.withMessage("Value must not be empty");
|
||||
.withMessage("Value must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void hashCodeAndEquals() {
|
||||
ContainerReference r1 = ContainerReference
|
||||
.of("92691aec176333f7ae890de9aaeeafef11166efcaa3908edf83eb44a5c943781");
|
||||
.of("92691aec176333f7ae890de9aaeeafef11166efcaa3908edf83eb44a5c943781");
|
||||
ContainerReference r2 = ContainerReference
|
||||
.of("92691aec176333f7ae890de9aaeeafef11166efcaa3908edf83eb44a5c943781");
|
||||
.of("92691aec176333f7ae890de9aaeeafef11166efcaa3908edf83eb44a5c943781");
|
||||
ContainerReference r3 = ContainerReference
|
||||
.of("02691aec176333f7ae890de9aaeeafef11166efcaa3908edf83eb44a5c943781");
|
||||
.of("02691aec176333f7ae890de9aaeeafef11166efcaa3908edf83eb44a5c943781");
|
||||
assertThat(r1).hasSameHashCodeAs(r2);
|
||||
assertThat(r1).isEqualTo(r1).isEqualTo(r2).isNotEqualTo(r3);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,9 +68,9 @@ class ImageConfigTests extends AbstractJsonTests {
|
||||
void updateWithLabelUpdatesLabels() throws Exception {
|
||||
ImageConfig imageConfig = getImageConfig();
|
||||
ImageConfig updatedImageConfig = imageConfig
|
||||
.copy((update) -> update.withLabel("io.buildpacks.stack.id", "test"));
|
||||
.copy((update) -> update.withLabel("io.buildpacks.stack.id", "test"));
|
||||
assertThat(imageConfig.getLabels()).hasSize(4)
|
||||
.contains(entry("io.buildpacks.stack.id", "org.cloudfoundry.stacks.cflinuxfs3"));
|
||||
.contains(entry("io.buildpacks.stack.id", "org.cloudfoundry.stacks.cflinuxfs3"));
|
||||
assertThat(updatedImageConfig.getLabels()).hasSize(4).contains(entry("io.buildpacks.stack.id", "test"));
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ class ImageNameTests {
|
||||
@Test
|
||||
void ofWhenNameIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ImageName.of(null))
|
||||
.withMessage("Value must not be empty");
|
||||
.withMessage("Value must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,20 +129,23 @@ class ImageNameTests {
|
||||
@Test
|
||||
void ofWhenContainsUppercaseThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ImageName.of("Test"))
|
||||
.withMessageContaining("Unable to parse name").withMessageContaining("Test");
|
||||
.withMessageContaining("Unable to parse name")
|
||||
.withMessageContaining("Test");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenNameIncludesTagThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ImageName.of("ubuntu:latest"))
|
||||
.withMessageContaining("Unable to parse name").withMessageContaining(":latest");
|
||||
.withMessageContaining("Unable to parse name")
|
||||
.withMessageContaining(":latest");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenNameIncludeDigestThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
() -> ImageName.of("ubuntu@sha256:47bfdb88c3ae13e488167607973b7688f69d9e8c142c2045af343ec199649c09"))
|
||||
.withMessageContaining("Unable to parse name").withMessageContaining("@sha256:47b");
|
||||
.withMessageContaining("Unable to parse name")
|
||||
.withMessageContaining("@sha256:47b");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -115,12 +115,12 @@ class ImageReferenceTests {
|
||||
@Test
|
||||
void ofNameAndDigest() {
|
||||
ImageReference reference = ImageReference
|
||||
.of("ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
.of("ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
assertThat(reference.getDomain()).isEqualTo("docker.io");
|
||||
assertThat(reference.getName()).isEqualTo("library/ubuntu");
|
||||
assertThat(reference.getTag()).isNull();
|
||||
assertThat(reference.getDigest())
|
||||
.isEqualTo("sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
.isEqualTo("sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
assertThat(reference).hasToString(
|
||||
"docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
}
|
||||
@@ -128,25 +128,25 @@ class ImageReferenceTests {
|
||||
@Test
|
||||
void ofNameAndTagAndDigest() {
|
||||
ImageReference reference = ImageReference
|
||||
.of("ubuntu:bionic@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
.of("ubuntu:bionic@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
assertThat(reference.getDomain()).isEqualTo("docker.io");
|
||||
assertThat(reference.getName()).isEqualTo("library/ubuntu");
|
||||
assertThat(reference.getTag()).isEqualTo("bionic");
|
||||
assertThat(reference.getDigest())
|
||||
.isEqualTo("sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
.isEqualTo("sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
assertThat(reference).hasToString(
|
||||
"docker.io/library/ubuntu:bionic@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofCustomDomainAndPortWithTag() {
|
||||
ImageReference reference = ImageReference.of(
|
||||
"example.com:8080/canonical/ubuntu:bionic@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
ImageReference reference = ImageReference
|
||||
.of("example.com:8080/canonical/ubuntu:bionic@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
assertThat(reference.getDomain()).isEqualTo("example.com:8080");
|
||||
assertThat(reference.getName()).isEqualTo("canonical/ubuntu");
|
||||
assertThat(reference.getTag()).isEqualTo("bionic");
|
||||
assertThat(reference.getDigest())
|
||||
.isEqualTo("sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
.isEqualTo("sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
assertThat(reference).hasToString(
|
||||
"example.com:8080/canonical/ubuntu:bionic@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
}
|
||||
@@ -174,9 +174,9 @@ class ImageReferenceTests {
|
||||
@Test
|
||||
void ofWhenHasIllegalCharacter() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ImageReference
|
||||
.of("registry.example.com/example/example-app:1.6.0-dev.2.uncommitted+wip.foo.c75795d"))
|
||||
.withMessageContaining("Unable to parse image reference");
|
||||
.isThrownBy(() -> ImageReference
|
||||
.of("registry.example.com/example/example-app:1.6.0-dev.2.uncommitted+wip.foo.c75795d"))
|
||||
.withMessageContaining("Unable to parse image reference");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -219,15 +219,16 @@ class ImageReferenceTests {
|
||||
@Test
|
||||
void randomWherePrefixIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ImageReference.random(null))
|
||||
.withMessage("Prefix must not be null");
|
||||
.withMessage("Prefix must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void inTaggedFormWhenHasDigestThrowsException() {
|
||||
ImageReference reference = ImageReference
|
||||
.of("ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
assertThatIllegalStateException().isThrownBy(() -> reference.inTaggedForm()).withMessage(
|
||||
"Image reference 'docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d' cannot contain a digest");
|
||||
.of("ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
assertThatIllegalStateException().isThrownBy(() -> reference.inTaggedForm())
|
||||
.withMessage(
|
||||
"Image reference 'docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d' cannot contain a digest");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -245,7 +246,7 @@ class ImageReferenceTests {
|
||||
@Test
|
||||
void inTaggedOrDigestFormWhenHasDigestUsesDigest() {
|
||||
ImageReference reference = ImageReference
|
||||
.of("ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
.of("ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
assertThat(reference.inTaggedOrDigestForm()).hasToString(
|
||||
"docker.io/library/ubuntu@sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d");
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ class ImageTests extends AbstractJsonTests {
|
||||
List<LayerId> layers = image.getLayers();
|
||||
assertThat(layers).hasSize(46);
|
||||
assertThat(layers.get(0))
|
||||
.hasToString("sha256:733a8e5ce32984099ef675fce04730f6e2a6dcfdf5bd292fea01a8f936265342");
|
||||
.hasToString("sha256:733a8e5ce32984099ef675fce04730f6e2a6dcfdf5bd292fea01a8f936265342");
|
||||
assertThat(layers.get(45))
|
||||
.hasToString("sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef");
|
||||
.hasToString("sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -52,7 +52,7 @@ class LayerIdTests {
|
||||
@Test
|
||||
void ofWhenValueIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> LayerId.of((String) null))
|
||||
.withMessage("Value must not be empty");
|
||||
.withMessage("Value must not be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,13 +80,13 @@ class LayerIdTests {
|
||||
@Test
|
||||
void ofSha256DigestWhenNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> LayerId.ofSha256Digest((byte[]) null))
|
||||
.withMessage("Digest must not be null");
|
||||
.withMessage("Digest must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofSha256DigestWhenWrongLengthThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> LayerId.ofSha256Digest(new byte[31]))
|
||||
.withMessage("Digest must be exactly 32 bytes");
|
||||
.withMessage("Digest must be exactly 32 bytes");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ class LayerTests {
|
||||
@Test
|
||||
void ofWhenLayoutIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Layer.of((IOConsumer<Layout>) null))
|
||||
.withMessage("Layout must not be null");
|
||||
.withMessage("Layout must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void fromTarArchiveWhenTarArchiveIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Layer.fromTarArchive(null))
|
||||
.withMessage("TarArchive must not be null");
|
||||
.withMessage("TarArchive must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,7 +56,7 @@ class LayerTests {
|
||||
layout.file("/directory/file", Owner.ROOT, Content.of("test"));
|
||||
});
|
||||
assertThat(layer.getId())
|
||||
.hasToString("sha256:d03a34f73804698c875eb56ff694fc2fceccc69b645e4adceb004ed13588613b");
|
||||
.hasToString("sha256:d03a34f73804698c875eb56ff694fc2fceccc69b645e4adceb004ed13588613b");
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
layer.writeTo(outputStream);
|
||||
try (TarArchiveInputStream tarStream = new TarArchiveInputStream(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ class RandomStringTests {
|
||||
@Test
|
||||
void generateWhenPrefixIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> RandomString.generate(null, 10))
|
||||
.withMessage("Prefix must not be null");
|
||||
.withMessage("Prefix must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -31,7 +31,7 @@ class VolumeNameTests {
|
||||
@Test
|
||||
void randomWhenPrefixIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.random(null))
|
||||
.withMessage("Prefix must not be null");
|
||||
.withMessage("Prefix must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,25 +57,25 @@ class VolumeNameTests {
|
||||
@Test
|
||||
void basedOnWhenSourceIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.basedOn(null, "prefix", "suffix", 6))
|
||||
.withMessage("Source must not be null");
|
||||
.withMessage("Source must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void basedOnWhenNameExtractorIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.basedOn("test", null, "prefix", "suffix", 6))
|
||||
.withMessage("NameExtractor must not be null");
|
||||
.withMessage("NameExtractor must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void basedOnWhenPrefixIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.basedOn("test", null, "suffix", 6))
|
||||
.withMessage("Prefix must not be null");
|
||||
.withMessage("Prefix must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void basedOnWhenSuffixIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.basedOn("test", "prefix", null, 6))
|
||||
.withMessage("Suffix must not be null");
|
||||
.withMessage("Suffix must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,13 +87,13 @@ class VolumeNameTests {
|
||||
@Test
|
||||
void basedOnWhenSizeIsTooBigThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.basedOn("name", "prefix", "suffix", 33))
|
||||
.withMessage("DigestLength must be less than or equal to 32");
|
||||
.withMessage("DigestLength must be less than or equal to 32");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenValueIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> VolumeName.of(null))
|
||||
.withMessage("Value must not be null");
|
||||
.withMessage("Value must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,7 +37,7 @@ class ContentTests {
|
||||
@Test
|
||||
void ofWhenStreamIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Content.of(1, (IOSupplier<InputStream>) null))
|
||||
.withMessage("Supplier must not be null");
|
||||
.withMessage("Supplier must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -51,7 +51,7 @@ class ContentTests {
|
||||
@Test
|
||||
void ofWhenStringIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Content.of((String) null))
|
||||
.withMessage("String must not be null");
|
||||
.withMessage("String must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,7 +63,7 @@ class ContentTests {
|
||||
@Test
|
||||
void ofWhenBytesIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Content.of((byte[]) null))
|
||||
.withMessage("Bytes must not be null");
|
||||
.withMessage("Bytes must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -51,7 +51,7 @@ class FilePermissionsTests {
|
||||
@DisabledOnOs(OS.WINDOWS)
|
||||
void umaskForPath() throws IOException {
|
||||
FileAttribute<Set<PosixFilePermission>> fileAttribute = PosixFilePermissions
|
||||
.asFileAttribute(PosixFilePermissions.fromString("rw-r-----"));
|
||||
.asFileAttribute(PosixFilePermissions.fromString("rw-r-----"));
|
||||
Path tempFile = Files.createTempFile(this.tempDir, "umask", null, fileAttribute);
|
||||
assertThat(FilePermissions.umaskForPath(tempFile)).isEqualTo(0640);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class FilePermissionsTests {
|
||||
@DisabledOnOs(OS.WINDOWS)
|
||||
void umaskForPathWithNonExistentFile() {
|
||||
assertThatIOException()
|
||||
.isThrownBy(() -> FilePermissions.umaskForPath(Paths.get(this.tempDir.toString(), "does-not-exist")));
|
||||
.isThrownBy(() -> FilePermissions.umaskForPath(Paths.get(this.tempDir.toString(), "does-not-exist")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,7 +68,7 @@ class FilePermissionsTests {
|
||||
void umaskForPathOnWindowsFails() throws IOException {
|
||||
Path tempFile = Files.createTempFile("umask", null);
|
||||
assertThatIllegalStateException().isThrownBy(() -> FilePermissions.umaskForPath(tempFile))
|
||||
.withMessageContaining("Unsupported file type for retrieving Posix attributes");
|
||||
.withMessageContaining("Unsupported file type for retrieving Posix attributes");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,19 +39,19 @@ class InspectedContentTests {
|
||||
@Test
|
||||
void ofWhenInputStreamThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> InspectedContent.of((InputStream) null))
|
||||
.withMessage("InputStream must not be null");
|
||||
.withMessage("InputStream must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenContentIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> InspectedContent.of((Content) null))
|
||||
.withMessage("Content must not be null");
|
||||
.withMessage("Content must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ofWhenConsumerIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> InspectedContent.of((IOConsumer<OutputStream>) null))
|
||||
.withMessage("Writer must not be null");
|
||||
.withMessage("Writer must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,9 +85,9 @@ class InspectedContentTests {
|
||||
InputStream inputStream = new ByteArrayInputStream("test".getBytes(StandardCharsets.UTF_8));
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
InspectedContent.of(inputStream, digest::update);
|
||||
assertThat(digest.digest()).inHexadecimal().contains(0x9f, 0x86, 0xd0, 0x81, 0x88, 0x4c, 0x7d, 0x65, 0x9a, 0x2f,
|
||||
0xea, 0xa0, 0xc5, 0x5a, 0xd0, 0x15, 0xa3, 0xbf, 0x4f, 0x1b, 0x2b, 0x0b, 0x82, 0x2c, 0xd1, 0x5d, 0x6c,
|
||||
0x15, 0xb0, 0xf0, 0x0a, 0x08);
|
||||
assertThat(digest.digest()).inHexadecimal()
|
||||
.contains(0x9f, 0x86, 0xd0, 0x81, 0x88, 0x4c, 0x7d, 0x65, 0x9a, 0x2f, 0xea, 0xa0, 0xc5, 0x5a, 0xd0, 0x15,
|
||||
0xa3, 0xbf, 0x4f, 0x1b, 0x2b, 0x0b, 0x82, 0x2c, 0xd1, 0x5d, 0x6c, 0x15, 0xb0, 0xf0, 0x0a, 0x08);
|
||||
}
|
||||
|
||||
private byte[] readBytes(InspectedContent content) throws IOException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ class ZipFileTarArchiveTests {
|
||||
@Test
|
||||
void createWhenZipIsNullThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new ZipFileTarArchive(null, Owner.ROOT))
|
||||
.withMessage("Zip must not be null");
|
||||
.withMessage("Zip must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,7 +54,7 @@ class ZipFileTarArchiveTests {
|
||||
File file = new File(this.tempDir, "test.zip");
|
||||
writeTestZip(file);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new ZipFileTarArchive(file, null))
|
||||
.withMessage("Owner must not be null");
|
||||
.withMessage("Owner must not be null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ public abstract class AbstractJsonTests {
|
||||
|
||||
protected final String getContentAsString(String name) {
|
||||
return new BufferedReader(new InputStreamReader(getContent(name), StandardCharsets.UTF_8)).lines()
|
||||
.collect(Collectors.joining("\n"));
|
||||
.collect(Collectors.joining("\n"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,7 +45,7 @@ class JsonStreamTests extends AbstractJsonTests {
|
||||
this.jsonStream.get(getContent("stream.json"), result::add);
|
||||
assertThat(result).hasSize(595);
|
||||
assertThat(result.get(594).toString())
|
||||
.contains("Status: Downloaded newer image for paketo-buildpacks/cnb:base");
|
||||
.contains("Status: Downloaded newer image for paketo-buildpacks/cnb:base");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,7 +55,7 @@ class JsonStreamTests extends AbstractJsonTests {
|
||||
assertThat(result).hasSize(595);
|
||||
assertThat(result.get(1).getId()).isEqualTo("5667fdb72017");
|
||||
assertThat(result.get(594).getStatus())
|
||||
.isEqualTo("Status: Downloaded newer image for paketo-buildpacks/cnb:base");
|
||||
.isEqualTo("Status: Downloaded newer image for paketo-buildpacks/cnb:base");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,13 +38,13 @@ class SharedObjectMapperTests {
|
||||
assertThat(mapper).isNotNull();
|
||||
assertThat(mapper.getRegisteredModuleIds()).contains(new ParameterNamesModule().getTypeId());
|
||||
assertThat(SerializationFeature.INDENT_OUTPUT
|
||||
.enabledIn(mapper.getSerializationConfig().getSerializationFeatures())).isTrue();
|
||||
.enabledIn(mapper.getSerializationConfig().getSerializationFeatures())).isTrue();
|
||||
assertThat(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
|
||||
.enabledIn(mapper.getDeserializationConfig().getDeserializationFeatures())).isFalse();
|
||||
.enabledIn(mapper.getDeserializationConfig().getDeserializationFeatures())).isFalse();
|
||||
assertThat(mapper.getSerializationConfig().getPropertyNamingStrategy())
|
||||
.isEqualTo(PropertyNamingStrategies.LOWER_CAMEL_CASE);
|
||||
.isEqualTo(PropertyNamingStrategies.LOWER_CAMEL_CASE);
|
||||
assertThat(mapper.getDeserializationConfig().getPropertyNamingStrategy())
|
||||
.isEqualTo(PropertyNamingStrategies.LOWER_CAMEL_CASE);
|
||||
.isEqualTo(PropertyNamingStrategies.LOWER_CAMEL_CASE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user