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:
Adhityaa
2018-06-10 22:45:56 +05:30
parent e42f77b4eb
commit 2020405e8b
25 changed files with 837 additions and 267 deletions

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