diff options
Diffstat (limited to 'src/http/auth_test.go')
-rw-r--r-- | src/http/auth_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/http/auth_test.go b/src/http/auth_test.go new file mode 100644 index 0000000..9e2d440 --- /dev/null +++ b/src/http/auth_test.go @@ -0,0 +1,24 @@ +package http + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestAuther(t *testing.T) { + + ctx := context.Background() + password := "foo" + hashedPassword := NewPasswordHash(password) + + auther := NewAuther(map[string]string{ + "FOO": hashedPassword, + }, 1*time.Millisecond) + + assert.False(t, auther.Allowed(ctx, "BAR", password)) + assert.False(t, auther.Allowed(ctx, "FOO", "bar")) + assert.True(t, auther.Allowed(ctx, "FOO", password)) +} |