Repository navigation
dir-sim: a provisioning plane separate from delivery #1477
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
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| //! The provisioning plane: an address claimed by more than one directory | ||
| //! object, whatever state the objects are in. | ||
| //! | ||
| //! Entra ID keeps `userPrincipalName` and `proxyAddresses` unique across | ||
| //! every object of the tenant; a duplicate value from a sync is quarantined | ||
| //! on the object that brought it, enabled or not, mail-enabled or not. That | ||
| //! is a separate question from who holds an address in Exchange (only | ||
| //! address owners: [`validate::address_owner`]) and from who receives mail | ||
| //! at it ([`validate::address_recipient`]), and it must not change either. | ||
|
|
||
| use lance_graph_dir_sim::validate::{ | ||
| address_owner, address_recipient, provisioning_conflicts, ProvisioningConflict, | ||
| }; | ||
| use lance_graph_dir_sim::*; | ||
| use ogar_dir_core::{DirectoryScope, Guid128}; | ||
| use ogar_dir_sim::*; | ||
|
|
||
| const SCOPE: DirectoryScope = DirectoryScope(Guid128([0x5C; 16])); | ||
|
|
||
| fn g(n: u8) -> Guid128 { | ||
| Guid128([n; 16]) | ||
| } | ||
|
|
||
| fn store(nodes: Vec<(Guid128, ObservedNode)>) -> (VersionStore, VersionId) { | ||
| let mut st = VersionStore::new(); | ||
| let v = st | ||
| .observe( | ||
| "lab", | ||
| 0, | ||
| Observation { | ||
| scope: SCOPE, | ||
| nodes, | ||
| members: vec![], | ||
| }, | ||
| ) | ||
| .unwrap(); | ||
| (st, v) | ||
| } | ||
|
|
||
| fn group(smtp: &str) -> ObservedNode { | ||
| let mut grp = ObservedNode::group(); | ||
| grp.primary_smtp = Some(smtp.into()); | ||
| grp | ||
| } | ||
|
|
||
| /// An enabled account whose recipient type was read and is empty: not | ||
| /// mail-enabled. Its SMTP and proxies are leftovers in Exchange terms. | ||
| fn not_mail_enabled(name: &str, smtp: &str) -> ObservedNode { | ||
| let mut u = ObservedNode::user(&format!("{name}.upn@x.test"), smtp); | ||
| u.recipient = Some(ObservedRecipient::default()); | ||
| u | ||
| } | ||
|
|
||
| // A non-mail-enabled account still carrying a group's address: Exchange | ||
| // holds and delivers the address to the group, and validation raises no | ||
| // address conflict, but provisioning reports the key as claimed twice. | ||
| #[test] | ||
| fn a_leftover_address_is_a_provisioning_conflict_not_a_delivery_change() { | ||
| let (mut st, v) = store(vec![ | ||
| (g(0xB0), group("team@x.test")), | ||
| (g(0xDA), not_mail_enabled("dave", "team@x.test")), | ||
| ]); | ||
| let key = { | ||
| let id = st.intern("team@x.test"); | ||
| st.key_of(id).unwrap() | ||
| }; | ||
| let out = st.validate(v).unwrap(); | ||
| assert!( | ||
| !out.iter() | ||
| .any(|x| matches!(x, Violation::AddressConflict { .. })), | ||
| "{out:?}" | ||
| ); | ||
| let view = st.view(v).unwrap(); | ||
| assert_eq!(address_owner(&view, key), Ok(Some(g(0xB0)))); | ||
| assert_eq!(address_recipient(&view, key), Ok(Some(g(0xB0)))); | ||
| assert_eq!( | ||
| provisioning_conflicts(&view), | ||
| vec![ProvisioningConflict { | ||
| key, | ||
| claims: vec![ | ||
| (g(0xB0), AddressRole::PrimarySmtp), | ||
| (g(0xDA), AddressRole::PrimarySmtp), | ||
| ], | ||
| }] | ||
| ); | ||
| } | ||
|
|
||
| // A disabled account's UPN is still claimed in the tenant. | ||
| #[test] | ||
| fn a_disabled_accounts_upn_is_still_claimed() { | ||
| let mut disabled = ObservedNode::user("shared@x.test", "old@x.test"); | ||
| disabled.active = Some(false); | ||
| disabled.recipient = Some(ObservedRecipient::default()); | ||
| let (mut st, v) = store(vec![ | ||
| (g(0xD1), disabled), | ||
| ( | ||
| g(0xA1), | ||
| ObservedNode::user("alice.upn@x.test", "shared@x.test"), | ||
| ), | ||
| ]); | ||
| let key = { | ||
| let id = st.intern("shared@x.test"); | ||
| st.key_of(id).unwrap() | ||
| }; | ||
| let view = st.view(v).unwrap(); | ||
| assert_eq!(address_owner(&view, key), Ok(Some(g(0xA1)))); | ||
| assert_eq!( | ||
| provisioning_conflicts(&view), | ||
| vec![ProvisioningConflict { | ||
| key, | ||
| claims: vec![ | ||
| (g(0xA1), AddressRole::PrimarySmtp), | ||
| (g(0xD1), AddressRole::Upn), | ||
| ], | ||
| }] | ||
| ); | ||
| } | ||
|
|
||
| // The silence half: distinct addresses, and one object claiming one key | ||
| // under two roles (its UPN is its primary SMTP), conflict with nothing. | ||
| #[test] | ||
| fn distinct_claims_and_one_object_under_two_roles_are_not_conflicts() { | ||
| let (st, v) = store(vec![ | ||
| (g(0xA1), ObservedNode::user("alice@x.test", "alice@x.test")), | ||
| (g(0xB0), group("team@x.test")), | ||
| (g(0xDA), not_mail_enabled("dave", "dave@x.test")), | ||
| ]); | ||
| let view = st.view(v).unwrap(); | ||
| assert_eq!(provisioning_conflicts(&view), vec![]); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.