feat(tunnel): implement the fake tunnel (#298)
This functionality should be helpful to test that the general interface of the tunnel package is okay from the engine package. Part of https://github.com/ooni/probe/issues/985
This commit is contained in:
parent
76a50facc3
commit
973501dd11
8 changed files with 234 additions and 4 deletions
44
internal/engine/tunnel/fake_integration_test.go
Normal file
44
internal/engine/tunnel/fake_integration_test.go
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package tunnel_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/tunnel"
|
||||
)
|
||||
|
||||
func TestFakeStartStop(t *testing.T) {
|
||||
// no need to skip because the bootstrap is obviously fast
|
||||
tunnelDir, err := ioutil.TempDir("testdata", "fake")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx := context.Background()
|
||||
sess, err := engine.NewSession(ctx, engine.SessionConfig{
|
||||
Logger: log.Log,
|
||||
SoftwareName: "miniooni",
|
||||
SoftwareVersion: "0.1.0-dev",
|
||||
TunnelDir: tunnelDir,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tunnel, err := tunnel.Start(context.Background(), &tunnel.Config{
|
||||
Name: "fake",
|
||||
Session: sess,
|
||||
TunnelDir: tunnelDir,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if tunnel.SOCKS5ProxyURL() == nil {
|
||||
t.Fatal("expected non nil URL here")
|
||||
}
|
||||
if tunnel.BootstrapTime() <= 0 {
|
||||
t.Fatal("expected positive bootstrap time here")
|
||||
}
|
||||
tunnel.Stop()
|
||||
}
|
||||
Loading…
Reference in a new issue