Skip to content

Commit

Permalink
test: use car fixtures in sharness t0124
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta committed Feb 24, 2023
1 parent 8e636e6 commit 1478aa1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
16 changes: 11 additions & 5 deletions test/sharness/t0124-gateway-ipns-record.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ test_description="Test HTTP Gateway IPNS Record (application/vnd.ipfs.ipns-recor
test_init_ipfs
test_launch_ipfs_daemon

# Import test case
# See the static fixtures in ./t0124-gateway-ipns-record/
IPNS_KEY=k51qzi5uqu5djucgtwlxrbfiyfez1nb0ct58q5s4owg6se02evza05dfgi6tw5
FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS
test_expect_success "Add the test directory & IPNS records" '
ipfs dag import ../t0124-gateway-ipns-record/fixtures.car &&
ipfs routing put /ipns/${IPNS_KEY} ../t0124-gateway-ipns-record/${IPNS_KEY}.ipns-record
'

test_expect_success "Create and Publish IPNS Key" '
FILE_CID=$(echo "Hello IPFS" | ipfs add --cid-version 1 -q) &&
IPNS_KEY=$(ipfs key gen ipns-record) &&
ipfs name publish /ipfs/$FILE_CID --key=ipns-record --ttl=30m &&
curl "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY" > curl_output_filename &&
test_should_contain "Hello IPFS" curl_output_filename
'
Expand All @@ -31,14 +37,14 @@ test_expect_success "GET KEY with format=ipns-record has expected HTTP headers"
curl -sD - "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY?format=ipns-record" > curl_output_filename 2>&1 &&
test_should_contain "Content-Disposition: attachment;" curl_output_filename &&
test_should_contain "Content-Type: application/vnd.ipfs.ipns-record" curl_output_filename &&
test_should_contain "Cache-Control: public, max-age=1800" curl_output_filename
test_should_contain "Cache-Control: public, max-age=3155760000" curl_output_filename
'

test_expect_success "GET KEY with 'Accept: application/vnd.ipfs.ipns-record' has expected HTTP headers" '
curl -H "Accept: application/vnd.ipfs.ipns-record" -sD - "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY" > curl_output_filename 2>&1 &&
test_should_contain "Content-Disposition: attachment;" curl_output_filename &&
test_should_contain "Content-Type: application/vnd.ipfs.ipns-record" curl_output_filename &&
test_should_contain "Cache-Control: public, max-age=1800" curl_output_filename
test_should_contain "Cache-Control: public, max-age=3155760000" curl_output_filename
'

test_expect_success "GET KEY with expliciy ?filename= succeeds with modified Content-Disposition header" '
Expand Down
27 changes: 27 additions & 0 deletions test/sharness/t0124-gateway-ipns-record/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Dataset description/sources

- fixtures.car
- raw CARv1

- record.json
- ipns record as naive json

generated with:

```sh
# ipfs version 0.18.1
FILE_CID=$(echo "Hello IPFS" | ipfs add --cid-version 1 -q)
IPNS_KEY=$(ipfs key gen ipns-record)

ipfs dag export ${FILE_CID} > fixtures.car

# publish a key valid for a 100 years
ipfs name publish --key=ipns-record --quieter --ttl=876600h /ipfs/${FILE_CID}
ipfs routing get /ipns/${IPNS_KEY} > ${IPNS_KEY}.ipns-record

echo IPNS_KEY=${IPNS_KEY}
echo FILE_CID=${FILE_CID} # A file containing "Hello IPFS"

# IPNS_KEY=k51qzi5uqu5djucgtwlxrbfiyfez1nb0ct58q5s4owg6se02evza05dfgi6tw5
# FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS
```
Binary file added test/sharness/t0124-gateway-ipns-record/fixtures.car
Binary file not shown.
Binary file not shown.

0 comments on commit 1478aa1

Please sign in to comment.