From d23b4dc9e64d3f00e746c65f3038a1a6de44b8f5 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 7 Oct 2025 19:01:18 +0900 Subject: hst/dbus: move dbus config struct This allows holding a xdg-dbus-proxy configuration without importing system/dbus. It also makes more sense in the project structure since the config struct is part of the hst API however the rest of the implementation is not. Signed-off-by: Ophestra --- system/dbus_test.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'system/dbus_test.go') diff --git a/system/dbus_test.go b/system/dbus_test.go index 0f3033a4..0bc7b7fd 100644 --- a/system/dbus_test.go +++ b/system/dbus_test.go @@ -11,6 +11,7 @@ import ( "hakurei.app/container/stub" "hakurei.app/helper" + "hakurei.app/hst" "hakurei.app/system/dbus" ) @@ -82,7 +83,7 @@ func TestDBusProxyOp(t *testing.T) { Op: "dbus", Err: ErrDBusConfig, Msg: "attempted to create message bus proxy args without session bus config", } - if err := sys.ProxyDBus(nil, new(dbus.Config), nil, nil); !reflect.DeepEqual(err, wantErr) { + if err := sys.ProxyDBus(nil, new(hst.BusConfig), nil, nil); !reflect.DeepEqual(err, wantErr) { t.Errorf("ProxyDBus: error = %v, want %v", err, wantErr) } }, nil, stub.Expect{}}, @@ -96,10 +97,10 @@ func TestDBusProxyOp(t *testing.T) { }() sys.MustProxyDBus( - m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"), &dbus.Config{ + m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"), &hst.BusConfig{ // use impossible value here as an implicit assert that it goes through the stub Talk: []string{"session\x00"}, Filter: true, - }, m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"), &dbus.Config{ + }, m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"), &hst.BusConfig{ // use impossible value here as an implicit assert that it goes through the stub Talk: []string{"system\x00"}, Filter: true, }) @@ -108,8 +109,8 @@ func TestDBusProxyOp(t *testing.T) { call("dbusFinalise", stub.ExpectArgs{ dbus.ProxyPair{"unix:path=/run/user/1000/bus", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"}, dbus.ProxyPair{"unix:path=/run/dbus/system_bus_socket", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"}, - &dbus.Config{Talk: []string{"session\x00"}, Filter: true}, - &dbus.Config{Talk: []string{"system\x00"}, Filter: true}, + &hst.BusConfig{Talk: []string{"session\x00"}, Filter: true}, + &hst.BusConfig{Talk: []string{"system\x00"}, Filter: true}, }, (*dbus.Final)(nil), syscall.EINVAL), }}}, @@ -119,10 +120,10 @@ func TestDBusProxyOp(t *testing.T) { Msg: "cannot finalise message bus proxy: unique error 0 injected by the test suite", } if err := sys.ProxyDBus( - &dbus.Config{ + &hst.BusConfig{ // use impossible value here as an implicit assert that it goes through the stub Talk: []string{"session\x00"}, Filter: true, - }, &dbus.Config{ + }, &hst.BusConfig{ // use impossible value here as an implicit assert that it goes through the stub Talk: []string{"system\x00"}, Filter: true, }, @@ -135,17 +136,17 @@ func TestDBusProxyOp(t *testing.T) { call("dbusFinalise", stub.ExpectArgs{ dbus.ProxyPair{"unix:path=/run/user/1000/bus", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"}, dbus.ProxyPair{"unix:path=/run/dbus/system_bus_socket", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"}, - &dbus.Config{Talk: []string{"session\x00"}, Filter: true}, - &dbus.Config{Talk: []string{"system\x00"}, Filter: true}, + &hst.BusConfig{Talk: []string{"session\x00"}, Filter: true}, + &hst.BusConfig{Talk: []string{"system\x00"}, Filter: true}, }, (*dbus.Final)(nil), stub.UniqueError(0)), }}}, {"full", 0xcafebabe, func(_ *testing.T, sys *I) { sys.MustProxyDBus( - m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"), &dbus.Config{ + m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"), &hst.BusConfig{ // use impossible value here as an implicit assert that it goes through the stub Talk: []string{"session\x00"}, Filter: true, - }, m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"), &dbus.Config{ + }, m("/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"), &hst.BusConfig{ // use impossible value here as an implicit assert that it goes through the stub Talk: []string{"system\x00"}, Filter: true, }) @@ -159,8 +160,8 @@ func TestDBusProxyOp(t *testing.T) { call("dbusFinalise", stub.ExpectArgs{ dbus.ProxyPair{"unix:path=/run/user/1000/bus", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus"}, dbus.ProxyPair{"unix:path=/run/dbus/system_bus_socket", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/system_bus_socket"}, - &dbus.Config{Talk: []string{"session\x00"}, Filter: true}, - &dbus.Config{Talk: []string{"system\x00"}, Filter: true}, + &hst.BusConfig{Talk: []string{"session\x00"}, Filter: true}, + &hst.BusConfig{Talk: []string{"system\x00"}, Filter: true}, }, dbusNewFinalSample(0), nil), call("isVerbose", stub.ExpectArgs{}, true, nil), call("verbose", stub.ExpectArgs{[]any{"session bus proxy:", []string{"unix:path=/run/user/1000/bus", "/tmp/hakurei.0/99dd71ee2146369514e0d10783368f8f/bus", "--filter", "--talk=session\x00"}}}, nil, nil), -- cgit v1.3.1