forked from vponomarev/libsmpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp_test.go
87 lines (77 loc) · 2.55 KB
/
http_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package libsmpp
import (
// "fmt"
"github.com/franela/goblin"
"testing"
)
func TestHTTPFunctions(t *testing.T) {
g := goblin.Goblin(t)
g.Describe("HTTP Encode tests", func() {
g.It("Encode simple packet", func() {
expected := "{\"ServiceType\":\"Service\",\"Source\":{\"TON\":5,\"NPI\":0,\"Addr\":\"TestMSG\"},\"Dest\":{\"TON\":1,\"NPI\":1,\"Addr\":\"79037011111\"},\"ESMClass\":5,\"ProtocolID\":6,\"PriorityFlag\":7,\"ScheduledDeliveryTime\":\"SDT\",\"ValidityPeriod\":\"VP\",\"RegisteredDelivery\":1,\"ReplaceIfPresent\":1,\"DataCoding\":8,\"SmDefaultMsgID\":0,\"SmLength\":0,\"ShortMessages\":\"MSG Content\",\"TLV\":null}"
s := SMPPSubmit{
ServiceType: "Service",
Source: SMPPAddress{
TON: 5,
NPI: 0,
Addr: "TestMSG",
},
Dest: SMPPAddress{
TON: 1,
NPI: 1,
Addr: "79037011111",
},
ESMClass: 5,
ProtocolID: 6,
PriorityFlag: 7,
ScheduledDeliveryTime: "SDT",
ValidityPeriod: "VP",
RegisteredDelivery: 1,
ReplaceIfPresent: 1,
DataCoding: 8,
SmDefaultMsgID: 0,
SmLength: 0,
ShortMessages: "MSG Content",
}
res, err := s.toJSON()
g.Assert(string(res)).Equal(expected)
g.Assert(err).Equal(nil)
})
g.It("Encode packet with TLV's", func() {
expected := "{\"ServiceType\":\"Service\",\"Source\":{\"TON\":5,\"NPI\":0,\"Addr\":\"TestMSG\"},\"Dest\":{\"TON\":1,\"NPI\":1,\"Addr\":\"79037011111\"},\"ESMClass\":5,\"ProtocolID\":6,\"PriorityFlag\":7,\"ScheduledDeliveryTime\":\"SDT\",\"ValidityPeriod\":\"VP\",\"RegisteredDelivery\":1,\"ReplaceIfPresent\":1,\"DataCoding\":8,\"SmDefaultMsgID\":0,\"SmLength\":0,\"ShortMessages\":\"MSG Content\",\"TLV\":{\"37\":{\"Data\":\"AAECAw==\",\"Len\":4}}}"
s := SMPPSubmit{
ServiceType: "Service",
Source: SMPPAddress{
TON: 5,
NPI: 0,
Addr: "TestMSG",
},
Dest: SMPPAddress{
TON: 1,
NPI: 1,
Addr: "79037011111",
},
ESMClass: 5,
ProtocolID: 6,
PriorityFlag: 7,
ScheduledDeliveryTime: "SDT",
ValidityPeriod: "VP",
RegisteredDelivery: 1,
ReplaceIfPresent: 1,
DataCoding: 8,
SmDefaultMsgID: 0,
SmLength: 0,
ShortMessages: "MSG Content",
TLV: map[TLVCode]TLVStruct{
TLVCode(0x25): {
Data: []byte("\x00\x01\x02\x03"),
Len: 4,
},
},
}
res, err := s.toJSON()
g.Assert(string(res)).Equal(expected)
g.Assert(err).Equal(nil)
})
})
}