Better split buffer testing for CONNECT, fixes issue #63.

This commit is contained in:
Derek Collison
2014-11-16 08:58:36 -08:00
parent 7341e4b48c
commit 65ff554574
4 changed files with 89 additions and 6 deletions

View File

@@ -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)
}

View File

@@ -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)
}