Skip to content

Commit 9f69765

Browse files
tboegigitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 86ceb33 commit 9f69765

File tree

1 file changed

+40
-17
lines changed

1 file changed

+40
-17
lines changed

t/t5601-clone.sh

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,17 @@ expect_ssh () {
301301
(cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)
302302
' &&
303303
{
304-
case "$1" in
305-
none)
304+
case "$#" in
305+
1)
306306
;;
307-
*)
307+
2)
308308
echo "ssh: $1 git-upload-pack '$2'"
309+
;;
310+
3)
311+
echo "ssh: $1 $2 git-upload-pack '$3'"
312+
;;
313+
*)
314+
echo "ssh: $1 $2 git-upload-pack '$3' $4"
309315
esac
310316
} >"$TRASH_DIRECTORY/ssh-expect" &&
311317
(cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output)
@@ -336,7 +342,8 @@ counter=0
336342
test_clone_url () {
337343
counter=$(($counter + 1))
338344
test_might_fail git clone "$1" tmp$counter &&
339-
expect_ssh "$2" "$3"
345+
shift &&
346+
expect_ssh "$@"
340347
}
341348

342349
test_expect_success !MINGW 'clone c:temp is ssl' '
@@ -359,7 +366,7 @@ done
359366
for repo in rep rep/home/project 123
360367
do
361368
test_expect_success "clone [::1]:$repo" '
362-
test_clone_url [::1]:$repo ::1 $repo
369+
test_clone_url [::1]:$repo ::1 "$repo"
363370
'
364371
done
365372
#home directory
@@ -400,24 +407,40 @@ test_expect_success 'clone ssh://host.xz:22/~repo' '
400407
'
401408

402409
#IPv6
403-
test_expect_success 'clone ssh://[::1]/home/user/repo' '
404-
test_clone_url "ssh://[::1]/home/user/repo" "::1" "/home/user/repo"
405-
'
410+
for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]
411+
do
412+
ehost=$(echo $tuah | tr -d "[]")
413+
test_expect_success "clone ssh://$tuah/home/user/repo" "
414+
test_clone_url ssh://$tuah/home/user/repo $ehost /home/user/repo
415+
"
416+
done
406417

407418
#IPv6 from home directory
408-
test_expect_success 'clone ssh://[::1]/~repo' '
409-
test_clone_url "ssh://[::1]/~repo" "::1" "~repo"
410-
'
419+
for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]
420+
do
421+
euah=$(echo $tuah | tr -d "[]")
422+
test_expect_success "clone ssh://$tuah/~repo" "
423+
test_clone_url ssh://$tuah/~repo $euah '~repo'
424+
"
425+
done
411426

412427
#IPv6 with port number
413-
test_expect_success 'clone ssh://[::1]:22/home/user/repo' '
414-
test_clone_url "ssh://[::1]:22/home/user/repo" "-p 22 ::1" "/home/user/repo"
415-
'
428+
for tuah in [::1] user@[::1] [user@::1]
429+
do
430+
euah=$(echo $tuah | tr -d "[]")
431+
test_expect_success "clone ssh://$tuah:22/home/user/repo" "
432+
test_clone_url ssh://$tuah:22/home/user/repo '-p 22' $euah /home/user/repo
433+
"
434+
done
416435

417436
#IPv6 from home directory with port number
418-
test_expect_success 'clone ssh://[::1]:22/~repo' '
419-
test_clone_url "ssh://[::1]:22/~repo" "-p 22 ::1" "~repo"
420-
'
437+
for tuah in [::1] user@[::1] [user@::1]
438+
do
439+
euah=$(echo $tuah | tr -d "[]")
440+
test_expect_success "clone ssh://$tuah:22/~repo" "
441+
test_clone_url ssh://$tuah:22/~repo '-p 22' $euah '~repo'
442+
"
443+
done
421444

422445
test_expect_success 'clone from a repository with two identical branches' '
423446

0 commit comments

Comments
 (0)