2009-06-09 22:49:53 +02:00
|
|
|
proc setup {} {
|
|
|
|
save_env
|
|
|
|
}; # setup()
|
|
|
|
|
|
|
|
|
|
|
|
proc teardown {} {
|
2009-11-29 14:42:42 +01:00
|
|
|
assert_env_unmodified {
|
|
|
|
/COMPREPLY=/d
|
|
|
|
/OLDHOME=/d
|
|
|
|
}
|
2009-06-09 22:49:53 +02:00
|
|
|
}; # teardown()
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
set hosts [get_hosts]
|
2009-07-07 23:02:27 +02:00
|
|
|
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
|
2009-09-04 23:08:56 +02:00
|
|
|
# doo, ike, jub, 10.0.0.1, kyl and 100.0.0.2 in ./fixtures/_known_hosts_real/known_hosts
|
|
|
|
lappend hosts doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2
|
2009-10-31 08:32:58 +01:00
|
|
|
set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
|
2009-09-04 23:08:56 +02:00
|
|
|
assert_bash_list $hosts $cmd $test
|
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"
|
|
|
|
set hosts [get_hosts]
|
|
|
|
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
|
2009-09-04 23:08:56 +02:00
|
|
|
# doo, ike jub, 10.0.0.1, kyl and 100.0.0.2 in ./fixtures/_known_hosts_real/known_hosts
|
|
|
|
lappend hosts doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2
|
2009-08-12 22:20:56 +02:00
|
|
|
set hosts [lsort -ascii $hosts]
|
|
|
|
set expected {}
|
|
|
|
foreach host $hosts {
|
|
|
|
lappend expected "user@$host:"
|
|
|
|
}; # foreach
|
|
|
|
# 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}
|
2009-09-04 23:08:56 +02:00
|
|
|
assert_bash_list $expected $cmd $test
|
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"
|
2009-06-19 12:33:50 +02:00
|
|
|
set hosts [get_hosts]
|
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'
|
2009-06-13 08:42:22 +02:00
|
|
|
# Host `two' is defined in ./fixtures/_known_hosts_real/known_hosts2
|
2009-11-28 17:35:01 +01:00
|
|
|
lappend hosts gee hus two
|
|
|
|
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" }
|
|
|
|
}; # expect
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
set hosts [get_hosts]
|
|
|
|
# Host `two' is defined in ./fixtures/_known_hosts_real/known_hosts2
|
|
|
|
# Host `three' is defined in ./fixtures/_known_hosts_real/known_hosts3
|
|
|
|
lappend hosts two three
|
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
|
|
|
|
set cmd {OLDHOME=$HOME; HOME=$TESTDIR}
|
|
|
|
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" }
|
|
|
|
}; # expect
|
|
|
|
# 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
|
2009-09-04 23:08:56 +02:00
|
|
|
# doo, ike, jub, 10.0.0.1, kyl and 100.0.0.2 in ./fixtures/_known_hosts_real/known_hosts
|
|
|
|
lappend hosts doo gee hus ike jar jub kyl 10.0.0.1 100.0.0.2
|
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}
|
2009-09-04 23:08:56 +02:00
|
|
|
assert_bash_list $hosts $cmd $test
|
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
|