| 1 |
#!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv) |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (C) 2013 Red Hat, Inc. |
| 5 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 |
|
| 7 |
|
| 8 |
import testlib |
| 9 |
|
| 10 |
|
| 11 |
@testlib.skipWsContainer("cockpit/ws always uses loopback") |
| 12 |
@testlib.skipImage("TODO: fix for OpenSUSE", "opensuse-tumbleweed") |
| 13 |
@testlib.nondestructive |
| 14 |
class TestLoopback(testlib.MachineCase): |
| 15 |
|
| 16 |
def testBasic(self): |
| 17 |
b = self.browser |
| 18 |
m = self.machine |
| 19 |
|
| 20 |
# Start Cockpit with option to access SSH |
| 21 |
m.stop_cockpit() |
| 22 |
pid = m.spawn(f"{self.libexecdir}/cockpit-ws --local-ssh --no-tls", "cockpit-ws") |
| 23 |
self.addCleanup(m.execute, "kill %i" % pid) |
| 24 |
m.wait_for_cockpit_running() |
| 25 |
|
| 26 |
b.login_and_go("/system", user="admin") |
| 27 |
b.logout() |
| 28 |
b.wait_visible("#login") |
| 29 |
|
| 30 |
m.disconnect() |
| 31 |
self.restore_dir("/etc/ssh", restart_unit=self.sshd_service) |
| 32 |
m.execute("sed -i 's/.*PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config $(ls /etc/ssh/sshd_config.d/* 2>/dev/null || true)") |
| 33 |
m.execute(self.restart_sshd) |
| 34 |
m.wait_execute() |
| 35 |
|
| 36 |
b.set_val('#login-user-input', "admin") |
| 37 |
b.set_val('#login-password-input', "foobar") |
| 38 |
b.click('#login-button') |
| 39 |
b.wait_text("#login-error-title", "Authentication failed") |
| 40 |
b.wait_text('#login-error-message', "Wrong user name or password") |
| 41 |
|
| 42 |
self.allow_journal_messages("Cannot run program cockpit-bridge: No such file or directory", |
| 43 |
".*server offered unsupported authentication methods: public-key.*") |
| 44 |
|
| 45 |
|
| 46 |
if __name__ == '__main__': |
| 47 |
testlib.test_main() |