Skip to content

Commit

Permalink
QA/webconnectivity: connection refused in redirect chain
Browse files Browse the repository at this point in the history
Make sure we do the same MK would do in this case.

Part of #810.
  • Loading branch information
bassosimone committed Aug 14, 2020
1 parent 99adf78 commit 27d8d9b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
31 changes: 31 additions & 0 deletions QA/webconnectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,36 @@ def runner(port):
common.with_free_port(runner)


def webconnectivity_http_connection_refused_with_consistent_dns(ooni_exe, outfile):
""" Test case where there's TCP/IP blocking w/ consistent DNS that occurs
while we're following the chain of redirects. """
# We use a bit.ly link redirecting to nexa.polito.it. We block the IP address
# used by nexa.polito.it. So the error should happen in the redirect chain.
ip = socket.gethostbyname("nexa.polito.it")
args = [
"-iptables-reset-ip",
ip,
]
tk = execute_jafar_and_return_validated_test_keys(
ooni_exe,
outfile,
"-i https://bit.ly/3h9EJR3 web_connectivity",
"webconnectivity_tcpip_blocking_with_consistent_dns",
args,
)
assert tk["dns_experiment_failure"] == None
assert tk["dns_consistency"] == "consistent"
assert tk["control_failure"] == None
assert tk["http_experiment_failure"] == "connection_refused"
assert tk["body_length_match"] == None
assert tk["body_proportion"] == 0
assert tk["status_code_match"] == None
assert tk["headers_match"] == None
assert tk["title_match"] == None
assert tk["blocking"] == "http-failure"
assert tk["accessible"] == False


def main():
if len(sys.argv) != 2:
sys.exit("usage: %s /path/to/ooniprobelegacy-like/binary" % sys.argv[0])
Expand All @@ -208,6 +238,7 @@ def main():
webconnectivity_nonexistent_domain,
webconnectivity_tcpip_blocking_with_consistent_dns,
webconnectivity_tcpip_blocking_with_inconsistent_dns,
webconnectivity_http_connection_refused_with_consistent_dns,
]
for test in tests:
test(ooni_exe, outfile)
Expand Down
5 changes: 3 additions & 2 deletions experiment/webconnectivity/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ func Summarize(tk *TestKeys) (out Summary) {
switch *tk.Requests[0].Failure {
case modelx.FailureConnectionRefused:
// This is possibly because a subsequent connection to some
// other endpoint has been blocked. So tcp-ip.
out.BlockingReason = &tcpIP
// other endpoint has been blocked. We call this http-failure
// because this is what MK would actually do.
out.BlockingReason = &httpFailure
out.Accessible = &inaccessible
case modelx.FailureConnectionReset:
// We don't currently support TLS failures and we don't have a
Expand Down
4 changes: 2 additions & 2 deletions experiment/webconnectivity/summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ func TestSummarize(t *testing.T) {
},
},
wantOut: webconnectivity.Summary{
BlockingReason: &tcpIP,
Blocking: &tcpIP,
BlockingReason: &httpFailure,
Blocking: &httpFailure,
Accessible: &falseValue,
},
}, {
Expand Down

0 comments on commit 27d8d9b

Please sign in to comment.