1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#! /usr/bin/python3
# This file is part of Cockpit.
#
# Copyright (C) 2013 Red Hat, Inc.
#
# Cockpit is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Cockpit is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
import parent
from testlib import *
@skipImage("Do not test BaseOS packages", "rhel-8-3-distropkg", "rhel-8-4-distropkg")
class TestEmbed(MachineCase):
def testBasic(self):
b = self.browser
m = self.machine
m.execute("mkdir -p /home/admin/.local/share/cockpit/embed-cockpit")
m.upload(["verify/files/embed-cockpit/index.html",
"verify/files/embed-cockpit/embed.js",
"verify/files/embed-cockpit/manifest.json"],
"/home/admin/.local/share/cockpit/embed-cockpit/")
# replace the shell with our embedded page, this way we can avoid
# cross-origin errors when executing js in the iframe
m.write("/etc/cockpit/cockpit.conf","""
[WebService]
Shell=/embed-cockpit/index.html
""")
m.start_cockpit()
self.login_and_go()
b.wait_visible("#embed-loaded")
b.wait_visible("#embed-address")
m.write("/etc/cockpit/cockpit.conf","""
[WebService]
Shell=/shell/index.html
""")
b.set_val("#embed-address", "http://{0}:{1}".format(m.web_address, m.web_port))
b.click("#embed-full")
b.wait_visible("iframe[name='embed-full'][loaded]")
b.switch_to_frame("embed-full")
b.wait_visible("#system_information_os_text")
# Page should show automatically now that other frame logged in
b.switch_to_top()
b.click("#embed-terminal")
b.wait_visible("iframe[name='embed-terminal'][loaded]")
b.switch_to_frame("embed-terminal")
b.wait_visible("#terminal")
# Clicking on the link with separate auth, shouldn't log in automatically
b.switch_to_top()
b.click("#embed-auth")
b.wait_visible("iframe[name='embed-auth'][loaded]")
b.switch_to_frame("embed-auth")
b.wait_visible("#login-user-input")
if __name__ == '__main__':
test_main()
|