mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Better split buffer testing for CONNECT, fixes issue #63.
This commit is contained in:
@@ -173,3 +173,23 @@ func TestSubToArgState(t *testing.T) {
|
||||
send("SUBZZZ foo 1\r\n")
|
||||
expect(errRe)
|
||||
}
|
||||
|
||||
// Issue #63
|
||||
func TestProtoCrash(t *testing.T) {
|
||||
s := runProtoServer()
|
||||
defer s.Shutdown()
|
||||
|
||||
c := createClientConn(t, "localhost", PROTO_TEST_PORT)
|
||||
defer c.Close()
|
||||
|
||||
send, expect := sendCommand(t, c), expectCommand(t, c)
|
||||
|
||||
checkInfoMsg(t, c)
|
||||
|
||||
send("CONNECT {\"verbose\":true,\"ssl_required\":false,\"user\":\"test\",\"pedantic\":true,\"pass\":\"password\"}")
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
send("\r\n")
|
||||
expect(okRe)
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ func checkSocket(t tLogger, addr string, wait time.Duration) {
|
||||
t.Fatalf("Failed to connect to the socket: %q", addr)
|
||||
}
|
||||
|
||||
func doConnect(t tLogger, c net.Conn, verbose, pedantic, ssl bool) {
|
||||
func checkInfoMsg(t tLogger, c net.Conn) {
|
||||
buf := expectResult(t, c, infoRe)
|
||||
js := infoRe.FindAllSubmatch(buf, 1)[0][1]
|
||||
var sinfo server.Info
|
||||
@@ -192,6 +192,10 @@ func doConnect(t tLogger, c net.Conn, verbose, pedantic, ssl bool) {
|
||||
if err != nil {
|
||||
stackFatalf(t, "Could not unmarshal INFO json: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func doConnect(t tLogger, c net.Conn, verbose, pedantic, ssl bool) {
|
||||
checkInfoMsg(t, c)
|
||||
cs := fmt.Sprintf("CONNECT {\"verbose\":%v,\"pedantic\":%v,\"ssl_required\":%v}\r\n", verbose, pedantic, ssl)
|
||||
sendProto(t, c, cs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user