@@ -1218,7 +1218,6 @@ async fn test_e2e_csv_sync() {
12181218 . expect ( "could not query Zitadel users" ) ;
12191219 let user = user. expect ( "could not find user" ) ;
12201220 assert_eq ! ( user. user_name, "john.doe@example.com" ) ;
1221- assert_eq ! ( user. id, "john.doe" , "Unexpected Zitadel userId" ) ;
12221221
12231222 if let Some ( UserType :: Human ( user) ) = user. r#type {
12241223 let profile = user. profile . expect ( "user lacks a profile" ) ;
@@ -1249,8 +1248,9 @@ async fn test_e2e_csv_sync() {
12491248 let localpart = zitadel
12501249 . get_user_metadata ( Some ( config. zitadel . organization_id . clone ( ) ) , & user. id , "localpart" )
12511250 . await
1252- . expect ( "could not get user metadata" ) ;
1253- assert_eq ! ( localpart, Some ( user. id. clone( ) ) , "Localpart metadata should match userId" ) ;
1251+ . expect ( "could not get user metadata" )
1252+ . expect ( "missing localpart" ) ;
1253+ assert_eq ! ( localpart, "john.doe" , "Unexpected Zitadel userId for user without localpart" ) ;
12541254
12551255 let grants = zitadel
12561256 . list_user_grants ( & config. zitadel . organization_id , & user. id )
@@ -1268,21 +1268,28 @@ async fn test_e2e_csv_sync() {
12681268
12691269 let user = user. expect ( "could not find user" ) ;
12701270 assert_eq ! ( user. user_name, "jane.smith@example.com" ) ;
1271- let uuid = Uuid :: new_v5 ( & FAMEDLY_NAMESPACE , "jane.smith@example.com" . as_bytes ( ) ) ;
1272- assert_eq ! ( user. id, uuid. to_string( ) , "Unexpected Zitadel userId for user without localpart" ) ;
12731271
1272+ let uuid = Uuid :: new_v5 ( & FAMEDLY_NAMESPACE , "jane.smith@example.com" . as_bytes ( ) ) ;
12741273 let localpart = zitadel
12751274 . get_user_metadata ( Some ( config. zitadel . organization_id . clone ( ) ) , & user. id , "localpart" )
12761275 . await
12771276 . expect ( "could not get user metadata" ) ;
1278- assert_eq ! ( localpart, Some ( user . id ) , "Localpart metadata should match userId" ) ;
1277+ assert_eq ! ( localpart, Some ( uuid . to_string ( ) ) , "Localpart metadata should match userId" ) ;
12791278
12801279 // Re-import an existing user to update (as checked by unique email)
12811280 let csv_content = indoc:: indoc! { r#"
12821281 email,first_name,last_name,phone,localpart
12831282 john.doe@example.com,Changed_Name,Changed_Surname,+2222222222,new.localpart
12841283 "# } ;
12851284 let _file = temp_csv_file ( & mut config, csv_content) ;
1285+
1286+ let user_id = zitadel
1287+ . get_user_by_login_name ( "john.doe@example.com" )
1288+ . await
1289+ . expect ( "could not query Zitadel users" )
1290+ . expect ( "Must be able to get the user pre-sync" )
1291+ . id ;
1292+
12861293 perform_sync ( config. clone ( ) ) . await . expect ( "syncing failed" ) ;
12871294
12881295 let user = zitadel
@@ -1292,7 +1299,7 @@ async fn test_e2e_csv_sync() {
12921299
12931300 let user = user. expect ( "could not find user" ) ;
12941301 assert_eq ! ( user. user_name, "john.doe@example.com" ) ;
1295- assert_eq ! ( user. id, "john.doe" , "Zitadel userId should not change" ) ;
1302+ assert_eq ! ( user. id, user_id , "Zitadel userId should not change" ) ;
12961303
12971304 if let Some ( UserType :: Human ( user) ) = user. r#type {
12981305 let profile = user. profile . expect ( "user lacks a profile" ) ;
@@ -1314,7 +1321,7 @@ async fn test_e2e_csv_sync() {
13141321 . get_user_metadata ( Some ( config. zitadel . organization_id . clone ( ) ) , & user. id , "localpart" )
13151322 . await
13161323 . expect ( "could not get user metadata" ) ;
1317- assert_eq ! ( localpart, Some ( user . id ) , "Localpart metadata should match userId" ) ;
1324+ assert_eq ! ( localpart, Some ( "john.doe" . to_owned ( ) ) , ) ;
13181325}
13191326
13201327#[ test( tokio:: test) ]
0 commit comments