-
Notifications
You must be signed in to change notification settings - Fork 1
[CXH-2156, CXH-2157] Enhance user account provisioning with custom privileges support #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d8a061a
[CXH-2156, CXH-2157] Enhance user account provisioning with custom pr…
FeliLucero1 9586b04
docs: document userAccount custom privileges; add slug regression pin
FeliLucero1 67ba83b
fix: correct ticket cross-reference in test-server NOTE comments
FeliLucero1 92831da
Address PR review feedback: symmetric privilege validation and Custom…
FeliLucero1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package connector | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/conductorone/baton-jamf/pkg/jamf" | ||
| ) | ||
|
|
||
| // TestMatchesIndividualPrivilege_CustomOnly guards against PR #28 review | ||
| // feedback: widening Privileges.Contains to all 7 categories must not grant | ||
| // individual-privilege roles to built-in-privilege-set accounts, even if | ||
| // their Privileges data happens to be populated. | ||
| func TestMatchesIndividualPrivilege_CustomOnly(t *testing.T) { | ||
| populated := &jamf.Privileges{JSSObjects: []string{"Read User"}} | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| privilegeSet string | ||
| privileges *jamf.Privileges | ||
| privilege string | ||
| want bool | ||
| }{ | ||
| {"custom account with matching privilege", privilegeSetCustom, populated, "Read User", true}, | ||
| {"custom account without matching privilege", privilegeSetCustom, populated, "Update User", false}, | ||
| {"administrator account with populated privileges must not match", privilegeSetAdministrator, populated, "Read User", false}, | ||
| {"auditor account with populated privileges must not match", privilegeSetAuditor, populated, "Read User", false}, | ||
| {"enrollment only account with populated privileges must not match", privilegeSetEnrollmentOnly, populated, "Read User", false}, | ||
| {"custom account with empty privileges", privilegeSetCustom, &jamf.Privileges{}, "Read User", false}, | ||
| {"nil privileges", privilegeSetCustom, nil, "Read User", false}, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| got := matchesIndividualPrivilege(tt.privilegeSet, tt.privileges, tt.privilege) | ||
| if got != tt.want { | ||
| t.Errorf("matchesIndividualPrivilege(%q, %+v, %q) = %v, want %v", tt.privilegeSet, tt.privileges, tt.privilege, got, tt.want) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package connector | ||
|
|
||
| import "testing" | ||
|
|
||
| // TestEntitlementSlugRegressionPin guards against an accidental rename of the | ||
| // shared entitlement slug: it's built into every group/role/userGroup/site | ||
| // entitlement and grant ID already synced for existing customers, so a rename | ||
| // here would silently orphan every existing grant of these types. Asserts | ||
| // against the literal string, not memberEntitlement itself, so renaming the | ||
| // constant's value actually fails this test instead of trivially passing. | ||
| func TestEntitlementSlugRegressionPin(t *testing.T) { | ||
| const wantMemberSlug = "member" | ||
| if memberEntitlement != wantMemberSlug { | ||
| t.Fatalf("memberEntitlement slug changed: got %q, want %q — this orphans every existing grant of this type", memberEntitlement, wantMemberSlug) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Connector]
role.gostill uses privilege-set string literals that now have named constants in this packageGood change to name these.
role.go:24declares a second, overlapping list of the same values as literals:Two near-identical lists of the same vendor enum in one package will drift — and
privilegeSetsgatesisCustomPrivilegeinGrants, so a drift there silently changes which grants are emitted. Reuse the constants:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 92831da: role.go now reuses privilegeSetAdministrator/privilegeSetAuditor/privilegeSetEnrollmentOnly from userAccount.go instead of a second literal list, with the same comment you suggested explaining why Custom is excluded.