github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/e2e/run_passwd_test.go (about)

     1  // +build !remoteclient
     2  
     3  package integration
     4  
     5  import (
     6  	"os"
     7  
     8  	. "github.com/containers/libpod/test/utils"
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  )
    12  
    13  var _ = Describe("Podman run passwd", 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  		podmanTest.SeedImages()
    28  	})
    29  
    30  	AfterEach(func() {
    31  		podmanTest.Cleanup()
    32  		f := CurrentGinkgoTestDescription()
    33  		processTestResult(f)
    34  
    35  	})
    36  
    37  	It("podman run no user specified ", func() {
    38  		session := podmanTest.Podman([]string{"run", BB, "mount"})
    39  		session.WaitWithDefaultTimeout()
    40  		Expect(session.ExitCode()).To(Equal(0))
    41  		Expect(session.LineInOutputContains("passwd")).To(BeFalse())
    42  	})
    43  	It("podman run user specified in container", func() {
    44  		session := podmanTest.Podman([]string{"run", "-u", "bin", BB, "mount"})
    45  		session.WaitWithDefaultTimeout()
    46  		Expect(session.ExitCode()).To(Equal(0))
    47  		Expect(session.LineInOutputContains("passwd")).To(BeFalse())
    48  	})
    49  
    50  	It("podman run UID specified in container", func() {
    51  		session := podmanTest.Podman([]string{"run", "-u", "2:1", BB, "mount"})
    52  		session.WaitWithDefaultTimeout()
    53  		Expect(session.ExitCode()).To(Equal(0))
    54  		Expect(session.LineInOutputContains("passwd")).To(BeFalse())
    55  	})
    56  
    57  	It("podman run UID not specified in container", func() {
    58  		session := podmanTest.Podman([]string{"run", "-u", "20001:1", BB, "mount"})
    59  		session.WaitWithDefaultTimeout()
    60  		Expect(session.ExitCode()).To(Equal(0))
    61  		Expect(session.LineInOutputContains("passwd")).To(BeTrue())
    62  	})
    63  })