You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
960 B
Go
40 lines
960 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestAgentSystemdUnitMatchesHostDeployment(t *testing.T) {
|
|
servicePath := filepath.Join("..", "..", "deploy", "virt-cloud-agent.service")
|
|
contents, err := os.ReadFile(servicePath)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
service := string(contents)
|
|
for _, required := range []string{
|
|
"Type=simple",
|
|
"User=root",
|
|
"Group=root",
|
|
"ExecStart=/home/agent/virt-agent -config /home/agent/config.json",
|
|
"Restart=on-failure",
|
|
"RestartSec=5",
|
|
"LimitCORE=0",
|
|
"TimeoutStopSec=30",
|
|
} {
|
|
if !strings.Contains(service, required) {
|
|
t.Fatalf("agent service is missing %q", required)
|
|
}
|
|
}
|
|
for _, forbidden := range []string{
|
|
"ProtectSystem=", "ProtectHome=", "ReadWritePaths=",
|
|
"StateDirectory=", "NoNewPrivileges=", "PrivateTmp=", "UMask=",
|
|
} {
|
|
if strings.Contains(service, forbidden) {
|
|
t.Fatalf("agent service contains retired sandbox setting %q", forbidden)
|
|
}
|
|
}
|
|
}
|