diff options
| author | Shulhan <ms@kilabit.info> | 2023-10-06 16:35:12 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-10-06 16:35:12 +0700 |
| commit | aedc3c206dd997c6dd96ce53a807b0b6ae635b3c (patch) | |
| tree | bc152d29ee0c864437cd8204e8bdfb0cd474b7a6 /cli_test.go | |
| parent | 3ca05089eccb6c2e738c0a86725bd22695f5b7a7 (diff) | |
| download | gotp-aedc3c206dd997c6dd96ce53a807b0b6ae635b3c.tar.xz | |
all: implement command "get"
The "get" command get and print the issuer by its LABEL.
This will print the issuer secret, unencrypted.
Diffstat (limited to 'cli_test.go')
| -rw-r--r-- | cli_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cli_test.go b/cli_test.go index 8d0218c..bf15eec 100644 --- a/cli_test.go +++ b/cli_test.go @@ -7,6 +7,7 @@ import ( "bytes" "fmt" "os" + "path/filepath" "testing" "github.com/shuLhan/share/lib/test" @@ -233,3 +234,47 @@ func TestCli_SetPrivateKey(t *testing.T) { rawConfig = tdata.Input[`config.ini`] test.Assert(t, `RemovePrivateKey`, string(rawConfig), string(gotConfig)) } + +func TestCli_ViewEncrypted(t *testing.T) { + var ( + configDir = t.TempDir() + + cli *Cli + err error + ) + + cli, err = NewCli(configDir) + if err != nil { + t.Fatal(err) + } + + var privateKeyFile = filepath.Join(`testdata`, `keys`, `rsa-openssh.pem`) + + err = cli.SetPrivateKey(privateKeyFile) + if err != nil { + t.Fatal(err) + } + + var issA *Issuer + + issA, err = NewIssuer(`testA`, `SHA1:TESTA`, nil) + if err != nil { + t.Fatal(err) + } + + err = cli.Add(issA) + if err != nil { + t.Fatal(err) + } + + var gotIssA *Issuer + + gotIssA, err = cli.Get(`testA`) + if err != nil { + t.Fatal(err) + } + + // Reset the raw issuer value for comparison. + issA.raw = nil + test.Assert(t, `Get: testA`, issA, gotIssA) +} |
