mirror of
https://github.com/containers/podman.git
synced 2025-05-29 14:06:29 +08:00
Add tests for exec --user
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #1315 Approved by: vrothberg
This commit is contained in:
@ -100,4 +100,29 @@ var _ = Describe("Podman exec", func() {
|
||||
Expect(session.ExitCode()).To(Equal(100))
|
||||
})
|
||||
|
||||
It("podman exec simple command with user", func() {
|
||||
setup := podmanTest.RunTopContainer("test1")
|
||||
setup.WaitWithDefaultTimeout()
|
||||
Expect(setup.ExitCode()).To(Equal(0))
|
||||
|
||||
session := podmanTest.Podman([]string{"exec", "--user", "root", "test1", "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
})
|
||||
|
||||
It("podman exec with user only in container", func() {
|
||||
testUser := "test123"
|
||||
setup := podmanTest.RunTopContainer("test1")
|
||||
setup.WaitWithDefaultTimeout()
|
||||
Expect(setup.ExitCode()).To(Equal(0))
|
||||
|
||||
session := podmanTest.Podman([]string{"exec", "test1", "useradd", testUser})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
|
||||
session2 := podmanTest.Podman([]string{"exec", "--user", testUser, "test1", "whoami"})
|
||||
session2.WaitWithDefaultTimeout()
|
||||
Expect(session2.ExitCode()).To(Equal(0))
|
||||
Expect(session2.OutputToString()).To(Equal(testUser))
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user