Skip to content

Commit

Permalink
consistent args
Browse files Browse the repository at this point in the history
  • Loading branch information
amritakohli committed Dec 20, 2024
1 parent 8d9e153 commit 4443184
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions toolkit/tools/pkg/imagecustomizerlib/imagehistory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func TestAddImageHistory(t *testing.T) {

// Verify the imageUuid is unique for each entry
assert.NotEqual(t, allHistory[0].ImageUuid, allHistory[1].ImageUuid, "imageUuid should be different for each entry")

}

func verifyHistoryFile(t *testing.T, expectedEntries int, expectedUuid string, expectedVersion string, expectedDate string, config imagecustomizerapi.Config, historyFilePath string) (allHistory []ImageHistory) {
Expand All @@ -81,24 +80,24 @@ func verifyHistoryFile(t *testing.T, expectedEntries int, expectedUuid string, e
// Since the config is modified its entirety won't be an exact match; picking one consistent field to verify
assert.Equal(t, config.OS.BootLoader.ResetType, entry.Config.OS.BootLoader.ResetType, "config bootloader reset type should match")

verifyAdditionalFilesHashes(entry.Config.OS.AdditionalFiles, t)
verifyAdditionalDirsHashes(entry.Config.OS.AdditionalDirs, t)
verifyScriptsHashes(entry.Config.Scripts.PostCustomization, t)
verifyScriptsHashes(entry.Config.Scripts.FinalizeCustomization, t)
verifySshPublicKeysRedacted(entry.Config.OS.Users, t)
verifyAdditionalFilesHashes(t, entry.Config.OS.AdditionalFiles)
verifyAdditionalDirsHashes(t, entry.Config.OS.AdditionalDirs)
verifyScriptsHashes(t, entry.Config.Scripts.PostCustomization)
verifyScriptsHashes(t, entry.Config.Scripts.FinalizeCustomization)
verifySshPublicKeysRedacted(t, entry.Config.OS.Users)

return
}

func verifySshPublicKeysRedacted(users []imagecustomizerapi.User, t *testing.T) {
func verifySshPublicKeysRedacted(t *testing.T, users []imagecustomizerapi.User) {
for _, user := range users {
for _, key := range user.SSHPublicKeys {
assert.Equal(t, redactedString, key, "SSH public keys should be redacted")
}
}
}

func verifyScriptsHashes(scripts []imagecustomizerapi.Script, t *testing.T) {
func verifyScriptsHashes(t *testing.T, scripts []imagecustomizerapi.Script) {
for _, script := range scripts {
if script.Path != "" {
verifyFileHash(t, script.Path, script.SHA256Hash)
Expand All @@ -107,7 +106,7 @@ func verifyScriptsHashes(scripts []imagecustomizerapi.Script, t *testing.T) {
}
}
}
func verifyAdditionalFilesHashes(files imagecustomizerapi.AdditionalFileList, t *testing.T) {
func verifyAdditionalFilesHashes(t *testing.T, files imagecustomizerapi.AdditionalFileList) {
for _, f := range files {
if f.Source != "" {
verifyFileHash(t, f.Source, f.SHA256Hash)
Expand All @@ -117,7 +116,7 @@ func verifyAdditionalFilesHashes(files imagecustomizerapi.AdditionalFileList, t
}
}

func verifyAdditionalDirsHashes(dirs imagecustomizerapi.DirConfigList, t *testing.T) {
func verifyAdditionalDirsHashes(t *testing.T, dirs imagecustomizerapi.DirConfigList) {
for _, dir := range dirs {
assert.NotEmpty(t, dir.SHA256HashMap, "SHA256HashMap for additional directories should not be empty")
for relPath, hash := range dir.SHA256HashMap {
Expand Down

0 comments on commit 4443184

Please sign in to comment.