commento/api/owner_get_test.go
Adhityaa ef0f45527a everywhere: use different session cookie names
If the user is hosting the dashboard in the same domain as
their blog (with a nginx suburi, for example), the two session
cookies clash; logging into one service logs you out of the other.
With this patch, both have separate names.

Fixes https://gitlab.com/commento/commento-ce/issues/49
2018-06-20 08:59:55 +05:30

60 lines
1.4 KiB
Go

package main
import (
"testing"
)
func TestOwnerGetByEmailBasics(t *testing.T) {
failTestOnError(t, setupTestEnv())
ownerHex, _ := ownerNew("test@example.com", "Test", "hunter2")
o, err := ownerGetByEmail("test@example.com")
if err != nil {
t.Errorf("unexpected error on ownerGetByEmail: %v", err)
return
}
if o.OwnerHex != ownerHex {
t.Errorf("expected ownerHex=%s got ownerHex=%s", ownerHex, o.OwnerHex)
return
}
}
func TestOwnerGetByEmailDNE(t *testing.T) {
failTestOnError(t, setupTestEnv())
if _, err := ownerGetByEmail("invalid@example.com"); err == nil {
t.Errorf("expected error not found on ownerGetByEmail before creating an account")
return
}
}
func TestOwnerGetByOwnerTokenBasics(t *testing.T) {
failTestOnError(t, setupTestEnv())
ownerHex, _ := ownerNew("test@example.com", "Test", "hunter2")
ownerToken, _ := ownerLogin("test@example.com", "hunter2")
o, err := ownerGetByOwnerToken(ownerToken)
if err != nil {
t.Errorf("unexpected error on ownerGetByOwnerToken: %v", err)
return
}
if o.OwnerHex != ownerHex {
t.Errorf("expected ownerHex=%s got ownerHex=%s", ownerHex, o.OwnerHex)
return
}
}
func TestOwnerGetByOwnerTokenDNE(t *testing.T) {
failTestOnError(t, setupTestEnv())
if _, err := ownerGetByOwnerToken("does-not-exist"); err == nil {
t.Errorf("expected error not found on ownerGetByOwnerToken before creating an account")
return
}
}