diff options
| author | Shulhan <ms@kilabit.info> | 2023-05-16 00:20:40 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-05-16 00:20:40 +0700 |
| commit | de4158b930a2afcfa59947ae2cd7127943751805 (patch) | |
| tree | 3cd3763ed102e1ebf729036ec9ba4da7ca1d0a26 /cli_test.go | |
| parent | 6a9e476354d23da316a94d0d5a7f8b14a273910e (diff) | |
| download | gotp-de4158b930a2afcfa59947ae2cd7127943751805.tar.xz | |
all: add command to remove the private key
The remove-private-key decrypt the issuer's value back using previous
private key and store it back to file as plain text.
Diffstat (limited to 'cli_test.go')
| -rw-r--r-- | cli_test.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/cli_test.go b/cli_test.go index a900ede..70a5e1d 100644 --- a/cli_test.go +++ b/cli_test.go @@ -156,7 +156,7 @@ func TestCli_SetPrivateKey(t *testing.T) { cfg *config ) - rawConfig = tdata.Input[`config.ini.before`] + rawConfig = tdata.Input[`config.ini`] cfg, err = loadConfig(rawConfig) if err != nil { @@ -208,4 +208,21 @@ func TestCli_SetPrivateKey(t *testing.T) { } test.Assert(t, `get all labels`, string(tdata.Output[`issuers`]), got.String()) + + // Remove the private key, and compare the plain config. + + err = cli.RemovePrivateKey() + if err != nil { + t.Fatal(err) + } + + var gotConfig []byte + + gotConfig, err = cli.cfg.MarshalText() + if err != nil { + t.Fatal(err) + } + + rawConfig = tdata.Input[`config.ini`] + test.Assert(t, `RemovePrivateKey`, string(rawConfig), string(gotConfig)) } |
