diff options
author | 2016-02-24 22:02:39 +0000 | |
---|---|---|
committer | 2016-02-25 14:13:16 +0000 | |
commit | 6e30521e0d230ba8138cb8bbe3bf3f4fb4fbfa60 (patch) | |
tree | d8a08c01f7a3a97a007f4e8e8cd4054e6f8ccf06 /src/test/shell/bazel | |
parent | e9bf0b407427158da672671eed7a0435e8d3d513 (diff) |
Handle http <-> https redirects
Support all 301 and 302 redirect handling in bazel. Only support
absolute Location redirects (this is the spec, we can revisit if we
find a lot of servers are doing it wrong).
Fixes #959.
--
MOS_MIGRATED_REVID=115490327
Diffstat (limited to 'src/test/shell/bazel')
-rwxr-xr-x | src/test/shell/bazel/external_integration_test.sh | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/test/shell/bazel/external_integration_test.sh b/src/test/shell/bazel/external_integration_test.sh index d65b35aa86..ce2980d9ea 100755 --- a/src/test/shell/bazel/external_integration_test.sh +++ b/src/test/shell/bazel/external_integration_test.sh @@ -345,6 +345,31 @@ EOF expect_log "Tra-la!" } +function test_http_to_https_redirect() { + http_response=$TEST_TMPDIR/http_response + cat > $http_response <<EOF +HTTP/1.0 301 Moved Permantently +Location: https://localhost:123456789/bad-port-shouldnt-work +EOF + nc_port=$(pick_random_unused_tcp_port) || exit 1 + nc_l $nc_port < $http_response & + nc_pid=$! + + cd ${WORKSPACE_DIR} + cat > WORKSPACE <<EOF +http_file( + name = 'toto', + url = 'http://localhost:$nc_port/toto', + sha256 = 'whatever' +) +EOF + bazel build @toto//file &> $TEST_log && fail "Expected run to fail" + kill_nc + # Observes that we tried to follow redirect, but failed due to ridiculous + # port. + expect_log "Failed to connect.*port out of range" +} + function test_http_404() { http_response=$TEST_TMPDIR/http_response cat > $http_response <<EOF @@ -366,7 +391,7 @@ http_file( EOF bazel build @toto//file &> $TEST_log && fail "Expected run to fail" kill_nc - expect_log "404: Help, I'm lost!" + expect_log "404 Not Found: Help, I'm lost!" } # Tests downloading a file and using it as a dependency. |