-
Notifications
You must be signed in to change notification settings - Fork 3
/
ringcentral_test.go
58 lines (47 loc) · 1.38 KB
/
ringcentral_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
57
58
package ringcentral
import (
"encoding/json"
"os"
"strings"
"testing"
)
func TestAuthorize(t *testing.T) {
rc := RestClient{
ClientID: os.Getenv("RINGCENTRAL_CLIENT_ID"),
ClientSecret: os.Getenv("RINGCENTRAL_CLIENT_SECRET"),
Server: os.Getenv("RINGCENTRAL_SERVER_URL"),
}
rc.Authorize(GetTokenRequest{
GrantType: "password",
Username: os.Getenv("RINGCENTRAL_USERNAME"),
Extension: os.Getenv("RINGCENTRAL_EXTENSION"),
Password: os.Getenv("RINGCENTRAL_PASSWORD"),
})
if len(rc.Token.AccessToken) <= 0 {
t.Error("access token length invalid")
}
rc.Revoke()
if rc.Token != nil {
t.Error("Revoke failed")
}
}
func TestAPICall(t *testing.T) {
rc := RestClient{
ClientID: os.Getenv("RINGCENTRAL_CLIENT_ID"),
ClientSecret: os.Getenv("RINGCENTRAL_CLIENT_SECRET"),
Server: os.Getenv("RINGCENTRAL_SERVER_URL"),
}
rc.Authorize(GetTokenRequest{
GrantType: "password",
Username: os.Getenv("RINGCENTRAL_USERNAME"),
Extension: os.Getenv("RINGCENTRAL_EXTENSION"),
Password: os.Getenv("RINGCENTRAL_PASSWORD"),
})
bytes := rc.Post("/restapi/v1.0/client-info/sip-provision", strings.NewReader(`{"sipInfo":[{"transport":"WSS"}]}`))
var createSipRegistrationResponse CreateSipRegistrationResponse
json.Unmarshal(bytes, &createSipRegistrationResponse)
if len(createSipRegistrationResponse.SipInfo) <= 0 {
t.Error("No SipInfo")
}
rc.Revoke()
}