forked from ooni/probe-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webconnectivityqa): add test for android_dns_cache_no_data (ooni…
…#1210) Part of ooni/probe#2029. The general idea is to modify v0.4 in a subsequent PR to make it WAI for this test case. Currently v0.4 does not correctly support this case, which is why we're doing this work. (See also ooni/probe#2499).
- Loading branch information
1 parent
5affe05
commit b735b3d
Showing
13 changed files
with
132 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package webconnectivityqa | ||
|
||
import ( | ||
"github.com/ooni/probe-cli/v3/internal/netemx" | ||
) | ||
|
||
// dnsBlockingAndroidDNSCacheNoData is the case where we're on Android and the getaddrinfo | ||
// resolver returns the android_dns_cache_no_data error. | ||
func dnsBlockingAndroidDNSCacheNoData() *TestCase { | ||
return &TestCase{ | ||
Name: "measuring https://www.example.com/ with getaddrinfo errors and android_dns_cache_no_data", | ||
Flags: TestCaseFlagNoV04, | ||
Input: "https://www.example.com/", | ||
Configure: func(env *netemx.QAEnv) { | ||
// make sure the env knows we want to emulate our getaddrinfo wrapper behavior | ||
env.EmulateAndroidGetaddrinfo(true) | ||
|
||
// remove the record so that the DNS query returns NXDOMAIN, which is then | ||
// converted into android_dns_cache_no_data by the emulation layer | ||
env.ISPResolverConfig().RemoveRecord("www.example.com") | ||
}, | ||
ExpectErr: false, | ||
ExpectTestKeys: &testKeys{Accessible: false, Blocking: "dns"}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package webconnectivityqa | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"testing" | ||
|
||
"github.com/apex/log" | ||
"github.com/ooni/probe-cli/v3/internal/netemx" | ||
"github.com/ooni/probe-cli/v3/internal/netxlite" | ||
) | ||
|
||
func TestDNSBlockingAndroidDNSCacheNoData(t *testing.T) { | ||
env := netemx.MustNewScenario(netemx.InternetScenario) | ||
tc := dnsBlockingAndroidDNSCacheNoData() | ||
tc.Configure(env) | ||
|
||
env.Do(func() { | ||
reso := netxlite.NewStdlibResolver(log.Log) | ||
addrs, err := reso.LookupHost(context.Background(), "www.example.com") | ||
if !errors.Is(err, netxlite.ErrAndroidDNSCacheNoData) { | ||
t.Fatal("unexpected error", err) | ||
} | ||
if len(addrs) != 0 { | ||
t.Fatal("expected to see no addresses") | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package netemx | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/ooni/netem" | ||
"github.com/ooni/probe-cli/v3/internal/netxlite" | ||
) | ||
|
||
// androidStack wraps [netem.UnderlyingNetwork] to simulate what our getaddrinfo | ||
// wrapper does on Android when it sees the EAI_NODATA return value. | ||
type androidStack struct { | ||
netem.UnderlyingNetwork | ||
} | ||
|
||
// GetaddrinfoLookupANY implements [netem.UnderlyingNetwork] | ||
func (as *androidStack) GetaddrinfoLookupANY(ctx context.Context, domain string) ([]string, string, error) { | ||
addrs, cname, err := as.UnderlyingNetwork.GetaddrinfoLookupANY(ctx, domain) | ||
if err != nil { | ||
err = netxlite.NewErrGetaddrinfo(0, netxlite.ErrAndroidDNSCacheNoData) | ||
} | ||
return addrs, cname, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters