Skip to content

Commit

Permalink
Remove session_note_label
Browse files Browse the repository at this point in the history
  • Loading branch information
Clemens Hanel committed Sep 11, 2020
1 parent 67306de commit d83e29c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ resource "keycloak_openid_user_session_note_protocol_mapper" "user_session_note_
claim_name = "foo"
claim_value_type = "String"
session_note = "bar"
session_note_label = "bar"
add_to_id_token = true
add_to_access_token = false
}
Expand All @@ -56,7 +55,6 @@ resource "keycloak_openid_user_session_note_protocol_mapper" "user_session_note_
claim_name = "foo"
claim_value_type = "String"
session_note = "bar"
session_note_label = "bar"
add_to_id_token = true
add_to_access_token = false
}
Expand All @@ -73,7 +71,6 @@ The following arguments are supported:
- `claim_name` - (Required) The name of the claim to insert into a token.
- `claim_value_type` - (Optional) The claim type used when serializing JSON tokens. Can be one of `String`, `JSON`, `long`, `int`, or `boolean`. Defaults to `String`.
- `session_note` - (Optional) String value being the name of stored user session note within the UserSession.note map.
- `session_note_label` - (Optional) String value being the name of stored user session note within the UserSessionModel.note map.
- `add_to_id_token` - (Optional) Indicates if the property should be added as a claim to the id token. Defaults to `true`.
- `add_to_access_token` - (Optional) Indicates if the property should be added as a claim to the access token. Defaults to `true`.

Expand Down
3 changes: 0 additions & 3 deletions keycloak/openid_user_session_note_protocol_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type OpenIdUserSessionNoteProtocolMapper struct {
ClaimName string
ClaimValueType string
UserSessionNote string
UserSessionNoteLabel string
}

func (mapper *OpenIdUserSessionNoteProtocolMapper) convertToGenericProtocolMapper() *protocolMapper {
Expand All @@ -33,7 +32,6 @@ func (mapper *OpenIdUserSessionNoteProtocolMapper) convertToGenericProtocolMappe
claimNameField: mapper.ClaimName,
claimValueTypeField: mapper.ClaimValueType,
userSessionNoteField: mapper.UserSessionNote,
userSessionModelNoteLabelField: mapper.UserSessionNoteLabel,
},
}
}
Expand Down Expand Up @@ -62,7 +60,6 @@ func (protocolMapper *protocolMapper) convertToOpenIdUserSessionNoteProtocolMapp
ClaimName: protocolMapper.Config[claimNameField],
ClaimValueType: protocolMapper.Config[claimValueTypeField],
UserSessionNote: protocolMapper.Config[userSessionNoteField],
UserSessionNoteLabel: protocolMapper.Config[userSessionModelNoteLabelField],
}, nil
}

Expand Down
1 change: 0 additions & 1 deletion keycloak/protocol_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ var (
userClientRoleMappingClientIdField = "usermodel.clientRoleMapping.clientId"
userClientRoleMappingRolePrefixField = "usermodel.clientRoleMapping.rolePrefix"
userSessionNoteField = "user.session.note"
userSessionModelNoteLabelField = "userSession.modelNote.label"
aggregateAttributeValuesField = "aggregate.attrs"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ func resourceKeycloakOpenIdUserSessionNoteProtocolMapper() *schema.Resource {
Optional: true,
Description: "String value being the name of stored user session note within the UserSessionModel.note map.",
},
"session_note_label": {
Type: schema.TypeString,
Optional: true,
Description: "String value being the name of stored user session note within the UserSessionModel.note map.",
},
},
}
}
Expand All @@ -95,7 +90,6 @@ func mapFromDataToOpenIdUserSessionNoteProtocolMapper(data *schema.ResourceData)
ClaimName: data.Get("claim_name").(string),
ClaimValueType: data.Get("claim_value_type").(string),
UserSessionNote: data.Get("session_note").(string),
UserSessionNoteLabel: data.Get("session_note_label").(string),
}
}

Expand All @@ -115,7 +109,6 @@ func mapFromOpenIdUserSessionNoteMapperToData(mapper *keycloak.OpenIdUserSession
data.Set("claim_name", mapper.ClaimName)
data.Set("claim_value_type", mapper.ClaimValueType)
data.Set("session_note", mapper.UserSessionNote)
data.Set("session_note_label", mapper.UserSessionNoteLabel)
}

func resourceKeycloakOpenIdUserSessionNoteProtocolMapperCreate(data *schema.ResourceData, meta interface{}) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ func TestAccKeycloakOpenIdUserSessionNoteProtocolMapper_updateClaim(t *testing.T
})
}

