|
16 | 16 | package dev.sigstore.tuf;
|
17 | 17 |
|
18 | 18 | import static dev.sigstore.json.GsonSupplier.GSON;
|
19 |
| -import static dev.sigstore.testkit.tuf.TestResources.UPDATER_REAL_TRUSTED_ROOT; |
20 | 19 | import static dev.sigstore.testkit.tuf.TestResources.UPDATER_SYNTHETIC_TRUSTED_ROOT;
|
21 | 20 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
22 | 21 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
27 | 26 |
|
28 | 27 | import com.google.common.collect.ImmutableList;
|
29 | 28 | import com.google.common.collect.ImmutableMap;
|
30 |
| -import com.google.common.hash.Hashing; |
31 | 29 | import com.google.common.io.Resources;
|
32 | 30 | import com.google.gson.JsonSyntaxException;
|
33 |
| -import dev.sigstore.encryption.signers.Verifier; |
34 |
| -import dev.sigstore.encryption.signers.Verifiers; |
35 | 31 | import dev.sigstore.testkit.tuf.TestResources;
|
| 32 | +import dev.sigstore.tuf.encryption.Verifier; |
| 33 | +import dev.sigstore.tuf.encryption.Verifiers; |
36 | 34 | import dev.sigstore.tuf.model.Hashes;
|
37 | 35 | import dev.sigstore.tuf.model.ImmutableKey;
|
38 | 36 | import dev.sigstore.tuf.model.ImmutableRootRole;
|
|
41 | 39 | import dev.sigstore.tuf.model.Role;
|
42 | 40 | import dev.sigstore.tuf.model.Root;
|
43 | 41 | import dev.sigstore.tuf.model.Signature;
|
44 |
| -import dev.sigstore.tuf.model.TargetMeta; |
45 | 42 | import dev.sigstore.tuf.model.Targets;
|
46 | 43 | import io.github.netmikey.logunit.api.LogCapturer;
|
47 | 44 | import java.io.File;
|
|
52 | 49 | import java.nio.file.Path;
|
53 | 50 | import java.security.InvalidKeyException;
|
54 | 51 | import java.security.NoSuchAlgorithmException;
|
55 |
| -import java.security.PublicKey; |
56 |
| -import java.security.SignatureException; |
57 | 52 | import java.security.spec.InvalidKeySpecException;
|
58 | 53 | import java.time.Clock;
|
59 | 54 | import java.time.Instant;
|
@@ -123,19 +118,6 @@ static void startRemoteResourceServer() throws Exception {
|
123 | 118 | System.out.println("TUF local server listening on: " + remoteUrl);
|
124 | 119 | }
|
125 | 120 |
|
126 |
| - @Test |
127 |
| - public void testRootUpdate_fromProdData() throws Exception { |
128 |
| - setupMirror( |
129 |
| - "real/prod", "1.root.json", "2.root.json", "3.root.json", "4.root.json", "5.root.json"); |
130 |
| - var updater = createTimeStaticUpdater(localStorePath, UPDATER_REAL_TRUSTED_ROOT); |
131 |
| - updater.updateRoot(); |
132 |
| - assertStoreContains("root.json"); |
133 |
| - Root oldRoot = TestResources.loadRoot(UPDATER_REAL_TRUSTED_ROOT); |
134 |
| - Root newRoot = TestResources.loadRoot(localStorePath.resolve("root.json")); |
135 |
| - assertRootVersionIncreased(oldRoot, newRoot); |
136 |
| - assertRootNotExpired(newRoot); |
137 |
| - } |
138 |
| - |
139 | 121 | @Test
|
140 | 122 | public void testRootUpdate_notEnoughSignatures()
|
141 | 123 | throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException {
|
@@ -603,50 +585,6 @@ public void testTargetsDownload_sha256Only() throws Exception {
|
603 | 585 | assertDoesNotThrow(updater::update);
|
604 | 586 | }
|
605 | 587 |
|
606 |
| - // End to end sanity test on the actual prod sigstore repo. |
607 |
| - @Test |
608 |
| - public void testUpdate_fromProdData() |
609 |
| - throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException { |
610 |
| - setupMirror( |
611 |
| - "real/prod", |
612 |
| - "1.root.json", |
613 |
| - "2.root.json", |
614 |
| - "3.root.json", |
615 |
| - "4.root.json", |
616 |
| - "5.root.json", |
617 |
| - "69.snapshot.json", |
618 |
| - "5.targets.json", |
619 |
| - "timestamp.json", |
620 |
| - "snapshot.json", |
621 |
| - "targets.json", |
622 |
| - "root.json", |
623 |
| - "targets/0ae7705e02db33e814329746a4a0e5603c5bdcd91c96d072158d71011a2695788866565a2fec0fe363eb72cbcaeda39e54c5fe8d416daf9f3101fdba4217ef35.rekor.pub", |
624 |
| - "targets/0f99f47dbc26c5f1e3cba0bfd9af4245a26e5cb735d6ef005792ec7e603f66fdb897de985973a6e50940ca7eff5e1849719e967b5ad2dac74a29115a41cf6f21.fulcio_intermediate_v1.crt.pem", |
625 |
| - "targets/4b20747d1afe2544238ad38cc0cc3010921b177d60ac743767e0ef675b915489bd01a36606c0ff83c06448622d7160f0d866c83d20f0c0f44653dcc3f9aa0bd4.ctfe.pub", |
626 |
| - "targets/308fd1d1d95d7f80aa33b837795251cc3e886792982275e062409e13e4e236ffc34d676682aa96fdc751414de99c864bf132dde71581fa651c6343905e3bf988.artifact.pub", |
627 |
| - "targets/0713252a7fd17f7f3ab12f88a64accf2eb14b8ad40ca711d7fe8b4ecba3b24db9e9dffadb997b196d3867b8f9ff217faf930d80e4dab4e235c7fc3f07be69224.fulcio.crt.pem", |
628 |
| - "targets/e83fa4f427b24ee7728637fad1b4aa45ebde2ba02751fa860694b1bb16059a490328f9985e51cc70e4d237545315a1bc866dc4fdeef2f6248d99cc7a6077bf85.ctfe_2022.pub", |
629 |
| - "targets/f2e33a6dc208cee1f51d33bbea675ab0f0ced269617497985f9a0680689ee7073e4b6f8fef64c91bda590d30c129b3070dddce824c05bc165ac9802f0705cab6.fulcio_v1.crt.pem"); |
630 |
| - var updater = createTimeStaticUpdater(localStorePath, UPDATER_REAL_TRUSTED_ROOT); |
631 |
| - updater.update(); |
632 |
| - |
633 |
| - Root oldRoot = TestResources.loadRoot(UPDATER_REAL_TRUSTED_ROOT); |
634 |
| - TrustedMetaStore metaStore = updater.getMetaStore(); |
635 |
| - TargetStore targetStore = updater.getTargetStore(); |
636 |
| - Root newRoot = metaStore.getRoot(); // should be present |
637 |
| - assertRootVersionIncreased(oldRoot, newRoot); |
638 |
| - Targets targets = metaStore.getTargets(); // should be present |
639 |
| - Map<String, TargetMeta.TargetData> targetsData = targets.getSignedMeta().getTargets(); |
640 |
| - for (String file : targetsData.keySet()) { |
641 |
| - TargetMeta.TargetData fileData = targetsData.get(file); |
642 |
| - byte[] fileBytes = targetStore.readTarget(file); |
643 |
| - assertNotNull(fileBytes, "each file from targets data should be present"); |
644 |
| - assertEquals(fileData.getLength(), fileBytes.length, "file length should match metadata"); |
645 |
| - assertEquals( |
646 |
| - fileData.getHashes().getSha512(), Hashing.sha512().hashBytes(fileBytes).toString()); |
647 |
| - } |
648 |
| - } |
649 |
| - |
650 | 588 | private static final byte[] TEST_HASH_VERIFYIER_BYTES =
|
651 | 589 | "testdata".getBytes(StandardCharsets.UTF_8);
|
652 | 590 | private static final String GOOD_256_HASH =
|
@@ -941,8 +879,8 @@ public void testUpdate_snapshotsAndTimestampHaveNoSizeAndNoHashesInMeta() throws
|
941 | 879 |
|
942 | 880 | @Test
|
943 | 881 | public void canCreateMultipleUpdaters() throws IOException {
|
944 |
| - createTimeStaticUpdater(localStorePath, UPDATER_REAL_TRUSTED_ROOT); |
945 |
| - createTimeStaticUpdater(localStorePath, UPDATER_REAL_TRUSTED_ROOT); |
| 882 | + createTimeStaticUpdater(localStorePath, UPDATER_SYNTHETIC_TRUSTED_ROOT); |
| 883 | + createTimeStaticUpdater(localStorePath, UPDATER_SYNTHETIC_TRUSTED_ROOT); |
946 | 884 | }
|
947 | 885 |
|
948 | 886 | static Key newKey(String keyContents) {
|
@@ -1027,43 +965,7 @@ static void shutdownRemoteResourceServer() throws Exception {
|
1027 | 965 | }
|
1028 | 966 |
|
1029 | 967 | public static final Verifiers.Supplier ALWAYS_VERIFIES =
|
1030 |
| - publicKey -> |
1031 |
| - new Verifier() { |
1032 |
| - @Override |
1033 |
| - public PublicKey getPublicKey() { |
1034 |
| - return null; |
1035 |
| - } |
1036 |
| - |
1037 |
| - @Override |
1038 |
| - public boolean verify(byte[] artifact, byte[] signature) |
1039 |
| - throws NoSuchAlgorithmException, InvalidKeyException, SignatureException { |
1040 |
| - return true; |
1041 |
| - } |
1042 |
| - |
1043 |
| - @Override |
1044 |
| - public boolean verifyDigest(byte[] artifactDigest, byte[] signature) |
1045 |
| - throws NoSuchAlgorithmException, InvalidKeyException, SignatureException { |
1046 |
| - return true; |
1047 |
| - } |
1048 |
| - }; |
| 968 | + (key) -> (Verifier) (artifactDigest, signature) -> true; |
1049 | 969 | public static final Verifiers.Supplier ALWAYS_FAILS =
|
1050 |
| - publicKey -> |
1051 |
| - new Verifier() { |
1052 |
| - @Override |
1053 |
| - public PublicKey getPublicKey() { |
1054 |
| - return null; |
1055 |
| - } |
1056 |
| - |
1057 |
| - @Override |
1058 |
| - public boolean verify(byte[] artifact, byte[] signature) |
1059 |
| - throws NoSuchAlgorithmException, InvalidKeyException, SignatureException { |
1060 |
| - return false; |
1061 |
| - } |
1062 |
| - |
1063 |
| - @Override |
1064 |
| - public boolean verifyDigest(byte[] artifactDigest, byte[] signature) |
1065 |
| - throws NoSuchAlgorithmException, InvalidKeyException, SignatureException { |
1066 |
| - return false; |
1067 |
| - } |
1068 |
| - }; |
| 970 | + (key) -> (Verifier) (artifactDigest, signature) -> false; |
1069 | 971 | }
|
0 commit comments