2018-03-01 17:51:11 -05:00
|
|
|
package system // import "github.com/docker/docker/integration/system"
|
2018-02-07 13:23:31 -05:00
|
|
|
|
|
|
|
import (
|
2018-04-19 18:30:59 -04:00
|
|
|
"context"
|
2018-02-07 13:23:31 -05:00
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
2018-08-21 08:06:06 -04:00
|
|
|
"github.com/docker/docker/internal/test/daemon"
|
2018-04-17 04:22:04 -04:00
|
|
|
"github.com/docker/docker/internal/test/request"
|
2018-06-11 09:32:11 -04:00
|
|
|
"gotest.tools/assert"
|
|
|
|
is "gotest.tools/assert/cmp"
|
2018-02-07 13:23:31 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestInfoAPI(t *testing.T) {
|
|
|
|
client := request.NewAPIClient(t)
|
|
|
|
|
|
|
|
info, err := client.Info(context.Background())
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2018-02-07 13:23:31 -05:00
|
|
|
|
|
|
|
// always shown fields
|
|
|
|
stringsToCheck := []string{
|
|
|
|
"ID",
|
|
|
|
"Containers",
|
|
|
|
"ContainersRunning",
|
|
|
|
"ContainersPaused",
|
|
|
|
"ContainersStopped",
|
|
|
|
"Images",
|
|
|
|
"LoggingDriver",
|
|
|
|
"OperatingSystem",
|
|
|
|
"NCPU",
|
|
|
|
"OSType",
|
|
|
|
"Architecture",
|
|
|
|
"MemTotal",
|
|
|
|
"KernelVersion",
|
|
|
|
"Driver",
|
|
|
|
"ServerVersion",
|
|
|
|
"SecurityOptions"}
|
|
|
|
|
|
|
|
out := fmt.Sprintf("%+v", info)
|
|
|
|
for _, linePrefix := range stringsToCheck {
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.Check(t, is.Contains(out, linePrefix))
|
2018-02-07 13:23:31 -05:00
|
|
|
}
|
|
|
|
}
|
2018-08-21 08:06:06 -04:00
|
|
|
|
|
|
|
func TestInfoAPIWarnings(t *testing.T) {
|
|
|
|
d := daemon.New(t)
|
|
|
|
|
|
|
|
client, err := d.NewClient()
|
|
|
|
assert.NilError(t, err)
|
|
|
|
|
|
|
|
d.StartWithBusybox(t, "--iptables=false", "-H=0.0.0.0:23756", "-H=unix://"+d.Sock())
|
|
|
|
defer d.Stop(t)
|
|
|
|
|
|
|
|
info, err := client.Info(context.Background())
|
|
|
|
assert.NilError(t, err)
|
|
|
|
|
|
|
|
stringsToCheck := []string{
|
|
|
|
"Access to the remote API is equivalent to root access",
|
|
|
|
"http://0.0.0.0:23756",
|
|
|
|
}
|
|
|
|
|
|
|
|
out := fmt.Sprintf("%+v", info)
|
|
|
|
for _, linePrefix := range stringsToCheck {
|
|
|
|
assert.Check(t, is.Contains(out, linePrefix))
|
|
|
|
}
|
|
|
|
}
|