mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-29 03:50:18 +00:00
Automate sensor proxy container mount and auth
This commit is contained in:
parent
156fd34c50
commit
e4c3b06f14
7 changed files with 467 additions and 75 deletions
25
cmd/pulse-sensor-proxy/auth_test.go
Normal file
25
cmd/pulse-sensor-proxy/auth_test.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestAuthorizePeer(t *testing.T) {
|
||||
p := &Proxy{
|
||||
config: &Config{AllowIDMappedRoot: true},
|
||||
allowedPeerUIDs: map[uint32]struct{}{0: {}},
|
||||
allowedPeerGIDs: map[uint32]struct{}{0: {}},
|
||||
idMappedUIDRanges: []idRange{{start: 165536, length: 65536}},
|
||||
idMappedGIDRanges: []idRange{{start: 165536, length: 65536}},
|
||||
}
|
||||
|
||||
if err := p.authorizePeer(&peerCredentials{uid: 0, gid: 0}); err != nil {
|
||||
t.Fatalf("expected root to be authorized, got %v", err)
|
||||
}
|
||||
|
||||
if err := p.authorizePeer(&peerCredentials{uid: 170000, gid: 170000}); err != nil {
|
||||
t.Fatalf("expected idmapped root to be authorized, got %v", err)
|
||||
}
|
||||
|
||||
if err := p.authorizePeer(&peerCredentials{uid: 900, gid: 900}); err == nil {
|
||||
t.Fatalf("expected non-allowed user to be rejected")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue