Commit 7d7001637efa0f961efcb25e7125045c11010475

Authored by Antonio Terceiro
1 parent 384a932a

Extract logic for greping headers

We need to remove the trailing \r's
test/bin/grep-header 0 → 100755
... ... @@ -0,0 +1,8 @@
  1 +#!/bin/sh
  2 +
  3 +set -eu
  4 +
  5 +header="$1"
  6 +
  7 +sed -e "/^$header:/ !d; s/\r//"
  8 +
... ...
test/gitlab_test.sh
... ... @@ -18,7 +18,7 @@ test_static_content_served_correctly() {
18 18 }
19 19  
20 20 test_redirects_to_the_correct_host() {
21   - redirect=$(curl-host softwarepublico.dev --head https://softwarepublico.dev/gitlab/dashboard/projects | grep Location:)
  21 + redirect=$(curl-host softwarepublico.dev --head https://softwarepublico.dev/gitlab/dashboard/projects | grep-header Location)
22 22 assertEquals "Location: https://softwarepublico.dev/gitlab/users/sign_in" "$redirect"
23 23 }
24 24  
... ...
test/reverse_proxy_test.sh
1 1 . $(dirname $0)/test_helper.sh
2 2  
3 3 test_redirect_http_to_https() {
4   - local redirect="$(curl --header 'Host: softwarepublico.dev' --head http://$reverseproxy/ | sed -e '/Location:/ !d; s/\r//')"
  4 + local redirect="$(curl --header 'Host: softwarepublico.dev' --head http://$reverseproxy/ | grep-header Location)"
5 5 assertEquals "Location: https://softwarepublico.dev/" "$redirect"
6 6 }
7 7  
... ...