2021-08-23 13:14:53 +00:00
|
|
|
//go:build !windows
|
2016-06-14 14:43:25 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-10-18 15:57:01 +00:00
|
|
|
"context"
|
2019-09-09 21:06:12 +00:00
|
|
|
"testing"
|
|
|
|
|
2019-10-18 15:57:01 +00:00
|
|
|
"github.com/docker/docker/client"
|
2021-06-07 11:44:32 +00:00
|
|
|
"github.com/docker/docker/daemon/config"
|
2020-02-07 13:39:24 +00:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
is "gotest.tools/v3/assert/cmp"
|
2016-06-14 14:43:25 +00:00
|
|
|
)
|
|
|
|
|
2022-06-16 21:32:10 +00:00
|
|
|
func (s *DockerCLIInfoSuite) TestInfoSecurityOptions(c *testing.T) {
|
2019-10-18 15:57:01 +00:00
|
|
|
testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
|
|
|
|
if !seccompEnabled() && !Apparmor() {
|
|
|
|
c.Skip("test requires Seccomp and/or AppArmor")
|
|
|
|
}
|
2016-06-14 14:43:25 +00:00
|
|
|
|
2019-10-18 15:57:01 +00:00
|
|
|
cli, err := client.NewClientWithOpts(client.FromEnv)
|
|
|
|
assert.NilError(c, err)
|
|
|
|
defer cli.Close()
|
|
|
|
info, err := cli.Info(context.Background())
|
|
|
|
assert.NilError(c, err)
|
|
|
|
|
|
|
|
if Apparmor() {
|
|
|
|
assert.Check(c, is.Contains(info.SecurityOptions, "name=apparmor"))
|
|
|
|
}
|
|
|
|
if seccompEnabled() {
|
2021-06-07 11:44:32 +00:00
|
|
|
assert.Check(c, is.Contains(info.SecurityOptions, "name=seccomp,profile="+config.SeccompProfileDefault))
|
2019-10-18 15:57:01 +00:00
|
|
|
}
|
2016-06-14 14:43:25 +00:00
|
|
|
}
|