From de4158b930a2afcfa59947ae2cd7127943751805 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Tue, 16 May 2023 00:20:40 +0700 Subject: 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. --- cli_test.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'cli_test.go') 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)) } -- cgit v1.3