fixed test

This commit is contained in:
snoop 2017-08-08 18:40:28 +09:00
parent 2e33d4b23c
commit 354f334cc3

View File

@ -1,71 +1,71 @@
package mysql
//
//import (
// "crypto/tls"
// "git.loafle.net/overflow/overflow_probe/collector/core/scan/service/matcher/packet"
// "net"
// "testing"
//)
//
//func TestMySql(t *testing.T) {
//
// m := NewMySqlMatcher()
//
// /*
// 192.168.1.103:3306 - normal
// 192.168.1.105:8306 - ssl
// 192.168.1.203:3306 - mysql with error code
// */
// conn, _ := net.Dial("tcp", "192.168.1.215:3306")
//
// defer conn.Close()
//
// bytes := make([]byte, 1024)
// n, _ := conn.Read(bytes)
// p := packet.NewPacket(bytes, n)
//
// if m.Match(0, p, nil) {
// t.Log(m.ServiceName())
// return
// }
//
// t.Error("MySQL not found")
//
//}
//
//func TestCassandraTLS(t *testing.T) {
//
// m := NewMySqlMatcher()
//
// conn, err := tls.Dial(
// "tcp",
// "192.168.1.105:8306",
// &tls.Config{
// InsecureSkipVerify: true,
// ServerName: "192.168.1.105",
// },
// )
// if err != nil {
// t.Fatal(err)
// }
//
// 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(m.ServiceName())
// return
// }
//
// t.Error("MySQL not found")
// }
//
//}
import (
"crypto/tls"
"git.loafle.net/overflow/overflow_probe/matcher/packet"
"net"
"testing"
)
func TestMySql(t *testing.T) {
m := NewMySqlMatcher()
/*
192.168.1.103:3306 - normal
192.168.1.105:8306 - ssl
192.168.1.203:3306 - mysql with error code
*/
conn, _ := net.Dial("tcp", "192.168.1.15:3306")
defer conn.Close()
bytes := make([]byte, 1024)
n, _ := conn.Read(bytes)
p := packet.NewPacket(bytes, n)
if m.Match(0, p, nil) {
t.Log(m.ServiceName())
return
}
t.Error("MySQL not found")
}
func TestCassandraTLS(t *testing.T) {
m := NewMySqlMatcher()
conn, err := tls.Dial(
"tcp",
"192.168.1.105:8306",
&tls.Config{
InsecureSkipVerify: true,
ServerName: "192.168.1.105",
},
)
if err != nil {
t.Fatal(err)
}
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(m.ServiceName())
return
}
t.Error("MySQL not found")
}
}