Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<!-- Plugin version -->
<build.helper-maven-plugin.version>3.6.2</build.helper-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.15</jacoco-maven-plugin.version>
<spotless-maven-plugin.version>3.10.2</spotless-maven-plugin.version>
<spotless-maven-plugin.version>3.10.3</spotless-maven-plugin.version>
<maven-compiler-plugin.version>3.16.0</maven-compiler-plugin.version>
<maven-clean-plugin.version>3.5.0</maven-clean-plugin.version>
<maven-install-plugin.version>3.2.0</maven-install-plugin.version>
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/land/oras/GitHubContainerRegistryITCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ void shouldGetReferrersUsingLegacyTagFallback() {
Referrers referrers = registry.getReferrers(containerRef, null);
assertFalse(referrers.getManifests().isEmpty(), "Referrers must be found through the legacy tag fallback");
assertTrue(
referrers.getManifests().stream().anyMatch(manifest -> "application/vnd.dev.sigstore.bundle.v0.3+json"
.equals(manifest.getArtifactType())),
referrers.getManifests().stream()
.anyMatch(manifest ->
"application/vnd.dev.sigstore.bundle.v0.3+json".equals(manifest.getArtifactType())),
"Sigstore bundle referrer must be found");
}

Expand Down
9 changes: 5 additions & 4 deletions src/test/java/land/oras/PublicAzureCRITCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ void shouldContainsCommonWindowsPlatform() {
containerSource = ContainerRef.parse(
"mcr.microsoft.com/windows/servercore@sha256:79aa6a176b2e4f1786eb29c4facd33077769eddde4c4a650aea552f6320893c7");
index = sourceRegistry.getIndex(containerSource);
assertTrue(index.getManifests().stream().anyMatch(m -> m.getPlatform()
.equals(Platform.windowsAmd64()
.withOsVersion("10.0.26100.32370")
.withOsFeatures(List.of("win32k")))));
assertTrue(index.getManifests().stream()
.anyMatch(m -> m.getPlatform()
.equals(Platform.windowsAmd64()
.withOsVersion("10.0.26100.32370")
.withOsFeatures(List.of("win32k")))));
}

@Test
Expand Down
46 changes: 28 additions & 18 deletions src/test/java/land/oras/auth/HttpClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ void whenCaFileFromStringThenSucceed(@TempDir Path tempDir) throws IOException {

@Test
void whenCaFileDoesNotExistThenThrow() {
OrasException exception = assertThrows(OrasException.class, () -> HttpClient.Builder.builder()
.withCaFile(Path.of("/nonexistent/ca.pem"))
.build());
OrasException exception = assertThrows(
OrasException.class,
() -> HttpClient.Builder.builder()
.withCaFile(Path.of("/nonexistent/ca.pem"))
.build());
assertTrue(exception.getMessage().contains("Unable to configure CA file"));
}

Expand Down Expand Up @@ -186,40 +188,48 @@ void whenCaContentIsEmptyThenThrow() {

@Test
void whenCaContentNotValidCertificateThenThrow() {
OrasException exception = assertThrows(OrasException.class, () -> HttpClient.Builder.builder()
.withCaContent("not a certificate")
.build());
OrasException exception = assertThrows(
OrasException.class,
() -> HttpClient.Builder.builder()
.withCaContent("not a certificate")
.build());
assertTrue(exception.getMessage().contains("Unable to configure CA certificates from content"));
}

@Test
void whenBothCaFileAndCaContentConfiguredThenThrow(@TempDir Path tempDir) throws IOException {
Path caFile = tempDir.resolve("ca.pem");
Files.writeString(caFile, ROOT_CA_PEM);
OrasException exception = assertThrows(OrasException.class, () -> HttpClient.Builder.builder()
.withCaFile(caFile)
.withCaContent(ROOT_CA_PEM)
.build());
OrasException exception = assertThrows(
OrasException.class,
() -> HttpClient.Builder.builder()
.withCaFile(caFile)
.withCaContent(ROOT_CA_PEM)
.build());
assertTrue(exception.getMessage().contains("Cannot configure both a CA file and CA content"));
}

@Test
void whenSkipTlsVerifyAndCaFileThenThrow(@TempDir Path tempDir) throws IOException {
Path caFile = tempDir.resolve("ca.pem");
Files.writeString(caFile, ROOT_CA_PEM);
OrasException exception = assertThrows(OrasException.class, () -> HttpClient.Builder.builder()
.withSkipTlsVerify(true)
.withCaFile(caFile)
.build());
OrasException exception = assertThrows(
OrasException.class,
() -> HttpClient.Builder.builder()
.withSkipTlsVerify(true)
.withCaFile(caFile)
.build());
assertTrue(exception.getMessage().contains("Cannot combine skipTlsVerify"));
}

@Test
void whenSkipTlsVerifyAndCaContentThenThrow() {
OrasException exception = assertThrows(OrasException.class, () -> HttpClient.Builder.builder()
.withSkipTlsVerify(true)
.withCaContent(ROOT_CA_PEM)
.build());
OrasException exception = assertThrows(
OrasException.class,
() -> HttpClient.Builder.builder()
.withSkipTlsVerify(true)
.withCaContent(ROOT_CA_PEM)
.build());
assertTrue(exception.getMessage().contains("Cannot combine skipTlsVerify"));
}

Expand Down
Loading