2 Star 8 Fork 6

user_499098 / imgproxy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
crypt_test.go 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
DarthSim 提交于 2018-11-15 18:35 . Multiple key/salt pairs support
package main
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type CryptTestSuite struct{ MainTestSuite }
func (s *CryptTestSuite) SetupTest() {
s.MainTestSuite.SetupTest()
conf.Keys = []securityKey{securityKey("test-key")}
conf.Salts = []securityKey{securityKey("test-salt")}
}
func (s *CryptTestSuite) TestValidatePath() {
err := validatePath("dtLwhdnPPiu_epMl1LrzheLpvHas-4mwvY6L3Z8WwlY", "asd")
assert.Nil(s.T(), err)
}
func (s *CryptTestSuite) TestValidatePathTruncated() {
conf.SignatureSize = 8
err := validatePath("dtLwhdnPPis", "asd")
assert.Nil(s.T(), err)
}
func (s *CryptTestSuite) TestValidatePathInvalid() {
err := validatePath("dtLwhdnPPis", "asd")
assert.Error(s.T(), err)
}
func (s *CryptTestSuite) TestValidatePathMultiplePairs() {
conf.Keys = append(conf.Keys, securityKey("test-key2"))
conf.Salts = append(conf.Salts, securityKey("test-salt2"))
err := validatePath("dtLwhdnPPiu_epMl1LrzheLpvHas-4mwvY6L3Z8WwlY", "asd")
assert.Nil(s.T(), err)
err = validatePath("jbDffNPt1-XBgDccsaE-XJB9lx8JIJqdeYIZKgOqZpg", "asd")
assert.Nil(s.T(), err)
err = validatePath("dtLwhdnPPis", "asd")
assert.Error(s.T(), err)
}
func TestCrypt(t *testing.T) {
suite.Run(t, new(CryptTestSuite))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/yunwisdoms/imgproxy.git
git@gitee.com:yunwisdoms/imgproxy.git
yunwisdoms
imgproxy
imgproxy
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891