Add e2e for ssh:// URLs
This commit is contained in:
parent
e412c5f9ee
commit
f521da5548
4
main.go
4
main.go
|
|
@ -572,7 +572,9 @@ func main() {
|
|||
if *flUsername == "" {
|
||||
// username and user@host URLs are validated as mutually exclusive
|
||||
if u, err := url.Parse(*flRepo); err == nil { // it may not even parse as a URL, that's OK
|
||||
if u.User != nil && u.Scheme != "ssh" {
|
||||
// Note that `ssh://user@host/path` URLs need to retain the user
|
||||
// field. Out of caution, we only handle HTTP(S) URLs here.
|
||||
if u.User != nil && (u.Scheme == "http" || u.Scheme == "https") {
|
||||
if user := u.User.Username(); user != "" {
|
||||
*flUsername = user
|
||||
}
|
||||
|
|
|
|||
40
test_e2e.sh
40
test_e2e.sh
|
|
@ -1892,7 +1892,7 @@ function e2e::auth_http_password_file() {
|
|||
}
|
||||
|
||||
##############################################
|
||||
# Test SSH
|
||||
# Test SSH (user@host:path syntax)
|
||||
##############################################
|
||||
function e2e::auth_ssh() {
|
||||
# Run a git-over-SSH server. Use key #3 to exercise the multi-key logic.
|
||||
|
|
@ -1929,6 +1929,44 @@ function e2e::auth_ssh() {
|
|||
assert_file_eq "$ROOT/link/file" "$FUNCNAME"
|
||||
}
|
||||
|
||||
##############################################
|
||||
# Test SSH (ssh://user@host/path syntax)
|
||||
##############################################
|
||||
function e2e::auth_ssh_url() {
|
||||
# Run a git-over-SSH server. Use key #3 to exercise the multi-key logic.
|
||||
CTR=$(docker_run \
|
||||
-v "$DOT_SSH/server/3":/dot_ssh:ro \
|
||||
-v "$REPO":/git/repo:ro \
|
||||
e2e/test/sshd)
|
||||
IP=$(docker_ip "$CTR")
|
||||
|
||||
# Try to sync with key #1.
|
||||
assert_fail \
|
||||
GIT_SYNC \
|
||||
--one-time \
|
||||
--repo="ssh://test@$IP/git/repo" \
|
||||
--root="$ROOT" \
|
||||
--link="link" \
|
||||
--ssh-known-hosts=false \
|
||||
--ssh-key-file="/ssh/secret.2"
|
||||
assert_file_absent "$ROOT/link/file"
|
||||
|
||||
# Try to sync with multiple keys
|
||||
GIT_SYNC \
|
||||
--one-time \
|
||||
--repo="ssh://test@$IP/git/repo" \
|
||||
--root="$ROOT" \
|
||||
--link="link" \
|
||||
--ssh-known-hosts=false \
|
||||
--ssh-key-file="/ssh/secret.1" \
|
||||
--ssh-key-file="/ssh/secret.2" \
|
||||
--ssh-key-file="/ssh/secret.3"
|
||||
|
||||
assert_link_exists "$ROOT/link"
|
||||
assert_file_exists "$ROOT/link/file"
|
||||
assert_file_eq "$ROOT/link/file" "$FUNCNAME"
|
||||
}
|
||||
|
||||
##############################################
|
||||
# Test askpass-url with bad password
|
||||
##############################################
|
||||
|
|
|
|||
Loading…
Reference in New Issue