2022-02-09 11:54:19 +01:00
|
|
|
package geolocate
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/apex/log"
|
2022-05-25 09:54:50 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/model"
|
2022-10-12 18:07:42 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
2022-02-09 11:54:19 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestIPLookupWorksUsingcloudlflare(t *testing.T) {
|
|
|
|
ip, err := cloudflareIPLookup(
|
|
|
|
context.Background(),
|
|
|
|
http.DefaultClient,
|
|
|
|
log.Log,
|
2022-05-25 09:54:50 +02:00
|
|
|
model.HTTPHeaderUserAgent,
|
2022-10-12 18:07:42 +02:00
|
|
|
netxlite.NewStdlibResolver(model.DiscardLogger),
|
2022-02-09 11:54:19 +01:00
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if net.ParseIP(ip) == nil {
|
|
|
|
t.Fatalf("not an IP address: '%s'", ip)
|
|
|
|
}
|
|
|
|
}
|