1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-12-03 23:19:17 +02:00
Files
imgproxy/crypt_test.go

39 lines
785 B
Go
Raw Normal View History

package main
import (
"testing"
"github.com/stretchr/testify/assert"
2018-11-06 17:19:34 +06:00
"github.com/stretchr/testify/suite"
)
2018-11-06 17:19:34 +06:00
type CryptTestSuite struct{ MainTestSuite }
func (s *CryptTestSuite) SetupTest() {
s.MainTestSuite.SetupTest()
2018-11-02 21:35:21 +06:00
conf.Key = []byte("test-key")
conf.Salt = []byte("test-salt")
2018-11-06 17:19:34 +06:00
}
func (s *CryptTestSuite) TestValidatePath() {
err := validatePath("dtLwhdnPPiu_epMl1LrzheLpvHas-4mwvY6L3Z8WwlY", "asd")
assert.Nil(s.T(), err)
}
func (s *CryptTestSuite) TestValidatePathTruncated() {
conf.SignatureSize = 8
2018-11-06 17:19:34 +06:00
err := validatePath("dtLwhdnPPis", "asd")
assert.Nil(s.T(), err)
}
func (s *CryptTestSuite) TestValidatePathInvalid() {
err := validatePath("dtLwhdnPPis", "asd")
assert.Error(s.T(), err)
}
func TestCrypt(t *testing.T) {
suite.Run(t, new(CryptTestSuite))
}