2021-08-23 13:14:53 +00:00
|
|
|
//go:build !windows
|
2016-06-14 14:43:25 +00:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
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"
|
2023-07-14 18:02:38 +00:00
|
|
|
"github.com/docker/docker/testutil"
|
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
|
|
|
|
2023-04-03 11:00:29 +00:00
|
|
|
apiClient, err := client.NewClientWithOpts(client.FromEnv)
|
2019-10-18 15:57:01 +00:00
|
|
|
assert.NilError(c, err)
|
2023-04-03 11:00:29 +00:00
|
|
|
defer apiClient.Close()
|
2023-07-14 18:02:38 +00:00
|
|
|
info, err := apiClient.Info(testutil.GetContext(c))
|
2019-10-18 15:57:01 +00:00
|
|
|
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
|
|
|
}
|