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

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))
}