Skip to content

Commit 35d9002

Browse files
feat(zitadel): Remove the feature setting custom Zitadel IDs
This feature is purely cosmetic, we've avoided using it for anything; As expected, a consistency bug was caused by it (likely due to bad handling of the historic status of this as an arbitrarily generated ID), though the bug happened upstream in Zitadel.
1 parent 6cd668e commit 35d9002

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

src/zitadel.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ impl<'s> Zitadel<'s> {
213213
.with_organization(
214214
Organization::new().with_org_id(self.zitadel_config.organization_id.clone()),
215215
)
216-
.with_metadata(metadata)
217-
.with_user_id(imported_user.localpart.clone()); // Set the Zitadel userId to the localpart
216+
.with_metadata(metadata);
218217

219218
if let Some(phone) = imported_user.phone.clone() {
220219
user.set_phone(

tests/e2e.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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)]

tests/environment/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
entrypoint: /certs/generate-certs.sh
99

1010
ldap:
11-
image: bitnami/openldap:2.5.18
11+
image: registry.famedly.net/public-ecr-aws/bitnami/openldap:2.6
1212
ports:
1313
- 1389:1389
1414
- 1636:1636

tests/environment/test-setup/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM bitnami/openldap:2.5.18
1+
FROM registry.famedly.net/public-ecr-aws/bitnami/openldap:2.6
22

33
USER root
44

0 commit comments

Comments
 (0)