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 21, 2023
1 parent a4086e6 commit beb8dc6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
18 changes: 15 additions & 3 deletions test/sharness/t0124-gateway-ipns-record.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ 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/
test_expect_success "Add the test directory & IPNS records" '
ipfs dag import ../t0124-gateway-ipns-record/fixtures.car
IPNS_KEY=`cat ../t0124-gateway-ipns-record/record.json | jq -r .key` &&
IPNS_PRIVATE_KEY=`cat ../t0124-gateway-ipns-record/record.json | jq -r .private_key` &&
IPNS_DEST=`cat ../t0124-gateway-ipns-record/record.json | jq -r .dest` &&
IPNS_TTL=`cat ../t0124-gateway-ipns-record/record.json | jq -r .ttl` &&
echo "${IPNS_PRIVATE_KEY}" | base64 -d | ipfs key import ipns-record - &&
ipfs name publish ${IPNS_DEST} --key=ipns-record --ttl=${IPNS_TTL}
'
FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS
IPNS_KEY=k51qzi5uqu5dhfm9ej3rvn9fiba5l5bpwz9ku153eog2fu9a73ggd7qwv21bgq # The record provider key

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 Down
32 changes: 32 additions & 0 deletions test/sharness/t0124-gateway-ipns-record/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Dataset description/sources

- fixtures.car
- raw CARv1

- record.json
- ipns record as naive json

generated with:

```sh
FILE_CID=$(echo "Hello IPFS" | ipfs add --cid-version 1 -q) &&
IPNS_KEY=$(ipfs key gen ipns-record) &&
IPNS_PRIVATE_KEY=$(ipfs key export ipns-record && cat ./ipns-record.key | base64 && rm ./ipns-record.key)

cat <<EOF > record.json
{
"key": "${IPNS_KEY}",
"private_key": "${IPNS_PRIVATE_KEY}",
"ttl": "30m",
"dest": "/ipfs/${FILE_CID}"
}
EOF

ipfs dag export ${FILE_CID} > fixtures.car

echo FILE_CID=${FILE_CID} # A file containing "Hello IPFS"
echo IPNS_KEY=${IPNS_KEY} # The record provider key

# FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS
# IPNS_KEY=k51qzi5uqu5dhfm9ej3rvn9fiba5l5bpwz9ku153eog2fu9a73ggd7qwv21bgq # The record provider key
```
Binary file added test/sharness/t0124-gateway-ipns-record/fixtures.car
Binary file not shown.
6 changes: 6 additions & 0 deletions test/sharness/t0124-gateway-ipns-record/record.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"key": "k51qzi5uqu5dhfm9ej3rvn9fiba5l5bpwz9ku153eog2fu9a73ggd7qwv21bgq",
"private_key": "CAESQOn0mgT/wAdeFennvNVNXAbLnDHL3UaGf7i7N4H2cPVWMi9Z7UTkf3oT69ANaTOo7kopnBXBM/Ir642RR2P9jko=",
"ttl": "30m",
"dest": "/ipfs/bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244"
}

0 comments on commit beb8dc6

Please sign in to comment.