Skip to content

Commit

Permalink
Merge pull request #17378 from mheon/fix_17366
Browse files Browse the repository at this point in the history
Fix a potential UID/GID collision in unit tests
  • Loading branch information
openshift-merge-robot authored Feb 7, 2023
2 parents 6ce7672 + 1916da5 commit db505ed
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions libpod/container_internal_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestGenerateUserPasswdEntry(t *testing.T) {
config: &ContainerConfig{
Spec: &spec.Spec{},
ContainerSecurityConfig: ContainerSecurityConfig{
User: "123:456",
User: "123456:456789",
},
},
state: &ContainerState{
Expand All @@ -26,22 +26,22 @@ func TestGenerateUserPasswdEntry(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, user, "123:*:123:456:container user:/:/bin/sh\n")
assert.Equal(t, user, "123456:*:123456:456789:container user:/:/bin/sh\n")

c.config.User = "567"
c.config.User = "567890"
user, err = c.generateUserPasswdEntry(0)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, user, "567:*:567:0:container user:/:/bin/sh\n")
assert.Equal(t, user, "567890:*:567890:0:container user:/:/bin/sh\n")
}

func TestGenerateUserGroupEntry(t *testing.T) {
c := Container{
config: &ContainerConfig{
Spec: &spec.Spec{},
ContainerSecurityConfig: ContainerSecurityConfig{
User: "123:456",
User: "123456:456789",
},
},
state: &ContainerState{
Expand All @@ -52,12 +52,12 @@ func TestGenerateUserGroupEntry(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Equal(t, group, "456:x:456:123\n")
assert.Equal(t, group, "456789:x:456789:123456\n")

c.config.User = "567"
c.config.User = "567890"
group, err = c.generateUserGroupEntry(0)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, group, "567:x:567:567\n")
assert.Equal(t, group, "567890:x:567890:567890\n")
}

0 comments on commit db505ed

Please sign in to comment.