photoprism/internal/entity/auth_client_add_test.go
Michael Mayer 06a18f5818 Auth: Add "access_token" authentication provider type #782 #808 #3943
Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-19 14:41:08 +01:00

44 lines
755 B
Go

package entity
import (
"testing"
"github.com/photoprism/photoprism/internal/form"
"github.com/stretchr/testify/assert"
)
func Test_AddClient(t *testing.T) {
t.Run("Success", func(t *testing.T) {
m := form.Client{
ClientName: "test",
AuthProvider: "client_credentials",
AuthMethod: "oauth2",
AuthScope: "all",
}
c, err := AddClient(m)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "test", c.ClientName)
})
t.Run("ClientNameEmpty", func(t *testing.T) {
m := form.Client{
ClientName: "",
AuthProvider: "client_credentials",
AuthMethod: "oauth2",
AuthScope: "all",
}
c, err := AddClient(m)
if err == nil {
t.Fatal("error expected")
}
assert.Equal(t, "", c.ClientName)
})
}