summaryrefslogtreecommitdiff
path: root/srv/src/http/auth_test.go
blob: 2a1e6e9a72993c1cbc3a53488f5669e6d781e6f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package http

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestAuther(t *testing.T) {

	password := "foo"
	hashedPassword := NewPasswordHash(password)

	auther := NewAuther(map[string]string{
		"FOO": hashedPassword,
	})

	assert.False(t, auther.Allowed("BAR", password))
	assert.False(t, auther.Allowed("FOO", "bar"))
	assert.True(t, auther.Allowed("FOO", password))
}