Skip to content

Commit

Permalink
1099 fix multi-valued user attributes cannot be enabled (#1107)
Browse files Browse the repository at this point in the history
* 1099 fix multi-valued user attributes cannot be enabled

Signed-off-by: Sebastian Schuster <[email protected]>

* Fixed test failure with KC<24

Signed-off-by: Sebastian Schuster <[email protected]>

* Also enabled CodeQL on release branches

Signed-off-by: Sebastian Schuster <[email protected]>

---------

Signed-off-by: Sebastian Schuster <[email protected]>
  • Loading branch information
sschu authored Jan 30, 2025
1 parent f778c59 commit 52d1445
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ name: "CodeQL"

on:
push:
branches: [ main ]
branches:
- "main"
- "release/*"
paths-ignore:
- '**/*.md'
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches:
- "main"
- "release/*"
paths-ignore:
- '**/*.md'
schedule:
Expand Down
2 changes: 1 addition & 1 deletion provider/resource_keycloak_realm_user_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func getRealmUserProfileAttributeFromData(m map[string]interface{}) *keycloak.Re
Group: m["group"].(string),
}

if v, ok := m["multivalued"].(bool); ok {
if v, ok := m["multi_valued"].(bool); ok {
attribute.MultiValued = v
} else {
attribute.MultiValued = false
Expand Down
11 changes: 10 additions & 1 deletion provider/resource_keycloak_realm_user_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,19 @@ func TestAccKeycloakRealmUserProfile_basicFull(t *testing.T) {

realmName := acctest.RandomWithPrefix("tf-acc")

mvSupported, err := keycloakClient.VersionIsGreaterThanOrEqualTo(testCtx, keycloak.Version_24)
if err != nil {
t.Errorf("error checking keycloak version: %v", err)
}

realmUserProfile := &keycloak.RealmUserProfile{
Attributes: []*keycloak.RealmUserProfileAttribute{
{Name: "username"}, {Name: "email"}, // Version >=23 needs these
{Name: "attribute1"},
{
Name: "attribute2",
DisplayName: "attribute 2",
MultiValued: false,
MultiValued: mvSupported,
Group: "group",
Selector: &keycloak.RealmUserProfileSelector{Scopes: []string{"roles"}},
Required: &keycloak.RealmUserProfileRequired{
Expand Down Expand Up @@ -545,6 +550,10 @@ resource "keycloak_realm_user_profile" "realm_user_profile" {
display_name = "{{ $attribute.DisplayName }}"
{{- end }}
{{- if $attribute.MultiValued }}
multi_valued = "{{ $attribute.MultiValued }}"
{{- end }}
{{- if $attribute.Group }}
group = "{{ $attribute.Group }}"
{{- end }}
Expand Down

0 comments on commit 52d1445

Please sign in to comment.