You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
475 B
25 lines
475 B
2 years ago
|
package http
|
||
2 years ago
|
|
||
|
import (
|
||
2 years ago
|
"context"
|
||
2 years ago
|
"testing"
|
||
2 years ago
|
"time"
|
||
2 years ago
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestAuther(t *testing.T) {
|
||
|
|
||
2 years ago
|
ctx := context.Background()
|
||
2 years ago
|
password := "foo"
|
||
|
hashedPassword := NewPasswordHash(password)
|
||
|
|
||
|
auther := NewAuther(map[string]string{
|
||
|
"FOO": hashedPassword,
|
||
2 years ago
|
}, 1*time.Millisecond)
|
||
2 years ago
|
|
||
2 years ago
|
assert.False(t, auther.Allowed(ctx, "BAR", password))
|
||
|
assert.False(t, auther.Allowed(ctx, "FOO", "bar"))
|
||
|
assert.True(t, auther.Allowed(ctx, "FOO", password))
|
||
2 years ago
|
}
|