From 466e6aa74f51f8dcaf7dbbd76b3ab2bbfb1096ea Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 20 Feb 2023 18:12:13 +0100 Subject: [PATCH 01/12] test: use car fixtures + ipns records in sharness t0124 --- test/sharness/t0124-gateway-ipns-record.sh | 16 +++++++---- .../t0124-gateway-ipns-record/README.md | 27 ++++++++++++++++++ .../t0124-gateway-ipns-record/fixtures.car | Bin 0 -> 107 bytes ...4qo0bftl9af6yie6uozkzd87bzkrbq.ipns-record | Bin 0 -> 378 bytes 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 test/sharness/t0124-gateway-ipns-record/README.md create mode 100644 test/sharness/t0124-gateway-ipns-record/fixtures.car create mode 100644 test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dm4inosjntx5i61w42pk04qo0bftl9af6yie6uozkzd87bzkrbq.ipns-record diff --git a/test/sharness/t0124-gateway-ipns-record.sh b/test/sharness/t0124-gateway-ipns-record.sh index cff00aa84d6..a4b8c0565e8 100755 --- a/test/sharness/t0124-gateway-ipns-record.sh +++ b/test/sharness/t0124-gateway-ipns-record.sh @@ -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=k51qzi5uqu5dm4inosjntx5i61w42pk04qo0bftl9af6yie6uozkzd87bzkrbq +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 ' @@ -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" ' diff --git a/test/sharness/t0124-gateway-ipns-record/README.md b/test/sharness/t0124-gateway-ipns-record/README.md new file mode 100644 index 00000000000..3588837dd9b --- /dev/null +++ b/test/sharness/t0124-gateway-ipns-record/README.md @@ -0,0 +1,27 @@ +# Dataset description/sources + +- fixtures.car + - raw CARv1 + +- k51....ipns-record + - ipns record, encoded with protocol buffer + +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=k51qzi5uqu5dm4inosjntx5i61w42pk04qo0bftl9af6yie6uozkzd87bzkrbq +FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS +``` diff --git a/test/sharness/t0124-gateway-ipns-record/fixtures.car b/test/sharness/t0124-gateway-ipns-record/fixtures.car new file mode 100644 index 0000000000000000000000000000000000000000..5c541e430ea6d1aed7c20545c40c9a56994ac546 GIT binary patch literal 107 zcmcColvtdbB zi~QG55kKX7r2GB;oEi6Dm#o?H=+%Yja}|Bo!9nUbZwfIPk)E-MrJ$VgOkJRJUy}S2166W&#QgTM6@P+T|Iy4ktqlN>aOnJ{^F^! z6w^~1wRE#y_1psqyFLy1g{Yx~n7d>uT7oi#%Svj7yV4LVOrf!xD2!QzIz% jct&t)VQFe!aw Date: Mon, 27 Feb 2023 11:22:21 +0100 Subject: [PATCH 02/12] test: update t0114 with records --- test/sharness/t0114-gateway-subdomains.sh | 46 +++++-------- ...GJb4mbDQkXFqr5MxxQ6aLcykd2kGBv.ipns-record | Bin 0 -> 378 bytes ...Yv1JycEge3demqPsUpmfyJnkgn6sb3.ipns-record | Bin 0 -> 1066 bytes .../t0114-gateway-subdomains/README.md | 61 +++++++++++++++++- .../t0124-gateway-ipns-record/README.md | 2 +- 5 files changed, 75 insertions(+), 34 deletions(-) create mode 100644 test/sharness/t0114-gateway-subdomains/12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv.ipns-record create mode 100644 test/sharness/t0114-gateway-subdomains/QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3.ipns-record diff --git a/test/sharness/t0114-gateway-subdomains.sh b/test/sharness/t0114-gateway-subdomains.sh index 04f762ad68e..fbda8402f81 100755 --- a/test/sharness/t0114-gateway-subdomains.sh +++ b/test/sharness/t0114-gateway-subdomains.sh @@ -93,40 +93,29 @@ test_launch_ipfs_daemon_without_network # Import test case # See the static fixtures in ./t0114-gateway-subdomains/ -test_expect_success "Add the test fixtures" ' - ipfs dag import ../t0114-gateway-subdomains/fixtures.car -' CID_VAL="hello" CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN -# CIDv0to1 is necessary because raw-leaves are enabled by default during -# "ipfs add" with CIDv1 and disabled with CIDv0 CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4 CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting -test_expect_success "Publish test text file to IPNS using RSA keys" ' - RSA_KEY=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 test_key_rsa | head -n1 | tr -d "\n") - RSA_IPNS_IDv0=$(echo "$RSA_KEY" | ipfs cid format -v 0) - RSA_IPNS_IDv1=$(echo "$RSA_KEY" | ipfs cid format -v 1 --mc libp2p-key -b base36) - RSA_IPNS_IDv1_DAGPB=$(echo "$RSA_IPNS_IDv0" | ipfs cid format -v 1 -b base36) - test_check_peerid "${RSA_KEY}" && - ipfs name publish --key test_key_rsa --allow-offline -Q "/ipfs/$CIDv1" > name_publish_out && - ipfs name resolve "$RSA_KEY" > output && - printf "/ipfs/%s\n" "$CIDv1" > expected2 && - test_cmp expected2 output -' +RSA_KEY=QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3 +RSA_IPNS_IDv0=QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3 +RSA_IPNS_IDv1=k2k4r8mualgw609qr2q5h4t7ea5ydufa2y4fo5qf4lpwg1lsk35ljcvq +RSA_IPNS_IDv1_DAGPB=k2jmtxuse1nx1o2vtk8rdcra0jem01b5hn4x6kguf68kp3623wuf1ddi -test_expect_success "Publish test text file to IPNS using ED25519 keys" ' - ED25519_KEY=$(ipfs key gen --ipns-base=b58mh --type=ed25519 test_key_ed25519 | head -n1 | tr -d "\n") - ED25519_IPNS_IDv0=$ED25519_KEY - ED25519_IPNS_IDv1=$(ipfs key list -l --ipns-base=base36 | grep test_key_ed25519 | cut -d " " -f1 | tr -d "\n") - ED25519_IPNS_IDv1_DAGPB=$(echo "$ED25519_IPNS_IDv1" | ipfs cid format -v 1 -b base36 --mc dag-pb) - test_check_peerid "${ED25519_KEY}" && - ipfs name publish --key test_key_ed25519 --allow-offline -Q "/ipfs/$CIDv1" > name_publish_out && - ipfs name resolve "$ED25519_KEY" > output && - printf "/ipfs/%s\n" "$CIDv1" > expected2 && - test_cmp expected2 output +ED25519_KEY=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv +ED25519_IPNS_IDv0=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv +ED25519_IPNS_IDv1=k51qzi5uqu5dlfd2bitdm0yv4t1oxyaqf5oaazh9ispho1osnsj1gltco5cbdp +ED25519_IPNS_IDv1_DAGPB=k50rm9yjlt0jg9mdacgyhpsidjfkqitcjxy74aykn99te6cx4xs5pvbodpffkt +IPNS_ED25519_B58MH=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv +IPNS_ED25519_B36CID=k51qzi5uqu5dlfd2bitdm0yv4t1oxyaqf5oaazh9ispho1osnsj1gltco5cbdp + +test_expect_success "Add the test fixtures" ' + ipfs dag import ../t0114-gateway-subdomains/fixtures.car && + ipfs routing put /ipns/${RSA_KEY} ../t0114-gateway-subdomains/${RSA_KEY}.ipns-record && + ipfs routing put /ipns/${ED25519_KEY} ../t0114-gateway-subdomains/${ED25519_KEY}.ipns-record ' # ensure we start with empty Gateway.PublicGateways @@ -588,11 +577,6 @@ test_expect_success \ ## https://github.com/ipfs/go-ipfs/issues/7318 ## ============================================================================ -# ed25519 fits under 63 char limit when represented in base36 -IPNS_KEY="test_key_ed25519" -IPNS_ED25519_B58MH=$(ipfs key list -l --ipns-base b58mh | grep $IPNS_KEY | cut -d" " -f1 | tr -d "\n") -IPNS_ED25519_B36CID=$(ipfs key list -l --ipns-base base36 | grep $IPNS_KEY | cut -d" " -f1 | tr -d "\n") - # local: *.localhost test_localhost_gateway_response_should_contain \ "request for a ED25519 libp2p-key at localhost/ipns/{b58mh} returns Location HTTP header for DNS-safe subdomain redirect in browsers" \ diff --git a/test/sharness/t0114-gateway-subdomains/12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv.ipns-record b/test/sharness/t0114-gateway-subdomains/12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv.ipns-record new file mode 100644 index 0000000000000000000000000000000000000000..2d42353317960c17e25de91f6b8c90a7cf136fc8 GIT binary patch literal 378 zcmd;b)XywPE7ng+Ov^4x%}lN=PB${n&MYr8Hc3r4N--}iPt7c-D9qT|iEfjsU%{wOA$QRR_fP?9z>Ff!IPFw!-$2r)FZ zGBU6-wbV1Rv@kX?j?!Q-U~qD{9DTim;hAN-yfUYnnIP+`-Dxim#H;QquUg=_b|vrU z%@5vw3X>L{(DZEkedz}?7j2x9KBYZ;`IWU%OJ}4@1-P(y^)fC^4hivLNDWH_x;=t& jk7op@76JnyIh7#;Xk=zeW=UlPK7ZuERE1O)q%r^iVaJb3 literal 0 HcmV?d00001 diff --git a/test/sharness/t0114-gateway-subdomains/QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3.ipns-record b/test/sharness/t0114-gateway-subdomains/QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3.ipns-record new file mode 100644 index 0000000000000000000000000000000000000000..da80af77db5bbc723c923aaf8d953bf6c671c95c GIT binary patch literal 1066 zcmd;b)XywPE7ng+Ov^4x%}lN=PB${n&MYr8Hc3r4N--}iPt7c-D92vJKl5RjlJx!IRgPaEDR&WX16{oj%sQ&pzw!vO9ms zO8@RbH9-&gnKdi=HH&1v{)yfFg;DizTfpDMPw_HE3s!x-<~(=S3sX(AQ2h2;3g+?4!!#vVe{;L-x>jzv^NOVUJG&1{ey#O3 zSo*d$gs(dN2ABGal(`zuaeJ~peFXW8HU&hIJDZ!|UC z|2&cH`%<$MLGPVeu2bd<-Bi|l$RjV;wX{gu85@{IX)qWtSgmH_U=UiyWYEN@WWdYDsnzDu_MMlJk&%^wxrvdV0VvMJ)Wpch zuv}5ub63-S&eRa)1FqBf|4YiPx9p!P#BxqLhJAx)@F{`Vsy4qlhu7LHbmMbd5|^pX z?~(G4mFQn~t%n|V8GC(>U3^*0D@SWu!|j8rC)hLNx1B$9 z=yk$%mxChrikX-h85o@!m|Uz%PhaO_m{j%2$DB7}xoDB_X{puz zzek^~-KKkG=cWANwYN#7spU7=oHtp%Sv zwhEteEd3ht=H--_9rZt(nU)DUEU91jQGH3{|9f4ZQ*YJ$-{G;ZNK7qATFG#=o>tAb zd41VQl`~5w9+zv?SNb}4-rewz3sqnFU-?qy#~-#rJk=nxR&GwT!WR7#UT*EDU#0f< zMtn?3w0&*-*7&f{uN!u2zWt4}yn1covK@vs2Och}eqeaP<7zXfDw~+D_bZ#L$%|T* zJ^pxHmRWY^f9E@sx98{B8=m{8CzY)9Q~Uf?uU^Kb$sr*=45?v>z`Pbgc}C3$PAvpx c+T>J*44{#jDVZge5%`jA4op=@WkD(f0Mk;;7ytkO literal 0 HcmV?d00001 diff --git a/test/sharness/t0114-gateway-subdomains/README.md b/test/sharness/t0114-gateway-subdomains/README.md index 611bd0ed5ad..a880d3de1c1 100644 --- a/test/sharness/t0114-gateway-subdomains/README.md +++ b/test/sharness/t0114-gateway-subdomains/README.md @@ -3,7 +3,13 @@ - fixtures.car - raw CARv1 -generated with: +- QmUKd....ipns-record + - ipns record, encoded with protocol buffer + +- 12D3K....ipns-record + - ipns record, encoded with protocol buffer + +Generated with: ```sh # using ipfs version 0.18.1 @@ -17,6 +23,7 @@ CIDv0to1=$(echo "$CIDv0" | ipfs cid base32) # sha512 will be over 63char limit, even when represented in Base36 CIDv1_TOO_LONG=$(echo $CID_VAL | ipfs add --cid-version 1 --hash sha2-512 -Q) +echo CID_VAL=${CID_VAL} echo CIDv1=${CIDv1} echo CIDv0=${CIDv0} echo CIDv0to1=${CIDv0to1} @@ -32,7 +39,7 @@ echo "I am a txt file" > testdirlisting/api/file.txt && echo "I am a txt file" > testdirlisting/ipfs/file.txt && DIR_CID=$(ipfs add -Qr --cid-version 1 testdirlisting) -echo DIR_CID=${DIR_CID} +echo DIR_CID=${DIR_CID} # ./testdirlisting ipfs files mkdir /t0114/ ipfs files cp /ipfs/${CIDv1} /t0114/ @@ -45,10 +52,60 @@ ROOT=`ipfs files stat /t0114/ --hash` ipfs dag export ${ROOT} > ./fixtures.car +# Then the keys + +KEY_NAME=test_key_rsa_$RANDOM +RSA_KEY=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 ${KEY_NAME} | head -n1 | tr -d "\n") +RSA_IPNS_IDv0=$(echo "$RSA_KEY" | ipfs cid format -v 0) +RSA_IPNS_IDv1=$(echo "$RSA_KEY" | ipfs cid format -v 1 --mc libp2p-key -b base36) +RSA_IPNS_IDv1_DAGPB=$(echo "$RSA_IPNS_IDv0" | ipfs cid format -v 1 -b base36) + +# publish a record valid for a 100 years +ipfs name publish --key ${KEY_NAME} --allow-offline -Q --ttl=876600h "/ipfs/$CIDv1" +ipfs routing get /ipns/${RSA_KEY} > ${RSA_KEY}.ipns-record + +echo RSA_KEY=${RSA_KEY} +echo RSA_IPNS_IDv0=${RSA_IPNS_IDv0} +echo RSA_IPNS_IDv1=${RSA_IPNS_IDv1} +echo RSA_IPNS_IDv1_DAGPB=${RSA_IPNS_IDv1_DAGPB} + +KEY_NAME=test_key_ed25519_$RANDOM +ED25519_KEY=$(ipfs key gen --ipns-base=b58mh --type=ed25519 ${KEY_NAME} | head -n1 | tr -d "\n") +ED25519_IPNS_IDv0=$ED25519_KEY +ED25519_IPNS_IDv1=$(ipfs key list -l --ipns-base=base36 | grep ${KEY_NAME} | cut -d " " -f1 | tr -d "\n") +ED25519_IPNS_IDv1_DAGPB=$(echo "$ED25519_IPNS_IDv1" | ipfs cid format -v 1 -b base36 --mc dag-pb) + +# ed25519 fits under 63 char limit when represented in base36 +IPNS_ED25519_B58MH=$(ipfs key list -l --ipns-base b58mh | grep $KEY_NAME | cut -d" " -f1 | tr -d "\n") +IPNS_ED25519_B36CID=$(ipfs key list -l --ipns-base base36 | grep $KEY_NAME | cut -d" " -f1 | tr -d "\n") + +# publish a record valid for a 100 years +ipfs name publish --key ${KEY_NAME} --allow-offline -Q --ttl=876600h "/ipfs/$CIDv1" +ipfs routing get /ipns/${ED25519_KEY} > ${ED25519_KEY}.ipns-record + +echo ED25519_KEY=${ED25519_KEY} +echo ED25519_IPNS_IDv0=${ED25519_IPNS_IDv0} +echo ED25519_IPNS_IDv1=${ED25519_IPNS_IDv1} +echo ED25519_IPNS_IDv1_DAGPB=${ED25519_IPNS_IDv1_DAGPB} +echo IPNS_ED25519_B58MH=${IPNS_ED25519_B58MH} +echo IPNS_ED25519_B36CID=${IPNS_ED25519_B36CID} + # CID_VAL="hello" # CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am # CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN # CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4 # CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs # DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting + +# RSA_KEY=QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3 +# RSA_IPNS_IDv0=QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3 +# RSA_IPNS_IDv1=k2k4r8mualgw609qr2q5h4t7ea5ydufa2y4fo5qf4lpwg1lsk35ljcvq +# RSA_IPNS_IDv1_DAGPB=k2jmtxuse1nx1o2vtk8rdcra0jem01b5hn4x6kguf68kp3623wuf1ddi + +# ED25519_KEY=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv +# ED25519_IPNS_IDv0=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv +# ED25519_IPNS_IDv1=k51qzi5uqu5dlfd2bitdm0yv4t1oxyaqf5oaazh9ispho1osnsj1gltco5cbdp +# ED25519_IPNS_IDv1_DAGPB=k50rm9yjlt0jg9mdacgyhpsidjfkqitcjxy74aykn99te6cx4xs5pvbodpffkt +# IPNS_ED25519_B58MH=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv +# IPNS_ED25519_B36CID=k51qzi5uqu5dlfd2bitdm0yv4t1oxyaqf5oaazh9ispho1osnsj1gltco5cbdp ``` diff --git a/test/sharness/t0124-gateway-ipns-record/README.md b/test/sharness/t0124-gateway-ipns-record/README.md index 3588837dd9b..cf8ae64536f 100644 --- a/test/sharness/t0124-gateway-ipns-record/README.md +++ b/test/sharness/t0124-gateway-ipns-record/README.md @@ -15,7 +15,7 @@ IPNS_KEY=$(ipfs key gen ipns-record) ipfs dag export ${FILE_CID} > fixtures.car -# publish a key valid for a 100 years +# publish a record 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 From 40ea41c650baa813898253bec1eb43580b82f82a Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 3 Mar 2023 10:38:41 +0100 Subject: [PATCH 03/12] test: fix & refresh keys --- test/sharness/t0114-gateway-subdomains.sh | 28 +++++++-------- ...XSZpdHs7oHbXub2G5WC8Tx4NQhyd2d.ipns-record | Bin 0 -> 394 bytes ...GJb4mbDQkXFqr5MxxQ6aLcykd2kGBv.ipns-record | Bin 378 -> 0 bytes ...8itnGufN7MEtPRCNHkKpNuA4onsRa3.ipns-record | Bin 0 -> 1082 bytes ...Yv1JycEge3demqPsUpmfyJnkgn6sb3.ipns-record | Bin 1066 -> 0 bytes .../t0114-gateway-subdomains/README.md | 34 +++++++++--------- test/sharness/t0124-gateway-ipns-record.sh | 2 +- .../t0124-gateway-ipns-record/README.md | 6 ++-- ...i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record | Bin 0 -> 392 bytes ...4qo0bftl9af6yie6uozkzd87bzkrbq.ipns-record | Bin 378 -> 0 bytes 10 files changed, 35 insertions(+), 35 deletions(-) create mode 100644 test/sharness/t0114-gateway-subdomains/12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d.ipns-record delete mode 100644 test/sharness/t0114-gateway-subdomains/12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv.ipns-record create mode 100644 test/sharness/t0114-gateway-subdomains/QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3.ipns-record delete mode 100644 test/sharness/t0114-gateway-subdomains/QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3.ipns-record create mode 100644 test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record delete mode 100644 test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dm4inosjntx5i61w42pk04qo0bftl9af6yie6uozkzd87bzkrbq.ipns-record diff --git a/test/sharness/t0114-gateway-subdomains.sh b/test/sharness/t0114-gateway-subdomains.sh index fbda8402f81..ac991622813 100755 --- a/test/sharness/t0114-gateway-subdomains.sh +++ b/test/sharness/t0114-gateway-subdomains.sh @@ -93,24 +93,24 @@ test_launch_ipfs_daemon_without_network # Import test case # See the static fixtures in ./t0114-gateway-subdomains/ -CID_VAL="hello" +CID_VAL=hello CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4 CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs -DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting - -RSA_KEY=QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3 -RSA_IPNS_IDv0=QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3 -RSA_IPNS_IDv1=k2k4r8mualgw609qr2q5h4t7ea5ydufa2y4fo5qf4lpwg1lsk35ljcvq -RSA_IPNS_IDv1_DAGPB=k2jmtxuse1nx1o2vtk8rdcra0jem01b5hn4x6kguf68kp3623wuf1ddi - -ED25519_KEY=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv -ED25519_IPNS_IDv0=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv -ED25519_IPNS_IDv1=k51qzi5uqu5dlfd2bitdm0yv4t1oxyaqf5oaazh9ispho1osnsj1gltco5cbdp -ED25519_IPNS_IDv1_DAGPB=k50rm9yjlt0jg9mdacgyhpsidjfkqitcjxy74aykn99te6cx4xs5pvbodpffkt -IPNS_ED25519_B58MH=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv -IPNS_ED25519_B36CID=k51qzi5uqu5dlfd2bitdm0yv4t1oxyaqf5oaazh9ispho1osnsj1gltco5cbdp +DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe + +RSA_KEY=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3 +RSA_IPNS_IDv0=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3 +RSA_IPNS_IDv1=k2k4r8m7xvggw5pxxk3abrkwyer625hg01hfyggrai7lk1m63fuihi7w +RSA_IPNS_IDv1_DAGPB=k2jmtxu61bnhrtj301lw7zizknztocdbeqhxgv76l2q9t36fn9jbzipo + +ED25519_KEY=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d +ED25519_IPNS_IDv0=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d +ED25519_IPNS_IDv1=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam +ED25519_IPNS_IDv1_DAGPB=k50rm9yjlt0jey4fqg6wafvqprktgbkpgkqdg27tpqje6iimzxewnhvtin9hhq +IPNS_ED25519_B58MH=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d +IPNS_ED25519_B36CID=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam test_expect_success "Add the test fixtures" ' ipfs dag import ../t0114-gateway-subdomains/fixtures.car && diff --git a/test/sharness/t0114-gateway-subdomains/12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d.ipns-record b/test/sharness/t0114-gateway-subdomains/12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d.ipns-record new file mode 100644 index 0000000000000000000000000000000000000000..39b2f41a40866132588557e1be7beb97f50b79d4 GIT binary patch literal 394 zcmd;b)XywPE7ng+Ov^4x%}lN=PB${n&MYr8Hc3r4N--}iPt7c-D9<^J}Yul1#e?Les=qsP9*TpHppd@W%Xk@HwV4`bi6k=#> zWnyAwYN=;oU}$b+5v9Rk(9qDcxZ%Nrr`k>qKjaU!b6-4rYi;`fm-}a{vCo?xRu}4g z^l|FihwZAz%U!lw{rY|+(EGO7p=OmC>knNP>?`)U^*Whrs^fvF0qEJ$Sl0Mn+K ATmS$7 literal 0 HcmV?d00001 diff --git a/test/sharness/t0114-gateway-subdomains/12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv.ipns-record b/test/sharness/t0114-gateway-subdomains/12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv.ipns-record deleted file mode 100644 index 2d42353317960c17e25de91f6b8c90a7cf136fc8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 378 zcmd;b)XywPE7ng+Ov^4x%}lN=PB${n&MYr8Hc3r4N--}iPt7c-D9qT|iEfjsU%{wOA$QRR_fP?9z>Ff!IPFw!-$2r)FZ zGBU6-wbV1Rv@kX?j?!Q-U~qD{9DTim;hAN-yfUYnnIP+`-Dxim#H;QquUg=_b|vrU z%@5vw3X>L{(DZEkedz}?7j2x9KBYZ;`IWU%OJ}4@1-P(y^)fC^4hivLNDWH_x;=t& jk7op@76JnyIh7#;Xk=zeW=UlPK7ZuERE1O)q%r^iVaJb3 diff --git a/test/sharness/t0114-gateway-subdomains/QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3.ipns-record b/test/sharness/t0114-gateway-subdomains/QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3.ipns-record new file mode 100644 index 0000000000000000000000000000000000000000..b37d9b75b50ce3baa472e0c790c63cc4476c8631 GIT binary patch literal 1082 zcmd;b)XywPE7ng+Ov^4x%}lN=PB${n&MYr8Hc3r4N--}iPt7c-D92(*IMXR5Go)>GsSynodq(GRGFw`JL;^nAdmmZe7@< z?;9u0)~oe;B6n8l#B-O4jHLznwHFfawsGeD^WdI5dD6CW_D`?(IR6u4yS}n>0Xs|C zV|Deu10TJ;+15H9y#1%w)-Pu|{~C5NEh+2ohgE%4GcFi^=!o1|c=mvclzM~Aq?sH1 zV;9|>pJ(C4b;k1K_pY`7N=jcyC2D2fRy9#Bx;b;nX--YmkL>f5|4X=(dm6Aa@2=jn zPF^r?@jIi2gJJgHoU|F^9$YA16dbkmCI8(bi=coUk?re*CGPIOm;0ZgQ?hD>F0X=C zL#OarR>@Lloz*!)FR?K>|cBO@yVa}y&! z15licsfm%1;pVJGT^wtTb=KA$^<13Nv3!=^X2&xt9)0ASbyDGP?WdlXx7q)`d@Z+h z!6|`%_KMwXk1o8Mo?{-MVA*x}^cm9=t?8#{Bqsazy{TE_Y}T4V{h&^m3)r^)bGv-5U2WMvuSX z7vtkGPzgn;O5JiMe~&<38&ZhUC?flR8gS@+~<#_0!o~ z@AZ8}8?WuOn%~@gsOVv8C3nV1oCd(eK6PTncvj@)S}Wr`}S-X)$F5@;ne3PMT?z z=NIb*B<2n+zLRAc6lAY~eeG%iDJwNZBx`P>1GC& uWCn)RutZ?qi=aH?W(21e0yA-PDnka)$jp??lFA5t$v6k5Dx|U?l>q?Oq1V#@ literal 0 HcmV?d00001 diff --git a/test/sharness/t0114-gateway-subdomains/QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3.ipns-record b/test/sharness/t0114-gateway-subdomains/QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3.ipns-record deleted file mode 100644 index da80af77db5bbc723c923aaf8d953bf6c671c95c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1066 zcmd;b)XywPE7ng+Ov^4x%}lN=PB${n&MYr8Hc3r4N--}iPt7c-D92vJKl5RjlJx!IRgPaEDR&WX16{oj%sQ&pzw!vO9ms zO8@RbH9-&gnKdi=HH&1v{)yfFg;DizTfpDMPw_HE3s!x-<~(=S3sX(AQ2h2;3g+?4!!#vVe{;L-x>jzv^NOVUJG&1{ey#O3 zSo*d$gs(dN2ABGal(`zuaeJ~peFXW8HU&hIJDZ!|UC z|2&cH`%<$MLGPVeu2bd<-Bi|l$RjV;wX{gu85@{IX)qWtSgmH_U=UiyWYEN@WWdYDsnzDu_MMlJk&%^wxrvdV0VvMJ)Wpch zuv}5ub63-S&eRa)1FqBf|4YiPx9p!P#BxqLhJAx)@F{`Vsy4qlhu7LHbmMbd5|^pX z?~(G4mFQn~t%n|V8GC(>U3^*0D@SWu!|j8rC)hLNx1B$9 z=yk$%mxChrikX-h85o@!m|Uz%PhaO_m{j%2$DB7}xoDB_X{puz zzek^~-KKkG=cWANwYN#7spU7=oHtp%Sv zwhEteEd3ht=H--_9rZt(nU)DUEU91jQGH3{|9f4ZQ*YJ$-{G;ZNK7qATFG#=o>tAb zd41VQl`~5w9+zv?SNb}4-rewz3sqnFU-?qy#~-#rJk=nxR&GwT!WR7#UT*EDU#0f< zMtn?3w0&*-*7&f{uN!u2zWt4}yn1covK@vs2Och}eqeaP<7zXfDw~+D_bZ#L$%|T* zJ^pxHmRWY^f9E@sx98{B8=m{8CzY)9Q~Uf?uU^Kb$sr*=45?v>z`Pbgc}C3$PAvpx c+T>J*44{#jDVZge5%`jA4op=@WkD(f0Mk;;7ytkO diff --git a/test/sharness/t0114-gateway-subdomains/README.md b/test/sharness/t0114-gateway-subdomains/README.md index a880d3de1c1..16291037749 100644 --- a/test/sharness/t0114-gateway-subdomains/README.md +++ b/test/sharness/t0114-gateway-subdomains/README.md @@ -12,7 +12,7 @@ Generated with: ```sh -# using ipfs version 0.18.1 +# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867) # CIDv0to1 is necessary because raw-leaves are enabled by default during # "ipfs add" with CIDv1 and disabled with CIDv0 @@ -61,7 +61,7 @@ RSA_IPNS_IDv1=$(echo "$RSA_KEY" | ipfs cid format -v 1 --mc libp2p-key -b base36 RSA_IPNS_IDv1_DAGPB=$(echo "$RSA_IPNS_IDv0" | ipfs cid format -v 1 -b base36) # publish a record valid for a 100 years -ipfs name publish --key ${KEY_NAME} --allow-offline -Q --ttl=876600h "/ipfs/$CIDv1" +ipfs name publish --key ${KEY_NAME} --allow-offline -Q --ttl=876600h --lifetime=876600h "/ipfs/$CIDv1" ipfs routing get /ipns/${RSA_KEY} > ${RSA_KEY}.ipns-record echo RSA_KEY=${RSA_KEY} @@ -80,7 +80,7 @@ IPNS_ED25519_B58MH=$(ipfs key list -l --ipns-base b58mh | grep $KEY_NAME | cut - IPNS_ED25519_B36CID=$(ipfs key list -l --ipns-base base36 | grep $KEY_NAME | cut -d" " -f1 | tr -d "\n") # publish a record valid for a 100 years -ipfs name publish --key ${KEY_NAME} --allow-offline -Q --ttl=876600h "/ipfs/$CIDv1" +ipfs name publish --key ${KEY_NAME} --allow-offline -Q --ttl=876600h --lifetime=876600h "/ipfs/$CIDv1" ipfs routing get /ipns/${ED25519_KEY} > ${ED25519_KEY}.ipns-record echo ED25519_KEY=${ED25519_KEY} @@ -90,22 +90,22 @@ echo ED25519_IPNS_IDv1_DAGPB=${ED25519_IPNS_IDv1_DAGPB} echo IPNS_ED25519_B58MH=${IPNS_ED25519_B58MH} echo IPNS_ED25519_B36CID=${IPNS_ED25519_B36CID} -# CID_VAL="hello" +# CID_VAL=hello # CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am # CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN # CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4 # CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs -# DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting - -# RSA_KEY=QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3 -# RSA_IPNS_IDv0=QmXaz6rApVddeVWEYv1JycEge3demqPsUpmfyJnkgn6sb3 -# RSA_IPNS_IDv1=k2k4r8mualgw609qr2q5h4t7ea5ydufa2y4fo5qf4lpwg1lsk35ljcvq -# RSA_IPNS_IDv1_DAGPB=k2jmtxuse1nx1o2vtk8rdcra0jem01b5hn4x6kguf68kp3623wuf1ddi - -# ED25519_KEY=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv -# ED25519_IPNS_IDv0=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv -# ED25519_IPNS_IDv1=k51qzi5uqu5dlfd2bitdm0yv4t1oxyaqf5oaazh9ispho1osnsj1gltco5cbdp -# ED25519_IPNS_IDv1_DAGPB=k50rm9yjlt0jg9mdacgyhpsidjfkqitcjxy74aykn99te6cx4xs5pvbodpffkt -# IPNS_ED25519_B58MH=12D3KooWPydmtfa4g7P3TjGJb4mbDQkXFqr5MxxQ6aLcykd2kGBv -# IPNS_ED25519_B36CID=k51qzi5uqu5dlfd2bitdm0yv4t1oxyaqf5oaazh9ispho1osnsj1gltco5cbdp +# DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe + +# RSA_KEY=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3 +# RSA_IPNS_IDv0=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3 +# RSA_IPNS_IDv1=k2k4r8m7xvggw5pxxk3abrkwyer625hg01hfyggrai7lk1m63fuihi7w +# RSA_IPNS_IDv1_DAGPB=k2jmtxu61bnhrtj301lw7zizknztocdbeqhxgv76l2q9t36fn9jbzipo + +# ED25519_KEY=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d +# ED25519_IPNS_IDv0=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d +# ED25519_IPNS_IDv1=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam +# ED25519_IPNS_IDv1_DAGPB=k50rm9yjlt0jey4fqg6wafvqprktgbkpgkqdg27tpqje6iimzxewnhvtin9hhq +# IPNS_ED25519_B58MH=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d +# IPNS_ED25519_B36CID=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam ``` diff --git a/test/sharness/t0124-gateway-ipns-record.sh b/test/sharness/t0124-gateway-ipns-record.sh index a4b8c0565e8..1d05b56985a 100755 --- a/test/sharness/t0124-gateway-ipns-record.sh +++ b/test/sharness/t0124-gateway-ipns-record.sh @@ -9,7 +9,7 @@ test_launch_ipfs_daemon # Import test case # See the static fixtures in ./t0124-gateway-ipns-record/ -IPNS_KEY=k51qzi5uqu5dm4inosjntx5i61w42pk04qo0bftl9af6yie6uozkzd87bzkrbq +IPNS_KEY=k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab 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 && diff --git a/test/sharness/t0124-gateway-ipns-record/README.md b/test/sharness/t0124-gateway-ipns-record/README.md index cf8ae64536f..d51a917957c 100644 --- a/test/sharness/t0124-gateway-ipns-record/README.md +++ b/test/sharness/t0124-gateway-ipns-record/README.md @@ -9,19 +9,19 @@ generated with: ```sh -# ipfs version 0.18.1 +# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867) 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 record valid for a 100 years -ipfs name publish --key=ipns-record --quieter --ttl=876600h /ipfs/${FILE_CID} +ipfs name publish --key=ipns-record --quieter --ttl=876600h --lifetime=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=k51qzi5uqu5dm4inosjntx5i61w42pk04qo0bftl9af6yie6uozkzd87bzkrbq +IPNS_KEY=k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS ``` diff --git a/test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record b/test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab.ipns-record new file mode 100644 index 0000000000000000000000000000000000000000..ec13ec550162b81f44b35a6ab54b4dd9cdd11707 GIT binary patch literal 392 zcmd;b)XywPE7ng+Ov^4x%}hy4Day%CEi}nBsmQA+t*kK1OiVR5OH0W$DNoNaO);sc zDo!#t&#cI(EG#e0&8RXmF%fe3WvzU>SFJ04j^dIZkA-4vOEfq6H0ie39ZWWO|7T-n zhTD&u+CmfaOSEsE-5&R2o=I`u(JdVUdxTlHr4_DQ%+Dynpd@8vXk@HwV4`bi6k=#> zWo%|;YN2OjY;I&8rNLm((9pBE;lYEa+D;DZwog8P;JtWuR2%!>xl6YFEuU6)>E){C z#}a3ym{+MAwLQ!K{b1W$zOv&|S}J#Rzj~K(y{i5eAFDB8+QsA7xBcYvn!>m=IV8kK zTKjY}14}XkLuy!JPHAcc<>8PKoLX3#nwOl)kO4F@GbOX6G6Ijca$t%=DhpB>023mb A4*&oF literal 0 HcmV?d00001 diff --git a/test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dm4inosjntx5i61w42pk04qo0bftl9af6yie6uozkzd87bzkrbq.ipns-record b/test/sharness/t0124-gateway-ipns-record/k51qzi5uqu5dm4inosjntx5i61w42pk04qo0bftl9af6yie6uozkzd87bzkrbq.ipns-record deleted file mode 100644 index df5bab4fa31e0fa943e4979567ce567ef8840009..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 378 zcmd;b)XywPE7ng+Ov^4x%}hy4Day%CEi}nBsmQA+t*kK1OiVR5OH0W$DNoNaO);sc zDo!#t&#cI(EG#e0&8RXmF%fcTGXCLfbg5^4t9AhAG4uNwGq%k-axLjndduN*>tdbB zi~QG55kKX7r2GB;oEi6Dm#o?H=+%Yja}|Bo!9nUbZwfIPk)E-MrJ$VgOkJRJUy}S2166W&#QgTM6@P+T|Iy4ktqlN>aOnJ{^F^! z6w^~1wRE#y_1psqyFLy1g{Yx~n7d>uT7oi#%Svj7yV4LVOrf!xD2!QzIz% jct&t)VQFe!aw Date: Fri, 3 Mar 2023 10:39:02 +0100 Subject: [PATCH 04/12] test: use network during gateway init - prevent error on `ipfs routing put` --- test/sharness/t0114-gateway-subdomains.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sharness/t0114-gateway-subdomains.sh b/test/sharness/t0114-gateway-subdomains.sh index ac991622813..f573ce4084b 100755 --- a/test/sharness/t0114-gateway-subdomains.sh +++ b/test/sharness/t0114-gateway-subdomains.sh @@ -89,7 +89,7 @@ test_expect_success "ipfs init" ' ipfs init --profile=test > /dev/null ' -test_launch_ipfs_daemon_without_network +test_launch_ipfs_daemon # Import test case # See the static fixtures in ./t0114-gateway-subdomains/ From bc3ad9f0d58c4a1fff30eacfd899592651290a7b Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Fri, 10 Mar 2023 09:34:23 +0100 Subject: [PATCH 05/12] test: fixture check at the beginning of the test --- test/sharness/t0114-gateway-subdomains.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/sharness/t0114-gateway-subdomains.sh b/test/sharness/t0114-gateway-subdomains.sh index f573ce4084b..da431c08cd3 100755 --- a/test/sharness/t0114-gateway-subdomains.sh +++ b/test/sharness/t0114-gateway-subdomains.sh @@ -118,6 +118,12 @@ test_expect_success "Add the test fixtures" ' ipfs routing put /ipns/${ED25519_KEY} ../t0114-gateway-subdomains/${ED25519_KEY}.ipns-record ' +test_expect_success "Getting back the fixtures" ' + ipfs get ${CIDv1} && + ipfs routing get /ipns/${RSA_KEY} && + ipfs routing get /ipns/${ED25519_KEY} +' + # ensure we start with empty Gateway.PublicGateways test_expect_success 'start daemon with empty config for Gateway.PublicGateways' ' test_kill_ipfs_daemon && From b651b12670f11a2f5992cb65b48c49f03e026348 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Tue, 11 Apr 2023 17:36:47 +0200 Subject: [PATCH 06/12] test: update t0116 with ipns fixtures --- test/sharness/t0116-gateway-cache.sh | 20 ++++++------------ test/sharness/t0116-gateway-cache/README.md | 20 ++++++++++++------ ...p32iwm9pdt9nq3y5rpn3ln9j12zfhe.ipns-record | Bin 0 -> 394 bytes 3 files changed, 21 insertions(+), 19 deletions(-) create mode 100644 test/sharness/t0116-gateway-cache/k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe.ipns-record diff --git a/test/sharness/t0116-gateway-cache.sh b/test/sharness/t0116-gateway-cache.sh index 0cb1a94eb00..25e403d0e46 100755 --- a/test/sharness/t0116-gateway-cache.sh +++ b/test/sharness/t0116-gateway-cache.sh @@ -5,7 +5,7 @@ test_description="Test HTTP Gateway Cache Control Support" . lib/test-lib.sh test_init_ipfs -test_launch_ipfs_daemon_without_network +test_launch_ipfs_daemon # Cache control support is based on logical roots (each path segment == one logical root). # To maximize the test surface, we want to test: @@ -25,24 +25,18 @@ test_launch_ipfs_daemon_without_network # Caching of things like raw blocks, CARs, dag-json and dag-cbor # is tested in their respective suites. -# Import test case -# See the static fixtures in ./t0116-gateway-cache/ -test_expect_success "Add the test directory" ' - ipfs dag import ../t0116-gateway-cache/fixtures.car -' ROOT1_CID=bafybeib3ffl2teiqdncv3mkz4r23b5ctrwkzrrhctdbne6iboayxuxk5ui # ./ ROOT2_CID=bafybeih2w7hjocxjg6g2ku25hvmd53zj7og4txpby3vsusfefw5rrg5sii # ./root2 ROOT3_CID=bafybeiawdvhmjcz65x5egzx4iukxc72hg4woks6v6fvgyupiyt3oczk5ja # ./root2/root3 ROOT4_CID=bafybeifq2rzpqnqrsdupncmkmhs3ckxxjhuvdcbvydkgvch3ms24k5lo7q # ./root2/root3/root4 FILE_CID=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am # ./root2/root3/root4/index.html +TEST_IPNS_ID=k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe -test_expect_success "Prepare IPNS unixfs content path for testing" ' - TEST_IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 cache_test_key | head -n1 | tr -d "\n") - ipfs name publish --key cache_test_key --allow-offline -Q "/ipfs/$ROOT1_CID" > name_publish_out && - test_check_peerid "${TEST_IPNS_ID}" && - ipfs name resolve "${TEST_IPNS_ID}" > output && - printf "/ipfs/%s\n" "$ROOT1_CID" > expected && - test_cmp expected output +# Import test case +# See the static fixtures in ./t0116-gateway-cache/ +test_expect_success "Add the test directory" ' + ipfs dag import ../t0116-gateway-cache/fixtures.car + ipfs routing put /ipns/${TEST_IPNS_ID} ../t0116-gateway-cache/${TEST_IPNS_ID}.ipns-record ' # GET /ipfs/ diff --git a/test/sharness/t0116-gateway-cache/README.md b/test/sharness/t0116-gateway-cache/README.md index 8b44fe640b7..1be92f45456 100644 --- a/test/sharness/t0116-gateway-cache/README.md +++ b/test/sharness/t0116-gateway-cache/README.md @@ -6,7 +6,8 @@ generated with: ```sh -# using ipfs version 0.18.1 +# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867) + mkdir -p root2/root3/root4 && echo "hello" > root2/root3/root4/index.html && ROOT1_CID=$(ipfs add -Qrw --cid-version 1 root2) @@ -15,11 +16,17 @@ ROOT3_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3 | cut -d "/" -f3) ROOT4_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3/root4 | cut -d "/" -f3) FILE_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3/root4/index.html | cut -d "/" -f3) -echo ROOT1_CID=${ROOT1_CID} -echo ROOT2_CID=${ROOT2_CID} -echo ROOT3_CID=${ROOT3_CID} -echo ROOT4_CID=${ROOT4_CID} -echo FILE_CID=${FILE_CID} +TEST_IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 cache_test_key | head -n1 | tr -d "\n") +# publish a record valid for a 100 years +ipfs name publish --key cache_test_key --allow-offline -Q --ttl=876600h --lifetime=876600h "/ipfs/$ROOT1_CID" +ipfs routing get /ipns/${TEST_IPNS_ID} > ${TEST_IPNS_ID}.ipns-record + +echo ROOT1_CID=${ROOT1_CID} # ./ +echo ROOT2_CID=${ROOT2_CID} # ./root2 +echo ROOT3_CID=${ROOT3_CID} # ./root2/root3 +echo ROOT4_CID=${ROOT4_CID} # ./root2/root3/root4 +echo FILE_CID=${FILE_CID} # ./root2/root3/root4/index.html +echo TEST_IPNS_ID=${TEST_IPNS_ID} ipfs dag export ${ROOT1_CID} > ./fixtures.car @@ -28,4 +35,5 @@ ipfs dag export ${ROOT1_CID} > ./fixtures.car # ROOT3_CID=bafybeiawdvhmjcz65x5egzx4iukxc72hg4woks6v6fvgyupiyt3oczk5ja # ./root2/root3 # ROOT4_CID=bafybeifq2rzpqnqrsdupncmkmhs3ckxxjhuvdcbvydkgvch3ms24k5lo7q # ./root2/root3/root4 # FILE_CID=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am # ./root2/root3/root4/index.html +# TEST_IPNS_ID=k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe ``` diff --git a/test/sharness/t0116-gateway-cache/k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe.ipns-record b/test/sharness/t0116-gateway-cache/k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe.ipns-record new file mode 100644 index 0000000000000000000000000000000000000000..9cd7491bf7e71ec8f11e908b51aa908702a4a353 GIT binary patch literal 394 zcmd;b)XywPE7ng+Osh;v%}g>*OUp4TNzE)w$xALX&dsheDKaunGEFWiD$lMeD#}PM zNlD5}HOoxOPpqsct;jYl%@lIj#Aa`PX!4XzpKmQY)6e$9U7<`kzNU$F%{D)#mwVMZ z{GZ-h%zgj3z3+a9thHt*l@~txHDQw3!_thyQ+_E$H*2s|5P0dSAWyk;;nVFJVQW=5IUpX*UA(aKG3;+eR BnWX># literal 0 HcmV?d00001 From 0e4d0916e87321fc370d94adf26dd8e1e3883e27 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Tue, 11 Apr 2023 18:05:50 +0200 Subject: [PATCH 07/12] test: update t0123 with ipns fixtures --- test/sharness/t0123-gateway-json-cbor.sh | 24 +++++++++--------- .../t0123-gateway-json-cbor/README.md | 24 +++++++++++++++++- ...xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record | Bin 0 -> 394 bytes ...e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record | Bin 0 -> 398 bytes 4 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record create mode 100644 test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record diff --git a/test/sharness/t0123-gateway-json-cbor.sh b/test/sharness/t0123-gateway-json-cbor.sh index b22c056de78..725467aeca6 100755 --- a/test/sharness/t0123-gateway-json-cbor.sh +++ b/test/sharness/t0123-gateway-json-cbor.sh @@ -5,7 +5,7 @@ test_description="Test HTTP Gateway DAG-JSON (application/vnd.ipld.dag-json) and . lib/test-lib.sh test_init_ipfs -test_launch_ipfs_daemon_without_network +test_launch_ipfs_daemon # Import test case # See the static fixtures in ./t0123-gateway-json-cbor/ @@ -163,6 +163,14 @@ test_expect_success "Add CARs for path traversal and DAG-PB representation tests test_should_contain $DAG_PB_CID import_output ' +IPNS_ID_DAG_JSON=k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2 +IPNS_ID_DAG_CBOR=k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l + +test_expect_success "Add ipns records for path traversal and DAG-PB representation tests" ' + ipfs routing put /ipns/${IPNS_ID_DAG_JSON} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_JSON}.ipns-record && + ipfs routing put /ipns/${IPNS_ID_DAG_CBOR} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_CBOR}.ipns-record +' + test_expect_success "GET DAG-JSON traversal returns 501 if there is path remainder" ' curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_JSON_TRAVERSAL_CID/foo?format=dag-json" > curl_output 2>&1 && test_should_contain "501 Not Implemented" curl_output && @@ -197,6 +205,7 @@ test_native_dag () { format=$2 disposition=$3 CID=$4 + IPNS_ID=$5 # GET without explicit format and Accept: text/html returns raw block @@ -313,15 +322,6 @@ test_native_dag () { # IPNS behavior (should be same as immutable /ipfs, but with different caching headers) # To keep tests small we only confirm payload is the same, and then only test delta around caching headers. - test_expect_success "Prepare IPNS with dag-$format" ' - IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 ${format}_test_key | head -n1 | tr -d "\n") && - ipfs name publish --key ${format}_test_key --allow-offline -Q "/ipfs/$CID" > name_publish_out && - test_check_peerid "${IPNS_ID}" && - ipfs name resolve "${IPNS_ID}" > output && - printf "/ipfs/%s\n" "$CID" > expected && - test_cmp expected output - ' - test_expect_success "GET $name from /ipns without explicit format returns the same payload as /ipfs" ' curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o ipfs_output && curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID" -o ipns_output && @@ -369,8 +369,8 @@ test_native_dag () { } -test_native_dag "DAG-JSON" "json" "inline" "$DAG_JSON_TRAVERSAL_CID" -test_native_dag "DAG-CBOR" "cbor" "attachment" "$DAG_CBOR_TRAVERSAL_CID" +test_native_dag "DAG-JSON" "json" "inline" "$DAG_JSON_TRAVERSAL_CID" ${IPNS_ID_DAG_JSON} +test_native_dag "DAG-CBOR" "cbor" "attachment" "$DAG_CBOR_TRAVERSAL_CID" ${IPNS_ID_DAG_CBOR} test_kill_ipfs_daemon diff --git a/test/sharness/t0123-gateway-json-cbor/README.md b/test/sharness/t0123-gateway-json-cbor/README.md index 4e83f42a161..5a63b192af8 100644 --- a/test/sharness/t0123-gateway-json-cbor/README.md +++ b/test/sharness/t0123-gateway-json-cbor/README.md @@ -14,7 +14,8 @@ generated with: ```sh -# using ipfs version 0.18.1 +# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867) + mkdir -p rootDir/ipfs && mkdir -p rootDir/ipns && mkdir -p rootDir/api && @@ -37,8 +38,29 @@ echo FILE_SIZE=${FILE_SIZE} ipfs dag export ${DIR_CID} > fixtures.car +DAG_CBOR_TRAVERSAL_CID="bafyreibs4utpgbn7uqegmd2goqz4bkyflre2ek2iwv743fhvylwi4zeeim" +DAG_JSON_TRAVERSAL_CID="baguqeeram5ujjqrwheyaty3w5gdsmoz6vittchvhk723jjqxk7hakxkd47xq" +DAG_PB_CID="bafybeiegxwlgmoh2cny7qlolykdf7aq7g6dlommarldrbm7c4hbckhfcke" + +test_native_dag() { + NAME=$1 + CID=$2 + + IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 ${NAME}_test_key | head -n1 | tr -d "\n") + ipfs name publish --key ${NAME}_test_key --allow-offline --ttl=876600h --lifetime=876600h -Q "/ipfs/${CID}" > name_publish_out + + ipfs routing get /ipns/${IPNS_ID} > ${IPNS_ID}.ipns-record + + echo "IPNS_ID_${NAME}=${IPNS_ID}" +} + +test_native_dag "DAG_JSON" "$DAG_JSON_TRAVERSAL_CID" +test_native_dag "DAG_CBOR" "$DAG_CBOR_TRAVERSAL_CID" + # DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir # FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json # FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt # FILE_SIZE=34 +# IPNS_ID_DAG_JSON=k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2 +# IPNS_ID_DAG_CBOR=k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l ``` diff --git a/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record b/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l.ipns-record new file mode 100644 index 0000000000000000000000000000000000000000..7186c709e3ceb29fbfda0fd38b4e43109f26ce55 GIT binary patch literal 394 zcmd;b)XywPE7ng+OsgzP%}gpbDJ>~TPs%edElf?%O)*N(FRU_2%C1byDM~d;%{Iy` zFEckWPRl5(%qh<_sY*@F%oTE|Wo^}bx%d5*Sx4q7wQu^*{jh&wK$gukjlQ6!w<^zC z3zgkZ3FJ7HbjEJnE2pg~YAb1T`}pU#Pwl?`TRqWK?I))MgOaq7p^>q!fr+l6afpG1 zm4T&|siB^QrJ=E@n00{M& AZ2$lO literal 0 HcmV?d00001 diff --git a/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record b/test/sharness/t0123-gateway-json-cbor/k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2.ipns-record new file mode 100644 index 0000000000000000000000000000000000000000..28676f4d9a8824989d039a03376aeea9ae63d0d3 GIT binary patch literal 398 zcmd;b*3T?RE7ng+OfM}=O)W~yH7(7`Dl96`NUcmPsWdJ(O;0J#&95>m%Pc8L&M3>s zHa9W`DyYad&q&O!$WAdauP799P;T3(=A&^x$Y#D|lG@q>LT5|;wEh}r>YUo65W?xX z)~)KP*_E#3s?1Ys{Wt72pZosTYWup`{b6o#URK<3lJD3g7?h-q42_I+4NPq4G7B@V2@KoE$;q~X{`u_XeTsd(Ml(;WP%n0C_P+X~( z`|*~;{f_SyrzS~i|89=(;gu+H(2(HipQ0Kl{`~X07?TnkT`#}eZV&jprZX;04hiv* z);`_Lz>>_skQ$blQ<@q Date: Wed, 12 Apr 2023 10:15:45 +0200 Subject: [PATCH 08/12] fix: readmes for sharness gen --- test/sharness/t0114-gateway-subdomains/README.md | 2 +- test/sharness/t0124-gateway-ipns-record/README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sharness/t0114-gateway-subdomains/README.md b/test/sharness/t0114-gateway-subdomains/README.md index 16291037749..005a7f0c51a 100644 --- a/test/sharness/t0114-gateway-subdomains/README.md +++ b/test/sharness/t0114-gateway-subdomains/README.md @@ -95,7 +95,7 @@ echo IPNS_ED25519_B36CID=${IPNS_ED25519_B36CID} # CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN # CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4 # CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs -# DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe +# DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting # RSA_KEY=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3 # RSA_IPNS_IDv0=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3 diff --git a/test/sharness/t0124-gateway-ipns-record/README.md b/test/sharness/t0124-gateway-ipns-record/README.md index d51a917957c..8ada577d4d7 100644 --- a/test/sharness/t0124-gateway-ipns-record/README.md +++ b/test/sharness/t0124-gateway-ipns-record/README.md @@ -22,6 +22,6 @@ 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=k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab -FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS +# IPNS_KEY=k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab +# FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS ``` From 10a31462c5829bdf43858206d1b5cad1384fee6b Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 12 Apr 2023 10:37:37 +0200 Subject: [PATCH 09/12] feat(routing): allow-offline during put --- core/commands/routing.go | 34 +++++++++++++++++++++++++--------- core/coreapi/routing.go | 13 ++++++++++--- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/core/commands/routing.go b/core/commands/routing.go index 2d578fcb60f..76672c6f2fa 100644 --- a/core/commands/routing.go +++ b/core/commands/routing.go @@ -10,6 +10,8 @@ import ( cmdenv "github.com/ipfs/kubo/core/commands/cmdenv" + iface "github.com/ipfs/boxo/coreiface" + "github.com/ipfs/boxo/coreiface/options" dag "github.com/ipfs/boxo/ipld/merkledag" path "github.com/ipfs/boxo/path" cid "github.com/ipfs/go-cid" @@ -19,6 +21,16 @@ import ( routing "github.com/libp2p/go-libp2p/core/routing" ) +var ( + errAllowOffline = errors.New("can't put while offline: pass `--allow-offline` to override") +) + +const ( + dhtVerboseOptionName = "verbose" + numProvidersOptionName = "num-providers" + allowOfflineOptionName = "allow-offline" +) + var RoutingCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Issue routing commands.", @@ -34,14 +46,6 @@ var RoutingCmd = &cmds.Command{ }, } -const ( - dhtVerboseOptionName = "verbose" -) - -const ( - numProvidersOptionName = "num-providers" -) - var findProvidersRoutingCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Find peers that can provide a specific value, given a key.", @@ -420,6 +424,9 @@ identified by QmFoo. cmds.StringArg("key", true, false, "The key to store the value at."), cmds.FileArg("value-file", true, false, "A path to a file containing the value to store.").EnableStdin(), }, + Options: []cmds.Option{ + cmds.BoolOption(allowOfflineOptionName, "When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing."), + }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { api, err := cmdenv.GetApi(env, req) if err != nil { @@ -437,13 +444,22 @@ identified by QmFoo. return err } - err = api.Routing().Put(req.Context, req.Arguments[0], data) + allowOffline, _ := req.Options[allowOfflineOptionName].(bool) + + opts := []options.RoutingPutOption{ + options.Put.AllowOffline(allowOffline), + } + + err = api.Routing().Put(req.Context, req.Arguments[0], data, opts...) if err != nil { return err } id, err := api.Key().Self(req.Context) if err != nil { + if err == iface.ErrOffline { + err = errAllowOffline + } return err } diff --git a/core/coreapi/routing.go b/core/coreapi/routing.go index 76d96931679..95b50aa631d 100644 --- a/core/coreapi/routing.go +++ b/core/coreapi/routing.go @@ -5,6 +5,7 @@ import ( "errors" coreiface "github.com/ipfs/boxo/coreiface" + caopts "github.com/ipfs/boxo/coreiface/options" "github.com/ipfs/boxo/path" peer "github.com/libp2p/go-libp2p/core/peer" ) @@ -24,9 +25,15 @@ func (r *RoutingAPI) Get(ctx context.Context, key string) ([]byte, error) { return r.routing.GetValue(ctx, dhtKey) } -func (r *RoutingAPI) Put(ctx context.Context, key string, value []byte) error { - if !r.nd.IsOnline { - return coreiface.ErrOffline +func (r *RoutingAPI) Put(ctx context.Context, key string, value []byte, opts ...caopts.RoutingPutOption) error { + options, err := caopts.RoutingPutOptions(opts...) + if err != nil { + return err + } + + err = r.checkOnline(options.AllowOffline) + if err != nil { + return err } dhtKey, err := normalizeKey(key) From 9e13ff28f1edc67b017e179f785094c52bd4a522 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 12 Apr 2023 10:41:52 +0200 Subject: [PATCH 10/12] test: use offline mode whenever possible --- test/sharness/t0114-gateway-subdomains.sh | 12 +++--------- test/sharness/t0116-gateway-cache.sh | 4 ++-- test/sharness/t0123-gateway-json-cbor.sh | 6 +++--- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/test/sharness/t0114-gateway-subdomains.sh b/test/sharness/t0114-gateway-subdomains.sh index da431c08cd3..bf507098590 100755 --- a/test/sharness/t0114-gateway-subdomains.sh +++ b/test/sharness/t0114-gateway-subdomains.sh @@ -89,7 +89,7 @@ test_expect_success "ipfs init" ' ipfs init --profile=test > /dev/null ' -test_launch_ipfs_daemon +test_launch_ipfs_daemon_without_network # Import test case # See the static fixtures in ./t0114-gateway-subdomains/ @@ -114,14 +114,8 @@ IPNS_ED25519_B36CID=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36d test_expect_success "Add the test fixtures" ' ipfs dag import ../t0114-gateway-subdomains/fixtures.car && - ipfs routing put /ipns/${RSA_KEY} ../t0114-gateway-subdomains/${RSA_KEY}.ipns-record && - ipfs routing put /ipns/${ED25519_KEY} ../t0114-gateway-subdomains/${ED25519_KEY}.ipns-record -' - -test_expect_success "Getting back the fixtures" ' - ipfs get ${CIDv1} && - ipfs routing get /ipns/${RSA_KEY} && - ipfs routing get /ipns/${ED25519_KEY} + ipfs routing put --allow-offline /ipns/${RSA_KEY} ../t0114-gateway-subdomains/${RSA_KEY}.ipns-record && + ipfs routing put --allow-offline /ipns/${ED25519_KEY} ../t0114-gateway-subdomains/${ED25519_KEY}.ipns-record ' # ensure we start with empty Gateway.PublicGateways diff --git a/test/sharness/t0116-gateway-cache.sh b/test/sharness/t0116-gateway-cache.sh index 25e403d0e46..b2e6b3af38b 100755 --- a/test/sharness/t0116-gateway-cache.sh +++ b/test/sharness/t0116-gateway-cache.sh @@ -5,7 +5,7 @@ test_description="Test HTTP Gateway Cache Control Support" . lib/test-lib.sh test_init_ipfs -test_launch_ipfs_daemon +test_launch_ipfs_daemon_without_network # Cache control support is based on logical roots (each path segment == one logical root). # To maximize the test surface, we want to test: @@ -36,7 +36,7 @@ TEST_IPNS_ID=k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe # See the static fixtures in ./t0116-gateway-cache/ test_expect_success "Add the test directory" ' ipfs dag import ../t0116-gateway-cache/fixtures.car - ipfs routing put /ipns/${TEST_IPNS_ID} ../t0116-gateway-cache/${TEST_IPNS_ID}.ipns-record + ipfs routing put --allow-offline /ipns/${TEST_IPNS_ID} ../t0116-gateway-cache/${TEST_IPNS_ID}.ipns-record ' # GET /ipfs/ diff --git a/test/sharness/t0123-gateway-json-cbor.sh b/test/sharness/t0123-gateway-json-cbor.sh index 725467aeca6..745e984db98 100755 --- a/test/sharness/t0123-gateway-json-cbor.sh +++ b/test/sharness/t0123-gateway-json-cbor.sh @@ -5,7 +5,7 @@ test_description="Test HTTP Gateway DAG-JSON (application/vnd.ipld.dag-json) and . lib/test-lib.sh test_init_ipfs -test_launch_ipfs_daemon +test_launch_ipfs_daemon_without_network # Import test case # See the static fixtures in ./t0123-gateway-json-cbor/ @@ -167,8 +167,8 @@ IPNS_ID_DAG_JSON=k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2 IPNS_ID_DAG_CBOR=k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l test_expect_success "Add ipns records for path traversal and DAG-PB representation tests" ' - ipfs routing put /ipns/${IPNS_ID_DAG_JSON} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_JSON}.ipns-record && - ipfs routing put /ipns/${IPNS_ID_DAG_CBOR} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_CBOR}.ipns-record + ipfs routing put --allow-offline /ipns/${IPNS_ID_DAG_JSON} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_JSON}.ipns-record && + ipfs routing put --allow-offline /ipns/${IPNS_ID_DAG_CBOR} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_CBOR}.ipns-record ' test_expect_success "GET DAG-JSON traversal returns 501 if there is path remainder" ' From b18d41e17a5a0260d2759199b6a742ee47ff6637 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Tue, 2 May 2023 16:31:39 +0200 Subject: [PATCH 11/12] test: prepare with offline routing test --- core/coreapi/test/api_test.go | 22 ++++++++++++---------- core/coreapi/test/path_test.go | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/core/coreapi/test/api_test.go b/core/coreapi/test/api_test.go index dafadcc1f28..64d8738963c 100644 --- a/core/coreapi/test/api_test.go +++ b/core/coreapi/test/api_test.go @@ -31,7 +31,7 @@ const testPeerID = "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe" type NodeProvider struct{} -func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int) ([]coreiface.CoreAPI, error) { +func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, online bool, n int) ([]coreiface.CoreAPI, error) { mn := mocknet.New() nodes := make([]*core.IpfsNode, n) @@ -82,7 +82,7 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int) Routing: libp2p.DHTServerOption, Repo: r, Host: mock.MockHostOption(mn), - Online: fullIdentity, + Online: online, ExtraOpts: map[string]bool{ "pubsub": true, }, @@ -102,15 +102,17 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int) return nil, err } - bsinf := bootstrap.BootstrapConfigWithPeers( - []peer.AddrInfo{ - nodes[0].Peerstore.PeerInfo(nodes[0].Identity), - }, - ) + if online { + bsinf := bootstrap.BootstrapConfigWithPeers( + []peer.AddrInfo{ + nodes[0].Peerstore.PeerInfo(nodes[0].Identity), + }, + ) - for _, n := range nodes[1:] { - if err := n.Bootstrap(bsinf); err != nil { - return nil, err + for _, n := range nodes[1:] { + if err := n.Bootstrap(bsinf); err != nil { + return nil, err + } } } diff --git a/core/coreapi/test/path_test.go b/core/coreapi/test/path_test.go index 9f67f3c7187..c89ce48c960 100644 --- a/core/coreapi/test/path_test.go +++ b/core/coreapi/test/path_test.go @@ -19,7 +19,7 @@ func TestPathUnixFSHAMTPartial(t *testing.T) { defer cancel() // Create a node - apis, err := NodeProvider{}.MakeAPISwarm(ctx, true, 1) + apis, err := NodeProvider{}.MakeAPISwarm(ctx, true, true, 1) if err != nil { t.Fatal(err) } From 18c42573e5e00c90617e992199dacb718f6e287b Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 3 May 2023 14:32:23 +0200 Subject: [PATCH 12/12] chore: bump to boxo 0.8.2 (#8059f1) --- docs/examples/kubo-as-a-library/go.mod | 2 +- docs/examples/kubo-as-a-library/go.sum | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/examples/kubo-as-a-library/go.mod b/docs/examples/kubo-as-a-library/go.mod index 6eb1bcb5eb5..fd3ad890990 100644 --- a/docs/examples/kubo-as-a-library/go.mod +++ b/docs/examples/kubo-as-a-library/go.mod @@ -7,7 +7,7 @@ go 1.18 replace github.com/ipfs/kubo => ./../../.. require ( - github.com/ipfs/boxo v0.8.1 + github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866 github.com/ipfs/kubo v0.0.0-00010101000000-000000000000 github.com/libp2p/go-libp2p v0.27.1 github.com/multiformats/go-multiaddr v0.9.0 diff --git a/docs/examples/kubo-as-a-library/go.sum b/docs/examples/kubo-as-a-library/go.sum index 2302548a970..15bf75e8294 100644 --- a/docs/examples/kubo-as-a-library/go.sum +++ b/docs/examples/kubo-as-a-library/go.sum @@ -321,8 +321,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.8.1 h1:3DkKBCK+3rdEB5t77WDShUXXhktYwH99mkAsgajsKrU= -github.com/ipfs/boxo v0.8.1/go.mod h1:xJ2hVb4La5WyD7GvKYE0lq2g1rmQZoCD2K4WNrV6aZI= +github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866 h1:ThRTXD/EyoLb/jz+YW+ZlOLbjX9FyaxP0dEpgUp3cCE= +github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866/go.mod h1:bORAHrH6hUtDZjbzTEaLrSpTdyhHKDIpjDRT+A14B7w= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY= diff --git a/go.mod b/go.mod index b83143f9bb1..159bbd3e4fd 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/google/uuid v1.3.0 github.com/hashicorp/go-multierror v1.1.1 - github.com/ipfs/boxo v0.8.1 + github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866 github.com/ipfs/go-block-format v0.1.2 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-cidutil v0.1.0 diff --git a/go.sum b/go.sum index b00e5aed63f..16d312ef5d7 100644 --- a/go.sum +++ b/go.sum @@ -356,8 +356,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.8.1 h1:3DkKBCK+3rdEB5t77WDShUXXhktYwH99mkAsgajsKrU= -github.com/ipfs/boxo v0.8.1/go.mod h1:xJ2hVb4La5WyD7GvKYE0lq2g1rmQZoCD2K4WNrV6aZI= +github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866 h1:ThRTXD/EyoLb/jz+YW+ZlOLbjX9FyaxP0dEpgUp3cCE= +github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866/go.mod h1:bORAHrH6hUtDZjbzTEaLrSpTdyhHKDIpjDRT+A14B7w= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=