Skip to content

Commit 4e7e048

Browse files
committed
feat: enable etag tests in t0116
1 parent f5cace9 commit 4e7e048

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

tests/t0116_gateway_cache_test.go

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ func TestGatewayCache(t *testing.T) {
1515
// https://specs.ipfs.tech/http-gateways/path-gateway/#get-ipns-name-path-params
1616
// var ipnsId string
1717

18-
// TODO: Add request chaining support to the test framework and enable the etag tests
1918
// https://specs.ipfs.tech/http-gateways/path-gateway/#etag-response-header
20-
// var etag string
19+
var etag string
2120

2221
tests := SugarTests{
2322
{
@@ -285,29 +284,46 @@ func TestGatewayCache(t *testing.T) {
285284
Status(304),
286285
},
287286
*/
288-
// The tests below require `etag` to be set.
289-
/*
290287
{
288+
Name: "GET for /ipfs/ dir listing responds with Etag",
289+
Request: Request().
290+
Path("ipfs/%s/root2/root3/", fixture.MustGetCid()),
291+
Response: Expect().
292+
Status(200).
293+
Headers(
294+
Header("Etag").
295+
Checks(func (v string) bool {
296+
etag = v
297+
return v != ""
298+
}),
299+
),
300+
},
301+
{
302+
// DependsOn: "GET for /ipfs/ dir listing responds with Etag"
291303
Name: "GET for /ipfs/ dir listing with matching strong Etag in If-None-Match returns 304 Not Modified",
292304
Request: Request().
293305
Path("ipfs/%s/root2/root3/", fixture.MustGetCid()).
294306
Headers(
295-
Header("If-None-Match", fmt.Sprintf("\"%s\"", etag)),
307+
Header("If-None-Match").
308+
ValueFrom(&etag),
296309
),
297310
Response: Expect().
298311
Status(304),
299312
},
300313
{
314+
// DependsOn: "GET for /ipfs/ dir listing responds with Etag"
301315
Name: "GET for /ipfs/ dir listing with matching strong Etag in If-None-Match returns 304 Not Modified",
302316
Request: Request().
303317
Path("ipfs/%s/root2/root3/", fixture.MustGetCid()).
304318
Headers(
305-
Header("If-None-Match", fmt.Sprintf("W/\"%s\"", etag)),
319+
Header("If-None-Match").
320+
ValueFromFunc(func () string {
321+
return fmt.Sprintf("W/%s", etag)
322+
}),
306323
),
307324
Response: Expect().
308325
Status(304),
309326
},
310-
*/
311327
}
312328

313329
Run(t, tests)

0 commit comments

Comments
 (0)