Working auth and photo json endpoint

Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
Kris Nóva 2021-02-09 11:17:06 -08:00
parent ef275f97f4
commit e4323b6047
2032 changed files with 821464 additions and 52 deletions

35
test/session_test.go Normal file
View file

@ -0,0 +1,35 @@
package test
import (
"testing"
photoprism "github.com/kris-nova/client-go"
)
const (
WellKnownUser = "admin"
WellKnownPass = "missy"
BadPassword = "charlie"
)
// TestHappyLogin should succeed with the good password "missy"
func TestHappyLogin(t *testing.T) {
creds := photoprism.NewClientAuthLogin(WellKnownUser, WellKnownPass)
client := photoprism.New("localhost:8080")
err := client.Auth(creds)
if err != nil {
t.Errorf("invalid login: %v", err)
}
}
// TestSadLogin should fail with the bad password "charlie"
func TestSadLogin(t *testing.T) {
creds := photoprism.NewClientAuthLogin(WellKnownUser, BadPassword)
client := photoprism.New("localhost:8080")
err := client.Auth(creds)
if err == nil {
t.Errorf("Missing error for known bad password")
return
}
t.Logf("Successful bad password auth attempt: %v", err)
}