github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/e2e/inspect_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"os"
     5  
     6  	. "github.com/hanks177/podman/v4/test/utils"
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  	. "github.com/onsi/gomega/gexec"
    10  	"github.com/opencontainers/selinux/go-selinux"
    11  )
    12  
    13  var _ = Describe("Podman inspect", func() {
    14  	var (
    15  		tempdir    string
    16  		err        error
    17  		podmanTest *PodmanTestIntegration
    18  	)
    19  
    20  	BeforeEach(func() {
    21  		tempdir, err = CreateTempDirInTempDir()
    22  		if err != nil {
    23  			os.Exit(1)
    24  		}
    25  		podmanTest = PodmanTestCreate(tempdir)
    26  		podmanTest.Setup()
    27  	})
    28  
    29  	AfterEach(func() {
    30  		podmanTest.Cleanup()
    31  		f := CurrentGinkgoTestDescription()
    32  		processTestResult(f)
    33  
    34  	})
    35  
    36  	It("podman inspect alpine image", func() {
    37  		session := podmanTest.Podman([]string{"inspect", "--format=json", ALPINE})
    38  		session.WaitWithDefaultTimeout()
    39  		Expect(session).Should(Exit(0))
    40  		Expect(session.OutputToString()).To(BeValidJSON())
    41  		imageData := session.InspectImageJSON()
    42  		Expect(imageData[0].RepoTags[0]).To(Equal("quay.io/libpod/alpine:latest"))
    43  	})
    44  
    45  	It("podman inspect bogus container", func() {
    46  		session := podmanTest.Podman([]string{"inspect", "foobar4321"})
    47  		session.WaitWithDefaultTimeout()
    48  		Expect(session).To(ExitWithError())
    49  	})
    50  
    51  	It("podman inspect filter should work if result contains tab", func() {
    52  		session := podmanTest.Podman([]string{"build", "--tag", "envwithtab", "build/envwithtab"})
    53  		session.WaitWithDefaultTimeout()
    54  		Expect(session).Should(Exit(0))
    55  
    56  		// Verify that OS and Arch are being set
    57  		inspect := podmanTest.Podman([]string{"inspect", "-f", "{{ .Config.Env }}", "envwithtab"})
    58  		inspect.WaitWithDefaultTimeout()
    59  		Expect(inspect).Should(Exit(0))
    60  		// output should not be empty
    61  		// test validates fix for https://github.com/containers/podman/issues/8785
    62  		Expect(inspect.OutputToString()).To(ContainSubstring("TEST="), ".Config.Env")
    63  
    64  		session = podmanTest.Podman([]string{"rmi", "envwithtab"})
    65  		session.WaitWithDefaultTimeout()
    66  		Expect(session).Should(Exit(0))
    67  	})
    68  
    69  	It("podman inspect with GO format", func() {
    70  		session := podmanTest.Podman([]string{"inspect", "--format", "{{.ID}}", ALPINE})
    71  		session.WaitWithDefaultTimeout()
    72  		Expect(session).Should(Exit(0))
    73  
    74  		result := podmanTest.Podman([]string{"images", "-q", "--no-trunc", ALPINE})
    75  		result.WaitWithDefaultTimeout()
    76  		Expect(session).Should(Exit(0))
    77  		Expect(result.OutputToStringArray()).To(ContainElement("sha256:"+session.OutputToString()), "'podman images -q --no-truncate' includes 'podman inspect --format .ID'")
    78  	})
    79  
    80  	It("podman inspect specified type", func() {
    81  		session := podmanTest.Podman([]string{"inspect", "--type", "image", ALPINE})
    82  		session.WaitWithDefaultTimeout()
    83  		Expect(session).Should(Exit(0))
    84  	})
    85  
    86  	It("podman inspect container with GO format for ConmonPidFile", func() {
    87  		session, ec, _ := podmanTest.RunLsContainer("test1")
    88  		session.WaitWithDefaultTimeout()
    89  		Expect(ec).To(Equal(0))
    90  
    91  		session = podmanTest.Podman([]string{"inspect", "--format", "{{.ConmonPidFile}}", "test1"})
    92  		session.WaitWithDefaultTimeout()
    93  		Expect(session).Should(Exit(0))
    94  	})
    95  
    96  	It("podman inspect container with size", func() {
    97  		session, ec, _ := podmanTest.RunLsContainer("sizetest")
    98  		session.WaitWithDefaultTimeout()
    99  		Expect(ec).To(Equal(0))
   100  
   101  		result := podmanTest.Podman([]string{"inspect", "--size", "sizetest"})
   102  		result.WaitWithDefaultTimeout()
   103  		Expect(result).Should(Exit(0))
   104  		conData := result.InspectContainerToJSON()
   105  		Expect(conData[0].SizeRootFs).To(BeNumerically(">", 0))
   106  		Expect(*conData[0].SizeRw).To(BeNumerically(">=", 0))
   107  	})
   108  
   109  	It("podman inspect container and image", func() {
   110  		ls, ec, _ := podmanTest.RunLsContainer("")
   111  		ls.WaitWithDefaultTimeout()
   112  		Expect(ec).To(Equal(0))
   113  		cid := ls.OutputToString()
   114  
   115  		result := podmanTest.Podman([]string{"inspect", "--format={{.ID}}", cid, ALPINE})
   116  		result.WaitWithDefaultTimeout()
   117  		Expect(result).Should(Exit(0))
   118  		Expect(result.OutputToStringArray()).To(HaveLen(2))
   119  	})
   120  
   121  	It("podman inspect container and filter for Image{ID}", func() {
   122  		ls, ec, _ := podmanTest.RunLsContainer("")
   123  		ls.WaitWithDefaultTimeout()
   124  		Expect(ec).To(Equal(0))
   125  		cid := ls.OutputToString()
   126  
   127  		result := podmanTest.Podman([]string{"inspect", "--format={{.ImageID}}", cid})
   128  		result.WaitWithDefaultTimeout()
   129  		Expect(result).Should(Exit(0))
   130  		Expect(result.OutputToStringArray()).To(HaveLen(1))
   131  
   132  		result = podmanTest.Podman([]string{"inspect", "--format={{.Image}}", cid})
   133  		result.WaitWithDefaultTimeout()
   134  		Expect(result).Should(Exit(0))
   135  		Expect(result.OutputToStringArray()).To(HaveLen(1))
   136  	})
   137  
   138  	It("podman inspect container and filter for CreateCommand", func() {
   139  		ls, ec, _ := podmanTest.RunLsContainer("")
   140  		ls.WaitWithDefaultTimeout()
   141  		Expect(ec).To(Equal(0))
   142  		cid := ls.OutputToString()
   143  
   144  		result := podmanTest.Podman([]string{"inspect", "--format={{.Config.CreateCommand}}", cid})
   145  		result.WaitWithDefaultTimeout()
   146  		Expect(result).Should(Exit(0))
   147  		Expect(result.OutputToStringArray()).To(HaveLen(1))
   148  	})
   149  
   150  	It("podman inspect -l with additional input should fail", func() {
   151  		SkipIfRemote("--latest flag n/a")
   152  		result := podmanTest.Podman([]string{"inspect", "-l", "1234foobar"})
   153  		result.WaitWithDefaultTimeout()
   154  		Expect(result).Should(Exit(125))
   155  	})
   156  
   157  	It("podman inspect with mount filters", func() {
   158  
   159  		ctrSession := podmanTest.Podman([]string{"create", "--name", "test", "-v", "/tmp:/test1", ALPINE, "top"})
   160  		ctrSession.WaitWithDefaultTimeout()
   161  		Expect(ctrSession).Should(Exit(0))
   162  
   163  		inspectSource := podmanTest.Podman([]string{"inspect", "test", "--format", "{{(index .Mounts 0).Source}}"})
   164  		inspectSource.WaitWithDefaultTimeout()
   165  		Expect(inspectSource).Should(Exit(0))
   166  		Expect(inspectSource.OutputToString()).To(Equal("/tmp"))
   167  
   168  		inspectSrc := podmanTest.Podman([]string{"inspect", "test", "--format", "{{(index .Mounts 0).Src}}"})
   169  		inspectSrc.WaitWithDefaultTimeout()
   170  		Expect(inspectSrc).Should(Exit(0))
   171  		Expect(inspectSrc.OutputToString()).To(Equal("/tmp"))
   172  
   173  		inspectDestination := podmanTest.Podman([]string{"inspect", "test", "--format", "{{(index .Mounts 0).Destination}}"})
   174  		inspectDestination.WaitWithDefaultTimeout()
   175  		Expect(inspectDestination).Should(Exit(0))
   176  		Expect(inspectDestination.OutputToString()).To(Equal("/test1"))
   177  
   178  		inspectDst := podmanTest.Podman([]string{"inspect", "test", "--format", "{{(index .Mounts 0).Dst}}"})
   179  		inspectDst.WaitWithDefaultTimeout()
   180  		Expect(inspectDst).Should(Exit(0))
   181  		Expect(inspectDst.OutputToString()).To(Equal("/test1"))
   182  	})
   183  
   184  	It("podman inspect shows healthcheck on docker image", func() {
   185  		podmanTest.AddImageToRWStore(healthcheck)
   186  		session := podmanTest.Podman([]string{"inspect", "--format=json", healthcheck})
   187  		session.WaitWithDefaultTimeout()
   188  		imageData := session.InspectImageJSON()
   189  		Expect(imageData[0].HealthCheck.Timeout).To(BeNumerically("==", 3000000000))
   190  		Expect(imageData[0].HealthCheck.Interval).To(BeNumerically("==", 60000000000))
   191  		Expect(imageData[0].HealthCheck).To(HaveField("Test", []string{"CMD-SHELL", "curl -f http://localhost/ || exit 1"}))
   192  	})
   193  
   194  	It("podman inspect --latest with no container fails", func() {
   195  		SkipIfRemote("testing --latest flag")
   196  
   197  		session := podmanTest.Podman([]string{"inspect", "--latest"})
   198  		session.WaitWithDefaultTimeout()
   199  		Expect(session).To(ExitWithError())
   200  	})
   201  
   202  	It("podman [image,container] inspect on image", func() {
   203  		baseInspect := podmanTest.Podman([]string{"inspect", ALPINE})
   204  		baseInspect.WaitWithDefaultTimeout()
   205  		Expect(baseInspect).Should(Exit(0))
   206  		baseJSON := baseInspect.InspectImageJSON()
   207  		Expect(baseJSON).To(HaveLen(1))
   208  
   209  		ctrInspect := podmanTest.Podman([]string{"container", "inspect", ALPINE})
   210  		ctrInspect.WaitWithDefaultTimeout()
   211  		Expect(ctrInspect).To(ExitWithError())
   212  
   213  		imageInspect := podmanTest.Podman([]string{"image", "inspect", ALPINE})
   214  		imageInspect.WaitWithDefaultTimeout()
   215  		Expect(imageInspect).Should(Exit(0))
   216  		imageJSON := imageInspect.InspectImageJSON()
   217  		Expect(imageJSON).To(HaveLen(1))
   218  
   219  		Expect(baseJSON[0]).To(HaveField("ID", imageJSON[0].ID))
   220  	})
   221  
   222  	It("podman [image, container] inspect on container", func() {
   223  		ctrName := "testCtr"
   224  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "sh"})
   225  		create.WaitWithDefaultTimeout()
   226  		Expect(create).Should(Exit(0))
   227  
   228  		baseInspect := podmanTest.Podman([]string{"inspect", ctrName})
   229  		baseInspect.WaitWithDefaultTimeout()
   230  		Expect(baseInspect).Should(Exit(0))
   231  		baseJSON := baseInspect.InspectContainerToJSON()
   232  		Expect(baseJSON).To(HaveLen(1))
   233  
   234  		ctrInspect := podmanTest.Podman([]string{"container", "inspect", ctrName})
   235  		ctrInspect.WaitWithDefaultTimeout()
   236  		Expect(ctrInspect).Should(Exit(0))
   237  		ctrJSON := ctrInspect.InspectContainerToJSON()
   238  		Expect(ctrJSON).To(HaveLen(1))
   239  
   240  		imageInspect := podmanTest.Podman([]string{"image", "inspect", ctrName})
   241  		imageInspect.WaitWithDefaultTimeout()
   242  		Expect(imageInspect).To(ExitWithError())
   243  
   244  		Expect(baseJSON[0]).To(HaveField("ID", ctrJSON[0].ID))
   245  	})
   246  
   247  	It("podman inspect always produces a valid array", func() {
   248  		baseInspect := podmanTest.Podman([]string{"inspect", "doesNotExist"})
   249  		baseInspect.WaitWithDefaultTimeout()
   250  		Expect(baseInspect).To(ExitWithError())
   251  		emptyJSON := baseInspect.InspectContainerToJSON()
   252  		Expect(emptyJSON).To(BeEmpty())
   253  	})
   254  
   255  	It("podman inspect one container with not exist returns 1-length valid array", func() {
   256  		ctrName := "testCtr"
   257  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "sh"})
   258  		create.WaitWithDefaultTimeout()
   259  		Expect(create).Should(Exit(0))
   260  
   261  		baseInspect := podmanTest.Podman([]string{"inspect", ctrName, "doesNotExist"})
   262  		baseInspect.WaitWithDefaultTimeout()
   263  		Expect(baseInspect).To(ExitWithError())
   264  		baseJSON := baseInspect.InspectContainerToJSON()
   265  		Expect(baseJSON).To(HaveLen(1))
   266  		Expect(baseJSON[0]).To(HaveField("Name", ctrName))
   267  	})
   268  
   269  	It("podman inspect container + image with same name gives container", func() {
   270  		podmanTest.AddImageToRWStore(ALPINE)
   271  		ctrName := "testcontainer"
   272  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "sh"})
   273  		create.WaitWithDefaultTimeout()
   274  		Expect(create).Should(Exit(0))
   275  
   276  		tag := podmanTest.Podman([]string{"tag", ALPINE, ctrName + ":latest"})
   277  		tag.WaitWithDefaultTimeout()
   278  		Expect(tag).Should(Exit(0))
   279  
   280  		baseInspect := podmanTest.Podman([]string{"inspect", ctrName})
   281  		baseInspect.WaitWithDefaultTimeout()
   282  		Expect(baseInspect).Should(Exit(0))
   283  		baseJSON := baseInspect.InspectContainerToJSON()
   284  		Expect(baseJSON).To(HaveLen(1))
   285  		Expect(baseJSON[0]).To(HaveField("Name", ctrName))
   286  	})
   287  
   288  	It("podman inspect - HostConfig.SecurityOpt ", func() {
   289  		if !selinux.GetEnabled() {
   290  			Skip("SELinux not enabled")
   291  		}
   292  
   293  		ctrName := "hugo"
   294  		create := podmanTest.Podman([]string{
   295  			"create", "--name", ctrName,
   296  			"--security-opt", "seccomp=unconfined",
   297  			"--security-opt", "label=type:spc_t",
   298  			"--security-opt", "label=level:s0",
   299  			ALPINE, "sh"})
   300  
   301  		create.WaitWithDefaultTimeout()
   302  		Expect(create).Should(Exit(0))
   303  
   304  		baseInspect := podmanTest.Podman([]string{"inspect", ctrName})
   305  		baseInspect.WaitWithDefaultTimeout()
   306  		Expect(baseInspect).Should(Exit(0))
   307  		baseJSON := baseInspect.InspectContainerToJSON()
   308  		Expect(baseJSON).To(HaveLen(1))
   309  		Expect(baseJSON[0].HostConfig).To(HaveField("SecurityOpt", []string{"label=type:spc_t,label=level:s0", "seccomp=unconfined"}))
   310  	})
   311  
   312  	It("podman inspect pod", func() {
   313  		podName := "testpod"
   314  		create := podmanTest.Podman([]string{"pod", "create", "--name", podName})
   315  		create.WaitWithDefaultTimeout()
   316  		Expect(create).Should(Exit(0))
   317  
   318  		inspect := podmanTest.Podman([]string{"inspect", podName})
   319  		inspect.WaitWithDefaultTimeout()
   320  		Expect(inspect).Should(Exit(0))
   321  		Expect(inspect.OutputToString()).To(BeValidJSON())
   322  		podData := inspect.InspectPodArrToJSON()
   323  		Expect(podData[0]).To(HaveField("Name", podName))
   324  	})
   325  
   326  	It("podman inspect pod with type", func() {
   327  		podName := "testpod"
   328  		create := podmanTest.Podman([]string{"pod", "create", "--name", podName})
   329  		create.WaitWithDefaultTimeout()
   330  		Expect(create).Should(Exit(0))
   331  
   332  		inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", podName})
   333  		inspect.WaitWithDefaultTimeout()
   334  		Expect(inspect).Should(Exit(0))
   335  		Expect(inspect.OutputToString()).To(BeValidJSON())
   336  		podData := inspect.InspectPodArrToJSON()
   337  		Expect(podData[0]).To(HaveField("Name", podName))
   338  	})
   339  
   340  	It("podman inspect latest pod", func() {
   341  		SkipIfRemote("--latest flag n/a")
   342  		podName := "testpod"
   343  		create := podmanTest.Podman([]string{"pod", "create", "--name", podName})
   344  		create.WaitWithDefaultTimeout()
   345  		Expect(create).Should(Exit(0))
   346  
   347  		inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", "--latest"})
   348  		inspect.WaitWithDefaultTimeout()
   349  		Expect(inspect).Should(Exit(0))
   350  		Expect(inspect.OutputToString()).To(BeValidJSON())
   351  		podData := inspect.InspectPodArrToJSON()
   352  		Expect(podData[0]).To(HaveField("Name", podName))
   353  	})
   354  	It("podman inspect latest defaults to latest container", func() {
   355  		SkipIfRemote("--latest flag n/a")
   356  		podName := "testpod"
   357  		pod := podmanTest.Podman([]string{"pod", "create", "--name", podName})
   358  		pod.WaitWithDefaultTimeout()
   359  		Expect(pod).Should(Exit(0))
   360  
   361  		inspect1 := podmanTest.Podman([]string{"inspect", "--type", "pod", podName})
   362  		inspect1.WaitWithDefaultTimeout()
   363  		Expect(inspect1).Should(Exit(0))
   364  		Expect(inspect1.OutputToString()).To(BeValidJSON())
   365  		podData := inspect1.InspectPodArrToJSON()
   366  		infra := podData[0].Containers[0].Name
   367  
   368  		inspect := podmanTest.Podman([]string{"inspect", "--latest"})
   369  		inspect.WaitWithDefaultTimeout()
   370  		Expect(inspect).Should(Exit(0))
   371  		Expect(inspect.OutputToString()).To(BeValidJSON())
   372  		containerData := inspect.InspectContainerToJSON()
   373  		Expect(containerData[0]).To(HaveField("Name", infra))
   374  	})
   375  
   376  	It("podman inspect network", func() {
   377  		name, path := generateNetworkConfig(podmanTest)
   378  		defer removeConf(path)
   379  
   380  		session := podmanTest.Podman([]string{"inspect", name, "--format", "{{.Driver}}"})
   381  		session.WaitWithDefaultTimeout()
   382  		Expect(session).Should(Exit(0))
   383  		Expect(session.OutputToString()).To(ContainSubstring("bridge"))
   384  	})
   385  
   386  	It("podman inspect a volume", func() {
   387  		session := podmanTest.Podman([]string{"volume", "create", "myvol"})
   388  		session.WaitWithDefaultTimeout()
   389  		volName := session.OutputToString()
   390  		Expect(session).Should(Exit(0))
   391  
   392  		session = podmanTest.Podman([]string{"inspect", volName})
   393  		session.WaitWithDefaultTimeout()
   394  		Expect(session).Should(Exit(0))
   395  		Expect(session.OutputToString()).To(BeValidJSON())
   396  	})
   397  
   398  	It("podman inspect a volume with --format", func() {
   399  		session := podmanTest.Podman([]string{"volume", "create", "myvol"})
   400  		session.WaitWithDefaultTimeout()
   401  		volName := session.OutputToString()
   402  		Expect(session).Should(Exit(0))
   403  
   404  		session = podmanTest.Podman([]string{"inspect", "--format", "{{.Name}}", volName})
   405  		session.WaitWithDefaultTimeout()
   406  		Expect(session).Should(Exit(0))
   407  		Expect(session.OutputToString()).To(Equal(volName))
   408  	})
   409  	It("podman inspect --type container on a pod should fail", func() {
   410  		podName := "testpod"
   411  		create := podmanTest.Podman([]string{"pod", "create", "--name", podName})
   412  		create.WaitWithDefaultTimeout()
   413  		Expect(create).Should(Exit(0))
   414  
   415  		inspect := podmanTest.Podman([]string{"inspect", "--type", "container", podName})
   416  		inspect.WaitWithDefaultTimeout()
   417  		Expect(inspect).To(ExitWithError())
   418  	})
   419  
   420  	It("podman inspect --type network on a container should fail", func() {
   421  		ctrName := "testctr"
   422  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE})
   423  		create.WaitWithDefaultTimeout()
   424  		Expect(create).Should(Exit(0))
   425  
   426  		inspect := podmanTest.Podman([]string{"inspect", "--type", "network", ctrName})
   427  		inspect.WaitWithDefaultTimeout()
   428  		Expect(inspect).To(ExitWithError())
   429  	})
   430  
   431  	It("podman inspect --type pod on a container should fail", func() {
   432  		ctrName := "testctr"
   433  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE})
   434  		create.WaitWithDefaultTimeout()
   435  		Expect(create).Should(Exit(0))
   436  
   437  		inspect := podmanTest.Podman([]string{"inspect", "--type", "pod", ctrName})
   438  		inspect.WaitWithDefaultTimeout()
   439  		Expect(inspect).To(ExitWithError())
   440  	})
   441  
   442  	It("podman inspect --type volume on a container should fail", func() {
   443  		ctrName := "testctr"
   444  		create := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE})
   445  		create.WaitWithDefaultTimeout()
   446  		Expect(create).Should(Exit(0))
   447  
   448  		inspect := podmanTest.Podman([]string{"inspect", "--type", "volume", ctrName})
   449  		inspect.WaitWithDefaultTimeout()
   450  		Expect(inspect).To(ExitWithError())
   451  	})
   452  
   453  	// Fixes https://github.com/containers/podman/issues/8444
   454  	It("podman inspect --format json .NetworkSettings.Ports", func() {
   455  		ctnrName := "Ctnr_" + RandomString(25)
   456  
   457  		create := podmanTest.Podman([]string{"create", "--name", ctnrName, "-p", "8084:80", ALPINE})
   458  		create.WaitWithDefaultTimeout()
   459  		Expect(create).Should(Exit(0))
   460  
   461  		inspect := podmanTest.Podman([]string{"inspect", `--format="{{json .NetworkSettings.Ports}}"`, ctnrName})
   462  		inspect.WaitWithDefaultTimeout()
   463  		Expect(inspect).Should(Exit(0))
   464  		Expect(inspect.OutputToString()).To(Equal(`"{"80/tcp":[{"HostIp":"","HostPort":"8084"}]}"`))
   465  	})
   466  
   467  	It("Verify container inspect has default network", func() {
   468  		SkipIfRootless("Requires root CNI networking")
   469  		ctrName := "testctr"
   470  		session := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, ALPINE, "top"})
   471  		session.WaitWithDefaultTimeout()
   472  		Expect(session).Should(Exit(0))
   473  
   474  		inspect := podmanTest.InspectContainer(ctrName)
   475  		Expect(inspect).To(HaveLen(1))
   476  		Expect(inspect[0].NetworkSettings.Networks).To(HaveLen(1))
   477  	})
   478  
   479  	It("Verify stopped container still has default network in inspect", func() {
   480  		SkipIfRootless("Requires root CNI networking")
   481  		ctrName := "testctr"
   482  		session := podmanTest.Podman([]string{"create", "--name", ctrName, ALPINE, "top"})
   483  		session.WaitWithDefaultTimeout()
   484  		Expect(session).Should(Exit(0))
   485  
   486  		inspect := podmanTest.InspectContainer(ctrName)
   487  		Expect(inspect).To(HaveLen(1))
   488  		Expect(inspect[0].NetworkSettings.Networks).To(HaveLen(1))
   489  	})
   490  
   491  	It("Container inspect with unlimited uilimits should be -1", func() {
   492  		ctrName := "testctr"
   493  		session := podmanTest.Podman([]string{"run", "-d", "--ulimit", "core=-1:-1", "--name", ctrName, ALPINE, "top"})
   494  		session.WaitWithDefaultTimeout()
   495  		Expect(session).Should(Exit(0))
   496  
   497  		inspect := podmanTest.Podman([]string{"inspect", ctrName})
   498  		inspect.WaitWithDefaultTimeout()
   499  		Expect(inspect).Should(Exit(0))
   500  
   501  		data := inspect.InspectContainerToJSON()
   502  		ulimits := data[0].HostConfig.Ulimits
   503  		Expect(len(ulimits)).To(BeNumerically(">", 0))
   504  		found := false
   505  		for _, ulimit := range ulimits {
   506  			if ulimit.Name == "RLIMIT_CORE" {
   507  				found = true
   508  				Expect(ulimit.Soft).To(BeNumerically("==", -1))
   509  				Expect(ulimit.Hard).To(BeNumerically("==", -1))
   510  			}
   511  		}
   512  		Expect(found).To(BeTrue())
   513  	})
   514  
   515  	It("Dropped capabilities are sorted", func() {
   516  		ctrName := "testCtr"
   517  		session := podmanTest.Podman([]string{"run", "-d", "--cap-drop", "CAP_AUDIT_WRITE", "--cap-drop", "CAP_MKNOD", "--cap-drop", "CAP_NET_RAW", "--name", ctrName, ALPINE, "top"})
   518  		session.WaitWithDefaultTimeout()
   519  		Expect(session).Should(Exit(0))
   520  
   521  		inspect := podmanTest.Podman([]string{"inspect", ctrName})
   522  		inspect.WaitWithDefaultTimeout()
   523  		Expect(inspect).Should(Exit(0))
   524  
   525  		data := inspect.InspectContainerToJSON()
   526  		Expect(data).To(HaveLen(1))
   527  		Expect(data[0].HostConfig.CapDrop).To(HaveLen(3))
   528  		Expect(data[0].HostConfig.CapDrop[0]).To(Equal("CAP_AUDIT_WRITE"))
   529  		Expect(data[0].HostConfig.CapDrop[1]).To(Equal("CAP_MKNOD"))
   530  		Expect(data[0].HostConfig.CapDrop[2]).To(Equal("CAP_NET_RAW"))
   531  	})
   532  
   533  	It("podman inspect container with GO format for PidFile", func() {
   534  		SkipIfRemote("pidfile not handled by remote")
   535  		session, ec, _ := podmanTest.RunLsContainer("test1")
   536  		session.WaitWithDefaultTimeout()
   537  		Expect(ec).To(Equal(0))
   538  
   539  		session = podmanTest.Podman([]string{"inspect", "--format", "{{.PidFile}}", "test1"})
   540  		session.WaitWithDefaultTimeout()
   541  		Expect(session).Should(Exit(0))
   542  	})
   543  })