photoprism/internal/api/share_preview_test.go
Michael Mayer 713593da4e Auth: Add CLI command to create access tokens for apps #782 #808 #3943
You can now run "photoprism auth add" to create new client access tokens
that allow external applications to use the built-in REST API.

Signed-off-by: Michael Mayer <michael@photoprism.app>
2024-01-05 16:31:07 +01:00

29 lines
819 B
Go

package api
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/photoprism/photoprism/internal/config"
)
func TestGetPreview(t *testing.T) {
t.Run("NotFound", func(t *testing.T) {
app, router, conf := NewApiTest()
conf.SetAuthMode(config.AuthModePasswd)
defer conf.SetAuthMode(config.AuthModePublic)
SharePreview(router)
r := PerformRequest(app, "GET", "api/v1/s/1jxf3jfn2k/ss6sg6bxpogaaba7/preview")
assert.Equal(t, http.StatusNotFound, r.Code)
})
t.Run("InvalidToken", func(t *testing.T) {
app, router, conf := NewApiTest()
conf.SetAuthMode(config.AuthModePasswd)
defer conf.SetAuthMode(config.AuthModePublic)
SharePreview(router)
r := PerformRequest(app, "GET", "api/v1/s/xxx/ss6sg6bxpogaaba7/preview")
assert.Equal(t, http.StatusNotFound, r.Code)
})
}