diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 14:54:26 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2022-05-20 14:54:26 -0600 |
commit | 1ffda21ae38d203e381bedbf7bdbbd69c9031062 (patch) | |
tree | 32b28a8fd92341e69f639b6959bfd04347728494 /srv/src/http/auth_test.go | |
parent | ae1fa76efc0d771ca50dede367bd228ce9f7b969 (diff) |
Implement ratelimit on authentications
Diffstat (limited to 'srv/src/http/auth_test.go')
-rw-r--r-- | srv/src/http/auth_test.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/srv/src/http/auth_test.go b/srv/src/http/auth_test.go index 2a1e6e9..9e2d440 100644 --- a/srv/src/http/auth_test.go +++ b/srv/src/http/auth_test.go @@ -1,21 +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("BAR", password)) - assert.False(t, auther.Allowed("FOO", "bar")) - assert.True(t, auther.Allowed("FOO", password)) + assert.False(t, auther.Allowed(ctx, "BAR", password)) + assert.False(t, auther.Allowed(ctx, "FOO", "bar")) + assert.True(t, auther.Allowed(ctx, "FOO", password)) } |