Skip to content

Commit

Permalink
Merge pull request #17290 from edsantiago/username_not_gecos
Browse files Browse the repository at this point in the history
e2e tests: fix incorrect os.User.Name
  • Loading branch information
openshift-merge-robot authored Jan 31, 2023
2 parents 929d03a + 0e3524b commit 56b9476
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion test/e2e/generate_kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ var _ = Describe("Podman kube generate", func() {
It("podman generate kube on pod with user namespace", func() {
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())
name := u.Name
name := u.Username
if name == "root" {
name = "containers"
}
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/pod_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ ENTRYPOINT ["sleep","99999"]
Expect(session).Should(Exit(0))
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())
Expect(session.OutputToString()).To(ContainSubstring(u.Name))
Expect(session.OutputToString()).To(Equal(u.Username))

// root owns /usr
session = podmanTest.Podman([]string{"run", "--pod", podName, ALPINE, "stat", "-c%u", "/usr"})
Expand Down Expand Up @@ -715,10 +715,10 @@ ENTRYPOINT ["sleep","99999"]
Expect(err).ToNot(HaveOccurred())
// container inside pod inherits user from infra container if --user is not set
// etc/passwd entry will look like USERNAME:*:1000:1000:Full User Name:/:/bin/sh
exec1 := podmanTest.Podman([]string{"exec", ctrName, "cat", "/etc/passwd"})
exec1 := podmanTest.Podman([]string{"exec", ctrName, "id", "-un"})
exec1.WaitWithDefaultTimeout()
Expect(exec1).Should(Exit(0))
Expect(exec1.OutputToString()).To(ContainSubstring(u.Name))
Expect(exec1.OutputToString()).To(Equal(u.Username))

exec2 := podmanTest.Podman([]string{"exec", ctrName, "useradd", "testuser"})
exec2.WaitWithDefaultTimeout()
Expand All @@ -733,7 +733,7 @@ ENTRYPOINT ["sleep","99999"]
It("podman pod create with --userns=auto", func() {
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())
name := u.Name
name := u.Username
if name == "root" {
name = "containers"
}
Expand Down Expand Up @@ -768,7 +768,7 @@ ENTRYPOINT ["sleep","99999"]
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())

name := u.Name
name := u.Username
if name == "root" {
name = "containers"
}
Expand Down Expand Up @@ -804,7 +804,7 @@ ENTRYPOINT ["sleep","99999"]
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())

name := u.Name
name := u.Username
if name == "root" {
name = "containers"
}
Expand Down Expand Up @@ -841,7 +841,7 @@ ENTRYPOINT ["sleep","99999"]
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())

name := u.Name
name := u.Username
if name == "root" {
name = "containers"
}
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/run_userns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var _ = Describe("Podman UserNS support", func() {
It("podman build with --userns=auto", func() {
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())
name := u.Name
name := u.Username
if name == "root" {
name = "containers"
}
Expand Down Expand Up @@ -157,7 +157,7 @@ var _ = Describe("Podman UserNS support", func() {
Expect(session).Should(Exit(0))
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())
Expect(session.OutputToString()).To(ContainSubstring(u.Name))
Expect(session.OutputToString()).To(Equal(u.Username))
})

It("podman --userns=keep-id root owns /usr", func() {
Expand Down Expand Up @@ -201,7 +201,7 @@ var _ = Describe("Podman UserNS support", func() {
It("podman --userns=auto", func() {
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())
name := u.Name
name := u.Username
if name == "root" {
name = "containers"
}
Expand Down Expand Up @@ -239,7 +239,7 @@ var _ = Describe("Podman UserNS support", func() {
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())

name := u.Name
name := u.Username
if name == "root" {
name = "containers"
}
Expand Down Expand Up @@ -277,7 +277,7 @@ var _ = Describe("Podman UserNS support", func() {
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())

name := u.Name
name := u.Username
if name == "root" {
name = "containers"
}
Expand Down Expand Up @@ -306,7 +306,7 @@ var _ = Describe("Podman UserNS support", func() {
u, err := user.Current()
Expect(err).ToNot(HaveOccurred())

name := u.Name
name := u.Username
if name == "root" {
name = "containers"
}
Expand Down

0 comments on commit 56b9476

Please sign in to comment.