fix(probeservices): use api.ooni.io (#926)

See https://github.com/ooni/probe/issues/2147.

Note that this PR also tries to reduce usage of legacy names inside unit/integration tests.
This commit is contained in:
Simone Basso
2022-09-02 16:48:14 +02:00
committed by GitHub
parent 535be51cd1
commit 7df25795c0
12 changed files with 35 additions and 76 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ func newclient() probeservices.Client {
ua := fmt.Sprintf("apitool/%s ooniprobe-engine/%s", version.Version, version.Version)
return probeservices.Client{
APIClientTemplate: httpx.APIClientTemplate{
BaseURL: "https://ams-pg.ooni.org/",
BaseURL: "https://api.ooni.io/",
HTTPClient: &http.Client{Transport: txp},
Logger: log.Log,
UserAgent: ua,
@@ -25,7 +25,7 @@ func TestBlock(t *testing.T) {
// Here we're filtering any domain containing ooni.io, so we
// expect the proxy to send 451 without actually proxing, thus
// there should not be any Via header in the output.
checkrequest(t, addr.String(), "mia-ps.ooni.io", 451, false)
checkrequest(t, addr.String(), "api.ooni.io", 451, false)
killproxy(t, server)
}
+1 -1
View File
@@ -21,7 +21,7 @@ func TestPass(t *testing.T) {
func TestBlock(t *testing.T) {
listener := newproxy(t, "ooni.io")
checkdialtls(t, listener.Addr().String(), false, &tls.Config{
ServerName: "mia-ps.ooni.io",
ServerName: "api.ooni.io",
})
killproxy(t, listener)
}
+14 -12
View File
@@ -86,7 +86,7 @@ func TestOOClientDoWithEmptyServerURL(t *testing.T) {
func TestOOClientDoWithInvalidTargetURL(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{TargetURL: "\t", ServerURL: "https://wcth.ooni.io"}
config := internal.OOConfig{TargetURL: "\t", ServerURL: "https://0.th.ooni.org"}
clnt := internal.OOClient{}
cresp, err := clnt.Do(ctx, config)
if !errors.Is(err, internal.ErrInvalidURL) {
@@ -104,7 +104,7 @@ func TestOOClientDoWithResolverFailure(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
HTTPClient: http.DefaultClient,
@@ -114,10 +114,12 @@ func TestOOClientDoWithResolverFailure(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if len(cresp.TCPConnect) > 0 {
// The current implementation of the test helper (the legacy codebase)
// only follows the IP addresses returned by the client.
t.Fatal("expected empty TCPConnect here")
if len(cresp.TCPConnect) <= 0 {
// The legacy implementation of the test helper (the legacy codebase)
// only follows the IP addresses returned by the client. However, since
// https://github.com/ooni/probe-cli/pull/890, the TH is following the
// IP addresses from the probe as well as its own addresses.
t.Fatal("expected non-empty TCPConnect here")
}
if cresp.HTTPRequest.StatusCode != 200 {
t.Fatal("expected 200 status code here")
@@ -131,7 +133,7 @@ func TestOOClientDoWithUnsupportedExplicitPort(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com:8080",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
@@ -168,7 +170,7 @@ func TestOOClientDoWithRoundTripError(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
@@ -189,7 +191,7 @@ func TestOOClientDoWithInvalidStatusCode(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
@@ -214,7 +216,7 @@ func TestOOClientDoWithBodyReadError(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
@@ -240,7 +242,7 @@ func TestOOClientDoWithInvalidJSON(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
@@ -290,7 +292,7 @@ func TestOOClientDoWithParseableJSON(t *testing.T) {
ctx := context.Background()
config := internal.OOConfig{
TargetURL: "http://www.example.com",
ServerURL: "https://wcth.ooni.io",
ServerURL: "https://0.th.ooni.org",
}
clnt := internal.OOClient{
Resolver: internal.NewFakeResolverWithResult([]string{"1.1.1.1"}),
+1 -1
View File
@@ -49,7 +49,7 @@ func main() {
func wcth() interface{} {
serverURL := *server
if serverURL == "" {
serverURL = "https://wcth.ooni.io/"
serverURL = "https://0.th.ooni.org/"
}
clnt := internal.OOClient{HTTPClient: httpClient, Resolver: resolver}
config := internal.OOConfig{TargetURL: *target, ServerURL: serverURL}
+1 -1
View File
@@ -67,7 +67,7 @@ func TestDNSDo(t *testing.T) {
t.Run("returns non-nil addresses list on nxdomin", func(t *testing.T) {
ctx := context.Background()
config := &dnsConfig{
Domain: "antani.ooni.org",
Domain: "www.ooni.nonexistent",
Logger: model.DiscardLogger,
NewResolver: func(model.Logger) model.Resolver {
return &mocks.Resolver{