Skip to content

Commit

Permalink
Merge pull request #1163 from adorsys/1018-enabling-a-realm-clears-th…
Browse files Browse the repository at this point in the history
…e-value-of-eventsexpiration

Fix enabling a realm clears the value of eventsExpiration
  • Loading branch information
AssahBismarkabah authored Oct 15, 2024
2 parents d624925 + e65b22a commit d126bab
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Fixed

- Fix enabling a realm clears the value of eventsExpiration

## [6.1.11] - 2024-10-14

- Fix env.JAVA_HOME test failures by ensuring env is set before build

## [6.1.10] - 2024-10-04


- Fixed securityContext entries in job template


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,11 @@ private void updateRealm(RealmImport realmImport) {

RealmRepresentation realm = CloneUtil.deepClone(realmImport, RealmRepresentation.class, ignoredPropertiesForRealmImport);

// The state must be loaded before we update realm to prevent
// the state erasure by custom attributes from configuration
RealmRepresentation existingRealm = realmRepository.get(realmImport.getRealm());

if (existingRealm.getEventsExpiration() != null) {
realm.setEventsExpiration(existingRealm.getEventsExpiration());
}
stateService.loadState(realm);

realmRepository.update(realm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,17 @@ void shouldNotUpdateSimpleRealmWithInvalidSyntax() {

assertThat(thrown.getMessage(), matchesPattern("(?s)^Unable to parse file 'file:.+/import-files/simple-realm/81_invalid_json.json': while parsing a flow mapping.+"));
}
@Test
@Order(83)
void shouldPreserveEventsExpirationWhenUpdatingRealm() throws Exception {
doImport("08.3_update_simple-realm_with_events-expiration.json");

RealmRepresentation realm = keycloakProvider.getInstance().realm(REALM_NAME).toRepresentation();
assertThat(realm.getEventsExpiration(), is(3600L));

doImport("08.4_update_simple-realm_without_events-expiration.json");

realm = keycloakProvider.getInstance().realm(REALM_NAME).toRepresentation();
assertThat(realm.getEventsExpiration(), is(3600L));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"realm": "simple",
"eventsEnabled": true,
"eventsExpiration": 3600
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"realm": "simple",
"eventsEnabled": true
}

0 comments on commit d126bab

Please sign in to comment.