t0300: add tests for some additional cases
There are some tricky cases in our credential helpers that we don't have test cases for. To help prevent regressions, let's add some for these cases: * If there are multiple configured credential helpers, one without a path and one with a path, we want to invoke both of them. * If there are percent-encoded values in the URL, we handle them properly. * And finally, if there is a username in the remote URL, we want to honor that over what the configuration tells us. Finally, there's an additional case that we'd like to test for as well, but that currently fails. In all other situations in our configuration, we pick the last configuration setting that's provided. However, we fail to do that for credential.username, where we pick the first setting instead. Let's add a failing test that we have the consistent behavior here, since that's the documented, expected behavior. Signed-off-by: brian m. carlson <bk2204@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
732f934408
commit
588c70e10f
@ -240,6 +240,57 @@ test_expect_success 'do not match configured credential' '
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success 'match multiple configured helpers' '
|
||||
test_config credential.helper "verbatim \"\" \"\"" &&
|
||||
test_config credential.https://example.com.helper "$HELPER" &&
|
||||
check fill <<-\EOF
|
||||
protocol=https
|
||||
host=example.com
|
||||
path=repo.git
|
||||
--
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=foo
|
||||
password=bar
|
||||
--
|
||||
verbatim: get
|
||||
verbatim: protocol=https
|
||||
verbatim: host=example.com
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success 'match multiple configured helpers with URLs' '
|
||||
test_config credential.https://example.com/repo.git.helper "verbatim \"\" \"\"" &&
|
||||
test_config credential.https://example.com.helper "$HELPER" &&
|
||||
check fill <<-\EOF
|
||||
protocol=https
|
||||
host=example.com
|
||||
path=repo.git
|
||||
--
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=foo
|
||||
password=bar
|
||||
--
|
||||
verbatim: get
|
||||
verbatim: protocol=https
|
||||
verbatim: host=example.com
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success 'match percent-encoded values' '
|
||||
test_config credential.https://example.com/%2566.git.helper "$HELPER" &&
|
||||
check fill <<-\EOF
|
||||
url=https://example.com/%2566.git
|
||||
--
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=foo
|
||||
password=bar
|
||||
--
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success 'pull username from config' '
|
||||
test_config credential.https://example.com.username foo &&
|
||||
check fill <<-\EOF
|
||||
@ -255,6 +306,63 @@ test_expect_success 'pull username from config' '
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success 'honors username from URL over helper (URL)' '
|
||||
test_config credential.https://example.com.username bob &&
|
||||
test_config credential.https://example.com.helper "verbatim \"\" bar" &&
|
||||
check fill <<-\EOF
|
||||
url=https://alice@example.com
|
||||
--
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=alice
|
||||
password=bar
|
||||
--
|
||||
verbatim: get
|
||||
verbatim: protocol=https
|
||||
verbatim: host=example.com
|
||||
verbatim: username=alice
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success 'honors username from URL over helper (components)' '
|
||||
test_config credential.https://example.com.username bob &&
|
||||
test_config credential.https://example.com.helper "verbatim \"\" bar" &&
|
||||
check fill <<-\EOF
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=alice
|
||||
--
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=alice
|
||||
password=bar
|
||||
--
|
||||
verbatim: get
|
||||
verbatim: protocol=https
|
||||
verbatim: host=example.com
|
||||
verbatim: username=alice
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_failure 'last matching username wins' '
|
||||
test_config credential.https://example.com/path.git.username bob &&
|
||||
test_config credential.https://example.com.username alice &&
|
||||
test_config credential.https://example.com.helper "verbatim \"\" bar" &&
|
||||
check fill <<-\EOF
|
||||
url=https://example.com/path.git
|
||||
--
|
||||
protocol=https
|
||||
host=example.com
|
||||
username=alice
|
||||
password=bar
|
||||
--
|
||||
verbatim: get
|
||||
verbatim: protocol=https
|
||||
verbatim: host=example.com
|
||||
verbatim: username=alice
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success 'http paths can be part of context' '
|
||||
check fill "verbatim foo bar" <<-\EOF &&
|
||||
protocol=https
|
||||
|
Loading…
Reference in New Issue
Block a user