t5601: add tests for ssh
Add more tests testing all the combinations: -IPv4 or IPv6 -path starting with "/" or with "/~" -with and without the ssh:// scheme Some tests fail; they need updates in connect.c Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Torsten Bögershausen committed
Nov 28, 2013 at 20:48 UTC
2171f3d2aa1412a744545c07b28003a7ff4af5df
1 file changed
+99
-1
t/t5601-clone.sh
+99
-1
@@ -313,7 +313,7 @@ expect_ssh () {
313
314
setup_ssh_wrapper
315
316
-test_expect_success 'cloning myhost:src uses ssh' '
316
+test_expect_success 'clone myhost:src uses ssh' '
317
git clone myhost:src ssh-clone &&
318
expect_ssh myhost src
319
'
@@ -329,6 +329,104 @@ test_expect_success 'bracketed hostnames are still ssh' '
329
expect_ssh myhost:123 src
330
'
331
332
+counter=0
333
+# $1 url
334
+# $2 none|host
335
+# $3 path
336
+test_clone_url () {
337
+ counter=$(($counter + 1))
338
+ test_might_fail git clone "$1" tmp$counter &&
339
+ expect_ssh "$2" "$3"
340
+}
341
+
342
+test_expect_success NOT_MINGW 'clone c:temp is ssl' '
343
+ test_clone_url c:temp c temp
344
+'
345
+
346
+test_expect_success MINGW 'clone c:temp is dos drive' '
347
+ test_clone_url c:temp none
348
+'
349
+
350
+#ip v4
351
+for repo in rep rep/home/project /~proj 123
352
+do
353
+ test_expect_success "clone host:$repo" '
354
+ test_clone_url host:$repo host $repo
355
+ '
356
+done
357
+
358
+#ipv6
359
+# failing
360
+for repo in /~proj
361
+do
362
+ test_expect_failure "clone [::1]:$repo" '
363
+ test_clone_url [::1]:$repo ::1 $repo
364
+ '
365
+done
366
+
367
+for repo in rep rep/home/project 123
368
+do
369
+ test_expect_success "clone [::1]:$repo" '
370
+ test_clone_url [::1]:$repo ::1 $repo
371
+ '
372
+done
373
+
374
+# Corner cases
375
+# failing
376
+for repo in [foo]bar/baz:qux [foo/bar]:baz
377
+do
378
+ test_expect_failure "clone $url is not ssh" '
379
+ test_clone_url $url none
380
+ '
381
+done
382
+
383
+for url in foo/bar:baz
384
+do
385
+ test_expect_success "clone $url is not ssh" '
386
+ test_clone_url $url none
387
+ '
388
+done
389
+
390
+#with ssh:// scheme
391
+test_expect_success 'clone ssh://host.xz/home/user/repo' '
392
+ test_clone_url "ssh://host.xz/home/user/repo" host.xz "/home/user/repo"
393
+'
394
+
395
+# from home directory
396
+test_expect_success 'clone ssh://host.xz/~repo' '
397
+ test_clone_url "ssh://host.xz/~repo" host.xz "~repo"
398
+'
399
+
400
+# with port number
401
+test_expect_success 'clone ssh://host.xz:22/home/user/repo' '
402
+ test_clone_url "ssh://host.xz:22/home/user/repo" "-p 22 host.xz" "/home/user/repo"
403
+'
404
+
405
+# from home directory with port number
406
+test_expect_success 'clone ssh://host.xz:22/~repo' '
407
+ test_clone_url "ssh://host.xz:22/~repo" "-p 22 host.xz" "~repo"
408
+'
409
+
410
+#IPv6
411
+test_expect_success 'clone ssh://[::1]/home/user/repo' '
412
+ test_clone_url "ssh://[::1]/home/user/repo" "::1" "/home/user/repo"
413
+'
414
+
415
+#IPv6 from home directory
416
+test_expect_success 'clone ssh://[::1]/~repo' '
417
+ test_clone_url "ssh://[::1]/~repo" "::1" "~repo"
418
+'
419
+
420
+#IPv6 with port number
421
+test_expect_success 'clone ssh://[::1]:22/home/user/repo' '
422
+ test_clone_url "ssh://[::1]:22/home/user/repo" "-p 22 ::1" "/home/user/repo"
423
+'
424
+
425
+#IPv6 from home directory with port number
426
+test_expect_success 'clone ssh://[::1]:22/~repo' '
427
+ test_clone_url "ssh://[::1]:22/~repo" "-p 22 ::1" "~repo"
428
+'
429
+
430
test_expect_success 'clone from a repository with two identical branches' '
431
432
(