blob: 9e2d4402475a7314512ade424ae6799c47e6eef9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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))
}
|