From bbeb5a8ae148d49da37e9c53071e84fb6c389ac5 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 21 Nov 2026 15:58:47 -0500 Subject: [PATCH 1/2] Make GitIdentifiers filesystem tests portable Check POSIX support and symbolic-link creation capabilities before running native fixtures, preserving fixture and cleanup failures. Derive expected link hashes from platform-specific target paths. Expand coverage for all 512 POSIX permission combinations, missing symlink privileges, non-POSIX filesystems, and link target formats. Update changes.xml. --- src/changes/changes.xml | 1 + .../digest/GitIdentifiersFileSystemTest.java | 282 ++++++++++++++++-- .../codec/digest/GitIdentifiersTest.java | 64 ++-- 3 files changed, 300 insertions(+), 47 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 1e0521a332..8201b65966 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -68,6 +68,7 @@ The type attribute can be add,update,fix,remove. Stop BaseNCodecInputStream from reading the underlying stream after codec EOF, preventing unnecessary reads and blocking after padding in lenient Base32 and Base64 decoding. Compute Digest ALL and * standard-input digests in a single pass with bounded buffering, removing the mark/reset input-size limit. Keep BaseNCodecInputStream.available() positive after codec EOF while output remains buffered. + Make GitIdentifiers filesystem tests account for unavailable POSIX attributes, symbolic-link creation privileges, and platform-specific link target paths. Bump org.apache.commons:commons-parent from 105 to 107. diff --git a/src/test/java/org/apache/commons/codec/digest/GitIdentifiersFileSystemTest.java b/src/test/java/org/apache/commons/codec/digest/GitIdentifiersFileSystemTest.java index 2b6eaf11d2..49e3dd8afd 100644 --- a/src/test/java/org/apache/commons/codec/digest/GitIdentifiersFileSystemTest.java +++ b/src/test/java/org/apache/commons/codec/digest/GitIdentifiersFileSystemTest.java @@ -18,8 +18,12 @@ package org.apache.commons.codec.digest; import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -27,14 +31,20 @@ import java.lang.reflect.Proxy; import java.net.URI; import java.nio.channels.SeekableByteChannel; +import java.nio.charset.StandardCharsets; import java.nio.file.AccessDeniedException; import java.nio.file.AccessMode; import java.nio.file.CopyOption; import java.nio.file.DirectoryStream; +import java.nio.file.FileAlreadyExistsException; import java.nio.file.FileStore; import java.nio.file.FileSystem; +import java.nio.file.FileSystemException; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.LinkOption; +import java.nio.file.NoSuchFileException; +import java.nio.file.NotDirectoryException; import java.nio.file.OpenOption; import java.nio.file.Path; import java.nio.file.PathMatcher; @@ -56,19 +66,25 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import java.util.stream.IntStream; +import java.util.stream.Stream; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.ValueSource; +import org.opentest4j.TestAbortedException; /** - * Tests file modes independently of the host file system's permissions and execution access. + * Tests filesystem capability assumptions, file modes, and symbolic links independently of the host filesystem. */ class GitIdentifiersFileSystemTest { /** - * A single-file tree exposing only the operations needed to compute its identifier. Proxies implement the small subset of the Path and attribute - * interfaces used by the tests; unsupported operations fail explicitly. No files or permissions on the host are changed. + * A single-entry tree with configurable attributes and symbolic-link operations. Proxies expose only the Path and attribute operations used by these + * tests; unsupported operations fail explicitly. No files or permissions on the host are changed. */ private static final class TestFileSystem extends FileSystem { @@ -76,7 +92,11 @@ private static final class TestFileSystem extends FileSystem { private boolean open = true; TestFileSystem(final String permissions, final boolean executable) { - provider = new TestFileSystemProvider(this, permissions, executable); + this(permissions, executable, null); + } + + TestFileSystem(final String permissions, final boolean executable, final String linkTarget) { + provider = new TestFileSystemProvider(this, permissions, executable, linkTarget); } @Override @@ -98,6 +118,8 @@ public Path getPath(final String first, final String... more) { return this; case "getFileName": return name.getFileName(); + case "resolve": + return getPath(name.resolve(args[0].toString()).toString()); case "toString": return name.toString(); default: @@ -133,7 +155,7 @@ public boolean isOpen() { @Override public boolean isReadOnly() { - return true; + return false; } @Override @@ -158,21 +180,28 @@ private static final class TestFileSystemProvider extends FileSystemProvider { private final String permissions; private final boolean executable; private final BasicFileAttributes attributes; + private final String linkTarget; + private Exception linkCreationFailure; + private Exception deletionFailure; + private int linksCreated; + private int linksDeleted; - TestFileSystemProvider(final TestFileSystem fileSystem, final String permissions, final boolean executable) { + TestFileSystemProvider(final TestFileSystem fileSystem, final String permissions, final boolean executable, final String linkTarget) { this.fileSystem = fileSystem; this.permissions = permissions; this.executable = executable; + this.linkTarget = linkTarget; final Class attributeType = permissions == null ? BasicFileAttributes.class : PosixFileAttributes.class; attributes = (BasicFileAttributes) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { attributeType }, (proxy, method, args) -> { switch (method.getName()) { case "isDirectory": - case "isSymbolicLink": case "isOther": return false; + case "isSymbolicLink": + return linkTarget != null; case "isRegularFile": - return true; + return linkTarget == null; case "permissions": return PosixFilePermissions.fromString(permissions); case "size": @@ -203,12 +232,25 @@ public void createDirectory(final Path dir, final FileAttribute... attrs) { } @Override - public void delete(final Path path) { - throw new UnsupportedOperationException(); + public void createSymbolicLink(final Path link, final Path target, final FileAttribute... attrs) throws IOException { + assertEquals("symlink-capability-probe", link.getFileName().toString()); + assertEquals("symlink-capability-target", target.toString()); + throwIfConfigured(linkCreationFailure); + linksCreated++; + } + + @Override + public void delete(final Path path) throws IOException { + assertEquals("symlink-capability-probe", path.getFileName().toString()); + throwIfConfigured(deletionFailure); + linksDeleted++; } @Override public V getFileAttributeView(final Path path, final Class type, final LinkOption... options) { + if (linkTarget != null) { + assertArrayEquals(new LinkOption[] { LinkOption.NOFOLLOW_LINKS }, options); + } if (type != BasicFileAttributeView.class && (type != PosixFileAttributeView.class || permissions == null)) { return null; } @@ -262,6 +304,7 @@ public SeekableByteChannel newByteChannel(final Path path, final Set newDirectoryStream(final Path dir, final DirectoryStream.Filter filter) throws IOException { + assertEquals("root", dir.toString(), "A symbolic link must not be traversed as a directory"); final Path file = fileSystem.getPath("file.txt"); final Set entries = filter.accept(file) ? Collections.singleton(file) : Collections.emptySet(); return new DirectoryStream() { @@ -284,11 +327,15 @@ public FileSystem newFileSystem(final URI uri, final Map env) { @Override public InputStream newInputStream(final Path path, final OpenOption... options) { + assertNull(linkTarget, "Symbolic link contents must not be read through the target"); return new ByteArrayInputStream(CONTENT); } @Override public A readAttributes(final Path path, final Class type, final LinkOption... options) { + if (linkTarget != null) { + assertArrayEquals(new LinkOption[] { LinkOption.NOFOLLOW_LINKS }, options); + } return type.cast(attributes); } @@ -297,6 +344,18 @@ public Map readAttributes(final Path path, final String attribut throw new UnsupportedOperationException(); } + @Override + public Path readSymbolicLink(final Path link) { + assertTrue(linkTarget != null, "This fixture must represent a symbolic link"); + // Preserve the provider's exact target text independently of the host's path syntax. + return (Path) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { Path.class }, (proxy, method, args) -> { + if ("toString".equals(method.getName())) { + return linkTarget; + } + throw new UnsupportedOperationException(method.getName()); + }); + } + @Override public void setAttribute(final Path path, final String attribute, final Object value, final LinkOption... options) { throw new UnsupportedOperationException(); @@ -305,45 +364,210 @@ public void setAttribute(final Path path, final String attribute, final Object v private static final byte[] CONTENT = { 'x' }; - private static void assertTreeId(final FileSystem fileSystem, final GitIdentifiers.FileMode mode) throws IOException { - final MessageDigest md = DigestUtils.getSha1Digest(); + private static void assertTreeId(final FileSystem fileSystem, final String algorithm, final GitIdentifiers.FileMode mode) throws IOException { + final MessageDigest md = DigestUtils.getDigest(algorithm); final GitIdentifiers.TreeIdBuilder builder = GitIdentifiers.treeIdBuilder(md); builder.addFile(mode, "file.txt", CONTENT); assertArrayEquals(builder.get(), GitIdentifiers.treeId(md, fileSystem.getPath("root"))); } + static Stream basicFileModes() { + return Stream.of(MessageDigestAlgorithms.SHA_1, MessageDigestAlgorithms.SHA_256) + .flatMap(algorithm -> Stream.of(false, true).map(executable -> Arguments.of(algorithm, executable))); + } + + static Stream posixFileModes() { + return Stream.of(MessageDigestAlgorithms.SHA_1, MessageDigestAlgorithms.SHA_256).flatMap(algorithm -> IntStream.range(0, 512).boxed() + .flatMap(mask -> Stream.of(false, true).map(executable -> { + final char[] permissions = "---------".toCharArray(); + for (int i = 0; i < permissions.length; i++) { + if ((mask & (1 << (8 - i))) != 0) { + permissions[i] = "rwxrwxrwx".charAt(i); + } + } + final GitIdentifiers.FileMode mode = (mask & 0100) == 0 ? GitIdentifiers.FileMode.REGULAR : GitIdentifiers.FileMode.EXECUTABLE; + return Arguments.of(algorithm, new String(permissions), executable, mode); + }))); + } + + static Stream symbolicLinks() { + return Stream.of(MessageDigestAlgorithms.SHA_1, MessageDigestAlgorithms.SHA_256).flatMap(algorithm -> + Stream.of(null, "rw-------", "rwxrwxrwx").flatMap(permissions -> Stream.of(false, true).flatMap(executable -> + Stream.of("file.txt", "subdir/file.txt", "subdir\\file.txt", "../missing.txt", "/target/file", "C:\\target\\file", + "directory", "dir/\u03bb.txt").map(target -> Arguments.of(algorithm, permissions, executable, target))))); + } + + private static void throwIfConfigured(final Exception failure) throws IOException { + if (failure instanceof IOException) { + throw (IOException) failure; + } + if (failure != null) { + throw (RuntimeException) failure; + } + } + + @ParameterizedTest + @ValueSource(strings = { MessageDigestAlgorithms.SHA_1, MessageDigestAlgorithms.SHA_256 }) + void testNativeBlobTestSkipsWithoutSymlinkPrivileges(final String algorithm) throws IOException { + try (TestFileSystem fileSystem = new TestFileSystem(null, false)) { + fileSystem.provider.linkCreationFailure = new AccessDeniedException("probe"); + assertThrows(TestAbortedException.class, + () -> new GitIdentifiersTest().testBlobIdSymlink(algorithm, "subdir/file.txt", false, fileSystem.getPath("root"))); + assertEquals(0, fileSystem.provider.linksCreated); + } + } + + @ParameterizedTest + @MethodSource("org.apache.commons.codec.digest.GitIdentifiersTest#virtualTreeProvider") + void testNativeUnixTreeSkipsWithoutPosix(final String algorithm, final byte[] helloId, final byte[] linkId, final byte[] linkTxtId, + final byte[] runId, final byte[] srcTreeId, final byte[] mainTreeId) throws IOException { + try (TestFileSystem fileSystem = new TestFileSystem(null, false)) { + assertThrows(TestAbortedException.class, () -> new GitIdentifiersTest().testTreeIdPathUnix(algorithm, helloId, linkId, linkTxtId, + runId, srcTreeId, mainTreeId, fileSystem.getPath("root"))); + assertEquals(0, fileSystem.provider.linksCreated, "The POSIX requirement must be checked before creating symbolic links"); + } + } + + @ParameterizedTest + @MethodSource("org.apache.commons.codec.digest.GitIdentifiersTest#virtualTreeProvider") + void testNativeUnixTreeSkipsWithoutSymlinkPrivileges(final String algorithm, final byte[] helloId, final byte[] linkId, final byte[] linkTxtId, + final byte[] runId, final byte[] srcTreeId, final byte[] mainTreeId) throws IOException { + try (TestFileSystem fileSystem = new TestFileSystem("rw-------", false)) { + fileSystem.provider.linkCreationFailure = new FileSystemException("probe", "target", "A required privilege is not held"); + assertThrows(TestAbortedException.class, () -> new GitIdentifiersTest().testTreeIdPathUnix(algorithm, helloId, linkId, linkTxtId, + runId, srcTreeId, mainTreeId, fileSystem.getPath("root"))); + assertEquals(0, fileSystem.provider.linksCreated); + } + } + + @ParameterizedTest + @ValueSource(booleans = { false, true }) + void testPosixCapabilityAssumption(final boolean posix) throws IOException { + try (TestFileSystem fileSystem = new TestFileSystem(posix ? "rw-------" : null, false)) { + final Path directory = fileSystem.getPath("root"); + if (posix) { + assertDoesNotThrow(() -> GitIdentifiersTest.assumePosixAttributes(directory)); + } else { + assertThrows(TestAbortedException.class, () -> GitIdentifiersTest.assumePosixAttributes(directory)); + } + assertEquals(0, fileSystem.provider.linksCreated); + } + } + + @ParameterizedTest(name = "{0}, permissions={1}, access={2}, target={3}") + @MethodSource("symbolicLinks") + void testSymbolicLinksWithoutHostSupport(final String algorithm, final String permissions, final boolean executable, final String target) + throws IOException { + try (TestFileSystem fileSystem = new TestFileSystem(permissions, executable, target)) { + final MessageDigest md = DigestUtils.getDigest(algorithm); + final Path link = fileSystem.getPath("file.txt"); + final byte[] expectedBlob = GitIdentifiers.blobId(md, target.getBytes(StandardCharsets.UTF_8)); + assertArrayEquals(expectedBlob, GitIdentifiers.blobId(md, link)); + final GitIdentifiers.TreeIdBuilder builder = GitIdentifiers.treeIdBuilder(md); + builder.addSymbolicLink("file.txt", target); + assertArrayEquals(builder.get(), GitIdentifiers.treeId(md, fileSystem.getPath("root"))); + } + } + + @ParameterizedTest + @ValueSource(booleans = { false, true }) + void testSymlinkProbeDoesNotHideCleanupFailures(final boolean posix) throws IOException { + for (final Exception failure : new Exception[] { new IOException("cleanup failed"), new AccessDeniedException("probe"), + new UnsupportedOperationException("cleanup unsupported"), new IllegalStateException("unexpected cleanup failure") }) { + try (TestFileSystem fileSystem = new TestFileSystem(posix ? "rw-------" : null, false)) { + fileSystem.provider.deletionFailure = failure; + assertSame(failure, assertThrows(failure.getClass(), () -> GitIdentifiersTest.assumeSymbolicLinks(fileSystem.getPath("root")))); + assertEquals(1, fileSystem.provider.linksCreated); + assertEquals(0, fileSystem.provider.linksDeleted); + } + } + } + + @ParameterizedTest + @ValueSource(booleans = { false, true }) + void testSymlinkProbeDoesNotHideInvalidFixtures(final boolean posix) throws IOException { + for (final Exception failure : new Exception[] { new FileAlreadyExistsException("probe"), new NoSuchFileException("directory"), + new NotDirectoryException("directory"), new IllegalArgumentException("invalid target"), new IllegalStateException("broken provider") }) { + try (TestFileSystem fileSystem = new TestFileSystem(posix ? "rw-------" : null, false)) { + fileSystem.provider.linkCreationFailure = failure; + assertSame(failure, assertThrows(failure.getClass(), () -> GitIdentifiersTest.assumeSymbolicLinks(fileSystem.getPath("root")))); + assertEquals(0, fileSystem.provider.linksCreated); + assertEquals(0, fileSystem.provider.linksDeleted); + } + } + } + + @ParameterizedTest + @ValueSource(booleans = { false, true }) + void testSymlinkProbeSkipsUnavailableCapabilities(final boolean posix) throws IOException { + for (final Exception failure : new Exception[] { new UnsupportedOperationException("links unsupported"), new IOException("links unavailable"), + new AccessDeniedException("probe"), new FileSystemException("probe", "target", "A required privilege is not held"), + new SecurityException("link permission denied") }) { + try (TestFileSystem fileSystem = new TestFileSystem(posix ? "rw-------" : null, false)) { + fileSystem.provider.linkCreationFailure = failure; + final TestAbortedException aborted = assertThrows(TestAbortedException.class, + () -> GitIdentifiersTest.assumeSymbolicLinks(fileSystem.getPath("root"))); + assertTrue(aborted.getMessage().contains(failure.toString())); + assertEquals(0, fileSystem.provider.linksCreated); + assertEquals(0, fileSystem.provider.linksDeleted); + } + } + } + + @ParameterizedTest + @ValueSource(booleans = { false, true }) + void testSymlinkProbeSucceedsAndCleansUp(final boolean posix) throws IOException { + try (TestFileSystem fileSystem = new TestFileSystem(posix ? "rw-------" : null, false)) { + GitIdentifiersTest.assumeSymbolicLinks(fileSystem.getPath("root")); + assertEquals(1, fileSystem.provider.linksCreated); + assertEquals(1, fileSystem.provider.linksDeleted); + } + } + /** * Execution access without POSIX attributes must not turn an ordinary file into an executable Git entry. */ - @ParameterizedTest - @ValueSource(booleans = { false, true }) - void testTreeIdWithoutPosixPermissions(final boolean executable) throws IOException { + @ParameterizedTest(name = "{0}, access={1}") + @MethodSource("basicFileModes") + void testTreeIdWithoutPosixPermissions(final String algorithm, final boolean executable) throws IOException { try (TestFileSystem fileSystem = new TestFileSystem(null, executable)) { final Path file = fileSystem.getPath("file.txt"); assertNull(Files.getFileAttributeView(file, PosixFileAttributeView.class)); assertEquals(executable, Files.isExecutable(file)); - assertTreeId(fileSystem, GitIdentifiers.FileMode.REGULAR); + assertTreeId(fileSystem, algorithm, GitIdentifiers.FileMode.REGULAR); } } /** - * Only the owner-execute bit determines the Git mode, even when group permissions or an ACL give the current process different execution access. + * Checks all 512 POSIX permission combinations independently of process execution access, using both Git hash algorithms. */ - @ParameterizedTest - @CsvSource({ - "rw-------, false, REGULAR", - "rw-------, true, REGULAR", - "rw-r-xr--, true, REGULAR", - "rw-r--r-x, true, REGULAR", - "rwx------, false, EXECUTABLE", - "rwx------, true, EXECUTABLE" - }) - void testTreeIdWithPosixPermissions(final String permissions, final boolean executable, final GitIdentifiers.FileMode mode) throws IOException { + @ParameterizedTest(name = "{0}, permissions={1}, access={2}, mode={3}") + @MethodSource("posixFileModes") + void testTreeIdWithPosixPermissions(final String algorithm, final String permissions, final boolean executable, final GitIdentifiers.FileMode mode) + throws IOException { try (TestFileSystem fileSystem = new TestFileSystem(permissions, executable)) { final Path file = fileSystem.getPath("file.txt"); assertEquals(PosixFilePermissions.fromString(permissions), Files.getPosixFilePermissions(file)); assertEquals(executable, Files.isExecutable(file)); - assertTreeId(fileSystem, mode); + assertTreeId(fileSystem, algorithm, mode); + } + } + + @ParameterizedTest + @ValueSource(strings = { MessageDigestAlgorithms.SHA_1, MessageDigestAlgorithms.SHA_256 }) + void testZipFileSystemKeepsRegularFileCoverage(final String algorithm, @TempDir final Path tempDir) throws IOException { + Assumptions.assumeTrue(FileSystemProvider.installedProviders().stream().anyMatch(provider -> "jar".equals(provider.getScheme())), + "ZIP filesystem provider is unavailable"); + final URI uri = URI.create("jar:" + tempDir.resolve("tree.zip").toUri()); + try (FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.singletonMap("create", "true"))) { + final Path root = fileSystem.getPath("/"); + Files.write(root.resolve("file.txt"), CONTENT); + assertThrows(TestAbortedException.class, () -> GitIdentifiersTest.assumePosixAttributes(root)); + assertThrows(TestAbortedException.class, () -> GitIdentifiersTest.assumeSymbolicLinks(root)); + final MessageDigest digest = DigestUtils.getDigest(algorithm); + final GitIdentifiers.TreeIdBuilder builder = GitIdentifiers.treeIdBuilder(digest); + builder.addFile(GitIdentifiers.FileMode.REGULAR, "file.txt", CONTENT); + assertArrayEquals(builder.get(), GitIdentifiers.treeId(digest, root)); } } } diff --git a/src/test/java/org/apache/commons/codec/digest/GitIdentifiersTest.java b/src/test/java/org/apache/commons/codec/digest/GitIdentifiersTest.java index 17c98ba2fa..8adb9f4fdd 100644 --- a/src/test/java/org/apache/commons/codec/digest/GitIdentifiersTest.java +++ b/src/test/java/org/apache/commons/codec/digest/GitIdentifiersTest.java @@ -26,9 +26,13 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.nio.file.FileAlreadyExistsException; import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.NotDirectoryException; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.attribute.PosixFileAttributeView; import java.nio.file.attribute.PosixFilePermissions; import java.security.MessageDigest; import java.util.ArrayList; @@ -130,6 +134,25 @@ class GitIdentifiersTest { */ private static final byte[] MAIN_TREE_ID_SHA256 = hex("58e9a59940e4d2ae7e374b63fedf3b7bba8cfdc60308f64abd066db137300bcd"); + static void assumePosixAttributes(final Path directory) { + Assumptions.assumeTrue(Files.getFileAttributeView(directory, PosixFileAttributeView.class) != null, + "POSIX file attributes are not supported on this filesystem"); + } + + static void assumeSymbolicLinks(final Path directory) throws IOException { + final Path probe = directory.resolve("symlink-capability-probe"); + final Path target = directory.getFileSystem().getPath("symlink-capability-target"); + try { + Files.createSymbolicLink(probe, target); + } catch (final FileAlreadyExistsException | NoSuchFileException | NotDirectoryException e) { + throw e; + } catch (final IOException | UnsupportedOperationException | SecurityException e) { + Assumptions.abort("Symbolic link creation is unavailable: " + e); + } + // A cleanup failure is a test failure, not evidence that symbolic links are unsupported. + Files.delete(probe); + } + static Stream blobIdProvider() { return Stream.of(Arguments.of("DigestUtilsTest/hello.txt", "5f4a83288e67f1be2d6fcdad84165a86c6a970d7"), Arguments.of("DigestUtilsTest/greetings.txt", "6cf4f797455661e61d1ee6913fc29344f5897243"), @@ -149,6 +172,12 @@ private static Path resourcePath(final String resourceName) throws Exception { return Paths.get(GitIdentifiersTest.class.getClassLoader().getResource(resourceName).toURI()); } + static Stream symlinkProvider() { + return Stream.of(MessageDigestAlgorithms.SHA_1, MessageDigestAlgorithms.SHA_256).flatMap(algorithm -> + Stream.of("subdir", "subdir/file.txt", "subdir/missing.txt").flatMap(target -> + Stream.of(false, true).map(absolute -> Arguments.of(algorithm, target, absolute)))); + } + static Stream virtualTreeProvider() { return Stream.of( Arguments.of(MessageDigestAlgorithms.SHA_1, HELLO_BLOB_ID_SHA1, LINK_BLOB_ID_SHA1, LINK_TXT_BLOB_ID_SHA1, RUN_BLOB_ID_SHA1, @@ -190,19 +219,19 @@ void testBlobIdPath(final String resourceName, final String expectedSha1Hex) thr assertArrayEquals(Hex.decodeHex(expectedSha1Hex), GitIdentifiers.blobId(DigestUtils.getSha1Digest(), resourcePath(resourceName))); } - @Test - void testBlobIdSymlink(@TempDir final Path tempDir) throws Exception { + @ParameterizedTest + @MethodSource("symlinkProvider") + void testBlobIdSymlink(final String algorithm, final String targetName, final boolean absolute, @TempDir final Path tempDir) throws Exception { + assumeSymbolicLinks(tempDir); final Path subDir = Files.createDirectory(tempDir.resolve("subdir")); Files.write(subDir.resolve("file.txt"), "hello".getBytes(StandardCharsets.UTF_8)); - try { - final Path linkToDir = Files.createSymbolicLink(tempDir.resolve("link-to-dir"), Paths.get("subdir")); - final Path linkToFile = Files.createSymbolicLink(tempDir.resolve("link-to-file"), Paths.get("subdir/file.txt")); - final MessageDigest sha1 = DigestUtils.getSha1Digest(); - assertArrayEquals(Hex.decodeHex("8bbe8a53790056316b23b7c270f10ab6bf6bb1b4"), GitIdentifiers.blobId(sha1, linkToDir)); - assertArrayEquals(Hex.decodeHex("dfe6ef8392ae13a11ff85419b4fd906d997b6cb7"), GitIdentifiers.blobId(sha1, linkToFile)); - } catch (final UnsupportedOperationException e) { - Assumptions.abort("Symbolic links not supported on this filesystem"); - } + final Path relativeTarget = tempDir.getFileSystem().getPath(targetName); + final Path target = absolute ? tempDir.resolve(relativeTarget) : relativeTarget; + final Path link = Files.createSymbolicLink(tempDir.resolve("link"), target); + final MessageDigest digest = DigestUtils.getDigest(algorithm); + // Path.toString() uses the filesystem's separators, including backslashes on Windows. + assertEquals(target.toString(), Files.readSymbolicLink(link).toString()); + assertArrayEquals(GitIdentifiers.blobId(digest, target.toString().getBytes(StandardCharsets.UTF_8)), GitIdentifiers.blobId(digest, link)); } @Test @@ -417,6 +446,8 @@ void testTreeIdPathRecordsFilesWithoutPosixExecutableBitAsRegular(final @TempDir @MethodSource("virtualTreeProvider") void testTreeIdPathUnix(final String algorithm, final byte[] helloId, final byte[] linkId, final byte[] linkTxtId, final byte[] runId, final byte[] srcTreeId, final byte[] mainTreeId, final @TempDir Path tempDir) throws Exception { + assumePosixAttributes(tempDir); + assumeSymbolicLinks(tempDir); final MessageDigest md = DigestUtils.getDigest(algorithm); // Files @@ -426,17 +457,14 @@ void testTreeIdPathUnix(final String algorithm, final byte[] helloId, final byte final Path hello = src.resolve("hello.txt"); final Path run = src.resolve("run.sh"); - // Create the same structure as the virtual tree. - try { - Files.createSymbolicLink(link, Paths.get(LINK_CONTENT)); - Files.createSymbolicLink(linkTxt, Paths.get(LINK_TXT_CONTENT)); - } catch (final UnsupportedOperationException e) { - Assumptions.abort("Symbolic links not supported on this filesystem"); - } + // Create the same structure as the virtual tree after checking the required capabilities. Files.createDirectory(src); Files.write(hello, HELLO_CONTENT); Files.write(run, RUN_CONTENT); + Files.setPosixFilePermissions(hello, PosixFilePermissions.fromString("rw-r--r--")); Files.setPosixFilePermissions(run, PosixFilePermissions.fromString("rwxr-xr-x")); + Files.createSymbolicLink(link, tempDir.getFileSystem().getPath(LINK_CONTENT)); + Files.createSymbolicLink(linkTxt, tempDir.getFileSystem().getPath(LINK_TXT_CONTENT)); // Verify individual blob IDs against pre-computed constants. assertArrayEquals(helloId, GitIdentifiers.blobId(md, hello)); From ac8ae40d2813eb8b57dd62c717ccf9e4f64ce720 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Sat, 21 Nov 2026 16:07:32 -0500 Subject: [PATCH 2/2] Run Maven CI on Ubuntu, Windows, and macOS Match Commons IO's operating-system matrix for all configured JDKs, including experimental builds. Use Zulu for Java 8 on macOS. --- .gitattributes | 4 + .github/workflows/maven.yml | 17 +- src/main/javadoc/overview.html | 8 +- .../commons/codec/digest/Crc16Test.java | 6 +- .../commons/codec/digest/DigestUtilsTest.java | 55 ++--- src/test/resources/Crc16Test/license.txt | 202 ++++++++++++++++++ 6 files changed, 255 insertions(+), 37 deletions(-) create mode 100644 src/test/resources/Crc16Test/license.txt diff --git a/.gitattributes b/.gitattributes index f42866e4bd..01021547fb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14,3 +14,7 @@ # limitations under the License. * text=auto + +# Preserve bytes used by fixed checksum and Git object ID test vectors. +/src/test/resources/Crc16Test/license.txt text eol=lf +/src/test/resources/DigestUtilsTest/**/*.txt text eol=lf diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 764408548d..9a44e4bfd3 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -27,17 +27,26 @@ permissions: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} continue-on-error: ${{ matrix.experimental }} strategy: + fail-fast: false max-parallel: 20 matrix: + os: [ubuntu-latest, windows-latest, macos-latest] java: [ 8, 11, 17, 21, 25, 27 ] experimental: [false] include: - - java: 28-ea + - os: ubuntu-latest + java: 28-ea experimental: true - + - os: windows-latest + java: 28-ea + experimental: true + - os: macos-latest + java: 28-ea + experimental: true + steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -51,7 +60,7 @@ jobs: - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0 with: - distribution: 'temurin' + distribution: ${{ runner.os == 'macOS' && matrix.java == '8' && 'zulu' || 'temurin' }} java-version: ${{ matrix.java }} - name: Build with Maven run: mvn --errors --show-version --batch-mode --no-transfer-progress diff --git a/src/main/javadoc/overview.html b/src/main/javadoc/overview.html index 47d10ab899..b8a4b12e17 100644 --- a/src/main/javadoc/overview.html +++ b/src/main/javadoc/overview.html @@ -90,12 +90,12 @@

Blake3 Provides a pure Java implementation of the Blake3 hash function which can be used for computing cryptographic hashes (message digests) which are extensible to - arbitrary output lengths (known as an extensible-output function or XOF), computing message authentication codes using a 32 byte (256-bit) secret key, computing + arbitrary output lengths (known as an extensible-output function or XOF), computing + message authentication codes using a 32 byte (256-bit) secret key, computing subkeys from a primary key using a key derivation function, and can be used as the basis for a cryptographically-secure pseudorandom - number generator. WARNING: Blake3 is not a password hashing algorithm! An algorithm such as Argon2 is more appropriate for password hashing. + number generator. WARNING: Blake3 is not a password hashing algorithm! An algorithm such as + Argon2 is more appropriate for password hashing. diff --git a/src/test/java/org/apache/commons/codec/digest/Crc16Test.java b/src/test/java/org/apache/commons/codec/digest/Crc16Test.java index 2097199735..7eec1f1d4c 100644 --- a/src/test/java/org/apache/commons/codec/digest/Crc16Test.java +++ b/src/test/java/org/apache/commons/codec/digest/Crc16Test.java @@ -22,12 +22,11 @@ import static org.junit.jupiter.api.Assertions.assertNotSame; import java.nio.charset.StandardCharsets; -import java.nio.file.Paths; import java.util.function.Supplier; import java.util.zip.Checksum; import org.apache.commons.codec.binary.StringUtils; -import org.apache.commons.io.file.PathUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.io.function.Uncheck; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -38,7 +37,8 @@ */ class Crc16Test { - private static final String BIG_TEXT = Uncheck.get(() -> PathUtils.readString(Paths.get("LICENSE.txt"), StandardCharsets.US_ASCII)); + private static final String BIG_TEXT = Uncheck.get(() -> IOUtils.resourceToString("Crc16Test/license.txt", + StandardCharsets.US_ASCII, Crc16Test.class.getClassLoader())); private static final byte[] TEST_BYTES = "123456789".getBytes(StandardCharsets.US_ASCII); private static final int TEST_BYTES_LEN = TEST_BYTES.length; diff --git a/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java index 72c83a161b..371bed6c35 100644 --- a/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java +++ b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java @@ -43,9 +43,7 @@ import org.apache.commons.codec.binary.Hex; import org.apache.commons.io.RandomAccessFileMode; -import org.apache.commons.lang3.JavaVersion; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.SystemUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -377,10 +375,6 @@ RandomAccessFile getTestRandomAccessFile() { return testRandomAccessFileWrapper; } - private boolean isJava9Plus() { - return SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9); - } - @BeforeEach void setUp() throws Exception { new Random().nextBytes(testData); @@ -439,27 +433,36 @@ void testGetDigests() { } @Test - void testGetDigestsJava9() { - if (isJava9Plus()) { + void testGetMessageDigest() { + final DigestUtils digestUtils = new DigestUtils(MessageDigestAlgorithms.MD5); + assertNotNull(digestUtils.getMessageDigest()); + assertEquals(MessageDigestAlgorithms.MD5, digestUtils.getMessageDigest().getAlgorithm()); + } + + @Test + void testGetSha3Digests() { + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_224)) { assertEquals("SHA3-224", DigestUtils.getSha3_224Digest().getAlgorithm()); - assertEquals("SHA3-256", DigestUtils.getSha3_256Digest().getAlgorithm()); - assertEquals("SHA3-384", DigestUtils.getSha3_384Digest().getAlgorithm()); - assertEquals("SHA3-512", DigestUtils.getSha3_512Digest().getAlgorithm()); } else { assertThrows(IllegalArgumentException.class, DigestUtils::getSha3_224Digest); + } + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_256)) { + assertEquals("SHA3-256", DigestUtils.getSha3_256Digest().getAlgorithm()); + } else { assertThrows(IllegalArgumentException.class, DigestUtils::getSha3_256Digest); + } + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_384)) { + assertEquals("SHA3-384", DigestUtils.getSha3_384Digest().getAlgorithm()); + } else { assertThrows(IllegalArgumentException.class, DigestUtils::getSha3_384Digest); + } + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_512)) { + assertEquals("SHA3-512", DigestUtils.getSha3_512Digest().getAlgorithm()); + } else { assertThrows(IllegalArgumentException.class, DigestUtils::getSha3_512Digest); } } - @Test - void testGetMessageDigest() { - final DigestUtils digestUtils = new DigestUtils(MessageDigestAlgorithms.MD5); - assertNotNull(digestUtils.getMessageDigest()); - assertEquals(MessageDigestAlgorithms.MD5, digestUtils.getMessageDigest().getAlgorithm()); - } - /** * Tests SHAKE digest lookup according to runtime algorithm availability. * @@ -694,7 +697,7 @@ void testSha256HexInputStream() throws IOException { @Test void testSha3_224() { - if (isJava9Plus()) { + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_224)) { // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values // // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-224_Msg0.pdf @@ -706,7 +709,7 @@ void testSha3_224() { @Test void testSha3_224HexInputStream() throws IOException { - if (isJava9Plus()) { + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_224)) { assertEquals(DigestUtils.sha3_224Hex(testData), DigestUtils.sha3_224Hex(new ByteArrayInputStream(testData))); } else { assertThrows(IllegalArgumentException.class, () -> DigestUtils.sha3_224Hex(new ByteArrayInputStream(testData))); @@ -715,7 +718,7 @@ void testSha3_224HexInputStream() throws IOException { @Test void testSha3_256() { - if (isJava9Plus()) { + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_256)) { // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values // // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-256_Msg0.pdf @@ -727,7 +730,7 @@ void testSha3_256() { @Test void testSha3_256HexInputStream() throws IOException { - if (isJava9Plus()) { + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_256)) { assertEquals(DigestUtils.sha3_256Hex(testData), DigestUtils.sha3_256Hex(new ByteArrayInputStream(testData))); } else { assertThrows(IllegalArgumentException.class, () -> DigestUtils.sha3_256Hex(new ByteArrayInputStream(testData))); @@ -736,7 +739,7 @@ void testSha3_256HexInputStream() throws IOException { @Test void testSha3_384() { - if (isJava9Plus()) { + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_384)) { // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values // // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-384_Msg0.pdf @@ -749,7 +752,7 @@ void testSha3_384() { @Test void testSha3_384HexInputStream() throws IOException { - if (isJava9Plus()) { + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_384)) { assertEquals(DigestUtils.sha3_384Hex(testData), DigestUtils.sha3_384Hex(new ByteArrayInputStream(testData))); } else { assertThrows(IllegalArgumentException.class, () -> DigestUtils.sha3_384Hex(new ByteArrayInputStream(testData))); @@ -758,7 +761,7 @@ void testSha3_384HexInputStream() throws IOException { @Test void testSha3_512() { - if (isJava9Plus()) { + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_512)) { // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values // // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-512_Msg0.pdf @@ -771,7 +774,7 @@ void testSha3_512() { @Test void testSha3_512HexInputStream() throws IOException { - if (isJava9Plus()) { + if (DigestUtils.isAvailable(MessageDigestAlgorithms.SHA3_512)) { assertEquals(DigestUtils.sha3_512Hex(testData), DigestUtils.sha3_512Hex(new ByteArrayInputStream(testData))); } else { assertThrows(IllegalArgumentException.class, () -> DigestUtils.sha3_512Hex(new ByteArrayInputStream(testData))); diff --git a/src/test/resources/Crc16Test/license.txt b/src/test/resources/Crc16Test/license.txt new file mode 100644 index 0000000000..ff9ad4530f --- /dev/null +++ b/src/test/resources/Crc16Test/license.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License.