Skip to content

Commit e4e028d

Browse files
committed
fix
1 parent d7710d5 commit e4e028d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/fixtures/keycloak.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,15 @@ func SetupCustomKeycloak(ctx context.Context, kcParams KeycloakConnectParams, ke
409409
return err
410410
}
411411
if customClient.Count < 1 {
412-
return nil
412+
break
413413
}
414+
baseClientID := *customClient.Client.ClientID
415+
baseClientName := *customClient.Client.Name
414416
numDigits := int(math.Log10(float64(customClient.Count-1))) + 1
415417
padFormat := fmt.Sprintf("%%s-%%%dd", numDigits)
416418
for i := 0; i < customClient.Count; i++ {
417-
customClient.Client.ClientID = gocloak.StringP(fmt.Sprintf(padFormat, customClient.Client.ClientID, i))
419+
customClient.Client.ClientID = gocloak.StringP(fmt.Sprintf(padFormat, baseClientID, i))
420+
customClient.Client.Name = gocloak.StringP(fmt.Sprintf(padFormat, baseClientName, i))
418421
_, err = createClient(ctx, client, token, &kcConnectParams, customClient.Client, realmRoles, clientRoleMap)
419422
if err != nil {
420423
return err
@@ -443,13 +446,15 @@ func SetupCustomKeycloak(ctx context.Context, kcParams KeycloakConnectParams, ke
443446
return err
444447
}
445448
if customUser.Count < 1 {
446-
return nil
449+
break
447450
}
451+
baseUserName := *customUser.User.Username
452+
baseEmail := *customUser.User.Email
448453
numDigits := int(math.Log10(float64(customUser.Count-1))) + 1
449454
padFormat := fmt.Sprintf("%%s-%%%dd", numDigits)
450455
for i := 0; i < customUser.Count; i++ {
451-
customUser.User.ID = gocloak.StringP(fmt.Sprintf(padFormat, customUser.User.ID, i))
452-
customUser.User.Username = gocloak.StringP(fmt.Sprintf(padFormat, customUser.User.Username, i))
456+
customUser.User.Username = gocloak.StringP(fmt.Sprintf(padFormat, baseUserName, i))
457+
customUser.User.Email = gocloak.StringP(fmt.Sprintf("%d-%s", i, baseEmail))
453458
_, err = createUser(ctx, client, token, &kcConnectParams, customUser.User)
454459
if err != nil {
455460
return err

service/cmd/keycloak_data.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,3 @@ realms:
111111
token_exchanges:
112112
- start_client: opentdf
113113
target_client: opentdf-sdk
114-

0 commit comments

Comments
 (0)