-
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(webconnectivityqa): add more QA tests (#1397)
This diff adds more QA tests extracted from #1392. Part of ooni/probe#2634.
- Loading branch information
1 parent
683d20c
commit c4241a0
Showing
7 changed files
with
124 additions
and
4 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,37 @@ | ||
package webconnectivityqa | ||
|
||
import ( | ||
"github.com/ooni/netem" | ||
"github.com/ooni/probe-cli/v3/internal/netemx" | ||
) | ||
|
||
// httpBlockingConnectionReset verifies the case where there is a connection reset | ||
// when the host header is emitted on the wire in cleartext. | ||
func httpBlockingConnectionReset() *TestCase { | ||
return &TestCase{ | ||
Name: "httpBlockingConnectionReset", | ||
Flags: 0, | ||
Input: "http://www.example.com/", | ||
Configure: func(env *netemx.QAEnv) { | ||
|
||
env.DPIEngine().AddRule(&netem.DPIResetTrafficForString{ | ||
Logger: env.Logger(), | ||
ServerIPAddress: netemx.AddressWwwExampleCom, | ||
ServerPort: 80, | ||
String: "www.example.com", | ||
}) | ||
|
||
}, | ||
ExpectErr: false, | ||
ExpectTestKeys: &testKeys{ | ||
DNSConsistency: "consistent", | ||
// TODO(bassosimone): it seems LTE QA does not check for the value of | ||
// the HTTPExperimentFailure field, why? | ||
HTTPExperimentFailure: "connection_reset", | ||
XStatus: 8448, // StatusExperimentHTTP | StatusAnomalyReadWrite | ||
XBlockingFlags: 8, // analysisFlagHTTPBlocking | ||
Accessible: false, | ||
Blocking: "http-failure", | ||
}, | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
internal/experiment/webconnectivityqa/httpblocking_test.go
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,33 @@ | ||
package webconnectivityqa | ||
|
||
import ( | ||
"net/http" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/apex/log" | ||
"github.com/ooni/probe-cli/v3/internal/netemx" | ||
"github.com/ooni/probe-cli/v3/internal/netxlite" | ||
) | ||
|
||
func TestHTTPBlockingConnectionReset(t *testing.T) { | ||
env := netemx.MustNewScenario(netemx.InternetScenario) | ||
defer env.Close() | ||
|
||
tc := httpBlockingConnectionReset() | ||
tc.Configure(env) | ||
|
||
env.Do(func() { | ||
dialer := netxlite.NewDialerWithStdlibResolver(log.Log) | ||
tlsDialer := netxlite.NewTLSDialer(dialer, netxlite.NewTLSHandshakerStdlib(log.Log)) | ||
txp := netxlite.NewHTTPTransportWithOptions(log.Log, dialer, tlsDialer) | ||
client := &http.Client{Transport: txp} | ||
resp, err := client.Get("http://www.example.com/") | ||
if err == nil || !strings.HasSuffix(err.Error(), "connection_reset") { | ||
t.Fatal("unexpected err", err) | ||
} | ||
if resp != nil { | ||
t.Fatal("expected nil resp") | ||
} | ||
}) | ||
} |
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