Remove some uses of MD5.
RELNOTES: None.
PiperOrigin-RevId: 274029065
diff --git a/src/test/java/com/google/devtools/build/lib/unix/NativePosixFilesTest.java b/src/test/java/com/google/devtools/build/lib/unix/NativePosixFilesTest.java
index 311864d..8b32295 100644
--- a/src/test/java/com/google/devtools/build/lib/unix/NativePosixFilesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/unix/NativePosixFilesTest.java
@@ -19,14 +19,10 @@
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.hash.HashCode;
import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.lib.util.OS;
import com.google.devtools.build.lib.vfs.DigestHashFunction;
-import com.google.devtools.build.lib.vfs.FileAccessException;
import com.google.devtools.build.lib.vfs.FileSystem;
-import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import java.io.File;
import java.io.FileNotFoundException;
@@ -51,50 +47,11 @@
testFile = workingDir.getRelative("test");
}
- /**
- * This test validates that the md5sum() method returns hashes that match the official test
- * vectors specified in RFC 1321, The MD5 Message-Digest Algorithm.
- *
- * @throws Exception
- */
- @Test
- public void testValidateMd5Sum() throws Exception {
- ImmutableMap<String, String> testVectors = ImmutableMap.<String, String>builder()
- .put("", "d41d8cd98f00b204e9800998ecf8427e")
- .put("a", "0cc175b9c0f1b6a831c399e269772661")
- .put("abc", "900150983cd24fb0d6963f7d28e17f72")
- .put("message digest", "f96b697d7cb7938d525a2f31aaf161d0")
- .put("abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b")
- .put("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- "d174ab98d277d9f5a5611c2c9f419d9f")
- .put(
- "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
- "57edf4a22be3c955ac49da2e2107b67a")
- .build();
-
- for (String testInput : testVectors.keySet()) {
- FileSystemUtils.writeContentAsLatin1(testFile, testInput);
- HashCode result = NativePosixFiles.md5sum(testFile.getPathString());
- assertThat(testVectors).containsEntry(testInput, result.toString());
- }
- }
-
- @Test
- public void throwsFileAccessException() throws Exception {
- FileSystemUtils.createEmptyFile(testFile);
- NativePosixFiles.chmod(testFile.getPathString(), 0200);
-
- FileAccessException e =
- assertThrows(
- FileAccessException.class, () -> NativePosixFiles.md5sum(testFile.getPathString()));
- assertThat(e).hasMessageThat().isEqualTo(testFile + " (Permission denied)");
- }
-
@Test
public void throwsFileNotFoundException() throws Exception {
FileNotFoundException e =
assertThrows(
- FileNotFoundException.class, () -> NativePosixFiles.md5sum(testFile.getPathString()));
+ FileNotFoundException.class, () -> NativePosixFiles.stat(testFile.getPathString()));
assertThat(e).hasMessageThat().isEqualTo(testFile + " (No such file or directory)");
}