-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathsession_test.go
52 lines (46 loc) · 1.35 KB
/
session_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
package epp
import (
"encoding/xml"
"testing"
"github.com/nbio/st"
)
func TestEncodeLogin(t *testing.T) {
x, err := encodeLogin("jane", "battery", "", "1.0", "en", nil, nil)
st.Expect(t, err, nil)
st.Expect(t, string(x), `<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"><command><login><clID>jane</clID><pw>battery</pw><options><version>1.0</version><lang>en</lang></options><svcs></svcs></login></command></epp>`)
var v struct{}
err = xml.Unmarshal(x, &v)
st.Expect(t, err, nil)
}
func TestEncodeLoginChangePassword(t *testing.T) {
x, err := encodeLogin("jane", "battery", "horse", "1.0", "en", nil, nil)
st.Expect(t, err, nil)
st.Expect(t, string(x), `<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"><command><login><clID>jane</clID><pw>battery</pw><newPW>horse</newPW><options><version>1.0</version><lang>en</lang></options><svcs></svcs></login></command></epp>`)
var v struct{}
err = xml.Unmarshal(x, &v)
st.Expect(t, err, nil)
}
var (
testObjects = []string{
ObjContact,
ObjDomain,
ObjFinance,
ObjHost,
}
testExtensions = []string{
ExtCharge,
ExtFee05,
ExtFee06,
ExtIDN,
ExtLaunch,
ExtRGP,
ExtSecDNS,
}
)
func BenchmarkEncodeLogin(b *testing.B) {
for i := 0; i < b.N; i++ {
encodeLogin("jane", "battery", "horse", "1.0", "en", testObjects, testExtensions)
}
}