frontend, api: allow custom emails as commenters
I'm really sorry this came out as one huge commit, but I'm afraid I can't split this up. Closes https://gitlab.com/commento/commento-ce/issues/9
This commit is contained in:
58
api/commenter_login_test.go
Normal file
58
api/commenter_login_test.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCommenterLoginBasics(t *testing.T) {
|
||||
failTestOnError(t, setupTestEnv())
|
||||
|
||||
if _, err := commenterLogin("test@example.com", "hunter2"); err == nil {
|
||||
t.Errorf("expected error not found when logging in without creating an account")
|
||||
return
|
||||
}
|
||||
|
||||
commenterNew("test@example.com", "Test", "undefined", "undefined", "commento", "hunter2")
|
||||
|
||||
if _, err := commenterLogin("test@example.com", "hunter2"); err != nil {
|
||||
t.Errorf("unexpected error when logging in: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := commenterLogin("test@example.com", "h******"); err == nil {
|
||||
t.Errorf("expected error not found when given wrong password")
|
||||
return
|
||||
}
|
||||
|
||||
if session, err := commenterLogin("test@example.com", "hunter2"); session == "" {
|
||||
t.Errorf("empty session on successful login: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommenterLoginEmpty(t *testing.T) {
|
||||
failTestOnError(t, setupTestEnv())
|
||||
|
||||
if _, err := commenterLogin("test@example.com", ""); err == nil {
|
||||
t.Errorf("expected error not found when passing empty password")
|
||||
return
|
||||
}
|
||||
|
||||
commenterNew("test@example.com", "Test", "undefined", "", "commenter", "hunter2")
|
||||
|
||||
if _, err := commenterLogin("test@example.com", ""); err == nil {
|
||||
t.Errorf("expected error not found when passing empty password")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommenterLoginNonCommento(t *testing.T) {
|
||||
failTestOnError(t, setupTestEnv())
|
||||
|
||||
commenterNew("test@example.com", "Test", "undefined", "undefined", "google", "")
|
||||
|
||||
if _, err := commenterLogin("test@example.com", "hunter2"); err == nil {
|
||||
t.Errorf("expected error not found logging into a non-Commento account")
|
||||
return
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user