diff options
| author | Shulhan <ms@kilabit.info> | 2024-01-28 16:37:00 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-01-28 17:45:39 +0700 |
| commit | 3aa08b00a1151249c6172f0739daac6be5ef857f (patch) | |
| tree | 5f337e8d19a484ec2e50feea199ab36ae3402fab /config_test.go | |
| parent | 6aeb5a7c882c30c9a9042f30f2ae16d35d2f47d3 (diff) | |
| download | gotp-3aa08b00a1151249c6172f0739daac6be5ef857f.tar.xz | |
all: make the path to private key static
Instead of prompting user, make the private key static, located at
"$XDG_CONFIG_DIR/gotp/gotp.key".
Implements: https://todo.sr.ht/~shulhan/gotp/1
Diffstat (limited to 'config_test.go')
| -rw-r--r-- | config_test.go | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/config_test.go b/config_test.go index 477b438..be61e5c 100644 --- a/config_test.go +++ b/config_test.go @@ -4,8 +4,6 @@ package gotp import ( - "os" - "path/filepath" "testing" "github.com/shuLhan/share/lib/test" @@ -23,19 +21,21 @@ func TestNewConfig(t *testing.T) { desc: `With file not exist`, configFile: `testdata/config-not-exist`, expConfig: &config{ - file: `testdata/config-not-exist`, - isNotExist: true, + dir: `testdata`, + file: `testdata/config-not-exist`, + privateKeyFile: `testdata/gotp.key`, }, }, { desc: `With openssh rsa`, configFile: `testdata/with_private_key.conf`, expConfig: &config{ - PrivateKey: `testdata/keys/rsa-openssl.pem`, Issuers: map[string]string{ `email-domain`: `XYZ`, `test`: `ABCD`, }, - file: `testdata/with_private_key.conf`, + dir: `testdata`, + privateKeyFile: `testdata/gotp.key`, + file: `testdata/with_private_key.conf`, }, }} @@ -60,13 +60,12 @@ func TestNewConfig(t *testing.T) { } } -func TestMarshaler(t *testing.T) { +func TestConfigMarshalText(t *testing.T) { var ( cfg = config{} - tdata *test.Data - userHomeDir string - err error + tdata *test.Data + err error ) tdata, err = test.LoadData(`testdata/config_marshaler_test.txt`) @@ -79,15 +78,6 @@ func TestMarshaler(t *testing.T) { t.Fatal(err) } - userHomeDir, err = os.UserHomeDir() - if err != nil { - t.Fatal(err) - } - - var expPrivateKey = filepath.Join(userHomeDir, `myprivatekey.pem`) - - test.Assert(t, `UnmarshalText: PrivateKey`, expPrivateKey, cfg.PrivateKey) - var gotText []byte gotText, err = cfg.MarshalText() |
