Working auth and photo json endpoint
Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
parent
ef275f97f4
commit
e4323b6047
2032 changed files with 821464 additions and 52 deletions
|
@ -48,21 +48,3 @@ func TestMain(m *testing.M) {
|
|||
// --- [ Tests ] ---
|
||||
|
||||
}
|
||||
|
||||
func TestHappyAPI(t *testing.T) {
|
||||
// Code to validate the API
|
||||
if true {
|
||||
t.Logf("Success!\n")
|
||||
} else {
|
||||
t.Errorf("Failure!\n")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSadAPI(t *testing.T) {
|
||||
// Code to validate the API
|
||||
if !false {
|
||||
t.Logf("Success!\n")
|
||||
} else {
|
||||
t.Errorf("Failure!\n")
|
||||
}
|
||||
}
|
||||
|
|
35
test/session_test.go
Normal file
35
test/session_test.go
Normal 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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue