21
21
import static org .junit .jupiter .api .Assertions .assertThrows ;
22
22
import static org .junit .jupiter .api .Assertions .assertTrue ;
23
23
24
- import com .google .api .client .http .HttpRequestFactory ;
25
- import dev .sigstore .http .HttpClients ;
26
- import dev .sigstore .http .HttpParams ;
27
- import dev .sigstore .http .ImmutableHttpParams ;
28
- import java .net .URI ;
29
24
import java .nio .charset .StandardCharsets ;
30
25
import java .security .MessageDigest ;
31
26
import okhttp3 .mockwebserver .MockResponse ;
36
31
import org .junit .jupiter .api .Test ;
37
32
38
33
public class TimestampClientHttpTest {
39
- private static HttpRequestFactory requestFactory ;
40
- private static HttpParams httpParams ;
41
34
private static TimestampRequest tsReq ;
42
35
43
36
private static final byte [] INVALID_TS_RESP_BYTES = new byte [14 ];
44
- private static final URI SIGSTORE_TSA_URI =
45
- URI .create ("https://timestamp.sigstage.dev/api/v1/timestamp" );
46
37
47
38
@ BeforeAll
48
39
public static void setup () throws Exception {
49
- httpParams = ImmutableHttpParams .builder ().build ();
50
- requestFactory = HttpClients .newRequestFactory (httpParams );
51
-
52
40
var digest = MessageDigest .getInstance ("SHA-256" );
53
41
var artifactHashBytes = digest .digest ("test" .getBytes (StandardCharsets .UTF_8 ));
54
42
tsReq =
@@ -60,7 +48,7 @@ public static void setup() throws Exception {
60
48
61
49
@ Test
62
50
public void timestamp_success () throws Exception {
63
- var client = new TimestampClientHttp ( requestFactory , SIGSTORE_TSA_URI );
51
+ var client = TimestampClientHttp . builder (). build ( );
64
52
65
53
var tsResp = client .timestamp (tsReq );
66
54
@@ -92,7 +80,7 @@ public void timestamp_failure_badResponse_incorrectDigestLength() throws Excepti
92
80
.nonce (tsReq .getNonce ())
93
81
.build ();
94
82
95
- var client = new TimestampClientHttp ( requestFactory , SIGSTORE_TSA_URI );
83
+ var client = TimestampClientHttp . builder (). build ( );
96
84
97
85
var tse =
98
86
assertThrows (
@@ -112,7 +100,7 @@ public void timestamp_failure_badResponse_nonRetryableError() throws Exception {
112
100
server .start ();
113
101
114
102
var tsaUri = server .url ("/v1/timestamp/" ).uri ();
115
- var client = new TimestampClientHttp ( requestFactory , tsaUri );
103
+ var client = TimestampClientHttp . builder (). setUri ( tsaUri ). build ( );
116
104
117
105
var tse =
118
106
assertThrows (
@@ -134,7 +122,7 @@ public void timestamp_failure_badResponse_RetryableError() throws Exception {
134
122
server .start ();
135
123
136
124
var tsaUri = server .url ("/v1/timestamp/" ).uri ();
137
- var client = new TimestampClientHttp ( requestFactory , tsaUri );
125
+ var client = TimestampClientHttp . builder (). setUri ( tsaUri ). build ( );
138
126
139
127
var tse =
140
128
assertThrows (
@@ -156,7 +144,7 @@ public void timestamp_failure_invalidResponseFormat() throws Exception {
156
144
server .start ();
157
145
158
146
var tsaUri = server .url ("/v1/timestamp/" ).uri ();
159
- var client = new TimestampClientHttp ( requestFactory , tsaUri );
147
+ var client = TimestampClientHttp . builder (). setUri ( tsaUri ). build ( );
160
148
161
149
var tse =
162
150
assertThrows (
@@ -180,7 +168,7 @@ public void timestamp_failure_responseBodyReadError() throws Exception {
180
168
server .start ();
181
169
182
170
var tsaUri = server .url ("/v1/timestamp/" ).uri ();
183
- var client = new TimestampClientHttp ( requestFactory , tsaUri );
171
+ var client = TimestampClientHttp . builder (). setUri ( tsaUri ). build ( );
184
172
185
173
var tse =
186
174
assertThrows (
0 commit comments