about summary refs log tree commit diff stats
path: root/svc/common_test.go
diff options
context:
space:
mode:
authorBenjamin Morrison <ben@gbmor.dev>2021-10-19 01:26:27 -0400
committerBenjamin Morrison <ben@gbmor.dev>2021-10-21 20:45:08 -0400
commitdcb254618dc5541bb50c488c96b5e02c36951c06 (patch)
tree8fa5ec4bad0550d2bbad307da8fe8b89e0e06a17 /svc/common_test.go
parentd2cbd7b2dca8b981f886c490d0aed205f0530c31 (diff)
downloadgetwtxt-dcb254618dc5541bb50c488c96b5e02c36951c06.tar.gz
config for admin password, store bcrypt hash in confObj
Diffstat (limited to 'svc/common_test.go')
-rw-r--r--svc/common_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/svc/common_test.go b/svc/common_test.go
new file mode 100644
index 0000000..d9a08b3
--- /dev/null
+++ b/svc/common_test.go
@@ -0,0 +1,34 @@
+package svc
+
+import (
+	"testing"
+)
+
+func TestHashPass(t *testing.T) {
+	cases := []struct {
+		in, name   string
+		shouldFail bool
+	}{
+		{
+			in:         "foo",
+			name:       "non-empty password",
+			shouldFail: false,
+		},
+		{
+			in:         "",
+			name:       "empty password",
+			shouldFail: true,
+		},
+	}
+	for _, v := range cases {
+		t.Run(v.name, func(t *testing.T) {
+			out, err := HashPass(v.in)
+			if err != nil && !v.shouldFail {
+				t.Errorf("Shouldn't have failed: Case %s, Error: %s", v.name, err)
+			}
+			if out == "" && v.in != "" {
+				t.Errorf("Got empty out for case %s input %s", v.name, v.in)
+			}
+		})
+	}
+}