photoprism/internal/config/config_auth_test.go
Michael Mayer 92e6c4fe1e Download: Add Disabled, Originals, MediaRaw & MediaSidecar Flags #2234
Extends DownloadSettings with 4 additional options:
- Name: File name pattern for downloaded files (existed)
- Disabled: Disables downloads
- Originals: Only download files stored in "originals" folder
- MediaRaw: Include RAW image files
- MediaSidecar: Include metadata sidecar files (JSON, XMP, YAML)
2022-04-15 09:42:07 +02:00

55 lines
1.3 KiB
Go

package config
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestUtils_CheckPassword(t *testing.T) {
c := NewConfig(CliTestContext())
formPassword := "photoprism"
c.options.AdminPassword = "$2b$10$cRhWIleqJkbaFWhBMp54VOI25RvVubxOooCWzWgdrvl5COFxaBnAy"
check := c.CheckPassword(formPassword)
assert.True(t, check)
c.options.AdminPassword = "photoprism"
check = c.CheckPassword(formPassword)
assert.True(t, check)
c.options.AdminPassword = "$2b$10$yprZEQzm/Qy7AaePXtKfkem0kANBZgRwl8HbLE4JrjK6/8Pypgi1W"
check = c.CheckPassword(formPassword)
assert.False(t, check)
c.options.AdminPassword = "admin"
check = c.CheckPassword(formPassword)
assert.False(t, check)
}
func TestUtils_isBcrypt(t *testing.T) {
p := "$2b$10$cRhWIleqJkbaFWhBMp54VOI25RvVubxOooCWzWgdrvl5COFxaBnAy"
assert.True(t, isBcrypt(p))
p = "$2b$10$cRhWIleqJkbaFWhBMp54VOI25RvVubxOooCWzWgdrvl5COFxaBnA"
assert.False(t, isBcrypt(p))
p = "admin"
assert.False(t, isBcrypt(p))
p = ""
assert.False(t, isBcrypt(p))
}
func TestConfig_InvalidDownloadToken(t *testing.T) {
c := NewConfig(CliTestContext())
assert.True(t, c.InvalidDownloadToken("xxx"))
}
func TestConfig_InvalidPreviewToken(t *testing.T) {
c := NewConfig(CliTestContext())
assert.True(t, c.InvalidPreviewToken("xxx"))
}