d6def35286
This implements the bare minimum needed to have circumvention proxy support in OONI Probe CLI. The reference issue is https://github.com/ooni/probe/issues/1955. (Most of that issue is implemented, save for the fact that currently we do not have support for `http` and `https` proxies.) While there, add to `Makefile` a rule for correctly building `ooniprobe` and `miniooni` for "this system" (i.e., the default `GOOS` and `GOARCH` on a system), because we needed this for testing this patch and we needed to figure out the commands instead.
30 lines
573 B
Go
30 lines
573 B
Go
package ooni
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path"
|
|
"testing"
|
|
)
|
|
|
|
func TestInit(t *testing.T) {
|
|
ooniHome, err := ioutil.TempDir("", "oonihome")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer os.RemoveAll(ooniHome)
|
|
|
|
probe := NewProbe("", ooniHome)
|
|
swName := "ooniprobe-cli-tests"
|
|
swVersion := "3.0.0-alpha"
|
|
if err := probe.Init(swName, swVersion, ""); err != nil {
|
|
t.Error(err)
|
|
t.Fatal("failed to init the context")
|
|
}
|
|
|
|
configPath := path.Join(ooniHome, "config.json")
|
|
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
|
t.Fatal("config file was not created")
|
|
}
|
|
}
|