forked from fioprotocol/fiostore
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhandler_test.go
39 lines (33 loc) · 1.09 KB
/
handler_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
package fiostore
import "testing"
func Test_parseRequest(t *testing.T) {
tokens = []string{"abc", "123"}
_, resp, _ := parseRequest([]byte(`{"fio_address":"","chain_code":"","token_code":"","amount":0.0,"memo":"","access_token":""}`))
if resp == nil {
t.Error("nil response")
return
}
if resp.Code != 403 {
t.Error("failed auth check")
}
_, resp, _ = parseRequest([]byte(`{"fio_address":"test@fiotestnet","chain_code":"","token_code":"","amount":0.0,"memo":"","access_token":"abc"}`))
if resp == nil {
t.Error("nil response")
return
}
if resp.Code == 403 {
t.Error("auth check did not allow valid token")
}
if resp.Message != `request fields cannot be blank` {
t.Error("blank field check failed")
}
_, resp, _ = parseRequest([]byte(`{"fio_address":"b@d@fiotestnet","chain_code":"","token_code":"","amount":0.0,"memo":"","access_token":"abc"}`))
if resp == nil {
t.Error("nil response")
return
}
if resp.Message != `invalid FIO address` {
t.Error("allowed invalid fio address")
}
}
// {"fio_address":"","chain_code":"","token_code":"","amount":0.0,"memo":"","access_token":""}