Skip to content

Commit

Permalink
Add test for missing service arguments
Browse files Browse the repository at this point in the history
The test currently fails due to QubesOS/qubes-issues#9089.  The test for
socket services will be added along with the fix, as without the fix it
hangs.
  • Loading branch information
DemiMarie committed Apr 5, 2024
1 parent afd258c commit 50ce10d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions qrexec/tests/socket/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import struct
import getpass
import itertools
import asyncio

import psutil
import pytest
Expand Down Expand Up @@ -55,6 +56,10 @@ def setUp(self):

def start_agent(self):
env = os.environ.copy()
try:
del os.environ["QREXEC_SERVICE_ARGUMENT"]
except KeyError:
pass
env["LD_LIBRARY_PATH"] = os.path.join(ROOT_PATH, "libqrexec")
env["VCHAN_DOMAIN"] = str(self.domain)
env["VCHAN_SOCKET_DIR"] = self.tempdir
Expand Down Expand Up @@ -579,6 +584,38 @@ def test_exec_broken_specific_service(self):
)
self.check_dom0(dom0)

@unittest.expectedFailure
def test_exec_null_argument_finds_service_for_empty_argument(self):
self.make_executable_service(
"local-rpc",
"qubes.Service+",
"""\
#!/bin/sh --
echo "${QREXEC_SERVICE_ARGUMENT+specific} service: $QREXEC_SERVICE_FULL_NAME"
""",
)
self.make_executable_service(
"rpc",
"qubes.Service",
"""\
#!/bin/sh
echo "general service"
""",
)
target, dom0 = self.execute_qubesrpc("qubes.Service", "domX")
target.send_message(qrexec.MSG_DATA_STDIN, b"")
messages = target.recv_all_messages()
self.assertListEqual(
util.sort_messages(messages),
[
(qrexec.MSG_DATA_STDOUT, b"specific service: qubes.Service+\n"),
(qrexec.MSG_DATA_STDOUT, b""),
(qrexec.MSG_DATA_STDERR, b""),
(qrexec.MSG_DATA_EXIT_CODE, b"\0\0\0\0"),
],
)
self.check_dom0(dom0)

def test_connect_socket_no_metadata(self):
socket_path = os.path.join(
self.tempdir, "rpc", "qubes.SocketService+arg2"
Expand Down

0 comments on commit 50ce10d

Please sign in to comment.