This commit is contained in:
@@ -2,6 +2,7 @@ package creator_auth_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.cin.su/m/Assistant/contracts/identity"
|
||||
"git.cin.su/m/Assistant/modules/identity/domain"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -32,6 +33,23 @@ func TestCreatorSessionIsTimeBoundAndDoesNotCarryAuthority(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatorUsernameAndPasswordMustBothMatch(t *testing.T) {
|
||||
if !domain.CreatorCredentialsMatch("m", "password", identity.CreatorCredentials{Username: "m", Password: "password"}) {
|
||||
t.Fatal("matching Creator credentials rejected")
|
||||
}
|
||||
for _, supplied := range []identity.CreatorCredentials{
|
||||
{},
|
||||
{Username: "m", Password: "wrong"},
|
||||
{Username: "wrong", Password: "password"},
|
||||
{Username: "m"},
|
||||
{Password: "password"},
|
||||
} {
|
||||
if domain.CreatorCredentialsMatch("m", "password", supplied) {
|
||||
t.Fatalf("invalid Creator credentials accepted: username=%q", supplied.Username)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatorBootstrapCredentialMustMatch(t *testing.T) {
|
||||
if !domain.BootstrapMatches("expected", "expected") {
|
||||
t.Fatal("matching bootstrap credential rejected")
|
||||
|
||||
Reference in New Issue
Block a user