LocalAuthentication
This commit is contained in:
@@ -23,6 +23,8 @@ func init() {
|
||||
|
||||
func TestNewPostgresqlStorage(t *testing.T) {
|
||||
storage, err := NewPostgresqlStorage(cfg)
|
||||
storage.DbConnection.Exec("Delete from accounts;")
|
||||
storage.DbConnection.Exec("Delete from account_auth;")
|
||||
if err != nil {
|
||||
t.Errorf("error creating new PostgreSQL storage: %v", err)
|
||||
}
|
||||
@@ -144,7 +146,7 @@ func TestPostgresqlStorage_CreateAccount(t *testing.T) {
|
||||
}
|
||||
account := Account{
|
||||
ID: Id,
|
||||
Namespace: "test_namespace",
|
||||
Namespace: "namespace",
|
||||
Authentication: AccountAuth{
|
||||
Local: localAuth,
|
||||
},
|
||||
@@ -232,3 +234,30 @@ func TestPostgresqlStorage_UpdateAccount(t *testing.T) {
|
||||
t.Errorf("failed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPostgresqlStorage_LocalAuthentication(t *testing.T) {
|
||||
db, err := NewPostgresqlStorage(cfg)
|
||||
if err != nil {
|
||||
t.Errorf("failed to create new psql connection")
|
||||
}
|
||||
accountByUsername, err := db.LocalAuthentication("test_namespace", "testuser", "", "")
|
||||
if err != nil {
|
||||
t.Errorf("Failed LocalAuthentication based on username and namespace")
|
||||
}
|
||||
fmt.Println(accountByUsername)
|
||||
accountByEmail, err := db.LocalAuthentication("test_namespace", "", "test@test.com", "")
|
||||
if err != nil {
|
||||
t.Errorf("Failed LocalAuthentication based on username and namespace")
|
||||
}
|
||||
fmt.Println(accountByEmail)
|
||||
accountByPhone, err := db.LocalAuthentication("test_namespace", "", "", "1234567890")
|
||||
if err != nil {
|
||||
t.Errorf("Failed LocalAuthentication based on username and namespace")
|
||||
}
|
||||
fmt.Println(accountByPhone)
|
||||
accountByAll, err := db.LocalAuthentication("test_namespace", "testuser", "test@test.com", "1234567890")
|
||||
if err != nil {
|
||||
t.Errorf("Failed LocalAuthentication based on username and namespace")
|
||||
}
|
||||
fmt.Println(accountByAll)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user