mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-06 08:47:52 +08:00
rename -f to --ipns-base
This commit is contained in:
parent
80e859ef6f
commit
23a26c05d3
@ -68,11 +68,11 @@ type KeyRenameOutput struct {
|
||||
}
|
||||
|
||||
const (
|
||||
keyStoreAlgorithmDefault = options.RSAKey
|
||||
keyStoreTypeOptionName = "type"
|
||||
keyStoreSizeOptionName = "size"
|
||||
keyFormatOptionName = "format"
|
||||
oldKeyOptionName = "oldkey"
|
||||
keyStoreAlgorithmDefault = options.RSAKey
|
||||
keyStoreTypeOptionName = "type"
|
||||
keyStoreSizeOptionName = "size"
|
||||
keyFormatOptionName = "ipns-base"
|
||||
oldKeyOptionName = "oldkey"
|
||||
)
|
||||
|
||||
var keyGenCmd = &cmds.Command{
|
||||
@ -82,7 +82,7 @@ var keyGenCmd = &cmds.Command{
|
||||
Options: []cmds.Option{
|
||||
cmds.StringOption(keyStoreTypeOptionName, "t", "type of the key to create: rsa, ed25519").WithDefault(keyStoreAlgorithmDefault),
|
||||
cmds.IntOption(keyStoreSizeOptionName, "s", "size of the key to generate"),
|
||||
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"),
|
||||
cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b36cid"),
|
||||
},
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("name", true, false, "name of key to create"),
|
||||
@ -223,7 +223,7 @@ var keyImportCmd = &cmds.Command{
|
||||
Tagline: "Import a key and prints imported key id",
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b58mh"),
|
||||
cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b58mh"),
|
||||
},
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("name", true, false, "name to associate with key in keychain"),
|
||||
@ -298,7 +298,7 @@ var keyListCmd = &cmds.Command{
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("l", "Show extra information about keys."),
|
||||
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"),
|
||||
cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b36cid"),
|
||||
},
|
||||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
|
||||
if err := verifyIDFormatLabel(req.Options[keyFormatOptionName].(string)); err != nil {
|
||||
@ -395,7 +395,7 @@ var keyRmCmd = &cmds.Command{
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("l", "Show extra information about keys."),
|
||||
cmds.StringOption(keyFormatOptionName, "f", "output format: b58mh or b36cid").WithDefault("b36cid"),
|
||||
cmds.StringOption(keyFormatOptionName, "", "output format: b58mh or b36cid").WithDefault("b36cid"),
|
||||
},
|
||||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
|
||||
api, err := cmdenv.GetApi(env, req)
|
||||
@ -417,7 +417,7 @@ var keyRmCmd = &cmds.Command{
|
||||
|
||||
list = append(list, KeyOutput{
|
||||
Name: name,
|
||||
Id: formatID(key.ID(), req.Options[keyFormatOptionName].(string)), // key.ID().Pretty(),
|
||||
Id: formatID(key.ID(), req.Options[keyFormatOptionName].(string)),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -56,8 +56,8 @@ test_rotate() {
|
||||
test_expect_success "checking ID" '
|
||||
ipfs config Identity.PeerID > expected-id &&
|
||||
ipfs id -f "<id>\n" > actual-id &&
|
||||
ipfs key list -l -f=b58mh | grep self | cut -d " " -f1 > keystore-id &&
|
||||
ipfs key list -l -f=b58mh | grep oldkey | cut -d " " -f1 | tr -d "\n" > old-keystore-id &&
|
||||
ipfs key list -l --ipns-base=b58mh | grep self | cut -d " " -f1 > keystore-id &&
|
||||
ipfs key list -l --ipns-base=b58mh | grep oldkey | cut -d " " -f1 | tr -d "\n" > old-keystore-id &&
|
||||
test_cmp expected-id actual-id &&
|
||||
test_cmp expected-id keystore-id &&
|
||||
test_cmp old-keystore-id first_id
|
||||
|
||||
@ -24,7 +24,7 @@ test_name_with_self() {
|
||||
ipfs init --profile=test -a=ed25519 > /dev/null
|
||||
;;
|
||||
esac &&
|
||||
export PEERID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` &&
|
||||
export PEERID=`ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1` &&
|
||||
test_check_peerid "${PEERID}"
|
||||
'
|
||||
|
||||
@ -109,8 +109,8 @@ test_name_with_self() {
|
||||
# test publishing with B36CID and B58MH resolve to the same B36CID
|
||||
|
||||
test_expect_success "verify self key output" '
|
||||
B58MH_ID=`ipfs key list -f=b58mh -l | grep self | cut -d " " -f1` &&
|
||||
B36CID_ID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` &&
|
||||
B58MH_ID=`ipfs key list --ipns-base=b58mh -l | grep self | cut -d " " -f1` &&
|
||||
B36CID_ID=`ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1` &&
|
||||
test_check_peerid "${B58MH_ID}" &&
|
||||
test_check_peerid "${B36CID_ID}"
|
||||
'
|
||||
@ -250,15 +250,15 @@ test_name_with_key() {
|
||||
test_expect_success "'prepare keys" '
|
||||
case $GEN_ALG in
|
||||
rsa)
|
||||
export KEY=`ipfs key gen -f=b58mh --type=rsa --size=2048 key` &&
|
||||
export KEY_B36CID=`ipfs key list -f=b36cid -l | grep key | cut -d " " -f1`
|
||||
export KEY=`ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 key` &&
|
||||
export KEY_B36CID=`ipfs key list --ipns-base=b36cid -l | grep key | cut -d " " -f1`
|
||||
;;
|
||||
ed25519_b58)
|
||||
export KEY=`ipfs key gen -f=b58mh --type=ed25519 key`
|
||||
export KEY_B36CID=`ipfs key list -f=b36cid -l | grep key | cut -d " " -f1`
|
||||
export KEY=`ipfs key gen --ipns-base=b58mh --type=ed25519 key`
|
||||
export KEY_B36CID=`ipfs key list --ipns-base=b36cid -l | grep key | cut -d " " -f1`
|
||||
;;
|
||||
ed25519_b36)
|
||||
export KEY=`ipfs key gen -f=b36cid --type=ed25519 key`
|
||||
export KEY=`ipfs key gen --ipns-base=b36cid --type=ed25519 key`
|
||||
export KEY_B36CID=$KEY
|
||||
;;
|
||||
esac &&
|
||||
|
||||
@ -113,7 +113,7 @@ test_expect_success "Add the test directory" '
|
||||
'
|
||||
|
||||
test_expect_success "Publish test text file to IPNS using RSA keys" '
|
||||
RSA_KEY=$(ipfs key gen -f=b58mh --type=rsa --size=2048 test_key_rsa | head -n1 | tr -d "\n")
|
||||
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 --codec libp2p-key -b base36)
|
||||
RSA_IPNS_IDv1_DAGPB=$(echo "$RSA_IPNS_IDv0" | ipfs cid format -v 1 -b base36)
|
||||
@ -125,9 +125,9 @@ test_expect_success "Publish test text file to IPNS using RSA keys" '
|
||||
'
|
||||
|
||||
test_expect_success "Publish test text file to IPNS using ED25519 keys" '
|
||||
ED25519_KEY=$(ipfs key gen -f=b58mh --type=ed25519 test_key_ed25519 | head -n1 | tr -d "\n")
|
||||
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 -f b36cid | grep test_key_ed25519 | cut -d " " -f1 | tr -d "\n")
|
||||
ED25519_IPNS_IDv1=$(ipfs key list -l --ipns-base=b36cid | 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 --codec protobuf)
|
||||
test_check_peerid "${ED25519_KEY}" &&
|
||||
ipfs name publish --key test_key_ed25519 --allow-offline -Q "/ipfs/$CIDv1" > name_publish_out &&
|
||||
|
||||
@ -22,8 +22,8 @@ test_expect_success "resolve: prepare dag" '
|
||||
'
|
||||
|
||||
test_expect_success "resolve: prepare keys" '
|
||||
self_hash=$(ipfs key list -f=b36cid -l | grep self | cut -d " " -f1) &&
|
||||
alt_hash=$(ipfs key gen -f=b36cid -t rsa alt)
|
||||
self_hash=$(ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1) &&
|
||||
alt_hash=$(ipfs key gen --ipns-base=b36cid -t rsa alt)
|
||||
echo self_hash $self_hash
|
||||
echo $(ipfs id -f="<id>")
|
||||
'
|
||||
|
||||
@ -13,10 +13,10 @@ test_init_ipfs
|
||||
test_key_cmd() {
|
||||
# test key output format
|
||||
test_expect_success "create an RSA key and test B58MH/B36CID output formats" '
|
||||
PEERID=$(ipfs key gen -f=b58mh --type=rsa --size=2048 key_rsa) &&
|
||||
PEERID=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 key_rsa) &&
|
||||
test_check_rsa2048_b58mh_peerid $PEERID &&
|
||||
ipfs key rm key_rsa &&
|
||||
PEERID=$(ipfs key gen -f=b36cid --type=rsa --size=2048 key_rsa) &&
|
||||
PEERID=$(ipfs key gen --ipns-base=b36cid --type=rsa --size=2048 key_rsa) &&
|
||||
test_check_rsa2048_b36cid_peerid $PEERID
|
||||
'
|
||||
|
||||
@ -27,18 +27,18 @@ rm key_rsa.key
|
||||
'
|
||||
|
||||
test_expect_success "test RSA key B58MH/B36CID multihash format" '
|
||||
PEERID=$(ipfs key list -f=b58mh -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
|
||||
PEERID=$(ipfs key list --ipns-base=b58mh -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
|
||||
test_check_rsa2048_b58mh_peerid $PEERID &&
|
||||
PEERID=$(ipfs key list -f=b36cid -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
|
||||
PEERID=$(ipfs key list --ipns-base=b36cid -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
|
||||
test_check_rsa2048_b36cid_peerid $PEERID &&
|
||||
ipfs key rm key_rsa
|
||||
'
|
||||
|
||||
test_expect_success "create an ED25519 key and test B58MH/B36CID output formats" '
|
||||
PEERID=$(ipfs key gen -f=b58mh --type=ed25519 key_ed25519) &&
|
||||
PEERID=$(ipfs key gen --ipns-base=b58mh --type=ed25519 key_ed25519) &&
|
||||
test_check_ed25519_b58mh_peerid $PEERID &&
|
||||
ipfs key rm key_ed25519 &&
|
||||
PEERID=$(ipfs key gen -f=b36cid --type=ed25519 key_ed25519) &&
|
||||
PEERID=$(ipfs key gen --ipns-base=b36cid --type=ed25519 key_ed25519) &&
|
||||
test_check_ed25519_b36cid_peerid $PEERID
|
||||
'
|
||||
|
||||
@ -49,9 +49,9 @@ rm key_ed25519.key
|
||||
'
|
||||
|
||||
test_expect_success "test ED25519 key B58MH/B36CID multihash format" '
|
||||
PEERID=$(ipfs key list -f=b58mh -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
|
||||
PEERID=$(ipfs key list --ipns-base=b58mh -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
|
||||
test_check_ed25519_b58mh_peerid $PEERID &&
|
||||
PEERID=$(ipfs key list -f=b36cid -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
|
||||
PEERID=$(ipfs key list --ipns-base=b36cid -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
|
||||
test_check_ed25519_b36cid_peerid $PEERID &&
|
||||
ipfs key rm key_ed25519
|
||||
'
|
||||
@ -59,12 +59,12 @@ ipfs key rm key_ed25519
|
||||
|
||||
|
||||
test_expect_success "create a new rsa key" '
|
||||
rsahash=$(ipfs key gen generated_rsa_key --type=rsa --size=2048 -f=b58mh)
|
||||
rsahash=$(ipfs key gen generated_rsa_key --type=rsa --size=2048 --ipns-base=b58mh)
|
||||
echo $rsahash > rsa_key_id
|
||||
'
|
||||
|
||||
test_expect_success "create a new ed25519 key" '
|
||||
edhash=$(ipfs key gen generated_ed25519_key --type=ed25519 -f=b58mh)
|
||||
edhash=$(ipfs key gen generated_ed25519_key --type=ed25519 --ipns-base=b58mh)
|
||||
echo $edhash > ed25519_key_id
|
||||
'
|
||||
|
||||
@ -119,13 +119,13 @@ ipfs key rm key_ed25519
|
||||
'
|
||||
|
||||
test_expect_success "key hashes show up in long list output" '
|
||||
ipfs key list -l -f=b58mh | grep $edhash > /dev/null &&
|
||||
ipfs key list -l -f=b58mh | grep $rsahash > /dev/null
|
||||
ipfs key list -l --ipns-base=b58mh | grep $edhash > /dev/null &&
|
||||
ipfs key list -l --ipns-base=b58mh | grep $rsahash > /dev/null
|
||||
'
|
||||
|
||||
test_expect_success "key list -l contains self key with peerID" '
|
||||
PeerID="$(ipfs config Identity.PeerID)"
|
||||
ipfs key list -l -f=b58mh | grep "$PeerID\s\+self"
|
||||
ipfs key list -l --ipns-base=b58mh | grep "$PeerID\s\+self"
|
||||
'
|
||||
|
||||
test_expect_success "key rm remove a key" '
|
||||
|
||||
@ -62,7 +62,7 @@ test_expect_success "ipfs daemon --offline --mount fails - #2995" '
|
||||
test_launch_ipfs_daemon --offline
|
||||
|
||||
test_expect_success "'ipfs name resolve' succeeds after ipfs id when daemon offline" '
|
||||
PEERID=`ipfs key list -f=b36cid -l | grep self | cut -d " " -f1` &&
|
||||
PEERID=`ipfs key list --ipns-base=b36cid -l | grep self | cut -d " " -f1` &&
|
||||
test_check_peerid "${PEERID}" &&
|
||||
ipfs name publish --allow-offline -Q "/ipfs/$HASH_WELCOME_DOCS" >publish_out
|
||||
'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user