2021-02-02 12:05:47 +01:00
|
|
|
package geolocate
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
"net/http"
|
2021-03-22 14:31:50 +01:00
|
|
|
"os"
|
2021-02-02 12:05:47 +01:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/apex/log"
|
2021-02-03 12:23:15 +01:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestIPLookupWorksUsingIPConfig(t *testing.T) {
|
2021-03-22 14:31:50 +01:00
|
|
|
if os.Getenv("CI") == "true" {
|
|
|
|
// See https://github.com/ooni/probe-cli/pull/259/checks?check_run_id=2166066881#step:5:123
|
|
|
|
// as well as https://github.com/ooni/probe/issues/1418.
|
|
|
|
t.Skip("This test does not work with GitHub Actions")
|
|
|
|
}
|
2021-02-02 12:05:47 +01:00
|
|
|
ip, err := ipConfigIPLookup(
|
|
|
|
context.Background(),
|
|
|
|
http.DefaultClient,
|
|
|
|
log.Log,
|
|
|
|
httpheader.UserAgent(),
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if net.ParseIP(ip) == nil {
|
|
|
|
t.Fatalf("not an IP address: '%s'", ip)
|
|
|
|
}
|
|
|
|
}
|