summaryrefslogtreecommitdiff
path: root/t/t0300-credentials.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-04-22 13:43:01 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-04-22 13:43:01 -0700
commita397e9c236b0ff56eb15f32a2a41c852b1e5dd3b (patch)
treef9f4f596a2e9a5647684c9d8086b05859dc7f614 /t/t0300-credentials.sh
parentMerge branch 'jt/rebase-allow-duplicate' (diff)
parentcredential: treat "?" and "#" in URLs as end of host (diff)
downloadtgif-a397e9c236b0ff56eb15f32a2a41c852b1e5dd3b.tar.xz
Merge branch 'jk/credential-parsing-end-of-host-in-URL'
Parsing of URL for the credential helper has been corrected. * jk/credential-parsing-end-of-host-in-URL: credential: treat "?" and "#" in URLs as end of host
Diffstat (limited to 't/t0300-credentials.sh')
-rwxr-xr-xt/t0300-credentials.sh36
1 files changed, 35 insertions, 1 deletions
diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
index 5555a1524f..48484cbcf6 100755
--- a/t/t0300-credentials.sh
+++ b/t/t0300-credentials.sh
@@ -532,7 +532,7 @@ test_expect_success 'url parser rejects embedded newlines' '
url=https://one.example.com?%0ahost=two.example.com/
EOF
cat >expect <<-\EOF &&
- warning: url contains a newline in its host component: https://one.example.com?%0ahost=two.example.com/
+ warning: url contains a newline in its path component: https://one.example.com?%0ahost=two.example.com/
fatal: credential url cannot be parsed: https://one.example.com?%0ahost=two.example.com/
EOF
test_i18ncmp expect stderr
@@ -575,4 +575,38 @@ test_expect_success 'credential system refuses to work with missing protocol' '
test_i18ncmp expect stderr
'
+# usage: check_host_and_path <url> <expected-host> <expected-path>
+check_host_and_path () {
+ # we always parse the path component, but we need this to make sure it
+ # is passed to the helper
+ test_config credential.useHTTPPath true &&
+ check fill "verbatim user pass" <<-EOF
+ url=$1
+ --
+ protocol=https
+ host=$2
+ path=$3
+ username=user
+ password=pass
+ --
+ verbatim: get
+ verbatim: protocol=https
+ verbatim: host=$2
+ verbatim: path=$3
+ EOF
+}
+
+test_expect_success 'url parser handles bare query marker' '
+ check_host_and_path https://example.com?foo.git example.com ?foo.git
+'
+
+test_expect_success 'url parser handles bare fragment marker' '
+ check_host_and_path https://example.com#foo.git example.com "#foo.git"
+'
+
+test_expect_success 'url parser not confused by encoded markers' '
+ check_host_and_path https://example.com%23%3f%2f/foo.git \
+ "example.com#?/" foo.git
+'
+
test_done