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