Skip to content

Commit

Permalink
fixup! Add test for new AdminIdentitiesFromRules function
Browse files Browse the repository at this point in the history
  • Loading branch information
denisonbarbosa committed Dec 2, 2024
1 parent ca30fff commit 0707b7e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/policies/privilege/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,37 +107,37 @@ func TestPolkitAdminIdentitiesFromRules(t *testing.T) {
emptyReturn bool
}{
"Fetch previous admin identities": {
policyKitDirs: []string{"existing-previous-local-admins-one/polkit-1"},
policyKitDirs: []string{"existing-previous-local-admins-one/etc/polkit-1"},
},
"Fetch previous admin identities from lower ascii file": {
policyKitDirs: []string{"existing-previous-local-admins-multi/polkit-1"},
policyKitDirs: []string{"existing-previous-local-admins-multi/etc/polkit-1"},
},
"Fetch previous admin identities ignoring adsys": {
policyKitDirs: []string{"existing-previous-local-admins-with-adsys-file/polkit-1"},
policyKitDirs: []string{"existing-previous-local-admins-with-adsys-file/etc/polkit-1"},
},

// Rules-specific cases
"Consider only first returned value": {
policyKitDirs: []string{"existing-previous-local-admins-return-early/polkit-1"},
policyKitDirs: []string{"existing-previous-local-admins-return-early/etc/polkit-1"},
},
"Prioritize first specified directory if files have same ascii": {
policyKitDirs: []string{"multiple-polkit-dirs-same-file/polkit-1", "multiple-polkit-dirs-same-file/polkit-2"},
policyKitDirs: []string{"multiple-polkit-dirs-same-file/etc/polkit-1", "multiple-polkit-dirs-same-file/etc/polkit-2"},
},
"Prioritize lower ascii file even if on second directory": {
policyKitDirs: []string{"multiple-polkit-dirs-diff-file/polkit-1", "multiple-polkit-dirs-diff-file/polkit-2"},
policyKitDirs: []string{"multiple-polkit-dirs-diff-file/etc/polkit-1", "multiple-polkit-dirs-diff-file/etc/polkit-2"},
},

// Edge cases
"No previous admin identities but regular directory structure": {
policyKitDirs: []string{"existing-other-files/polkit-1"},
policyKitDirs: []string{"existing-other-files/etc/polkit-1"},
emptyReturn: true,
},
"Returns an empty string if directory does not exists": {
policyKitDirs: []string{"doesnotexists"},
emptyReturn: true,
},
"Directory instead of a conf file is ignored": {
policyKitDirs: []string{"incorrect-policikit-conf-is-dir/polkit-1"},
policyKitDirs: []string{"incorrect-policikit-conf-is-dir/etc/polkit-1"},
emptyReturn: true,
},
}
Expand Down

0 comments on commit 0707b7e

Please sign in to comment.