ooni-probe-cli/internal/engine/geolocate/cloudflare_test.go

29 lines
531 B
Go
Raw Normal View History

package geolocate
import (
"context"
"net"
"net/http"
"testing"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/model"
"github.com/ooni/probe-cli/v3/internal/netxlite"
)
func TestIPLookupWorksUsingcloudlflare(t *testing.T) {
ip, err := cloudflareIPLookup(
context.Background(),
http.DefaultClient,
log.Log,
model.HTTPHeaderUserAgent,
netxlite.NewStdlibResolver(model.DiscardLogger),
)
if err != nil {
t.Fatal(err)
}
if net.ParseIP(ip) == nil {
t.Fatalf("not an IP address: '%s'", ip)
}
}