Skip to content

Commit

Permalink
Re-add frame-src CSP to allow downloading the desktop viewer file
Browse files Browse the repository at this point in the history
This was removed 0dcf864 under the impression it wasn't needed
as all integration tests but the tests never validated if the desktop
viewer file could be downloaded.

Additionally add an integration test which verifies that the file can be
downloaded successfully.

Closes: #1799
  • Loading branch information
jelly committed Sep 2, 2024
1 parent abd4fa8 commit 96a448b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
]
}
},
"content-security-policy": "frame-src 'self' data:",
"config": {
"StorageMigrationSupported": {
"rhel": false
Expand Down
30 changes: 23 additions & 7 deletions test/check-machines-consoles
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ import testlib
@testlib.nondestructive
class TestMachinesConsoles(machineslib.VirtualMachinesCase):

def waitDownloadFile(self, filename: str, expected_size: int | None = None, content: str | None = None) -> None:
b = self.browser
filepath = b.driver.download_dir / filename

# Big downloads can take a while
testlib.wait(filepath.exists, tries=120)
if expected_size is not None:
testlib.wait(lambda: filepath.stat().st_size == expected_size)

if content is not None:
self.assertEqual(filepath.read_text(), content)

@testlib.skipImage('SPICE not supported on RHEL', "rhel-*", "centos-*")
def testExternalConsole(self):
b = self.browser
Expand All @@ -43,14 +55,18 @@ class TestMachinesConsoles(machineslib.VirtualMachinesCase):
b.wait_in_text(".pf-v5-c-console__manual-connection dl > div:first-child dd", "127.0.0.1")
b.wait_in_text(".pf-v5-c-console__manual-connection dl > div:nth-child(2) dd", "5900")

b.allow_download()
b.click(".pf-v5-c-console__remote-viewer-launch-vv") # "Launch Remote Viewer" button
b.wait_visible("#dynamically-generated-file") # is .vv file generated for download?
self.assertEqual(b.attr("#dynamically-generated-file", "href"),
u"data:application/x-virt-viewer,%5Bvirt-viewer%5D%0Atype%3Dspice%0Ahost%3D127.0.0.1%0Aport%3D5900%0Adelete-this-file%3D1%0Afullscreen%3D0%0A")

# HACK: clicking 'Launch Remote Viewer' kills execution context and thus CDP fails
b.reload()
b.enter_page("/machines")
content = """[virt-viewer]
type=spice
host=127.0.0.1
port=5900
delete-this-file=1
fullscreen=0
[...............................GraphicsConsole]
"""
self.waitDownloadFile("download", content=content)

# Go to the expanded console view
b.click("button:contains(Expand)")
Expand Down

0 comments on commit 96a448b

Please sign in to comment.