Skip to content

Commit

Permalink
manifest: add unit test for makeKickstartSudoersPost()
Browse files Browse the repository at this point in the history
  • Loading branch information
achilleas-k committed Mar 12, 2024
1 parent 107b0a0 commit dc61c22
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/manifest/anaconda_installer_iso_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,23 @@ func TestAnacondaISOTreeSerializeWithContainer(t *testing.T) {
assert.NoError(t, checkISOTreeStages(sp.Stages, append(payloadStages, "org.osbuild.isolinux"), variantStages))
})
}

func TestMakeKickstartSudoersPostEmpty(t *testing.T) {
assert.Equal(t, "", makeKickstartSudoersPost(nil))
}

func TestMakeKickstartSudoersPost(t *testing.T) {
exp := `
%post
echo -e "%group31\tALL=(ALL)\tNOPASSWD: ALL" > "/etc/sudoers.d/%group31"
chmod 0440 /etc/sudoers.d/%group31
echo -e "user42\tALL=(ALL)\tNOPASSWD: ALL" > "/etc/sudoers.d/user42"
chmod 0440 /etc/sudoers.d/user42
restorecon -rvF /etc/sudoers.d
%end
`
assert.Equal(t, exp, makeKickstartSudoersPost([]string{"user42", "%group31"}))
assert.Equal(t, exp, makeKickstartSudoersPost([]string{"%group31", "user42"}))
assert.Equal(t, exp, makeKickstartSudoersPost([]string{"%group31", "user42", "%group31"}))
assert.Equal(t, exp, makeKickstartSudoersPost([]string{"%group31", "user42", "%group31", "%group31", "user42", "%group31", "%group31", "user42", "%group31"}))
}

0 comments on commit dc61c22

Please sign in to comment.