aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/key_store_test.go
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-01-07 23:06:26 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-01-16 02:40:10 +0800
commita1c2749380523178f87ae3fdfb02bc6641362924 (patch)
tree4e8a22b27b6f219f311531a52a87589be1e40520 /crypto/key_store_test.go
parent945798f913d5cabd79635f45045b680b02396bf9 (diff)
downloaddexon-a1c2749380523178f87ae3fdfb02bc6641362924.tar
dexon-a1c2749380523178f87ae3fdfb02bc6641362924.tar.gz
dexon-a1c2749380523178f87ae3fdfb02bc6641362924.tar.bz2
dexon-a1c2749380523178f87ae3fdfb02bc6641362924.tar.lz
dexon-a1c2749380523178f87ae3fdfb02bc6641362924.tar.xz
dexon-a1c2749380523178f87ae3fdfb02bc6641362924.tar.zst
dexon-a1c2749380523178f87ae3fdfb02bc6641362924.zip
Address pull request comments
* Simplify scrypt constants with const block * Add key store constructors and make their types private * Simplify key store and file namings to be less Java Enterpriseā„¢ * Change test error logging to use t.Error(err) * Reduce number of naked returns (just like my ex-gf) * Simplify file reading path code
Diffstat (limited to 'crypto/key_store_test.go')
-rw-r--r--crypto/key_store_test.go31
1 files changed, 14 insertions, 17 deletions
diff --git a/crypto/key_store_test.go b/crypto/key_store_test.go
index 412735444..8469d2369 100644
--- a/crypto/key_store_test.go
+++ b/crypto/key_store_test.go
@@ -6,20 +6,19 @@ import (
"testing"
)
-func TestKeyStorePlaintext(t *testing.T) {
- ks := new(KeyStorePlaintext)
- ks.keysDirPath = DefaultDataDir()
+func TestKeyStorePlain(t *testing.T) {
+ ks := NewKeyStorePlain(DefaultDataDir())
pass := "" // not used but required by API
k1, err := ks.GenerateNewKey(pass)
if err != nil {
- fmt.Println(err.Error())
+ t.Error(err)
t.FailNow()
}
k2 := new(Key)
k2, err = ks.GetKey(k1.Id, pass)
if err != nil {
- fmt.Println(err.Error())
+ t.Error(err)
t.FailNow()
}
@@ -40,25 +39,24 @@ func TestKeyStorePlaintext(t *testing.T) {
err = ks.DeleteKey(k2.Id, pass)
if err != nil {
- fmt.Println(err.Error())
+ t.Error(err)
t.FailNow()
}
}
func TestKeyStorePassphrase(t *testing.T) {
- ks := new(KeyStorePassphrase)
- ks.keysDirPath = DefaultDataDir()
+ ks := NewKeyStorePassphrase(DefaultDataDir())
pass := "foo"
k1, err := ks.GenerateNewKey(pass)
if err != nil {
- fmt.Println(err.Error())
+ t.Error(err)
t.FailNow()
}
k2 := new(Key)
k2, err = ks.GetKey(k1.Id, pass)
if err != nil {
- fmt.Println(err.Error())
+ t.Error(err)
t.FailNow()
}
@@ -79,36 +77,35 @@ func TestKeyStorePassphrase(t *testing.T) {
err = ks.DeleteKey(k2.Id, pass) // also to clean up created files
if err != nil {
- fmt.Println(err.Error())
+ t.Error(err)
t.FailNow()
}
}
func TestKeyStorePassphraseDecryptionFail(t *testing.T) {
- ks := new(KeyStorePassphrase)
- ks.keysDirPath = DefaultDataDir()
+ ks := NewKeyStorePassphrase(DefaultDataDir())
pass := "foo"
k1, err := ks.GenerateNewKey(pass)
if err != nil {
- fmt.Println(err.Error())
+ t.Error(err)
t.FailNow()
}
_, err = ks.GetKey(k1.Id, "bar") // wrong passphrase
- // fmt.Println(err.Error())
+ // t.Error(err)
if err == nil {
t.FailNow()
}
err = ks.DeleteKey(k1.Id, "bar") // wrong passphrase
if err == nil {
- fmt.Println(err.Error())
+ t.Error(err)
t.FailNow()
}
err = ks.DeleteKey(k1.Id, pass) // to clean up
if err != nil {
- fmt.Println(err.Error())
+ t.Error(err)
t.FailNow()
}
}