-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsignature_test.go
43 lines (38 loc) · 999 Bytes
/
signature_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package pusher
import (
"testing"
)
func TestSign(t *testing.T) {
signature := &Signature{
"key",
"secret",
"POST",
"/some/path",
"1234",
"1.0",
[]byte("content"),
map[string]string{"query": "params", "go": "here"},
}
expected := "5da41b658c67bb135898072d6d325e7a98e5f790d9c7c70cc5e210173d81be52"
sig := signature.Sign()
if expected != sig {
t.Errorf("Sign(): Expected %s, got %s", expected, sig)
}
}
func TestEncodedQuery(t *testing.T) {
signature := &Signature{
"key",
"secret",
"POST",
"/some/path",
"1234",
"1.0",
[]byte("content"),
map[string]string{"query": "params", "go": "here"},
}
expected := "auth_key=key&auth_signature=5da41b658c67bb135898072d6d325e7a98e5f790d9c7c70cc5e210173d81be52&auth_timestamp=1234&auth_version=1.0&body_md5=9a0364b9e99bb480dd25e1f0284c8555&go=here&query=params"
encodedQuery := signature.EncodedQuery()
if expected != encodedQuery {
t.Errorf("EncodedQuery(): Expected %s, got %s", expected, encodedQuery)
}
}