mirror of https://github.com/fatedier/frp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
52 lines
1.6 KiB
package framework
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/fatedier/frp/test/e2e/pkg/request"
|
|
)
|
|
|
|
func ExpectRequest(protocol string, port int, in, out []byte, timeout time.Duration, explain ...interface{}) {
|
|
switch protocol {
|
|
case "tcp":
|
|
ExpectTCPRequest(port, in, out, timeout, explain...)
|
|
case "udp":
|
|
ExpectUDPRequest(port, in, out, timeout, explain...)
|
|
default:
|
|
Failf("ExpectRequest not support protocol: %s", protocol)
|
|
}
|
|
}
|
|
|
|
func ExpectRequestError(protocol string, port int, in []byte, timeout time.Duration, explain ...interface{}) {
|
|
switch protocol {
|
|
case "tcp":
|
|
ExpectTCPRequestError(port, in, timeout, explain...)
|
|
case "udp":
|
|
ExpectUDPRequestError(port, in, timeout, explain...)
|
|
default:
|
|
Failf("ExpectRequestError not support protocol: %s", protocol)
|
|
}
|
|
}
|
|
|
|
func ExpectTCPRequest(port int, in, out []byte, timeout time.Duration, explain ...interface{}) {
|
|
res, err := request.SendTCPRequest(port, in, timeout)
|
|
ExpectNoError(err, explain...)
|
|
ExpectEqual(string(out), res, explain...)
|
|
}
|
|
|
|
func ExpectTCPRequestError(port int, in []byte, timeout time.Duration, explain ...interface{}) {
|
|
_, err := request.SendTCPRequest(port, in, timeout)
|
|
ExpectError(err, explain...)
|
|
}
|
|
|
|
func ExpectUDPRequest(port int, in, out []byte, timeout time.Duration, explain ...interface{}) {
|
|
res, err := request.SendUDPRequest(port, in, timeout)
|
|
ExpectNoError(err, explain...)
|
|
ExpectEqual(string(out), res, explain...)
|
|
}
|
|
|
|
func ExpectUDPRequestError(port int, in []byte, timeout time.Duration, explain ...interface{}) {
|
|
_, err := request.SendUDPRequest(port, in, timeout)
|
|
ExpectError(err, explain...)
|
|
}
|