]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t0300-credentials.sh
credential: refuse to operate when missing host or protocol
[thirdparty/git.git] / t / t0300-credentials.sh
index 1c1010bc54cd567411d10521b5e1878239a4ffb0..646f8456ff772f91e018d65d859ab60e6c55ec44 100755 (executable)
@@ -400,18 +400,16 @@ test_expect_success 'empty helper spec resets helper list' '
        EOF
 '
 
-test_expect_success 'url parser ignores embedded newlines' '
-       check fill <<-EOF
+test_expect_success 'url parser rejects embedded newlines' '
+       test_must_fail git credential fill 2>stderr <<-\EOF &&
        url=https://one.example.com?%0ahost=two.example.com/
-       --
-       username=askpass-username
-       password=askpass-password
-       --
+       EOF
+       cat >expect <<-\EOF &&
        warning: url contains a newline in its host component: https://one.example.com?%0ahost=two.example.com/
        warning: skipping credential lookup for url: https://one.example.com?%0ahost=two.example.com/
-       askpass: Username:
-       askpass: Password:
+       fatal: refusing to work with credential missing host field
        EOF
+       test_i18ncmp expect stderr
 '
 
 test_expect_success 'host-less URLs are parsed as empty host' '
@@ -431,4 +429,24 @@ test_expect_success 'host-less URLs are parsed as empty host' '
        EOF
 '
 
+test_expect_success 'credential system refuses to work with missing host' '
+       test_must_fail git credential fill 2>stderr <<-\EOF &&
+       protocol=http
+       EOF
+       cat >expect <<-\EOF &&
+       fatal: refusing to work with credential missing host field
+       EOF
+       test_i18ncmp expect stderr
+'
+
+test_expect_success 'credential system refuses to work with missing protocol' '
+       test_must_fail git credential fill 2>stderr <<-\EOF &&
+       host=example.com
+       EOF
+       cat >expect <<-\EOF &&
+       fatal: refusing to work with credential missing protocol field
+       EOF
+       test_i18ncmp expect stderr
+'
+
 test_done