From 0d7c892cecd81eed22ce141608df698ba6902b78 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 15 Feb 2023 15:31:54 +0100 Subject: [PATCH 01/12] test: use car fixtures in sharness t0117 --- test/sharness/t0117-gateway-block.sh | 11 +++++----- test/sharness/t0117-gateway-block/README.md | 20 ++++++++++++++++++ .../sharness/t0117-gateway-block/fixtures.car | Bin 0 -> 309 bytes 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 test/sharness/t0117-gateway-block/README.md create mode 100644 test/sharness/t0117-gateway-block/fixtures.car diff --git a/test/sharness/t0117-gateway-block.sh b/test/sharness/t0117-gateway-block.sh index 5f1d080a3d4..d5e40bb830b 100755 --- a/test/sharness/t0117-gateway-block.sh +++ b/test/sharness/t0117-gateway-block.sh @@ -7,12 +7,13 @@ test_description="Test HTTP Gateway Raw Block (application/vnd.ipld.raw) Support test_init_ipfs test_launch_ipfs_daemon_without_network -test_expect_success "Create text fixtures" ' - mkdir -p dir && - echo "hello application/vnd.ipld.raw" > dir/ascii.txt && - ROOT_DIR_CID=$(ipfs add -Qrw --cid-version 1 dir) && - FILE_CID=$(ipfs resolve -r /ipfs/$ROOT_DIR_CID/dir/ascii.txt | cut -d "/" -f3) +# Import test case +# See the static fixtures in ./t0117-gateway-block/ +test_expect_success "Add the dir test directory" ' + ipfs dag import ../t0117-gateway-block/fixtures.car ' +ROOT_DIR_CID=bafybeie72edlprgtlwwctzljf6gkn2wnlrddqjbkxo3jomh4n7omwblxly # ./ +FILE_CID=bafkreihhpc5y2pqvl5rbe5uuyhqjouybfs3rvlmisccgzue2kkt5zq6upq # ./dir/ascii.txt # GET unixfs dir root block and compare it with `ipfs block get` output diff --git a/test/sharness/t0117-gateway-block/README.md b/test/sharness/t0117-gateway-block/README.md new file mode 100644 index 00000000000..8ca237345a7 --- /dev/null +++ b/test/sharness/t0117-gateway-block/README.md @@ -0,0 +1,20 @@ +# Dataset description/sources + +- fixtures.car + - raw CARv1 + +generated with: + +```sh +mkdir -p dir && +echo "hello application/vnd.ipld.raw" > dir/ascii.txt && +ROOT_DIR_CID=$(ipfs add -Qrw --cid-version 1 dir) && +FILE_CID=$(ipfs resolve -r /ipfs/$ROOT_DIR_CID/dir/ascii.txt | cut -d "/" -f3) && +ipfs dag export $ROOT_DIR_CID > fixtures.car + +echo ROOT_DIR_CID=${ROOT_DIR_CID} # ./ +echo FILE_CID=${FILE_CID} # ./dir/ascii.txt + +# ROOT_DIR_CID=bafybeie72edlprgtlwwctzljf6gkn2wnlrddqjbkxo3jomh4n7omwblxly # ./ +# FILE_CID=bafkreihhpc5y2pqvl5rbe5uuyhqjouybfs3rvlmisccgzue2kkt5zq6upq # ./dir/ascii.txt +``` diff --git a/test/sharness/t0117-gateway-block/fixtures.car b/test/sharness/t0117-gateway-block/fixtures.car new file mode 100644 index 0000000000000000000000000000000000000000..77da1b5542e281eb1c80a4a8763c85bd7424b60b GIT binary patch literal 309 zcmcColveYNahp`Ifpb-g~vLz*Snd z?RAF`b4q5BLWzWsh6*V>uh`vdCmNq5R5s<{gXzJHI@_hzc1&o=xiBke z`JKa8YJ@lwi<2`m^-3yAB;-M+I}@WTBQ+-{Um>xeASW|9u>|N@{j$6iz087~6uqLv GaxMV9-hqPv literal 0 HcmV?d00001 From 64ccdbd6f26bcd0c24a27d209b662b1fbe80648c Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 15 Feb 2023 15:43:03 +0100 Subject: [PATCH 02/12] test: use car fixtures in sharness t0113 --- test/sharness/t0113-gateway-symlink.sh | 20 +++++++----------- test/sharness/t0113-gateway-symlink/README.md | 16 ++++++++++++++ .../t0113-gateway-symlink/testfiles.car | Bin 0 -> 282 bytes 3 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 test/sharness/t0113-gateway-symlink/README.md create mode 100644 test/sharness/t0113-gateway-symlink/testfiles.car diff --git a/test/sharness/t0113-gateway-symlink.sh b/test/sharness/t0113-gateway-symlink.sh index 9fa7ffa6edf..ea85b815000 100755 --- a/test/sharness/t0113-gateway-symlink.sh +++ b/test/sharness/t0113-gateway-symlink.sh @@ -9,26 +9,22 @@ test_description="Test symlink support on the HTTP gateway" test_init_ipfs test_launch_ipfs_daemon - -test_expect_success "Create a test directory with symlinks" ' - mkdir testfiles && - echo "content" > testfiles/foo && - ln -s foo testfiles/bar && - test_cmp testfiles/foo testfiles/bar -' - -test_expect_success "Add the test directory" ' - HASH=$(ipfs add -Qr testfiles) +# Import test case +# See the static fixtures in ./t0113-gateway-symlink/ +test_expect_success "Add the test directory with symlinks" ' + ipfs dag import ../t0113-gateway-symlink/testfiles.car ' +ROOT_DIR_CID=QmWvY6FaqFMS89YAQ9NAPjVP4WZKA1qbHbicc9HeSKQTgt # ./testfiles/ test_expect_success "Test the directory listing" ' - curl "$GWAY_ADDR/ipfs/$HASH/" > list_response && + curl "$GWAY_ADDR/ipfs/$ROOT_DIR_CID/" > list_response && test_should_contain ">foo<" list_response && test_should_contain ">bar<" list_response ' +# TODO: it's unclear to me if that `echo -n "foo" > expected` should be a fixture somehow. test_expect_success "Test the symlink" ' - curl "$GWAY_ADDR/ipfs/$HASH/bar" > bar_actual && + curl "$GWAY_ADDR/ipfs/$ROOT_DIR_CID/bar" > bar_actual && echo -n "foo" > bar_expected && test_cmp bar_expected bar_actual ' diff --git a/test/sharness/t0113-gateway-symlink/README.md b/test/sharness/t0113-gateway-symlink/README.md new file mode 100644 index 00000000000..350405e321b --- /dev/null +++ b/test/sharness/t0113-gateway-symlink/README.md @@ -0,0 +1,16 @@ +# Dataset description/sources + +- testfiles.car + - raw CARv1 + +generated with: + +```sh +mkdir testfiles && +echo "content" > testfiles/foo && +ln -s foo testfiles/bar && +ROOT_DIR_CID=$(ipfs add -Qr testfiles) && +ipfs dag export $ROOT_DIR_CID > testfiles.car + +# ROOT_DIR_CID=QmWvY6FaqFMS89YAQ9NAPjVP4WZKA1qbHbicc9HeSKQTgt +``` diff --git a/test/sharness/t0113-gateway-symlink/testfiles.car b/test/sharness/t0113-gateway-symlink/testfiles.car new file mode 100644 index 0000000000000000000000000000000000000000..88e5825f3029ceb158138812c946825544704d26 GIT binary patch literal 282 zcmcCmlvG!RGgWg$JoF~Sh0{cmy(cz`^^ncIdY^b8_T#q9k%X>mgtKR@Vd1l;Qez>Zf=ID z2|~NuBOwJsCUfy|FbQ!a=jWBA=9O?sZ~y=yG;7fS literal 0 HcmV?d00001 From 771d62c8f4877b12ed0074a5186f5cc2a33be888 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 15 Feb 2023 16:00:05 +0100 Subject: [PATCH 03/12] test: use car fixtures in sharness t0114 --- test/sharness/t0114-gateway-subdomains.sh | 32 ++++------- .../t0114-gateway-subdomains/README.md | 52 ++++++++++++++++++ .../t0114-gateway-subdomains/fixtures.car | Bin 0 -> 1518 bytes 3 files changed, 63 insertions(+), 21 deletions(-) create mode 100644 test/sharness/t0114-gateway-subdomains/README.md create mode 100644 test/sharness/t0114-gateway-subdomains/fixtures.car diff --git a/test/sharness/t0114-gateway-subdomains.sh b/test/sharness/t0114-gateway-subdomains.sh index a7e5a59c938..04f762ad68e 100755 --- a/test/sharness/t0114-gateway-subdomains.sh +++ b/test/sharness/t0114-gateway-subdomains.sh @@ -91,27 +91,19 @@ test_expect_success "ipfs init" ' 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 -test_expect_success "Add test text file" ' - CID_VAL="hello" - CIDv1=$(echo $CID_VAL | ipfs add --cid-version 1 -Q) - CIDv0=$(echo $CID_VAL | ipfs add --cid-version 0 -Q) - CIDv0to1=$(echo "$CIDv0" | ipfs cid base32) - echo CIDv0to1=${CIDv0to1} -' - -# Directory tree crafted to test for edge cases like "/ipfs/ipfs/ipns/bar" -test_expect_success "Add the test directory" ' - mkdir -p testdirlisting/ipfs/ipns && - echo "hello" > testdirlisting/hello && - echo "text-file-content" > testdirlisting/ipfs/ipns/bar && - mkdir -p testdirlisting/api && - mkdir -p testdirlisting/ipfs && - 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) -' +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") @@ -600,8 +592,6 @@ test_expect_success \ 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") -# 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) # local: *.localhost test_localhost_gateway_response_should_contain \ diff --git a/test/sharness/t0114-gateway-subdomains/README.md b/test/sharness/t0114-gateway-subdomains/README.md new file mode 100644 index 00000000000..8f0075ccd7e --- /dev/null +++ b/test/sharness/t0114-gateway-subdomains/README.md @@ -0,0 +1,52 @@ +# Dataset description/sources + +- fixtures.car + - raw CARv1 + +generated with: + +```sh +# CIDv0to1 is necessary because raw-leaves are enabled by default during +# "ipfs add" with CIDv1 and disabled with CIDv0 +CID_VAL="hello" +CIDv1=$(echo $CID_VAL | ipfs add --cid-version 1 -Q) +CIDv0=$(echo $CID_VAL | ipfs add --cid-version 0 -Q) +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 CIDv1=${CIDv1} +echo CIDv0=${CIDv0} +echo CIDv0to1=${CIDv0to1} +echo CIDv1_TOO_LONG=${CIDv1_TOO_LONG} + +# Directory tree crafted to test for edge cases like "/ipfs/ipfs/ipns/bar" +mkdir -p testdirlisting/ipfs/ipns && +echo "hello" > testdirlisting/hello && +echo "text-file-content" > testdirlisting/ipfs/ipns/bar && +mkdir -p testdirlisting/api && +mkdir -p testdirlisting/ipfs && +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} + +ipfs files mkdir /t0114/ +ipfs files cp /ipfs/${CIDv1} /t0114/ +ipfs files cp /ipfs/${CIDv0} /t0114/ +ipfs files cp /ipfs/${CIDv0to1} /t0114/ +ipfs files cp /ipfs/${DIR_CID} /t0114/ +ipfs files cp /ipfs/${CIDv1_TOO_LONG} /t0114/ + +ROOT=`ipfs files stat /t0114/ --hash` + +ipfs dag export ${ROOT} > ./fixtures.car + +# CID_VAL="hello" +# CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am +# CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN +# CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4 +# CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs +# DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting +``` diff --git a/test/sharness/t0114-gateway-subdomains/fixtures.car b/test/sharness/t0114-gateway-subdomains/fixtures.car new file mode 100644 index 0000000000000000000000000000000000000000..bc7b913dfa27573c76673744a7d15df6a885e891 GIT binary patch literal 1518 zcmb`GeQXnD9LKqJF0;ypXM$%)qznuxqXXLO6<<(B>E0+~lC3KP)VtnuFTJ<6&-Jc% zAZ8emC~AekvSdRu6%$2pDmVyKbW4oUh*Ouak!YMEFO$(kV@4F?-TIe*wK4wxe1E_1 z_w)Tds|P?zQB>G{VOezX9MmN~(GT9Z{qdnmvbArh-#syZWbfg+Tan$T4@h55eY@f; ztAP~c6&blvUi>i{an_)&H@Tn7FI=1Wb${3JnFYlCebrK8&fHYrI5rZ0MrqbM(YnW^ zu8yz}42300@JCyjAlohnjRv+pl3BNTUDR0L)Y!N&qJ$g5d^FUGRiVJS1nEFs(N|8K zs2TgAQmW1m&iixxn*|^Km5d$7zuvuP;7Y?EIS2X>MKVGP@G%3jUZ240nhyu8mkuO# zz$Y@g0%^sYFmRF9aIZ{}X*MmUf$Y}^Qo<_GA;h^J>9~9C_)FH>jS%Uy6m6hZq5P>0cx{A{x167X4IXPgm9G=!hNcl5z z%n(d6!TXdLjfVQ>ldKqnmUWv@q6GFfA%g-u!^kuw<2on! zL_H34oz5g>Rf_#$dF}$EKoWDMP0zHBACLO-}0A%ME6Wp7|2ub%9_vC zUORPPXk=Gza3*{G?e`WvFk6JZhEoYz)vX->2DGF^@Ki!GiDW|Ic-o4|LB>c0M8A|U zAgy~fiJ~}wz2-oNnG5tU7n~W9Hr?-NQS^b33-9l?*R}IyIwW^X%ccU0^X$ zvx}5mq{|YyY_)UWEX<-I{(~j7t^mm0H@&Is{G{{mu_pNH>0R@m?J@7lwGC|;xu>Q5 zokxEewE@Wx3)vAmZ9YW>cC%L0g@>Q_W*sNTZUpY|gtsF3{I*8<`0M+oyE~6==;=-O cqYjEpVW>TqDCNBhGOEXh;)yA;3S`y!570JmG5`Po literal 0 HcmV?d00001 From 8641d16a2b3acec0d5ff84ae9bbcbaa14ad6f436 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Thu, 16 Feb 2023 10:23:37 +0100 Subject: [PATCH 04/12] test: use car fixtures in sharness t0115 --- test/sharness/t0115-gateway-dir-listing.sh | 18 ++++------ .../t0115-gateway-dir-listing/README.md | 31 ++++++++++++++++++ .../t0115-gateway-dir-listing/fixtures.car | Bin 0 -> 1053 bytes 3 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 test/sharness/t0115-gateway-dir-listing/README.md create mode 100644 test/sharness/t0115-gateway-dir-listing/fixtures.car diff --git a/test/sharness/t0115-gateway-dir-listing.sh b/test/sharness/t0115-gateway-dir-listing.sh index 708e0c4cf8b..cf95bf4b05e 100755 --- a/test/sharness/t0115-gateway-dir-listing.sh +++ b/test/sharness/t0115-gateway-dir-listing.sh @@ -18,20 +18,14 @@ test_expect_success "ipfs init" ' test_launch_ipfs_daemon_without_network +# Import test case +# See the static fixtures in ./t0115-gateway-dir-listing/ test_expect_success "Add the test directory" ' - mkdir -p rootDir/ipfs && - mkdir -p rootDir/ipns && - mkdir -p rootDir/api && - mkdir -p rootDir/ą/ę && - echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt && - echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt && - echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt && - echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt && - DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) && - FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) && - FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size) - echo "$FILE_CID / $FILE_SIZE" + ipfs dag import ../t0115-gateway-dir-listing/fixtures.car ' +DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir/ +FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt +FILE_SIZE=34 ## ============================================================================ ## Test dir listing on path gateway (eg. 127.0.0.1:8080/ipfs/) diff --git a/test/sharness/t0115-gateway-dir-listing/README.md b/test/sharness/t0115-gateway-dir-listing/README.md new file mode 100644 index 00000000000..8b6e332750d --- /dev/null +++ b/test/sharness/t0115-gateway-dir-listing/README.md @@ -0,0 +1,31 @@ +# Dataset description/sources + +- fixtures.car + - raw CARv1 + +generated with: + +```sh +mkdir -p rootDir/ipfs && +mkdir -p rootDir/ipns && +mkdir -p rootDir/api && +mkdir -p rootDir/ą/ę && +echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt && +echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt && +echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt && +echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt && +DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) && +FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) && +FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size) +echo "$FILE_CID / $FILE_SIZE" + +echo DIR_CID=${DIR_CID} +echo FILE_CID=${FILE_CID} +echo FILE_SIZE=${FILE_SIZE} + +ipfs dag export ${DIR_CID} > ./fixtures.car + +# DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir/ +# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt +# FILE_SIZE=34 +``` diff --git a/test/sharness/t0115-gateway-dir-listing/fixtures.car b/test/sharness/t0115-gateway-dir-listing/fixtures.car new file mode 100644 index 0000000000000000000000000000000000000000..71a5603822741f25320438bd70823589120e313c GIT binary patch literal 1053 zcmcColvR$Z!{1TqeSN@tUjjg{Tlgc7mrAdS5w!gPn*17KH6I(#F3Vnld4xzQ6ixRGTe(8O`Zyg zxeAF2KuroD-3pm`3d#9-X{E)PdFcxJz;IJY$t>amyOUtJLEZWM>i;({85gv-W(d_V zKa@*2eN@-d)vWbj%$Z-NzS6vINbXbzxziiuPC}aSyAu>)2!|4kFsMU?&s>>u#q@K) zg=4JD+Ddu%u4<)wm#M_8IM$cG*3(nQFic@T$&fnuIuO3{I&*k2EHJEuD( zXEu8GPP(?~NTtQ!*2R(r|4!eUF1UKJ@frzWikc}A4+_gfkg)`nn?n*5x8rrT>037M zkdg1bF*9{rSzCT(#hs2>E#m S1&JjY3gwwVqO>H Date: Mon, 20 Feb 2023 15:57:38 +0100 Subject: [PATCH 05/12] test: fix prometheus test folder path --- .../prometheus_metrics | 0 .../prometheus_metrics_added_by_enabling_rcmgr | 0 test/sharness/t0119-prometheus.sh | 6 +++--- 3 files changed, 3 insertions(+), 3 deletions(-) rename test/sharness/{t0116-prometheus-data => t0119-prometheus-data}/prometheus_metrics (100%) rename test/sharness/{t0116-prometheus-data => t0119-prometheus-data}/prometheus_metrics_added_by_enabling_rcmgr (100%) diff --git a/test/sharness/t0116-prometheus-data/prometheus_metrics b/test/sharness/t0119-prometheus-data/prometheus_metrics similarity index 100% rename from test/sharness/t0116-prometheus-data/prometheus_metrics rename to test/sharness/t0119-prometheus-data/prometheus_metrics diff --git a/test/sharness/t0116-prometheus-data/prometheus_metrics_added_by_enabling_rcmgr b/test/sharness/t0119-prometheus-data/prometheus_metrics_added_by_enabling_rcmgr similarity index 100% rename from test/sharness/t0116-prometheus-data/prometheus_metrics_added_by_enabling_rcmgr rename to test/sharness/t0119-prometheus-data/prometheus_metrics_added_by_enabling_rcmgr diff --git a/test/sharness/t0119-prometheus.sh b/test/sharness/t0119-prometheus.sh index e96b8b96f8a..3387f4feb3b 100755 --- a/test/sharness/t0119-prometheus.sh +++ b/test/sharness/t0119-prometheus.sh @@ -27,7 +27,7 @@ test_expect_success "filter metrics" ' ' test_expect_success "make sure metrics haven't changed" ' - diff -u ../t0116-prometheus-data/prometheus_metrics filtered_metrics + diff -u ../t0119-prometheus-data/prometheus_metrics filtered_metrics ' # Check what was added by enabling ResourceMgr.Enabled @@ -50,11 +50,11 @@ test_kill_ipfs_daemon test_expect_success "filter metrics and find ones added by enabling ResourceMgr" ' sed -ne "s/^\([a-z0-9_]\+\).*/\1/p" raw_metrics | LC_ALL=C sort > filtered_metrics && - grep -v -x -f ../t0116-prometheus-data/prometheus_metrics filtered_metrics > rcmgr_metrics + grep -v -x -f ../t0119-prometheus-data/prometheus_metrics filtered_metrics > rcmgr_metrics ' test_expect_success "make sure initial metrics added by setting ResourceMgr.Enabled haven't changed" ' - diff -u ../t0116-prometheus-data/prometheus_metrics_added_by_enabling_rcmgr rcmgr_metrics + diff -u ../t0119-prometheus-data/prometheus_metrics_added_by_enabling_rcmgr rcmgr_metrics ' test_done From 284bb8c819fbd8d50e757f733957980c183855b0 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 20 Feb 2023 16:04:16 +0100 Subject: [PATCH 06/12] test: use car fixtures in sharness t0116 --- test/sharness/t0116-gateway-cache.sh | 15 +++++---- test/sharness/t0116-gateway-cache/README.md | 30 ++++++++++++++++++ .../sharness/t0116-gateway-cache/fixtures.car | Bin 0 -> 468 bytes 3 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 test/sharness/t0116-gateway-cache/README.md create mode 100644 test/sharness/t0116-gateway-cache/fixtures.car diff --git a/test/sharness/t0116-gateway-cache.sh b/test/sharness/t0116-gateway-cache.sh index 0af4ec0eb71..508fc73c288 100755 --- a/test/sharness/t0116-gateway-cache.sh +++ b/test/sharness/t0116-gateway-cache.sh @@ -25,15 +25,16 @@ 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" ' - mkdir -p root2/root3/root4 && - echo "hello" > root2/root3/root4/index.html && - ROOT1_CID=$(ipfs add -Qrw --cid-version 1 root2) - ROOT2_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2 | cut -d "/" -f3) - 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) + 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_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") diff --git a/test/sharness/t0116-gateway-cache/README.md b/test/sharness/t0116-gateway-cache/README.md new file mode 100644 index 00000000000..91c4389418d --- /dev/null +++ b/test/sharness/t0116-gateway-cache/README.md @@ -0,0 +1,30 @@ +# Dataset description/sources + +- fixtures.car + - raw CARv1 + +generated with: + +```sh +mkdir -p root2/root3/root4 && +echo "hello" > root2/root3/root4/index.html && +ROOT1_CID=$(ipfs add -Qrw --cid-version 1 root2) +ROOT2_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2 | cut -d "/" -f3) +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} + +ipfs dag export ${ROOT1_CID} > ./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 +``` diff --git a/test/sharness/t0116-gateway-cache/fixtures.car b/test/sharness/t0116-gateway-cache/fixtures.car new file mode 100644 index 0000000000000000000000000000000000000000..43e570e1d6acb0a03531b47feb540318f5027204 GIT binary patch literal 468 zcmcColvx?P5~W2SVzij7-;r*+x4)dz{ z2?vnLaUeGn)L{a2bEuF)#Kf&zm9F0B$mRdAQQ-H@OVV5Z6eh1XxzN Date: Mon, 20 Feb 2023 16:13:17 +0100 Subject: [PATCH 07/12] test: use car fixtures in sharness t0118 --- test/sharness/t0118-gateway-car.sh | 17 ++++++++-------- test/sharness/t0118-gateway-car/README.md | 19 ++++++++++++++++++ .../t0118-gateway-car/deterministic.car | Bin 0 -> 127 bytes .../t0118-gateway-car/subdir/ascii.txt | 1 + test/sharness/t0118-gateway-car/test-dag.car | Bin 0 -> 312 bytes 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 test/sharness/t0118-gateway-car/deterministic.car create mode 100644 test/sharness/t0118-gateway-car/subdir/ascii.txt create mode 100644 test/sharness/t0118-gateway-car/test-dag.car diff --git a/test/sharness/t0118-gateway-car.sh b/test/sharness/t0118-gateway-car.sh index 62b2725d0cd..7b7d998eef8 100755 --- a/test/sharness/t0118-gateway-car.sh +++ b/test/sharness/t0118-gateway-car.sh @@ -11,15 +11,14 @@ test_launch_ipfs_daemon_without_network # but if we have a small file that fits into a single block, and export its CID # we will get a CAR that is a deterministic array of bytes. - test_expect_success "Create a deterministic CAR for testing" ' - mkdir -p subdir && - echo "hello application/vnd.ipld.car" > subdir/ascii.txt && - ROOT_DIR_CID=$(ipfs add -Qrw --cid-version 1 subdir) && - FILE_CID=$(ipfs resolve -r /ipfs/$ROOT_DIR_CID/subdir/ascii.txt | cut -d "/" -f3) && - ipfs dag export $ROOT_DIR_CID > test-dag.car && - ipfs dag export $FILE_CID > deterministic.car && - purge_blockstore - ' +# Import test case +# See the static fixtures in ./t0118-gateway-car/ +test_expect_success "Add the dir test directory" ' + cp ../t0118-gateway-car/test-dag.car ./test-dag.car && + cp ../t0118-gateway-car/deterministic.car ./deterministic.car +' +ROOT_DIR_CID=bafybeiefu3d7oytdumk5v7gn6s7whpornueaw7m7u46v2o6omsqcrhhkzi # ./ +FILE_CID=bafkreifkam6ns4aoolg3wedr4uzrs3kvq66p4pecirz6y2vlrngla62mxm # /subdir/ascii.txt # GET a reference DAG with dag-cbor+dag-pb+raw blocks as CAR diff --git a/test/sharness/t0118-gateway-car/README.md b/test/sharness/t0118-gateway-car/README.md index 2efccc18544..f19494833c5 100644 --- a/test/sharness/t0118-gateway-car/README.md +++ b/test/sharness/t0118-gateway-car/README.md @@ -8,3 +8,22 @@ - description of the contents and layout of the raw CAR, encoded in DAG-JSON - Source: https://ipld.io/specs/transport/car/fixture/carv1-basic/carv1-basic.json +- test-dag.car + deterministic.car + - raw CARv1 + +generated with: + +```shell +mkdir -p subdir && +echo "hello application/vnd.ipld.car" > subdir/ascii.txt && +ROOT_DIR_CID=$(ipfs add -Qrw --cid-version 1 subdir) && +FILE_CID=$(ipfs resolve -r /ipfs/$ROOT_DIR_CID/subdir/ascii.txt | cut -d "/" -f3) && +ipfs dag export $ROOT_DIR_CID > test-dag.car && +ipfs dag export $FILE_CID > deterministic.car && + +echo ROOT_DIR_CID=${ROOT_DIR_CID} # ./ +echo FILE_CID=${FILE_CID} # /\subdir/ascii.txt + +# ROOT_DIR_CID=bafybeiefu3d7oytdumk5v7gn6s7whpornueaw7m7u46v2o6omsqcrhhkzi # ./ +# FILE_CID=bafkreifkam6ns4aoolg3wedr4uzrs3kvq66p4pecirz6y2vlrngla62mxm # /subdir/ascii.txt +``` diff --git a/test/sharness/t0118-gateway-car/deterministic.car b/test/sharness/t0118-gateway-car/deterministic.car new file mode 100644 index 0000000000000000000000000000000000000000..3967f909dce9b45cc3109ef1bccb0febfaf3c964 GIT binary patch literal 127 zcmcColvurnv%3WfpBhW%hPLndXVc_T{3dI4x6g)Z xpWW$YsYS(^`FV`a#Hh|l&B@7ENGvGG$xKcx0cz7P%S+MAEXYaGOHM4}0stv?G@1Ya literal 0 HcmV?d00001 diff --git a/test/sharness/t0118-gateway-car/subdir/ascii.txt b/test/sharness/t0118-gateway-car/subdir/ascii.txt new file mode 100644 index 00000000000..a2f1a843bba --- /dev/null +++ b/test/sharness/t0118-gateway-car/subdir/ascii.txt @@ -0,0 +1 @@ +hello application/vnd.ipld.car diff --git a/test/sharness/t0118-gateway-car/test-dag.car b/test/sharness/t0118-gateway-car/test-dag.car new file mode 100644 index 0000000000000000000000000000000000000000..e80fa4b0756cb7c9f5ebc44242424506fb7283cb GIT binary patch literal 312 zcmcColv^5u?@7svMQ{B%`(=Of-ix^$+_m$U+s0a-OIe^X z=hdn7vecsD%=|pYC}LC#8E~n9)Saw+P!{lU+i#stX^z~mrGeJ6Qa_#6abJ&?`ByJ= zomD}It++HPC9_B(f{TfRF_tJT#z3P(g%nmX+uSVRD>}Pdpzx`&WNv8to_{t?F2!%M zR(JbssP@?{#FH}E7+o2uIXU?Xi3J5YnaPPIK>zBO<)!Fl7UZPp JB_|ef0RZo3fVKbt literal 0 HcmV?d00001 From a57ca965c1c6923efb7b11134dc6fc92d10960fa Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 20 Feb 2023 16:17:50 +0100 Subject: [PATCH 08/12] test: use car fixtures in sharness t0122 --- test/sharness/t0122-gateway-tar.sh | 22 ++++------- test/sharness/t0122-gateway-tar/README.md | 37 ++++++++++++++++++ test/sharness/t0122-gateway-tar/fixtures.car | Bin 0 -> 1053 bytes .../inside-root.car | Bin .../outside-root.car | Bin 5 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 test/sharness/t0122-gateway-tar/README.md create mode 100644 test/sharness/t0122-gateway-tar/fixtures.car rename test/sharness/{t0122-gateway-tar-data => t0122-gateway-tar}/inside-root.car (100%) rename test/sharness/{t0122-gateway-tar-data => t0122-gateway-tar}/outside-root.car (100%) diff --git a/test/sharness/t0122-gateway-tar.sh b/test/sharness/t0122-gateway-tar.sh index 34dc1ba12c8..20cc1bf4cdc 100755 --- a/test/sharness/t0122-gateway-tar.sh +++ b/test/sharness/t0122-gateway-tar.sh @@ -10,20 +10,14 @@ test_launch_ipfs_daemon_without_network OUTSIDE_ROOT_CID="bafybeicaj7kvxpcv4neaqzwhrqqmdstu4dhrwfpknrgebq6nzcecfucvyu" INSIDE_ROOT_CID="bafybeibfevfxlvxp5vxobr5oapczpf7resxnleb7tkqmdorc4gl5cdva3y" +# Import test case +# See the static fixtures in ./t0122-gateway-tar/ test_expect_success "Add the test directory" ' - mkdir -p rootDir/ipfs && - mkdir -p rootDir/ipns && - mkdir -p rootDir/api && - mkdir -p rootDir/ą/ę && - echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt && - echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt && - echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt && - echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt && - DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) && - FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) && - FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size) - echo "$FILE_CID / $FILE_SIZE" + ipfs dag import ../t0122-gateway-tar/fixtures.car ' +DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir +FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt +FILE_SIZE=34 test_expect_success "GET TAR with format=tar and extract" ' curl "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=tar" | tar -x @@ -69,9 +63,9 @@ test_expect_success "GET TAR with explicit ?filename= succeeds with modified Con " test_expect_success "Add CARs with relative paths to test with" ' - ipfs dag import ../t0122-gateway-tar-data/outside-root.car > import_output && + ipfs dag import ../t0122-gateway-tar/outside-root.car > import_output && test_should_contain $OUTSIDE_ROOT_CID import_output && - ipfs dag import ../t0122-gateway-tar-data/inside-root.car > import_output && + ipfs dag import ../t0122-gateway-tar/inside-root.car > import_output && test_should_contain $INSIDE_ROOT_CID import_output ' diff --git a/test/sharness/t0122-gateway-tar/README.md b/test/sharness/t0122-gateway-tar/README.md new file mode 100644 index 00000000000..8b9311277cc --- /dev/null +++ b/test/sharness/t0122-gateway-tar/README.md @@ -0,0 +1,37 @@ +# Dataset description/sources + +- inside-root.car + +- outside-root.car + +- fixtures.car + - raw CARv1 + +generated with: + +```sh +# ipfs version 0.18.1 + +mkdir -p rootDir/ipfs && +mkdir -p rootDir/ipns && +mkdir -p rootDir/api && +mkdir -p rootDir/ą/ę && +echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt && +echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt && +echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt && +echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt && +DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) && +FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) && +FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size) +echo "$FILE_CID / $FILE_SIZE" + +echo DIR_CID=${DIR_CID} # ./rootDir +echo FILE_CID=${FILE_CID} # ./rootDir/ą/ę/file-źł.txt +echo FILE_SIZE=${FILE_SIZE} + +ipfs dag export ${DIR_CID} > ./fixtures.car + +# DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir +# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt +# FILE_SIZE=34 +``` diff --git a/test/sharness/t0122-gateway-tar/fixtures.car b/test/sharness/t0122-gateway-tar/fixtures.car new file mode 100644 index 0000000000000000000000000000000000000000..71a5603822741f25320438bd70823589120e313c GIT binary patch literal 1053 zcmcColvR$Z!{1TqeSN@tUjjg{Tlgc7mrAdS5w!gPn*17KH6I(#F3Vnld4xzQ6ixRGTe(8O`Zyg zxeAF2KuroD-3pm`3d#9-X{E)PdFcxJz;IJY$t>amyOUtJLEZWM>i;({85gv-W(d_V zKa@*2eN@-d)vWbj%$Z-NzS6vINbXbzxziiuPC}aSyAu>)2!|4kFsMU?&s>>u#q@K) zg=4JD+Ddu%u4<)wm#M_8IM$cG*3(nQFic@T$&fnuIuO3{I&*k2EHJEuD( zXEu8GPP(?~NTtQ!*2R(r|4!eUF1UKJ@frzWikc}A4+_gfkg)`nn?n*5x8rrT>037M zkdg1bF*9{rSzCT(#hs2>E#m S1&JjY3gwwVqO>H Date: Mon, 20 Feb 2023 16:24:57 +0100 Subject: [PATCH 09/12] test: use car fixtures in sharness t0123 --- test/sharness/t0123-gateway-json-cbor.sh | 21 +++------ .../t0123-gateway-json-cbor/README.md | 43 ++++++++++++++++++ .../t0123-gateway-json-cbor/fixtures.car | Bin 0 -> 1179 bytes 3 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 test/sharness/t0123-gateway-json-cbor/README.md create mode 100644 test/sharness/t0123-gateway-json-cbor/fixtures.car diff --git a/test/sharness/t0123-gateway-json-cbor.sh b/test/sharness/t0123-gateway-json-cbor.sh index 704d075f940..b22c056de78 100755 --- a/test/sharness/t0123-gateway-json-cbor.sh +++ b/test/sharness/t0123-gateway-json-cbor.sh @@ -7,22 +7,15 @@ test_description="Test HTTP Gateway DAG-JSON (application/vnd.ipld.dag-json) and test_init_ipfs test_launch_ipfs_daemon_without_network +# Import test case +# See the static fixtures in ./t0123-gateway-json-cbor/ test_expect_success "Add the test directory" ' - mkdir -p rootDir/ipfs && - mkdir -p rootDir/ipns && - mkdir -p rootDir/api && - mkdir -p rootDir/ą/ę && - echo "{ \"test\": \"i am a plain json file\" }" > rootDir/ą/ę/t.json && - echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt && - echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt && - echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt && - echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt && - DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) && - FILE_JSON_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/t.json | jq -r .Hash) && - FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) && - FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size) - echo "$FILE_CID / $FILE_SIZE" + ipfs dag import ../t0123-gateway-json-cbor/fixtures.car ' +DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir +FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json +FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt +FILE_SIZE=34 ## Quick regression check for JSON stored on UnixFS: ## it has nothing to do with DAG-JSON and JSON codecs, diff --git a/test/sharness/t0123-gateway-json-cbor/README.md b/test/sharness/t0123-gateway-json-cbor/README.md new file mode 100644 index 00000000000..0d9f0e1e196 --- /dev/null +++ b/test/sharness/t0123-gateway-json-cbor/README.md @@ -0,0 +1,43 @@ +# Dataset description/sources + +- dag-cbor-traversal.car + +- dag-json-traversal.car + +- dag-pb.car + +- dag-pb.json + +- fixtures.car + - raw CARv1 + +generated with: + +```sh +mkdir -p rootDir/ipfs && +mkdir -p rootDir/ipns && +mkdir -p rootDir/api && +mkdir -p rootDir/ą/ę && +echo "{ \"test\": \"i am a plain json file\" }" > rootDir/ą/ę/t.json && +echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt && +echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt && +echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt && +echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt && +DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) && +FILE_JSON_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/t.json | jq -r .Hash) && +FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) && +FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size) +echo "$FILE_CID / $FILE_SIZE" + +echo DIR_CID=${DIR_CID} # ./rootDir +echo FILE_JSON_CID=${FILE_JSON_CID} # ./rootDir/ą/ę/t.json +echo FILE_CID=${FILE_CID} # ./rootDir/ą/ę/file-źł.txt +echo FILE_SIZE=${FILE_SIZE} + +ipfs dag export ${DIR_CID} > fixtures.car + +# DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir +# FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json +# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt +# FILE_SIZE=34 +``` diff --git a/test/sharness/t0123-gateway-json-cbor/fixtures.car b/test/sharness/t0123-gateway-json-cbor/fixtures.car new file mode 100644 index 0000000000000000000000000000000000000000..8663730f2fed608271d33fd2e205c68d544e89b7 GIT binary patch literal 1179 zcmcColvR$Z!{1Tq}`!({@E*_B@ucod~pEh~Fe6+Vnh$AgCCsnVcqC`RsWVjbGnmiQ} za}^R5fSMFQx)n0>6q57v(n^an^U@Xcf#If*l3BzBb|=AbgSzwi)&Fl^GA?Lu%@C?# zekhl4`lzm@t6A&6m@~gjeWiKbkld*ba;G=QorE;ucPA*q5Dq06VNiz(pSd#Sis|Qo z3&&WQwUzSjUDZnWE>nqFajY+Wv%U0UCaex6q=}G2^B@il2gN+Wlmbmr3p)>Tspfra zzuq^&%Z+8;aog1@_L@tNFW#`M%_oCfEfAQZW=d=Wr>M!`oI_B9IV4GOJ6>m-zGd?c z8TsBDGgG&fwdGf4EPLy4gI8MqnXLZyU?E;mqR>6M>u3`=T`36}Kr|XwU!0k9pY`dI z-dtbCS2N$ly#8A6{kLABvd8AnvB?FELTn{^S;hHz5~`pWb_2yQA-m86EKFpafyI_VZ5QMu0#h}}HQ*$!q)^KR00zs~cmMzZ literal 0 HcmV?d00001 From 3ed8f394e00fb3a7dc18af567b04512db51e6dbb Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 20 Feb 2023 16:45:28 +0100 Subject: [PATCH 10/12] test: use car fixtures in sharness t0400 --- test/sharness/t0400-api-no-gateway.sh | 9 +++++++-- test/sharness/t0400-api-no-gateway/README.md | 15 +++++++++++++++ test/sharness/t0400-api-no-gateway/fixtures.car | Bin 0 -> 108 bytes 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 test/sharness/t0400-api-no-gateway/README.md create mode 100644 test/sharness/t0400-api-no-gateway/fixtures.car diff --git a/test/sharness/t0400-api-no-gateway.sh b/test/sharness/t0400-api-no-gateway.sh index 137f99a950e..d0daeece3da 100755 --- a/test/sharness/t0400-api-no-gateway.sh +++ b/test/sharness/t0400-api-no-gateway.sh @@ -10,6 +10,13 @@ test_description="Test API security" test_init_ipfs +# Import test case +# See the static fixtures in ./t0400-api-no-gateway/ +test_expect_success "Add the test directory" ' + ipfs dag import ../t0400-api-no-gateway/fixtures.car +' +HASH=QmNYERzV2LfD2kkfahtfv44ocHzEFK1sLBaE7zdcYT2GAZ # a file containing the string "testing" + # by default, we don't let you load arbitrary ipfs objects through the api, # because this would open up the api to scripting vulnerabilities. # only the webui objects are allowed. @@ -17,14 +24,12 @@ test_init_ipfs test_launch_ipfs_daemon test_expect_success "Gateway on API unavailable" ' - HASH=$(echo "testing" | ipfs add -q) test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 404 Not Found" ' test_kill_ipfs_daemon test_launch_ipfs_daemon --unrestricted-api test_expect_success "Gateway on --unrestricted-api API available" ' - HASH=$(echo "testing" | ipfs add -q) test_curl_resp_http_code "http://127.0.0.1:$API_PORT/ipfs/$HASH" "HTTP/1.1 200 OK" ' test_kill_ipfs_daemon diff --git a/test/sharness/t0400-api-no-gateway/README.md b/test/sharness/t0400-api-no-gateway/README.md new file mode 100644 index 00000000000..83d184d4a42 --- /dev/null +++ b/test/sharness/t0400-api-no-gateway/README.md @@ -0,0 +1,15 @@ +# Dataset description/sources + +- fixtures.car + - raw CARv1 + +generated with: + +```sh +HASH=$(echo "testing" | ipfs add -q) +ipfs dag export $HASH > fixtures.car + +echo HASH=${HASH} # a file containing the string "testing" + +# HASH=QmNYERzV2LfD2kkfahtfv44ocHzEFK1sLBaE7zdcYT2GAZ # a file containing the string "testing" +``` diff --git a/test/sharness/t0400-api-no-gateway/fixtures.car b/test/sharness/t0400-api-no-gateway/fixtures.car new file mode 100644 index 0000000000000000000000000000000000000000..1e090db6dc1e7d3a07c8523de752e61dc744bd1f GIT binary patch literal 108 zcmcCmlv Date: Thu, 23 Feb 2023 11:42:51 +0100 Subject: [PATCH 11/12] fix: add versions --- test/sharness/t0113-gateway-symlink/README.md | 1 + test/sharness/t0114-gateway-subdomains/README.md | 2 ++ test/sharness/t0115-gateway-dir-listing/README.md | 1 + test/sharness/t0116-gateway-cache/README.md | 1 + test/sharness/t0117-gateway-block/README.md | 1 + test/sharness/t0118-gateway-car/README.md | 3 ++- test/sharness/t0123-gateway-json-cbor/README.md | 1 + test/sharness/t0400-api-no-gateway/README.md | 1 + 8 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/sharness/t0113-gateway-symlink/README.md b/test/sharness/t0113-gateway-symlink/README.md index 350405e321b..31a257bdded 100644 --- a/test/sharness/t0113-gateway-symlink/README.md +++ b/test/sharness/t0113-gateway-symlink/README.md @@ -6,6 +6,7 @@ generated with: ```sh +# using ipfs version 0.18.1 mkdir testfiles && echo "content" > testfiles/foo && ln -s foo testfiles/bar && diff --git a/test/sharness/t0114-gateway-subdomains/README.md b/test/sharness/t0114-gateway-subdomains/README.md index 8f0075ccd7e..611bd0ed5ad 100644 --- a/test/sharness/t0114-gateway-subdomains/README.md +++ b/test/sharness/t0114-gateway-subdomains/README.md @@ -6,6 +6,8 @@ generated with: ```sh +# using ipfs version 0.18.1 + # CIDv0to1 is necessary because raw-leaves are enabled by default during # "ipfs add" with CIDv1 and disabled with CIDv0 CID_VAL="hello" diff --git a/test/sharness/t0115-gateway-dir-listing/README.md b/test/sharness/t0115-gateway-dir-listing/README.md index 8b6e332750d..937438bcd65 100644 --- a/test/sharness/t0115-gateway-dir-listing/README.md +++ b/test/sharness/t0115-gateway-dir-listing/README.md @@ -6,6 +6,7 @@ generated with: ```sh +# using ipfs version 0.18.1 mkdir -p rootDir/ipfs && mkdir -p rootDir/ipns && mkdir -p rootDir/api && diff --git a/test/sharness/t0116-gateway-cache/README.md b/test/sharness/t0116-gateway-cache/README.md index 91c4389418d..8b44fe640b7 100644 --- a/test/sharness/t0116-gateway-cache/README.md +++ b/test/sharness/t0116-gateway-cache/README.md @@ -6,6 +6,7 @@ generated with: ```sh +# using ipfs version 0.18.1 mkdir -p root2/root3/root4 && echo "hello" > root2/root3/root4/index.html && ROOT1_CID=$(ipfs add -Qrw --cid-version 1 root2) diff --git a/test/sharness/t0117-gateway-block/README.md b/test/sharness/t0117-gateway-block/README.md index 8ca237345a7..4ce37ae086f 100644 --- a/test/sharness/t0117-gateway-block/README.md +++ b/test/sharness/t0117-gateway-block/README.md @@ -6,6 +6,7 @@ generated with: ```sh +# using ipfs version 0.18.1 mkdir -p dir && echo "hello application/vnd.ipld.raw" > dir/ascii.txt && ROOT_DIR_CID=$(ipfs add -Qrw --cid-version 1 dir) && diff --git a/test/sharness/t0118-gateway-car/README.md b/test/sharness/t0118-gateway-car/README.md index f19494833c5..7b81e543bc1 100644 --- a/test/sharness/t0118-gateway-car/README.md +++ b/test/sharness/t0118-gateway-car/README.md @@ -13,7 +13,8 @@ generated with: -```shell +```sh +# using ipfs version 0.18.1 mkdir -p subdir && echo "hello application/vnd.ipld.car" > subdir/ascii.txt && ROOT_DIR_CID=$(ipfs add -Qrw --cid-version 1 subdir) && diff --git a/test/sharness/t0123-gateway-json-cbor/README.md b/test/sharness/t0123-gateway-json-cbor/README.md index 0d9f0e1e196..4e83f42a161 100644 --- a/test/sharness/t0123-gateway-json-cbor/README.md +++ b/test/sharness/t0123-gateway-json-cbor/README.md @@ -14,6 +14,7 @@ generated with: ```sh +# using ipfs version 0.18.1 mkdir -p rootDir/ipfs && mkdir -p rootDir/ipns && mkdir -p rootDir/api && diff --git a/test/sharness/t0400-api-no-gateway/README.md b/test/sharness/t0400-api-no-gateway/README.md index 83d184d4a42..32222d41b84 100644 --- a/test/sharness/t0400-api-no-gateway/README.md +++ b/test/sharness/t0400-api-no-gateway/README.md @@ -6,6 +6,7 @@ generated with: ```sh +# using ipfs version 0.18.1 HASH=$(echo "testing" | ipfs add -q) ipfs dag export $HASH > fixtures.car From 92a068a82b74e453c4afea37ec4b0f3155b0d248 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 27 Feb 2023 11:21:02 +0100 Subject: [PATCH 12/12] fix: remove leftover fixtures & notes --- test/sharness/t0113-gateway-symlink.sh | 1 - test/sharness/t0118-gateway-car/subdir/ascii.txt | 1 - 2 files changed, 2 deletions(-) delete mode 100644 test/sharness/t0118-gateway-car/subdir/ascii.txt diff --git a/test/sharness/t0113-gateway-symlink.sh b/test/sharness/t0113-gateway-symlink.sh index ea85b815000..29e5b960de3 100755 --- a/test/sharness/t0113-gateway-symlink.sh +++ b/test/sharness/t0113-gateway-symlink.sh @@ -22,7 +22,6 @@ test_expect_success "Test the directory listing" ' test_should_contain ">bar<" list_response ' -# TODO: it's unclear to me if that `echo -n "foo" > expected` should be a fixture somehow. test_expect_success "Test the symlink" ' curl "$GWAY_ADDR/ipfs/$ROOT_DIR_CID/bar" > bar_actual && echo -n "foo" > bar_expected && diff --git a/test/sharness/t0118-gateway-car/subdir/ascii.txt b/test/sharness/t0118-gateway-car/subdir/ascii.txt deleted file mode 100644 index a2f1a843bba..00000000000 --- a/test/sharness/t0118-gateway-car/subdir/ascii.txt +++ /dev/null @@ -1 +0,0 @@ -hello application/vnd.ipld.car