mirror of
https://github.com/bolkedebruin/rdpgw.git
synced 2025-08-17 14:03:50 +02:00
Add tunnelauth tests
This commit is contained in:
parent
057799e0e5
commit
29d4b276e6
2 changed files with 79 additions and 0 deletions
|
@ -12,6 +12,8 @@ const (
|
|||
HandshakeResponseLen = HeaderLen + 10
|
||||
TunnelCreateRequestLen = HeaderLen + 8 // + dynamic
|
||||
TunnelCreateResponseLen = HeaderLen + 18
|
||||
TunnelAuthLen = HeaderLen + 2 // + dynamic
|
||||
TunnelAuthResponseLen = HeaderLen + 16
|
||||
)
|
||||
|
||||
func verifyPacketHeader(data []byte , expPt uint16, expSize uint32) (uint16, uint32, []byte, error) {
|
||||
|
@ -113,4 +115,47 @@ func TestTunnelCreation(t *testing.T) {
|
|||
if !((caps & HTTP_CAPABILITY_IDLE_TIMEOUT) == HTTP_CAPABILITY_IDLE_TIMEOUT) {
|
||||
t.Fatalf("tunnelResponse failed got caps %d, expected %d", caps, caps | HTTP_CAPABILITY_IDLE_TIMEOUT)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTunnelAuth(t *testing.T) {
|
||||
client := ClientConfig{}
|
||||
s := &SessionInfo{}
|
||||
hc := &HandlerConf{
|
||||
TokenAuth: true,
|
||||
IdleTimeout: 10,
|
||||
RedirectFlags: RedirectFlags{
|
||||
Clipboard: true,
|
||||
},
|
||||
}
|
||||
h := NewHandler(s, hc)
|
||||
name := "test_name"
|
||||
|
||||
data := client.tunnelAuthRequest(name)
|
||||
_, _, pkt, err := verifyPacketHeader(data, PKT_TYPE_TUNNEL_AUTH, uint32(TunnelAuthLen + len(name) * 2))
|
||||
if err != nil {
|
||||
t.Fatalf("verifyHeader failed: %s", err)
|
||||
}
|
||||
|
||||
n := h.readTunnelAuthRequest(pkt)
|
||||
if n != name {
|
||||
t.Fatalf("readTunnelAuthRequest failed got name %s, expected %s", n, name)
|
||||
}
|
||||
|
||||
data = h.createTunnelAuthResponse()
|
||||
_, _, pkt, err = verifyPacketHeader(data, PKT_TYPE_TUNNEL_AUTH_RESPONSE, TunnelAuthResponseLen)
|
||||
if err != nil {
|
||||
t.Fatalf("verifyHeader failed: %s", err)
|
||||
}
|
||||
flags, timeout, err := client.tunnelAuthResponse(pkt)
|
||||
if err != nil {
|
||||
t.Fatalf("tunnel auth error %s", err)
|
||||
}
|
||||
if (flags & HTTP_TUNNEL_REDIR_DISABLE_CLIPBOARD) == HTTP_TUNNEL_REDIR_DISABLE_CLIPBOARD {
|
||||
t.Fatalf("tunnelAuthResponse failed got flags %d, expected %d",
|
||||
flags, flags | HTTP_TUNNEL_REDIR_DISABLE_CLIPBOARD)
|
||||
}
|
||||
if int(timeout) != hc.IdleTimeout {
|
||||
t.Fatalf("tunnelAuthResponse failed got timeout %d, expected %d",
|
||||
timeout, hc.IdleTimeout)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue