/
cmd_test_passphrase.go
62 lines (51 loc) · 1.47 KB
/
cmd_test_passphrase.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package client
import (
"golang.org/x/net/context"
"github.com/keybase/cli"
"github.com/adamwalz/keybase-client/go/libcmdline"
"github.com/adamwalz/keybase-client/go/libkb"
keybase1 "github.com/adamwalz/keybase-client/go/protocol/keybase1"
"github.com/keybase/go-framed-msgpack-rpc/rpc"
)
func NewCmdTestPassphrase(cl *libcmdline.CommandLine, g *libkb.GlobalContext) cli.Command {
return cli.Command{
Name: "test-passphrase",
Usage: "Test the GetPassphrase protocol",
Action: func(c *cli.Context) {
cl.ChooseCommand(&CmdTestPassphrase{Contextified: libkb.NewContextified(g)}, "test-passphrase", c)
},
}
}
type CmdTestPassphrase struct {
libkb.Contextified
}
func (s *CmdTestPassphrase) ParseArgv(ctx *cli.Context) error {
return nil
}
func (s *CmdTestPassphrase) GetUsage() libkb.Usage {
return libkb.Usage{}
}
func (s *CmdTestPassphrase) Run() (err error) {
defer libkb.Trace(s.G().Log, "CmdTestPassphrase.Run", &err)()
protocols := []rpc.Protocol{
NewSecretUIProtocol(s.G()),
}
if err = RegisterProtocolsWithContext(protocols, s.G()); err != nil {
return err
}
cli, err := GetAccountClient(s.G())
if err != nil {
return err
}
ctx := context.Background()
arg := keybase1.PassphrasePromptArg{
GuiArg: libkb.DefaultPassphraseArg(libkb.NewMetaContext(ctx, s.G())),
}
res, err := cli.PassphrasePrompt(ctx, arg)
if err != nil {
return err
}
res.Passphrase = "[passphrase redacted]"
s.G().Log.Debug("passphrase prompt result: %+v", res)
return nil
}