mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-10 20:22:31 +02:00
Option to use truncated signature (#88)
* CircleCI * Fix docs resize_type -> resizing_type (#91) As noted in my issue... * Option to use truncated signature * Don't use 0 as no-limit for SignatureSize
This commit is contained in:
committed by
Sergey Alexandrovich
parent
7f5f312dfc
commit
7aae98e087
21
crypt_test.go
Normal file
21
crypt_test.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestSignatureFor(t *testing.T) {
|
||||
oldSignatureSize := conf.SignatureSize
|
||||
base64Signature := func(x string) string { return base64.RawURLEncoding.EncodeToString(signatureFor(x)) }
|
||||
conf.Key = []byte("test-key")
|
||||
conf.Salt = []byte("test-salt")
|
||||
assert.Equal(t, "dtLwhdnPPiu_epMl1LrzheLpvHas-4mwvY6L3Z8WwlY", base64Signature("asd"))
|
||||
assert.Equal(t, "8x1xvzxVqZ3Uz3kEC8gVvBfU0dfU1vKv0Gho8m3Ysgw", base64Signature("qwe"))
|
||||
conf.SignatureSize = 8
|
||||
assert.Equal(t, "dtLwhdnPPis", base64Signature("asd"))
|
||||
assert.Equal(t, "8x1xvzxVqZ0", base64Signature("qwe"))
|
||||
conf.SignatureSize = oldSignatureSize
|
||||
}
|
Reference in New Issue
Block a user