17
17
18
18
import com .google .protobuf .util .JsonFormat ;
19
19
import dev .sigstore .proto .trustroot .v1 .TrustedRoot ;
20
+ import dev .sigstore .trustroot .SigstoreTrustedRoot ;
20
21
import java .io .IOException ;
21
22
import java .nio .charset .StandardCharsets ;
22
23
import java .nio .file .Path ;
@@ -38,23 +39,32 @@ public void testUpdate_publicGoodHasTrustedRootJson() throws Exception {
38
39
.tufCacheLocation (localStorePath )
39
40
.build ();
40
41
client .forceUpdate ();
41
- Assertions .assertNotNull (client .getSigstoreTrustedRoot ());
42
42
43
- Assertions .assertDoesNotThrow (() -> client .getSigstoreTrustedRoot ().getTLogs ().current ());
44
- Assertions .assertDoesNotThrow (() -> client .getSigstoreTrustedRoot ().getCTLogs ().current ());
45
- Assertions .assertDoesNotThrow (() -> client .getSigstoreTrustedRoot ().getCAs ().current ());
43
+ assertTrustedRootValid (client .getSigstoreTrustedRoot ());
46
44
}
47
45
48
46
@ Test
49
47
public void testUpdate_stagingHasTrustedRootJson () throws Exception {
50
48
var client =
51
49
SigstoreTufClient .builder ().useStagingInstance ().tufCacheLocation (localStorePath ).build ();
52
50
client .forceUpdate ();
53
- Assertions .assertNotNull (client .getSigstoreTrustedRoot ());
54
51
55
- Assertions .assertDoesNotThrow (() -> client .getSigstoreTrustedRoot ().getTLogs ().current ());
56
- Assertions .assertDoesNotThrow (() -> client .getSigstoreTrustedRoot ().getCTLogs ().current ());
57
- Assertions .assertDoesNotThrow (() -> client .getSigstoreTrustedRoot ().getCAs ().current ());
52
+ assertTrustedRootValid (client .getSigstoreTrustedRoot ());
53
+ }
54
+
55
+ private void assertTrustedRootValid (SigstoreTrustedRoot trustedRoot ) throws Exception {
56
+ Assertions .assertNotNull (trustedRoot );
57
+ Assertions .assertDoesNotThrow (() -> trustedRoot .getTLogs ().current ());
58
+ Assertions .assertDoesNotThrow (() -> trustedRoot .getCTLogs ().current ());
59
+ Assertions .assertDoesNotThrow (() -> trustedRoot .getCAs ().current ());
60
+
61
+ for (var tlog : trustedRoot .getTLogs ()) {
62
+ Assertions .assertDoesNotThrow (() -> tlog .getPublicKey ().toJavaPublicKey ());
63
+ }
64
+
65
+ for (var ctlog : trustedRoot .getCTLogs ()) {
66
+ Assertions .assertDoesNotThrow (() -> ctlog .getPublicKey ().toJavaPublicKey ());
67
+ }
58
68
}
59
69
60
70
@ Test
0 commit comments