t: make credential helper handle local URLs
The lfstest credential helper provides credentials found by reading a file on the system. Currently, it expects that there is a colon in the URL followed by one or more slashes. If there is not (say, because we're using a file:/// or cert:/// URL), it fails to concatenate the path properly, and instead of looking in the credentials directory, looks for a different file one directory higher. This occurs because filepath.Join strips off a trailing slash if the second argument passed to it is empty. This, of course, makes the credential helper fail to work and the tests hang waiting for input. Insert an additional slash in the environment variable and handle the empty string case properly so that credentials for local paths can be looked up properly.
This commit is contained in:
parent
4500e2008b
commit
1790168bd5
@ -89,7 +89,17 @@ func fill() {
|
||||
}
|
||||
|
||||
func credsForHostAndPath(host, path string) (string, string, error) {
|
||||
hostFilename := filepath.Join(credsDir, host)
|
||||
var hostFilename string
|
||||
|
||||
// We need hostFilename to end in a slash so that our credentials all
|
||||
// end up in the same directory. credsDir will come in from the
|
||||
// testsuite with a slash, but filepath.Join will strip it off if host
|
||||
// is empty, such as when we have a file:/// or cert:/// URL.
|
||||
if host != "" {
|
||||
hostFilename = filepath.Join(credsDir, host)
|
||||
} else {
|
||||
hostFilename = credsDir
|
||||
}
|
||||
|
||||
if len(path) > 0 {
|
||||
pathFilename := fmt.Sprintf("%s--%s", hostFilename, strings.Replace(path, "/", "-", -1))
|
||||
|
@ -90,7 +90,7 @@ REMOTEDIR="$ROOTDIR/t/remote"
|
||||
# # stores the credentials for http://git-server.com
|
||||
# $CREDSDIR/git-server.com
|
||||
#
|
||||
CREDSDIR="$REMOTEDIR/creds"
|
||||
CREDSDIR="$REMOTEDIR/creds/"
|
||||
|
||||
# This is the prefix for Git config files. See the "Test Suite" section in
|
||||
# t/README.md
|
||||
|
Loading…
Reference in New Issue
Block a user