[gnome-control-center/benzea/reenable-tests] tests: Disable all service start dirs




commit 76ea6bd51b190e84750e7902bf268f8c18cb8425
Author: Benjamin Berg <bberg redhat com>
Date:   Thu Jan 20 15:49:33 2022 +0100

    tests: Disable all service start dirs

 tests/shared/x11session.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
---
diff --git a/tests/shared/x11session.py b/tests/shared/x11session.py
index a7cfdf64b..fd78783ba 100644
--- a/tests/shared/x11session.py
+++ b/tests/shared/x11session.py
@@ -18,6 +18,7 @@
 import os
 import sys
 import subprocess
+import tempfile
 from dbusmock import DBusTestCase
 
 # Intended to be shared across projects, submitted for inclusion into
@@ -42,6 +43,60 @@ class X11SessionTestCase(DBusTestCase):
         klass.start_system_bus()
         klass.start_session_bus()
 
+    @classmethod
+    def start_session_bus(cls) -> None:
+        '''Set up a private local session bus
+
+        This gets stopped automatically in tearDownClass().
+        '''
+        with tempfile.NamedTemporaryFile(prefix='dbusmock_session_cfg') as c:
+            c.write(b'''<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd";>
+<busconfig>
+  <type>session</type>
+  <keep_umask/>
+  <listen>unix:tmpdir=/tmp</listen>
+  <!-- We do not add standard_system_servicedirs (i.e. we have *no* service directory). -->
+
+  <policy context="default">
+    <allow send_destination="*" eavesdrop="true"/>
+    <allow eavesdrop="true"/>
+    <allow own="*"/>
+  </policy>
+</busconfig>
+''')
+            c.flush()
+            (DBusTestCase.system_bus_pid, addr) = cls.start_dbus(conf=c.name)
+        os.environ['DBUS_SESSION_BUS_ADDRESS'] = addr
+
+    @classmethod
+    def start_system_bus(cls) -> None:
+        '''Set up a private local system bus
+
+        This gets stopped automatically in tearDownClass().
+        '''
+        # create a temporary configuration which makes the fake bus actually
+        # appear a type "system"
+        with tempfile.NamedTemporaryFile(prefix='dbusmock_cfg') as c:
+            c.write(b'''<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd";>
+<busconfig>
+  <type>system</type>
+  <keep_umask/>
+  <listen>unix:tmpdir=/tmp</listen>
+  <!-- We do not add standard_system_servicedirs (i.e. we have *no* service directory). -->
+
+  <policy context="default">
+    <allow send_destination="*" eavesdrop="true"/>
+    <allow eavesdrop="true"/>
+    <allow own="*"/>
+  </policy>
+</busconfig>
+''')
+            c.flush()
+            (DBusTestCase.system_bus_pid, addr) = cls.start_dbus(conf=c.name)
+        os.environ['DBUS_SYSTEM_BUS_ADDRESS'] = addr
+
     @classmethod
     def start_xorg(klass):
         r, w = os.pipe()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]