test: name --verify forgets the verified key
Laurent Senta committed
Mar 9, 2023 at 15:21 UTC
fc81639af441cb78b28ca78c6886ba0dd8c5db04
1 file changed
+28
test/sharness/t0100-name.sh
+28
@@ -314,4 +314,32 @@ test_name_with_key 'rsa'
314
test_name_with_key 'ed25519_b58'
315
test_name_with_key 'ed25519_b36'
316
317
+
318
+# `ipfs name inspect --verify` using the wrong RSA key should not succeed
319
+
320
+test_init_ipfs
321
+test_launch_ipfs_daemon
322
+
323
+test_expect_success "prepare RSA keys" '
324
+ export KEY_1=`ipfs key gen --type=rsa --size=4096 key1` &&
325
+ export KEY_2=`ipfs key gen --type=rsa --size=4096 key2` &&
326
+ export PEERID_1=`ipfs key list --ipns-base=base36 -l | grep key1 | cut -d " " -f1` &&
327
+ export PEERID_2=`ipfs key list --ipns-base=base36 -l | grep key2 | cut -d " " -f1`
328
+'
329
+
330
+test_expect_success "ipfs name publish --allow-offline --key=<peer-id> <hash>' succeeds" '
331
+ ipfs name publish --allow-offline --key=${KEY_1} "/ipfs/$( echo "helloworld" | ipfs add --inline -q )" &&
332
+ ipfs routing get "/ipns/$PEERID_1" > ipns_record
333
+'
334
+
335
+test_expect_success "ipfs name inspect --verify' has '.Validation.Validity' set to 'true' with correct Peer ID" '
336
+ ipfs name inspect --verify $PEERID_1 --enc json < ipns_record | jq -e ".Validation.Valid == true"
337
+'
338
+
339
+test_expect_success "ipfs name inspect --verify' has '.Validation.Validity' set to 'false' when we verify the wrong Peer ID" '
340
+ ipfs name inspect --verify $PEERID_2 --enc json < ipns_record | jq -e ".Validation.Valid == false"
341
+'
342
+
343
+test_kill_ipfs_daemon
344
+
345
test_done