From 1ffda21ae38d203e381bedbf7bdbbd69c9031062 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 20 May 2022 14:54:26 -0600 Subject: Implement ratelimit on authentications --- srv/src/http/auth_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'srv/src/http/auth_test.go') 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)) } -- cgit v1.2.3