t5601: add more test cases for IPV6

Test the parsing of literall IPV6 addresses more systematically:
- with and without brackets (e.g. ::1 [::1])
- with brackets and port number: (e.g. [::1]:22)
- with username (e.g. user@::1)
- with username and brackets:
  Because user@[::1] was not supported on older Git version,
  [user@::1] had to be used as a workaround.
  Test that user@::1 user@[::1] and [user@::1] all do the same.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Torsten Bögershausen 2015-02-21 16:53:01 +01:00 committed by Junio C Hamano
parent 86ceb337ec
commit 9f6976528b

View file

@ -301,11 +301,17 @@ expect_ssh () {
(cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output) (cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)
' && ' &&
{ {
case "$1" in case "$#" in
none) 1)
;;
2)
echo "ssh: $1 git-upload-pack '$2'"
;;
3)
echo "ssh: $1 $2 git-upload-pack '$3'"
;; ;;
*) *)
echo "ssh: $1 git-upload-pack '$2'" echo "ssh: $1 $2 git-upload-pack '$3' $4"
esac esac
} >"$TRASH_DIRECTORY/ssh-expect" && } >"$TRASH_DIRECTORY/ssh-expect" &&
(cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output) (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output)
@ -336,7 +342,8 @@ counter=0
test_clone_url () { test_clone_url () {
counter=$(($counter + 1)) counter=$(($counter + 1))
test_might_fail git clone "$1" tmp$counter && test_might_fail git clone "$1" tmp$counter &&
expect_ssh "$2" "$3" shift &&
expect_ssh "$@"
} }
test_expect_success !MINGW 'clone c:temp is ssl' ' test_expect_success !MINGW 'clone c:temp is ssl' '
@ -359,7 +366,7 @@ done
for repo in rep rep/home/project 123 for repo in rep rep/home/project 123
do do
test_expect_success "clone [::1]:$repo" ' test_expect_success "clone [::1]:$repo" '
test_clone_url [::1]:$repo ::1 $repo test_clone_url [::1]:$repo ::1 "$repo"
' '
done done
#home directory #home directory
@ -400,24 +407,40 @@ test_expect_success 'clone ssh://host.xz:22/~repo' '
' '
#IPv6 #IPv6
test_expect_success 'clone ssh://[::1]/home/user/repo' ' for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]
test_clone_url "ssh://[::1]/home/user/repo" "::1" "/home/user/repo" do
' ehost=$(echo $tuah | tr -d "[]")
test_expect_success "clone ssh://$tuah/home/user/repo" "
test_clone_url ssh://$tuah/home/user/repo $ehost /home/user/repo
"
done
#IPv6 from home directory #IPv6 from home directory
test_expect_success 'clone ssh://[::1]/~repo' ' for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]
test_clone_url "ssh://[::1]/~repo" "::1" "~repo" do
' euah=$(echo $tuah | tr -d "[]")
test_expect_success "clone ssh://$tuah/~repo" "
test_clone_url ssh://$tuah/~repo $euah '~repo'
"
done
#IPv6 with port number #IPv6 with port number
test_expect_success 'clone ssh://[::1]:22/home/user/repo' ' for tuah in [::1] user@[::1] [user@::1]
test_clone_url "ssh://[::1]:22/home/user/repo" "-p 22 ::1" "/home/user/repo" do
' euah=$(echo $tuah | tr -d "[]")
test_expect_success "clone ssh://$tuah:22/home/user/repo" "
test_clone_url ssh://$tuah:22/home/user/repo '-p 22' $euah /home/user/repo
"
done
#IPv6 from home directory with port number #IPv6 from home directory with port number
test_expect_success 'clone ssh://[::1]:22/~repo' ' for tuah in [::1] user@[::1] [user@::1]
test_clone_url "ssh://[::1]:22/~repo" "-p 22 ::1" "~repo" do
' euah=$(echo $tuah | tr -d "[]")
test_expect_success "clone ssh://$tuah:22/~repo" "
test_clone_url ssh://$tuah:22/~repo '-p 22' $euah '~repo'
"
done
test_expect_success 'clone from a repository with two identical branches' ' test_expect_success 'clone from a repository with two identical branches' '