82 lines
2.5 KiB
Plaintext
82 lines
2.5 KiB
Plaintext
proc setup {} {
|
|
save_env
|
|
}; # setup()
|
|
|
|
|
|
proc teardown {} {
|
|
assert_env_unmodified {/COMPREPLY=/d}
|
|
}; # teardown()
|
|
|
|
|
|
setup
|
|
|
|
|
|
set test "Hosts should be put in COMPREPLY"
|
|
set hosts [get_hosts]
|
|
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
|
|
# 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
|
|
set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
|
|
assert_bash_list $hosts $cmd $test
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
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
|
|
# 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
|
|
set hosts [lsort -ascii $hosts]
|
|
set expected {}
|
|
foreach host $hosts {
|
|
lappend expected "user@$host:"
|
|
}; # foreach
|
|
# Call _known_hosts
|
|
set cmd {unset COMPREPLY; _known_hosts_real -acF fixtures/_known_hosts_real/config 'user@'; echo_array COMPREPLY}
|
|
assert_bash_list $expected $cmd $test
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set test "Config file containing space should work"
|
|
set hosts [get_hosts]
|
|
# Hosts `gee' and `hus' are defined in ./fixtures/_known_hosts_real/spaced conf
|
|
# Host `two' is defined in ./fixtures/_known_hosts_real/known_hosts2
|
|
lappend hosts gee hus doo ike two
|
|
set hosts [lsort -ascii $hosts]
|
|
set hosts [join $hosts "\\s+"]
|
|
# Call _known_hosts
|
|
set cmd {unset COMPREPLY; _known_hosts_real -aF 'fixtures/_known_hosts_real/spaced conf' ''; echo_array COMPREPLY}
|
|
send "$cmd\r"
|
|
expect -ex "$cmd\r\n"
|
|
expect {
|
|
-re "^$hosts\r\n/@$" { pass "$test" }
|
|
-re /@ { unresolved "$test at prompt" }
|
|
default { unresolved "$test" }
|
|
}; # expect
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
set test "Empty COMP_KNOWN_HOSTS_WITH_HOSTFILE should omit HOSTFILE"
|
|
assert_bash_exec "COMP_KNOWN_HOSTS_WITH_HOSTFILE="
|
|
set hosts [get_hosts_avahi]
|
|
# Hosts `gee', `hus' and `jar' are defined in ./fixtures/_known_hosts_real/config
|
|
# 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
|
|
# Call _known_hosts
|
|
set cmd {unset COMPREPLY; _known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
|
|
assert_bash_list $hosts $cmd $test
|
|
sync_after_int
|
|
assert_bash_exec "unset -v COMP_KNOWN_HOSTS_WITH_HOSTFILE"
|
|
|
|
|
|
sync_after_int
|
|
|
|
|
|
teardown
|