func TestAccKeycloakOpenIdUserSessionNoteProtocolMapper_updateLabel(t *testing.T) {
func TestAccKeycloakOpenIdUserSessionNoteProtocolMapper_updateNote(t *testing.T) {
realmName := "terraform-realm-" + acctest.RandString(10)
clientId := "terraform-client-" + acctest.RandString(10)
mapperName := "terraform-openid-connect-user-session-note-mapper-" + acctest.RandString(5)

labelName := "session-note-label-" + acctest.RandString(10)
updatedLabelName := "session-note-label-update-" + acctest.RandString(10)
noteName := "session-note-" + acctest.RandString(10)
updatedNoteName := "session-note-update-" + acctest.RandString(10)

resourceName := "keycloak_openid_user_session_note_protocol_mapper.user_session_note_mapper"

Expand All @@ -131,11 +131,11 @@ func TestAccKeycloakOpenIdUserSessionNoteProtocolMapper_updateLabel(t *testing.T
CheckDestroy: testAccKeycloakOpenIdUserSessionNoteProtocolMapperDestroy(),
Steps: []resource.TestStep{
{
Config: testKeycloakOpenIdUserSessionNoteProtocolMapper_label(realmName, clientId, mapperName, labelName),
Config: testKeycloakOpenIdUserSessionNoteProtocolMapper_note(realmName, clientId, mapperName, noteName),
Check: testKeycloakOpenIdUserSessionNoteProtocolMapperExists(resourceName),
},
{
Config: testKeycloakOpenIdUserSessionNoteProtocolMapper_label(realmName, clientId, mapperName, updatedLabelName),
Config: testKeycloakOpenIdUserSessionNoteProtocolMapper_note(realmName, clientId, mapperName, updatedNoteName),
Check: testKeycloakOpenIdUserSessionNoteProtocolMapperExists(resourceName),
},
},
Expand Down Expand Up @@ -348,7 +348,6 @@ resource "keycloak_openid_user_session_note_protocol_mapper" "user_session_note_
claim_name = "foo"
claim_value_type = "String"
session_note = "bar"
session_note_label = "bar"
}`, realmName, clientId, mapperName)
}

Expand All @@ -368,7 +367,6 @@ resource "keycloak_openid_user_session_note_protocol_mapper" "user_session_note_
claim_name = "foo"
claim_value_type = "String"
session_note = "bar"
session_note_label = "bar"
}`, realmName, clientScopeId, mapperName)
}

Expand All @@ -391,7 +389,7 @@ resource "keycloak_openid_user_session_note_protocol_mapper" "user_session_note_
}`, realmName, clientId, mapperName, claimName)
}

func testKeycloakOpenIdUserSessionNoteProtocolMapper_label(realmName, clientId, mapperName, labelName string) string {
func testKeycloakOpenIdUserSessionNoteProtocolMapper_note(realmName, clientId, mapperName, noteName string) string {
return fmt.Sprintf(`
resource "keycloak_realm" "realm" {
realm = "%s"
Expand All @@ -407,9 +405,8 @@ resource "keycloak_openid_user_session_note_protocol_mapper" "user_session_note_
client_id = "${keycloak_openid_client.openid_client.id}"
claim_name = "foo"
claim_value_type = "String"
session_note = "bar"
session_note_label = "%s"
}`, realmName, clientId, mapperName, labelName)
session_note = "%s"
}`, realmName, clientId, mapperName, noteName)
}

func testKeycloakOpenIdUserSessionNoteProtocolMapper_import(realmName, clientId, clientScopeId, mapperName string) string {
Expand All @@ -429,7 +426,6 @@ resource "keycloak_openid_user_session_note_protocol_mapper" "user_session_note_
claim_name = "foo"
claim_value_type = "String"
session_note = "bar"
session_note_label = "bar"
}
resource "keycloak_openid_client_scope" "client_scope" {
name = "%s"
Expand All @@ -442,7 +438,6 @@ resource "keycloak_openid_user_session_note_protocol_mapper" "user_session_note_
claim_name = "foo"
claim_value_type = "String"
session_note = "bar"
session_note_label = "bar"
}`, realmName, clientId, mapperName, clientScopeId, mapperName)
}

Expand All @@ -463,6 +458,5 @@ resource "keycloak_openid_user_session_note_protocol_mapper" "user_session_note_
claim_name = "foo"
claim_value_type = "%s"
session_note = "bar"
session_note_label = "bar"
}`, realmName, mapperName, claimValueType)
}

0 comments on commit d83e29c

Please sign in to comment.