Attach /r/n to msg to avoid extra write. Fix auth checks

This commit is contained in:
Derek Collison
2013-08-19 12:14:29 -07:00
parent cb6a71fb46
commit 8fa318738c
5 changed files with 55 additions and 15 deletions

View File

@@ -169,7 +169,8 @@ func TestParsePub(t *testing.T) {
t.Fatalf("Did not parse msg size correctly: 5 vs %d\n", c.pa.size)
}
c.state = OP_START
// Clear snapshots
c.argBuf, c.msgBuf, c.state = nil, nil, OP_START
pub = []byte("PUB foo.bar INBOX.22 11\r\nhello world\r")
err = c.parse(pub)
@@ -243,7 +244,8 @@ func TestParseMsg(t *testing.T) {
t.Fatalf("Did not parse sid correctly: 'RSID:1:2' vs '%s'\n", c.pa.sid)
}
c.state = OP_START
// Clear snapshots
c.argBuf, c.msgBuf, c.state = nil, nil, OP_START
pub = []byte("MSG foo.bar RSID:1:2 INBOX.22 11\r\nhello world\r")
err = c.parse(pub)
@@ -341,4 +343,12 @@ func TestShouldFail(t *testing.T) {
if err := c.parse([]byte("SUB foo bar baz 22\r\n")); err == nil {
t.Fatal("Should have received a parse error")
}
c.state = OP_START
if err := c.parse([]byte("PUB foo 2\r\nok \r\n")); err == nil {
t.Fatal("Should have received a parse error")
}
c.state = OP_START
if err := c.parse([]byte("PUB foo 2\r\nok\r \n")); err == nil {
t.Fatal("Should have received a parse error")
}
}