From 7d7001637efa0f961efcb25e7125045c11010475 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Mon, 2 Mar 2015 14:40:13 -0300 Subject: [PATCH] Extract logic for greping headers --- test/bin/grep-header | 8 ++++++++ test/gitlab_test.sh | 2 +- test/reverse_proxy_test.sh | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100755 test/bin/grep-header diff --git a/test/bin/grep-header b/test/bin/grep-header new file mode 100755 index 0000000..a3d4a6f --- /dev/null +++ b/test/bin/grep-header @@ -0,0 +1,8 @@ +#!/bin/sh + +set -eu + +header="$1" + +sed -e "/^$header:/ !d; s/\r//" + diff --git a/test/gitlab_test.sh b/test/gitlab_test.sh index 10ddb45..4ced1ac 100644 --- a/test/gitlab_test.sh +++ b/test/gitlab_test.sh @@ -18,7 +18,7 @@ test_static_content_served_correctly() { } test_redirects_to_the_correct_host() { - redirect=$(curl-host softwarepublico.dev --head https://softwarepublico.dev/gitlab/dashboard/projects | grep Location:) + redirect=$(curl-host softwarepublico.dev --head https://softwarepublico.dev/gitlab/dashboard/projects | grep-header Location) assertEquals "Location: https://softwarepublico.dev/gitlab/users/sign_in" "$redirect" } diff --git a/test/reverse_proxy_test.sh b/test/reverse_proxy_test.sh index bae2ba4..f1b63a0 100644 --- a/test/reverse_proxy_test.sh +++ b/test/reverse_proxy_test.sh @@ -1,7 +1,7 @@ . $(dirname $0)/test_helper.sh test_redirect_http_to_https() { - local redirect="$(curl --header 'Host: softwarepublico.dev' --head http://$reverseproxy/ | sed -e '/Location:/ !d; s/\r//')" + local redirect="$(curl --header 'Host: softwarepublico.dev' --head http://$reverseproxy/ | grep-header Location)" assertEquals "Location: https://softwarepublico.dev/" "$redirect" } -- libgit2 0.21.2