-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpanda_test.go
38 lines (31 loc) · 1.1 KB
/
panda_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
package panda
import (
"testing"
)
const (
testCloudId = "<INSERT YOUR CLOUD ID HERE>"
testAccessKey = "<INSERT YOUR ACCESS KEY HERE>"
testSecretKey = "<INSERT YOUR SECRET KEY HERE>"
testApiHost = "api.pandastream.com"
testApiPort = 443
)
func Test_SignatureGeneration(t *testing.T) {
// example values from http://www.pandastream.com/docs/api#api_authentication
exampleTestCloudId := "123456789"
exampleTestAccessKey := "abcdefgh"
exampleTestSecretKey := "ijklmnop"
exampleTestApiHost := "api.pandastream.com"
exampleTestApiPort := 443
exampleTestTimestamp := "2011-03-01T15:39:10.260762Z"
exampleTestSignedSignature := "kVnZs%2FNX13ldKPdhFYoVnoclr8075DwiZF0TGgIbMsc%3D"
client := &PandaApi{}
client.Init(exampleTestAccessKey, exampleTestSecretKey, exampleTestCloudId, exampleTestApiHost, exampleTestApiPort)
signedParams, err := client.signedParams("GET", "/videos.json", nil, exampleTestTimestamp)
if err != nil {
t.Error(err.Error())
}
if URLEscape(signedParams["signature"]) != exampleTestSignedSignature {
t.Log(signedParams["signature"])
t.Error("Signature does not match")
}
}