Skip to content

Commit

Permalink
lib: Fix remote hosts with nonstandard port
Browse files Browse the repository at this point in the history
The connection properties' "port" field  can be an integer, so stringify
it (or any other field except "visible" which is a boolean and already
special-cased) when building the GVariant wrapper in update_saved_machine().

Adjust TestMultiMachineAdd to reproduce/verify this case by putting the
second external machine (m3) onto port 2222.

Fixes cockpit-project#6291
Closes cockpit-project#6466
  • Loading branch information
martinpitt authored and petervo committed May 8, 2017
1 parent 3779af4 commit 4f6c6ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions pkg/lib/machines.js
Expand Up @@ -172,11 +172,16 @@
}

function update_saved_machine(host, values) {
// wrap values in variants for D-Bus call
// wrap values in variants for D-Bus call; at least values.port can
// be int or string, so stringify everything but the "visible" boolean
var values_variant = {};
for (var prop in values)
if (values[prop] !== null)
values_variant[prop] = cockpit.variant(prop == "visible" ? 'b' : 's', values[prop]);
if (values[prop] !== null) {
if (prop == "visible")
values_variant[prop] = cockpit.variant('b', values[prop]);
else
values_variant[prop] = cockpit.variant('s', values[prop].toString());
}

// FIXME: investigate re-using the proxy from Loader (runs in different frame/scope)
var bridge = cockpit.dbus(null, { bus: "internal", "superuser": "try" });
Expand Down
6 changes: 4 additions & 2 deletions test/verify/check-multi-machine
Expand Up @@ -130,10 +130,12 @@ class TestMultiMachineAdd(MachineCase):
b = self.browser
m2 = self.machine2
m3 = self.machine3
change_ssh_port(m3, 2222)

self.login_and_go(None)
add_machine(b, m2.address)
add_machine(b, m3.address)
m3_con = m3.address + ":2222"
add_machine(b, m3_con)

# TODO: The concrete error message when killing the bridge and
# session is not predictable. So we just wait for any error
Expand Down Expand Up @@ -167,7 +169,7 @@ class TestMultiMachineAdd(MachineCase):
b.click("#dashboard-hosts a[data-address='%s']" % m3.address)
b.switch_to_top()
b.wait_js_cond('window.location.pathname != "/dashboard"')
b.enter_page("/system", host=m3.address)
b.enter_page("/system", host=m3_con)
b.wait_text_not("#system_information_hostname_button", "")
b.switch_to_top()
b.go("/dashboard")
Expand Down

0 comments on commit 4f6c6ae

Please sign in to comment.