@cryptotaxi247 / kubo / commits / a3b38e8be

Add a test for the keystore

License: MIT Signed-off-by: Jeromy <why@ipfs.io>

Jeromy committed Jan 11, 2017 at 04:11 UTC a3b38e8be8df60e4279c53a4449ccb8d9a7d3a47
2 files changed +39 -2
core/commands/keystore.go
+2 -2
@@ -143,7 +143,7 @@ var KeyListCmd = &cmds.Command{
143 Tagline: "List all local keypairs",
144 },
145 Options: []cmds.Option{
146 - cmds.BoolOption("show-ids", "l", "also show key ids"),
146 + cmds.BoolOption("l", "Show extra information about keys."),
147 },
148 Run: func(req cmds.Request, res cmds.Response) {
149 n, err := req.InvocContext().GetNode()
@@ -189,7 +189,7 @@ var KeyListCmd = &cmds.Command{
189 }
190
191 func keyOutputListMarshaler(res cmds.Response) (io.Reader, error) {
192 - withId, _, _ := res.Request().Option("show-ids").Bool()
192 + withId, _, _ := res.Request().Option("l").Bool()
193
194 list, ok := res.Output().(*KeyOutputList)
195 if !ok {
test/sharness/t0165-keystore.sh new
+37
@@ -0,0 +1,37 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2017 Jeromy Johnson
4 +# MIT Licensed; see the LICENSE file in this repository.
5 +#
6 +
7 +test_description="Test keystore commands"
8 +
9 +. lib/test-lib.sh
10 +
11 +test_init_ipfs
12 +
13 +test_key_cmd() {
14 + test_expect_success "create a new rsa key" '
15 + rsahash=$(ipfs key gen foobarsa --type=rsa --size=2048)
16 + '
17 +
18 + test_expect_success "create a new ed25519 key" '
19 + edhash=$(ipfs key gen bazed --type=ed25519)
20 + '
21 +
22 + test_expect_success "both keys show up in list output" '
23 + echo bazed > list_exp &&
24 + echo foobarsa >> list_exp &&
25 + ipfs key list | sort > list_out &&
26 + test_cmp list_exp list_out
27 + '
28 +
29 + test_expect_success "key hashes show up in long list output" '
30 + ipfs key list -l | grep $edhash > /dev/null &&
31 + ipfs key list -l | grep $rsahash > /dev/null
32 + '
33 +}
34 +
35 +test_key_cmd
36 +
37 +test_done