2009-06-09 22:49:53 +02:00
|
|
|
proc setup {} {
|
2010-11-12 23:35:36 +01:00
|
|
|
# NOTE: Changing dir to $SRCDIR is necessary because file locations in the
|
|
|
|
# ssh config files (e.g. UserKnownHostsFile) are relative to $SRCDIR.
|
|
|
|
assert_bash_exec {cd $SRCDIR}
|
2009-06-09 22:49:53 +02:00
|
|
|
save_env
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-06-09 22:49:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
proc teardown {} {
|
2009-11-29 14:42:42 +01:00
|
|
|
assert_env_unmodified {
|
|
|
|
/COMPREPLY=/d
|
|
|
|
/OLDHOME=/d
|
|
|
|
}
|
2010-11-12 23:35:36 +01:00
|
|
|
assert_bash_exec {cd $TESTDIR}
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-06-09 22:49:53 +02:00
|
|
|
|
|
|
|
|
2009-06-19 12:33:50 +02:00
|
|
|
setup
|
2009-06-09 22:49:53 +02:00
|
|
|
|
|
|
|
|
2009-06-19 12:33:50 +02:00
|
|
|
set test "Hosts should be put in COMPREPLY"
|
2011-03-27 23:12:14 +02:00
|
|
|
set hosts [get_hosts -unsorted]
|
2009-07-07 23:02:27 +02:00
|
|
|
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
|
2010-10-04 21:29:44 +03:00
|
|
|
# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts
|
|
|
|
lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
|
2009-10-31 08:32:58 +01:00
|
|
|
set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
|
2010-10-31 17:51:14 +01:00
|
|
|
assert_bash_list $hosts $cmd $test -sort
|
2009-06-09 22:49:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
2009-08-12 22:20:56 +02:00
|
|
|
set test "Hosts should have username prefix and colon suffix"
|
2011-03-27 23:12:14 +02:00
|
|
|
set hosts [get_hosts -unsorted]
|
2009-08-12 22:20:56 +02:00
|
|
|
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
|
2010-10-04 21:29:44 +03:00
|
|
|
# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts
|
|
|
|
lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
|
2009-08-12 22:20:56 +02:00
|
|
|
set hosts [lsort -ascii $hosts]
|
|
|
|
set expected {}
|
|
|
|
foreach host $hosts {
|
|
|
|
lappend expected "user@$host:"
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-08-12 22:20:56 +02:00
|
|
|
# Call _known_hosts
|
2009-10-31 08:32:58 +01:00
|
|
|
set cmd {unset COMPREPLY; _known_hosts_real -acF fixtures/_known_hosts_real/config 'user@'; echo_array COMPREPLY}
|
2010-10-31 17:51:14 +01:00
|
|
|
assert_bash_list $expected $cmd $test -sort
|
2009-08-12 22:20:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
2009-11-28 17:35:01 +01:00
|
|
|
set test "Files containing consecutive spaces should work"
|
2011-03-27 23:12:14 +02:00
|
|
|
set hosts [get_hosts -unsorted]
|
2009-11-28 17:35:01 +01:00
|
|
|
set hosts_orig $hosts
|
|
|
|
# Hosts `gee' and `hus' are defined in `./fixtures/_known_hosts_real/spaced conf'
|
2011-11-05 00:53:39 +02:00
|
|
|
# Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2
|
|
|
|
lappend hosts gee hus two two2 two3 two4
|
2009-11-28 17:35:01 +01:00
|
|
|
set hosts_config $hosts
|
|
|
|
# Hosts `doo' and `ike' are defined in `./fixtures/_known_hosts_/spaced known_hosts'
|
|
|
|
lappend hosts doo ike
|
2009-12-02 22:38:30 +01:00
|
|
|
set hosts [join [bash_sort $hosts ] "\\s+"]
|
|
|
|
set hosts_orig [join [bash_sort $hosts_orig ] "\\s+"]
|
|
|
|
set hosts_config [join [bash_sort $hosts_config] "\\s+"]
|
2009-06-09 22:49:53 +02:00
|
|
|
# Call _known_hosts
|
2009-10-31 08:32:58 +01:00
|
|
|
set cmd {unset COMPREPLY; _known_hosts_real -aF 'fixtures/_known_hosts_real/spaced conf' ''; echo_array COMPREPLY}
|
2009-06-09 22:49:53 +02:00
|
|
|
send "$cmd\r"
|
|
|
|
expect -ex "$cmd\r\n"
|
|
|
|
expect {
|
|
|
|
-re "^$hosts\r\n/@$" { pass "$test" }
|
2009-11-29 14:42:42 +01:00
|
|
|
-re "^$hosts_orig\r\n/@$" { fail "$test (config file)" }
|
|
|
|
-re "^$hosts_config\r\n/@$" { fail "$test (known hosts file)" }
|
2009-06-09 22:49:53 +02:00
|
|
|
-re /@ { unresolved "$test at prompt" }
|
|
|
|
default { unresolved "$test" }
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-06-09 22:49:53 +02:00
|
|
|
|
|
|
|
|
2009-08-12 22:20:56 +02:00
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
2009-11-29 14:42:42 +01:00
|
|
|
set test "Files starting with tilde (~) should work"
|
2011-03-27 23:12:14 +02:00
|
|
|
set hosts [get_hosts -unsorted]
|
2011-11-05 00:53:39 +02:00
|
|
|
# Hosts `two*' are defined in ./fixtures/_known_hosts_real/known_hosts2
|
2009-11-29 14:42:42 +01:00
|
|
|
# Host `three' is defined in ./fixtures/_known_hosts_real/known_hosts3
|
2011-12-05 21:58:04 +02:00
|
|
|
# Host `four' is defined in ./fixtures/_known_hosts_real/known_hosts4
|
|
|
|
lappend hosts two two2 two3 two4 three four
|
2009-12-02 22:38:30 +01:00
|
|
|
set hosts [join [bash_sort $hosts] "\\s+"]
|
2009-11-29 14:42:42 +01:00
|
|
|
# Setup environment
|
2010-11-12 23:35:36 +01:00
|
|
|
set cmd {OLDHOME=$HOME; HOME=$SRCDIRABS}
|
2009-11-29 14:42:42 +01:00
|
|
|
send "$cmd\r"
|
|
|
|
expect -ex "$cmd\r\n/@"
|
|
|
|
# Call _known_hosts
|
|
|
|
set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config_tilde ''; echo_array COMPREPLY}
|
|
|
|
send "$cmd\r"
|
|
|
|
expect -ex "$cmd\r\n"
|
|
|
|
expect {
|
|
|
|
-re "^$hosts\r\n/@$" { pass "$test" }
|
|
|
|
default { unresolved "$test" }
|
2010-06-18 17:21:38 +02:00
|
|
|
}
|
2009-11-29 14:42:42 +01:00
|
|
|
# Teardown environment
|
|
|
|
set cmd {HOME=$OLDHOME}
|
|
|
|
send "$cmd\r"
|
|
|
|
expect -ex "$cmd\r\n/@"
|
|
|
|
|
|
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
2009-08-12 22:20:56 +02:00
|
|
|
set test "Empty COMP_KNOWN_HOSTS_WITH_HOSTFILE should omit HOSTFILE"
|
|
|
|
assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE="
|
2009-08-18 21:28:43 +02:00
|
|
|
set hosts [get_hosts_avahi]
|
2009-08-12 22:20:56 +02:00
|
|
|
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
|
2010-10-04 21:29:44 +03:00
|
|
|
# doo, ike, jub, 10.0.0.1, kyl, 100.0.0.2, 10.10.0.3, blah, and bunch of IPv6 test cases in ./fixtures/_known_hosts_real/known_hosts
|
|
|
|
lappend hosts blah doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2 10.10.0.3 fd00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:5555 fe80::123:0xff:dead:beef%eth0 1111:2222:3333:4444:5555:6666:xxxx:abab 11xx:2222:3333:4444:5555:6666:xxxx:abab ::42
|
2009-08-12 22:20:56 +02:00
|
|
|
# Call _known_hosts
|
2009-10-31 08:32:58 +01:00
|
|
|
set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
|
2010-10-31 17:51:14 +01:00
|
|
|
assert_bash_list $hosts $cmd $test -sort
|
2009-08-12 22:20:56 +02:00
|
|
|
sync_after_int
|
|
|
|
assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE"
|
|
|
|
|
|
|
|
|
2009-08-23 09:38:19 +02:00
|
|
|
sync_after_int
|
|
|
|
|
|
|
|
|
2009-06-09 22:49:53 +02:00
|
|
|
teardown
|