2020-02-03 15:50:46 +01:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2022-10-13 22:11:02 +02:00
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/internal/config"
|
2020-02-03 15:50:46 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetPreview(t *testing.T) {
|
2022-10-13 22:11:02 +02:00
|
|
|
t.Run("NotFound", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
|
|
|
conf.SetAuthMode(config.AuthModePasswd)
|
|
|
|
defer conf.SetAuthMode(config.AuthModePublic)
|
2020-06-26 14:26:36 +02:00
|
|
|
SharePreview(router)
|
2021-03-10 15:52:38 +01:00
|
|
|
r := PerformRequest(app, "GET", "api/v1/s/1jxf3jfn2k/st9lxuqxpogaaba7/preview")
|
2020-05-13 20:05:33 +02:00
|
|
|
assert.Equal(t, http.StatusNotFound, r.Code)
|
2020-02-03 15:50:46 +01:00
|
|
|
})
|
2022-10-13 22:11:02 +02:00
|
|
|
t.Run("InvalidToken", func(t *testing.T) {
|
|
|
|
app, router, conf := NewApiTest()
|
|
|
|
conf.SetAuthMode(config.AuthModePasswd)
|
|
|
|
defer conf.SetAuthMode(config.AuthModePublic)
|
2020-07-14 17:02:39 +02:00
|
|
|
SharePreview(router)
|
2021-03-10 15:52:38 +01:00
|
|
|
r := PerformRequest(app, "GET", "api/v1/s/xxx/st9lxuqxpogaaba7/preview")
|
2020-07-14 17:02:39 +02:00
|
|
|
assert.Equal(t, http.StatusNotFound, r.Code)
|
|
|
|
})
|
2020-02-03 15:50:46 +01:00
|
|
|
}
|