Skip to content

Commit fb88a80

Browse files
committed
chore(tests): add hello integration test
1 parent 12097ea commit fb88a80

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/hello_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package tests
2+
3+
import (
4+
"crypto/tls"
5+
"testing"
6+
"time"
7+
8+
"github.com/pixel365/goepp"
9+
"github.com/stretchr/testify/assert"
10+
"github.com/stretchr/testify/require"
11+
)
12+
13+
func TestHello(t *testing.T) {
14+
addr := netAddr()
15+
conn, err := tls.Dial("tcp", addr, &tls.Config{
16+
MinVersion: tls.VersionTLS12,
17+
InsecureSkipVerify: true, //nolint:gosec
18+
})
19+
20+
require.NoError(t, err)
21+
22+
_ = conn.SetDeadline(time.Now().Add(10 * time.Second))
23+
_, _ = readEPPFrame(conn)
24+
25+
payload := `
26+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
27+
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
28+
<hello/>
29+
</epp>
30+
`
31+
32+
err = writeEPPFrame(conn, []byte(payload))
33+
require.NoError(t, err)
34+
35+
resp, err := readEPPFrame(conn)
36+
require.NoError(t, err)
37+
38+
parser := goepp.CmdParser{}
39+
_, err = parser.Parse(resp)
40+
41+
require.Error(t, err)
42+
assert.Contains(t, err.Error(), "exactly one command must be present")
43+
44+
t.Cleanup(func() {
45+
_ = conn.Close()
46+
})
47+
}

0 commit comments

Comments
 (0)