-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth_test.go
56 lines (53 loc) · 1.1 KB
/
auth_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
44
45
46
47
48
49
50
51
52
53
54
55
56
package sendowl
import (
"net/url"
"testing"
)
func TestSigningText(t *testing.T) {
var tests = []struct {
signingKeySecret string
url.Values
signingText string
}{
{
"sauce",
url.Values{},
"&secret=sauce",
},
{
"sauce",
url.Values{"expires_at": {"1234"}},
"expires_at=1234&secret=sauce",
},
{
"sauce",
url.Values{"z": {"1"}, "expires_at": {"1234"}},
"expires_at=1234&z=1&secret=sauce",
},
}
for i, tt := range tests {
actual := SigningText(tt.signingKeySecret, tt.Values)
if actual != tt.signingText {
t.Errorf("%d. SigningText(%s, %q) = %q, want %q", i, tt.signingKeySecret, tt.Values, actual, tt.signingKeySecret)
}
}
}
func TestSigningKey(t *testing.T) {
var tests = []struct {
signingKey string
signingKeySecret string
expected string
}{
{
"barbeque",
"sauce",
"barbeque&sauce",
},
}
for i, tt := range tests {
actual := SigningKey(tt.signingKey, tt.signingKeySecret)
if actual != tt.expected {
t.Errorf("%d. SigningKey(%q, %q) = %q, want %q", i, tt.signingKey, tt.signingKeySecret, actual, tt.expected)
}
}
}