-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: clearly indicate which resolver we're using
See what we documented at ooni/spec#257 Reference issue: ooni/probe#2238 While there, bump [email protected] version because this change has an impact onto the generated data format.
- Loading branch information
1 parent
c3964e4
commit 8a04419
Showing
19 changed files
with
362 additions
and
59 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,47 @@ | ||
package measurex | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/miekg/dns" | ||
"github.com/ooni/probe-cli/v3/internal/model/mocks" | ||
"github.com/ooni/probe-cli/v3/internal/netxlite" | ||
) | ||
|
||
func TestDNSXModifiesStdlibTransportName(t *testing.T) { | ||
// See https://github.com/ooni/spec/pull/257 for more information. | ||
child := netxlite.NewDNSOverGetaddrinfoTransport() | ||
mx := NewMeasurerWithDefaultSettings() | ||
dbout := &MeasurementDB{} | ||
txp := mx.WrapDNSXRoundTripper(dbout, child) | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
cancel() // we want to fail immediately | ||
query := &mocks.DNSQuery{ | ||
MockDomain: func() string { | ||
return "dns.google" | ||
}, | ||
MockType: func() uint16 { | ||
return dns.TypeANY | ||
}, | ||
MockBytes: func() ([]byte, error) { | ||
return []byte{}, nil | ||
}, | ||
MockID: func() uint16 { | ||
return 1453 | ||
}, | ||
} | ||
_, _ = txp.RoundTrip(ctx, query) | ||
measurement := dbout.AsMeasurement() | ||
var good int | ||
for _, rtinfo := range measurement.DNSRoundTrip { | ||
network := rtinfo.Network | ||
if network != netxlite.StdlibResolverSystem { | ||
t.Fatal("unexpected network", network) | ||
} | ||
good++ | ||
} | ||
if good < 1 { | ||
t.Fatal("no good entry seen") | ||
} | ||
} |
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,58 @@ | ||
package measurex | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/ooni/probe-cli/v3/internal/model" | ||
"github.com/ooni/probe-cli/v3/internal/netxlite" | ||
) | ||
|
||
func TestResolverModifiesStdlibResolverName(t *testing.T) { | ||
// See https://github.com/ooni/spec/pull/257 for more information. | ||
|
||
t.Run("for LookupHost", func(t *testing.T) { | ||
child := netxlite.NewStdlibResolver(model.DiscardLogger) | ||
mx := NewMeasurerWithDefaultSettings() | ||
dbout := &MeasurementDB{} | ||
txp := mx.WrapResolver(dbout, child) | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
cancel() // we want to fail immediately | ||
_, _ = txp.LookupHost(ctx, "dns.google") | ||
measurement := dbout.AsMeasurement() | ||
var good int | ||
for _, rtinfo := range measurement.LookupHost { | ||
network := rtinfo.Network | ||
if network != netxlite.StdlibResolverSystem { | ||
t.Fatal("unexpected network", network) | ||
} | ||
good++ | ||
} | ||
if good < 1 { | ||
t.Fatal("no good entry seen") | ||
} | ||
}) | ||
|
||
t.Run("for LookupHTTPS", func(t *testing.T) { | ||
child := netxlite.NewStdlibResolver(model.DiscardLogger) | ||
mx := NewMeasurerWithDefaultSettings() | ||
dbout := &MeasurementDB{} | ||
txp := mx.WrapResolver(dbout, child) | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
cancel() // we want to fail immediately | ||
_, _ = txp.LookupHTTPS(ctx, "dns.google") | ||
measurement := dbout.AsMeasurement() | ||
var good int | ||
for _, rtinfo := range measurement.LookupHTTPSSvc { | ||
network := rtinfo.Network | ||
if network != netxlite.StdlibResolverSystem { | ||
t.Fatal("unexpected network", network) | ||
} | ||
good++ | ||
} | ||
if good < 1 { | ||
t.Fatal("no good entry seen") | ||
} | ||
}) | ||
|
||
} |
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
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
Oops, something went wrong.