-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Retry creating, updating User with an invalid phone number
- Loading branch information
Showing
2 changed files
with
155 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -399,6 +399,84 @@ async fn test_e2e_no_phone() { | |
}; | ||
} | ||
|
||
#[test(tokio::test)] | ||
#[test_log(default_log_filter = "debug")] | ||
async fn test_e2e_sync_invalid_phone() { | ||
let mut ldap = Ldap::new().await; | ||
ldap.create_user( | ||
"John", | ||
"Good Phone", | ||
"Johnny1", | ||
"[email protected]", | ||
Some("+12015550123"), | ||
"good_gone_bad_phone", | ||
false, | ||
) | ||
.await; | ||
|
||
ldap.create_user( | ||
"John", | ||
"Bad Phone", | ||
"Johnny2", | ||
"[email protected]", | ||
Some("abc"), | ||
"bad_phone_all_along", | ||
false, | ||
) | ||
.await; | ||
|
||
let config = config().await; | ||
config.perform_sync().await.expect("syncing failed"); | ||
|
||
let zitadel = open_zitadel_connection().await; | ||
|
||
let user = zitadel | ||
.get_user_by_login_name("[email protected]") | ||
.await | ||
.expect("could not query Zitadel users"); | ||
assert!(user.is_some()); | ||
let user = user.expect("could not find user"); | ||
match user.r#type { | ||
Some(UserType::Human(user)) => { | ||
assert_eq!( | ||
user.phone.expect("phone field should always be present").phone, | ||
"+12015550123" | ||
); | ||
} | ||
_ => panic!("user lacks details"), | ||
} | ||
let user = zitadel | ||
.get_user_by_login_name("[email protected]") | ||
.await | ||
.expect("could not query Zitadel users"); | ||
assert!(user.is_some()); | ||
let user = user.expect("could not find user"); | ||
match user.r#type { | ||
Some(UserType::Human(user)) => { | ||
assert_eq!(user.phone.expect("phone field should always be present").phone, ""); | ||
} | ||
_ => panic!("user lacks details"), | ||
} | ||
|
||
ldap.change_user("good_gone_bad_phone", vec![("telephoneNumber", HashSet::from(["abc"]))]) | ||
.await; | ||
|
||
config.perform_sync().await.expect("syncing failed"); | ||
|
||
let user = zitadel | ||
.get_user_by_login_name("[email protected]") | ||
.await | ||
.expect("could not query Zitadel users"); | ||
assert!(user.is_some()); | ||
let user = user.expect("could not find user"); | ||
match user.r#type { | ||
Some(UserType::Human(user)) => { | ||
assert_eq!(user.phone.expect("phone field should always be present").phone, ""); | ||
} | ||
_ => panic!("user lacks details"), | ||
} | ||
} | ||
|
||
#[test(tokio::test)] | ||
#[test_log(default_log_filter = "debug")] | ||
async fn test_e2e_binary_attr() { | ||
|