diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2022-05-19 21:35:45 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2022-05-19 21:35:45 -0600 |
commit | 8da42184eb26bbd35618d81e47bcd23b6ce21adb (patch) | |
tree | 22983ba9306e242b94a257270476df67f5e89e85 /srv/src/api/auth_test.go | |
parent | 56530a8a66937194fb4e99af95bcea6bb0281f66 (diff) |
Implement basic auth middleware
Diffstat (limited to 'srv/src/api/auth_test.go')
-rw-r--r-- | srv/src/api/auth_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/srv/src/api/auth_test.go b/srv/src/api/auth_test.go new file mode 100644 index 0000000..cdf83ef --- /dev/null +++ b/srv/src/api/auth_test.go @@ -0,0 +1,21 @@ +package api + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestAuther(t *testing.T) { + + password := "foo" + hashedPassword := NewPasswordHash(password) + + auther := NewAuther(map[string]string{ + "FOO": hashedPassword, + }) + + assert.False(t, auther.Allowed("BAR", password)) + assert.False(t, auther.Allowed("FOO", "bar")) + assert.True(t, auther.Allowed("FOO", password)) +} |