diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-10-09 20:41:42 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-10-09 20:41:42 +0900 |
| commit | 753c5191b13b75a8395a083299b553dbb7d99cbe (patch) | |
| tree | 4316235946aa152a9a06ddd9a109f32830bd9d2e /dbus/dbus_test.go | |
| parent | 6232291caebc2dc1365cdb422ed16c09c06b3f28 (diff) | |
dbus/run: support running xdg-dbus-proxy in a restrictive bubblewrap sandbox
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'dbus/dbus_test.go')
| -rw-r--r-- | dbus/dbus_test.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/dbus/dbus_test.go b/dbus/dbus_test.go index c20f9bef..b1d46690 100644 --- a/dbus/dbus_test.go +++ b/dbus/dbus_test.go @@ -98,6 +98,15 @@ func TestProxy_Seal(t *testing.T) { } func TestProxy_Start_Wait_Close_String(t *testing.T) { + t.Run("sandboxed", func(t *testing.T) { + testProxyStartWaitCloseString(t, true) + }) + t.Run("direct", func(t *testing.T) { + testProxyStartWaitCloseString(t, false) + }) +} + +func testProxyStartWaitCloseString(t *testing.T, sandbox bool) { for id, tc := range testCasePairs() { // this test does not test errors if tc[0].wantErr { @@ -116,6 +125,7 @@ func TestProxy_Start_Wait_Close_String(t *testing.T) { t.Run("proxy for "+id, func(t *testing.T) { helper.InternalReplaceExecCommand(t) p := dbus.New(tc[0].bus, tc[1].bus) + output := new(strings.Builder) t.Run("unsealed behaviour of "+id, func(t *testing.T) { t.Run("unsealed string of "+id, func(t *testing.T) { @@ -154,13 +164,13 @@ func TestProxy_Start_Wait_Close_String(t *testing.T) { } t.Run("sealed start of "+id, func(t *testing.T) { - if err := p.Start(nil, nil); err != nil { + if err := p.Start(nil, output, sandbox); err != nil { t.Errorf("Start(nil, nil) error = %v", err) } t.Run("started string of "+id, func(t *testing.T) { - wantSubstr := dbus.ProxyName + " --args=3" + wantSubstr := dbus.ProxyName + " --args=" if got := p.String(); !strings.Contains(got, wantSubstr) { t.Errorf("String() = %v, want %v", p.String(), wantSubstr) @@ -185,8 +195,8 @@ func TestProxy_Start_Wait_Close_String(t *testing.T) { t.Run("started wait of "+id, func(t *testing.T) { if err := p.Wait(); err != nil { - t.Errorf("Wait() error = %v", - err) + t.Errorf("Wait() error = %v\noutput: %s", + err, output.String()) } }) }) |
