test: use car fixtures in sharness t0114
Laurent Senta committed
Feb 15, 2023 at 16:00 UTC
771d62c8f4877b12ed0074a5186f5cc2a33be888
3 files changed
+63
-21
test/sharness/t0114-gateway-subdomains.sh
+11
-21
@@ -91,27 +91,19 @@ test_expect_success "ipfs init" '
91
92
test_launch_ipfs_daemon_without_network
93
94
+# Import test case
95
+# See the static fixtures in ./t0114-gateway-subdomains/
96
+test_expect_success "Add the test fixtures" '
97
+ ipfs dag import ../t0114-gateway-subdomains/fixtures.car
98
+'
99
+CID_VAL="hello"
100
+CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am
101
+CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
102
# CIDv0to1 is necessary because raw-leaves are enabled by default during
103
# "ipfs add" with CIDv1 and disabled with CIDv0
96
-test_expect_success "Add test text file" '
97
- CID_VAL="hello"
98
- CIDv1=$(echo $CID_VAL | ipfs add --cid-version 1 -Q)
99
- CIDv0=$(echo $CID_VAL | ipfs add --cid-version 0 -Q)
100
- CIDv0to1=$(echo "$CIDv0" | ipfs cid base32)
101
- echo CIDv0to1=${CIDv0to1}
102
-'
103
-
104
-# Directory tree crafted to test for edge cases like "/ipfs/ipfs/ipns/bar"
105
-test_expect_success "Add the test directory" '
106
- mkdir -p testdirlisting/ipfs/ipns &&
107
- echo "hello" > testdirlisting/hello &&
108
- echo "text-file-content" > testdirlisting/ipfs/ipns/bar &&
109
- mkdir -p testdirlisting/api &&
110
- mkdir -p testdirlisting/ipfs &&
111
- echo "I am a txt file" > testdirlisting/api/file.txt &&
112
- echo "I am a txt file" > testdirlisting/ipfs/file.txt &&
113
- DIR_CID=$(ipfs add -Qr --cid-version 1 testdirlisting)
114
-'
104
+CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4
105
+CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs
106
+DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting
107
108
test_expect_success "Publish test text file to IPNS using RSA keys" '
109
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 \
592
IPNS_KEY="test_key_ed25519"
593
IPNS_ED25519_B58MH=$(ipfs key list -l --ipns-base b58mh | grep $IPNS_KEY | cut -d" " -f1 | tr -d "\n")
594
IPNS_ED25519_B36CID=$(ipfs key list -l --ipns-base base36 | grep $IPNS_KEY | cut -d" " -f1 | tr -d "\n")
603
-# sha512 will be over 63char limit, even when represented in Base36
604
-CIDv1_TOO_LONG=$(echo $CID_VAL | ipfs add --cid-version 1 --hash sha2-512 -Q)
595
596
# local: *.localhost
597
test_localhost_gateway_response_should_contain \
test/sharness/t0114-gateway-subdomains/README.md
new
+52
@@ -0,0 +1,52 @@
1
+# Dataset description/sources
2
+
3
+- fixtures.car
4
+ - raw CARv1
5
+
6
+generated with:
7
+
8
+```sh
9
+# CIDv0to1 is necessary because raw-leaves are enabled by default during
10
+# "ipfs add" with CIDv1 and disabled with CIDv0
11
+CID_VAL="hello"
12
+CIDv1=$(echo $CID_VAL | ipfs add --cid-version 1 -Q)
13
+CIDv0=$(echo $CID_VAL | ipfs add --cid-version 0 -Q)
14
+CIDv0to1=$(echo "$CIDv0" | ipfs cid base32)
15
+# sha512 will be over 63char limit, even when represented in Base36
16
+CIDv1_TOO_LONG=$(echo $CID_VAL | ipfs add --cid-version 1 --hash sha2-512 -Q)
17
+
18
+echo CIDv1=${CIDv1}
19
+echo CIDv0=${CIDv0}
20
+echo CIDv0to1=${CIDv0to1}
21
+echo CIDv1_TOO_LONG=${CIDv1_TOO_LONG}
22
+
23
+# Directory tree crafted to test for edge cases like "/ipfs/ipfs/ipns/bar"
24
+mkdir -p testdirlisting/ipfs/ipns &&
25
+echo "hello" > testdirlisting/hello &&
26
+echo "text-file-content" > testdirlisting/ipfs/ipns/bar &&
27
+mkdir -p testdirlisting/api &&
28
+mkdir -p testdirlisting/ipfs &&
29
+echo "I am a txt file" > testdirlisting/api/file.txt &&
30
+echo "I am a txt file" > testdirlisting/ipfs/file.txt &&
31
+DIR_CID=$(ipfs add -Qr --cid-version 1 testdirlisting)
32
+
33
+echo DIR_CID=${DIR_CID}
34
+
35
+ipfs files mkdir /t0114/
36
+ipfs files cp /ipfs/${CIDv1} /t0114/
37
+ipfs files cp /ipfs/${CIDv0} /t0114/
38
+ipfs files cp /ipfs/${CIDv0to1} /t0114/
39
+ipfs files cp /ipfs/${DIR_CID} /t0114/
40
+ipfs files cp /ipfs/${CIDv1_TOO_LONG} /t0114/
41
+
42
+ROOT=`ipfs files stat /t0114/ --hash`
43
+
44
+ipfs dag export ${ROOT} > ./fixtures.car
45
+
46
+# CID_VAL="hello"
47
+# CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am
48
+# CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
49
+# CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4
50
+# CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs
51
+# DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting
52
+```
test/sharness/t0114-gateway-subdomains/fixtures.car
Binary files /dev/null and b/test/sharness/t0114-gateway-subdomains/fixtures.car differ