mirror of
https://github.com/jpillora/chisel
synced 2026-06-08 15:07:02 +00:00
53e72fe2ba
* split out share/ package into multiple subpackages * added share/compat.go to keep backward compatibility(ish) * moved shared tunnelling logic from client/server packages into share/tunnel/ * added remote protocol "<host>:<port>/<protocol>", currently supporting tcp and udp * added an end-to-end test suite * added TODO e2e tests as contribution targets * added deep context integration for improved cleanup and cancellation
49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
package e2e_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
chclient "github.com/jpillora/chisel/client"
|
|
chserver "github.com/jpillora/chisel/server"
|
|
)
|
|
|
|
func TestBase(t *testing.T) {
|
|
tmpPort := availablePort()
|
|
//setup server, client, fileserver
|
|
teardown := simpleSetup(t,
|
|
&chserver.Config{},
|
|
&chclient.Config{
|
|
Remotes: []string{tmpPort + ":$FILEPORT"},
|
|
})
|
|
defer teardown()
|
|
//test remote
|
|
result, err := post("http://localhost:"+tmpPort, "foo")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if result != "foo!" {
|
|
t.Fatalf("expected exclamation mark added")
|
|
}
|
|
}
|
|
|
|
func TestReverse(t *testing.T) {
|
|
tmpPort := availablePort()
|
|
//setup server, client, fileserver
|
|
teardown := simpleSetup(t,
|
|
&chserver.Config{
|
|
Reverse: true,
|
|
},
|
|
&chclient.Config{
|
|
Remotes: []string{"R:" + tmpPort + ":$FILEPORT"},
|
|
})
|
|
defer teardown()
|
|
//test remote (this goes through the server and out the client)
|
|
result, err := post("http://localhost:"+tmpPort, "foo")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if result != "foo!" {
|
|
t.Fatalf("expected exclamation mark added")
|
|
}
|
|
}
|