webhookd/pkg/auth/htpasswd-file_test.go
2018-12-18 19:52:03 +00:00

16 lines
518 B
Go

package auth
import (
"testing"
"github.com/ncarlier/webhookd/pkg/assert"
)
func TestValidateCredentials(t *testing.T) {
htpasswdFile, err := NewHtpasswdFromFile("test.htpasswd")
assert.Nil(t, err, ".htpasswd file should be loaded")
assert.NotNil(t, htpasswdFile, ".htpasswd file should be loaded")
assert.Equal(t, true, htpasswdFile.validateCredentials("foo", "bar"), "credentials should be valid")
assert.Equal(t, false, htpasswdFile.validateCredentials("foo", "bir"), "credentials should not be valid")
}