Skip to content

Commit

Permalink
add test for apply bounding or ambient caps for other process
Browse files Browse the repository at this point in the history
Signed-off-by: lifubang <[email protected]>
  • Loading branch information
lifubang committed Oct 13, 2024
1 parent 3fb56d9 commit a782713
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions capability/capability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package capability_test

import (
"errors"
"runtime"
"testing"

Expand Down Expand Up @@ -151,3 +152,35 @@ func TestAmbientCapSet(t *testing.T) {
}
}
}

func TestApplyAmbientCapsForOtherProcess(t *testing.T) {
if runtime.GOOS != "linux" {
return
}
requirePCapSet(t)

pid, err := NewPid(1)
if err != nil {
t.Fatal(err)
}
err = pid.Apply(AMBIENT)
if !errors.Is(err, ErrAmbientNotMine) {
t.Fatalf("expected not support error when rasing ambient caps for other process, but got: %v", err)
}
}

func TestApplyBoundingCapsForOtherProcess(t *testing.T) {
if runtime.GOOS != "linux" {
return
}
requirePCapSet(t)

pid, err := NewPid(1)
if err != nil {
t.Fatal(err)
}
err = pid.Apply(BOUNDING)
if !errors.Is(err, ErrBoundingNotMine) {
t.Fatalf("expected not support error when drop bounding caps for other process, but got: %v", err)
}
}

0 comments on commit a782713

Please sign in to comment.