aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/app_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-14 01:33:44 +0900
committerOphestra <cat@gensokyo.uk>2025-10-14 01:33:44 +0900
commit790d77075e40ee3162d7925e983f01747b5c2c89 (patch)
tree56a59641aa87a40c9b28600ff8bd5d5642d95f5e /internal/app/app_test.go
parente5ff40e7d32d28cace183cd2c80f40f142855ff5 (diff)
system/dbus: remove builder state leak
This enables external testing of system.I state. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/app_test.go')
-rw-r--r--internal/app/app_test.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/internal/app/app_test.go b/internal/app/app_test.go
index 2f42f70a..c89910a7 100644
--- a/internal/app/app_test.go
+++ b/internal/app/app_test.go
@@ -25,6 +25,7 @@ import (
"hakurei.app/message"
"hakurei.app/system"
"hakurei.app/system/acl"
+ "hakurei.app/system/dbus"
)
func TestApp(t *testing.T) {
@@ -213,7 +214,7 @@ func TestApp(t *testing.T) {
Ensure(m("/run/user/1971"), 0700).UpdatePermType(system.User, m("/run/user/1971"), acl.Execute). // this is ordered as is because the previous Ensure only calls mkdir if XDG_RUNTIME_DIR is unset
Ephemeral(system.Process, m("/run/user/1971/hakurei/ebf083d1b175911782d413369b64ce7c"), 0700).UpdatePermType(system.Process, m("/run/user/1971/hakurei/ebf083d1b175911782d413369b64ce7c"), acl.Execute).
Link(m("/run/user/1971/pulse/native"), m("/run/user/1971/hakurei/ebf083d1b175911782d413369b64ce7c/pulse")).
- MustProxyDBus(m("/tmp/hakurei.0/ebf083d1b175911782d413369b64ce7c/bus"), &hst.BusConfig{
+ MustProxyDBus(&hst.BusConfig{
Talk: []string{
"org.freedesktop.Notifications",
"org.freedesktop.FileManager1",
@@ -235,13 +236,19 @@ func TestApp(t *testing.T) {
"org.freedesktop.portal.*": "@/org/freedesktop/portal/*",
},
Filter: true,
- }, m("/tmp/hakurei.0/ebf083d1b175911782d413369b64ce7c/system_bus_socket"), &hst.BusConfig{
+ }, &hst.BusConfig{
Talk: []string{
"org.bluez",
"org.freedesktop.Avahi",
"org.freedesktop.UPower",
},
Filter: true,
+ }, dbus.ProxyPair{
+ "unix:path=/run/user/1971/bus",
+ "/tmp/hakurei.0/ebf083d1b175911782d413369b64ce7c/bus",
+ }, dbus.ProxyPair{
+ "unix:path=/var/run/dbus/system_bus_socket",
+ "/tmp/hakurei.0/ebf083d1b175911782d413369b64ce7c/system_bus_socket",
}).
UpdatePerm(m("/tmp/hakurei.0/ebf083d1b175911782d413369b64ce7c/bus"), acl.Read, acl.Write).
UpdatePerm(m("/tmp/hakurei.0/ebf083d1b175911782d413369b64ce7c/system_bus_socket"), acl.Read, acl.Write),
@@ -364,7 +371,7 @@ func TestApp(t *testing.T) {
Ephemeral(system.Process, m("/run/user/1971/hakurei/8e2c76b066dabe574cf073bdb46eb5c1"), 0700).UpdatePermType(system.Process, m("/run/user/1971/hakurei/8e2c76b066dabe574cf073bdb46eb5c1"), acl.Execute).
Link(m("/run/user/1971/pulse/native"), m("/run/user/1971/hakurei/8e2c76b066dabe574cf073bdb46eb5c1/pulse")).
Ephemeral(system.Process, m("/tmp/hakurei.0/8e2c76b066dabe574cf073bdb46eb5c1"), 0711).
- MustProxyDBus(m("/tmp/hakurei.0/8e2c76b066dabe574cf073bdb46eb5c1/bus"), &hst.BusConfig{
+ MustProxyDBus(&hst.BusConfig{
Talk: []string{
"org.freedesktop.FileManager1", "org.freedesktop.Notifications",
"org.freedesktop.ScreenSaver", "org.freedesktop.secrets",
@@ -377,13 +384,19 @@ func TestApp(t *testing.T) {
},
Call: map[string]string{}, Broadcast: map[string]string{},
Filter: true,
- }, m("/tmp/hakurei.0/8e2c76b066dabe574cf073bdb46eb5c1/system_bus_socket"), &hst.BusConfig{
+ }, &hst.BusConfig{
Talk: []string{
"org.bluez",
"org.freedesktop.Avahi",
"org.freedesktop.UPower",
},
Filter: true,
+ }, dbus.ProxyPair{
+ "unix:path=/run/user/1971/bus",
+ "/tmp/hakurei.0/8e2c76b066dabe574cf073bdb46eb5c1/bus",
+ }, dbus.ProxyPair{
+ "unix:path=/var/run/dbus/system_bus_socket",
+ "/tmp/hakurei.0/8e2c76b066dabe574cf073bdb46eb5c1/system_bus_socket",
}).
UpdatePerm(m("/tmp/hakurei.0/8e2c76b066dabe574cf073bdb46eb5c1/bus"), acl.Read, acl.Write).
UpdatePerm(m("/tmp/hakurei.0/8e2c76b066dabe574cf073bdb46eb5c1/system_bus_socket"), acl.Read, acl.Write),
@@ -739,6 +752,10 @@ func (k *stubNixOS) overflowGid(message.Msg) int { return 65534 }
func (k *stubNixOS) mustHsuPath() *check.Absolute { return m("/proc/nonexistent/hsu") }
+func (k *stubNixOS) dbusAddress() (string, string) {
+ return "unix:path=/run/user/1971/bus", "unix:path=/var/run/dbus/system_bus_socket"
+}
+
func (k *stubNixOS) fatalf(format string, v ...any) { panic(fmt.Sprintf(format, v...)) }
func (k *stubNixOS) isVerbose() bool { return true }