overflow_discovery/service/matcher/redis/redis_test.go

38 lines
553 B
Go
Raw Normal View History

2017-11-21 12:47:55 +00:00
package redis
import (
"git.loafle.net/overflow/overflow_discovery/match/packet"
"net"
"testing"
)
const (
ADDR string = "192.168.1.16:26379"
)
func TestRedisMatcher(t *testing.T) {
m := NewRedisMatcher()
conn, _ := net.Dial("tcp", ADDR)
defer conn.Close()
for i := 0; i < m.PacketCount(); i++ {
pack := m.Packet(i)
conn.Write(pack.Buffer)
bytes := make([]byte, 1024)
n, _ := conn.Read(bytes)
p := packet.NewPacket(bytes, n)
if m.Match(i, p, nil) {
t.Log("Redis found.")
return
}
t.Error("Redis not found")
}
}