File tree Expand file tree Collapse file tree
main/java/land/oras/utils
test/java/land/oras/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434@ NullMarked
3535public enum SupportedAlgorithm {
3636
37+ /**
38+ * SHA-1
39+ * This is unsecure, only useful when computing digests for git content (like Flux CD)
40+ */
41+ SHA1 ("SHA-1" , "sha1" ),
42+
3743 /**
3844 * SHA-256
3945 */
Original file line number Diff line number Diff line change @@ -59,6 +59,9 @@ void shouldDigest() throws IOException {
5959 assertEquals (
6060 "sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" ,
6161 SupportedAlgorithm .SHA256 .digest (Files .newInputStream (file )));
62+ assertEquals (
63+ "sha1:aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d" ,
64+ SupportedAlgorithm .SHA1 .digest (Files .newInputStream (file )));
6265 }
6366
6467 @ Test
@@ -97,8 +100,9 @@ void shouldCheckSupport() {
97100 assertTrue (SupportedAlgorithm .isSupported (
98101 "blake3:0b8b60248fad7ac6dfac221b7e01a8b91c772421a15b387dd1fb2d6a94aee438" ));
99102
103+ assertTrue (SupportedAlgorithm .isSupported ("sha1:c22b5f9178342609428d6f51b2c5af4c0bde6a42" ));
104+
100105 // Not supported
101- assertFalse (SupportedAlgorithm .isSupported ("sha1:c22b5f9178342609428d6f51b2c5af4c0bde6a42" ));
102106 assertFalse (SupportedAlgorithm .isSupported ("latest" ));
103107 }
104108
@@ -126,6 +130,7 @@ void shouldCheckPattern() {
126130
127131 @ Test
128132 void shouldGetAlgorithmName () {
133+ assertEquals ("SHA-1" , SupportedAlgorithm .SHA1 .getAlgorithmName ());
129134 assertEquals ("SHA-256" , SupportedAlgorithm .SHA256 .getAlgorithmName ());
130135 assertEquals ("SHA-384" , SupportedAlgorithm .SHA384 .getAlgorithmName ());
131136 assertEquals ("SHA-512" , SupportedAlgorithm .SHA512 .getAlgorithmName ());
You can’t perform that action at this time.
0 commit comments