Minor model fix

This commit is contained in:
mposolda 2015-03-18 19:03:33 +01:00
parent e1188e0c68
commit 82e290e06c
4 changed files with 31 additions and 9 deletions

View file

@ -108,6 +108,15 @@ public class ModelToRepresentation {
rep.setQuickLoginCheckMilliSeconds(realm.getQuickLoginCheckMilliSeconds());
rep.setMaxDeltaTimeSeconds(realm.getMaxDeltaTimeSeconds());
rep.setFailureFactor(realm.getFailureFactor());
rep.setEventsEnabled(realm.isEventsEnabled());
if (realm.getEventsExpiration() != 0) {
rep.setEventsExpiration(realm.getEventsExpiration());
}
if (realm.getEventsListeners() != null) {
rep.setEventsListeners(new LinkedList<String>(realm.getEventsListeners()));
}
rep.setVerifyEmail(realm.isVerifyEmail());
rep.setResetPasswordAllowed(realm.isResetPasswordAllowed());
rep.setAccessTokenLifespan(realm.getAccessTokenLifespan());

View file

@ -1104,9 +1104,9 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
@Override
public void setSupportedLocales(Set<String> locales) {
if (locales != null) {
realm.setEventsListeners(new ArrayList<String>(locales));
realm.setSupportedLocales(new ArrayList<String>(locales));
} else {
realm.setEventsListeners(Collections.EMPTY_LIST);
realm.setSupportedLocales(Collections.EMPTY_LIST);
}
updateRealm();
}

View file

@ -54,6 +54,7 @@ public class ApplianceBootstrap {
realm.setSsoSessionMaxLifespan(36000);
realm.setAccessCodeLifespan(60);
realm.setAccessCodeLifespanUserAction(300);
realm.setAccessCodeLifespanLogin(1800);
realm.setSslRequired(SslRequired.EXTERNAL);
realm.setRegistrationAllowed(false);
realm.setRegistrationEmailAsUsername(false);

View file

@ -9,7 +9,9 @@ import org.keycloak.models.utils.KeycloakModelUtils;
import org.keycloak.models.utils.ModelToRepresentation;
import org.keycloak.representations.idm.RealmRepresentation;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
public class ModelTest extends AbstractModelTest {
@ -33,11 +35,14 @@ public class ModelTest extends AbstractModelTest {
smtp.put("hostname", "localhost");
realm.setSmtpConfig(smtp);
HashMap<String, String> social = new HashMap<String,String>();
social.put("google.key", "1234");
social.put("google.secret", "5678");
//FIXME: KEYCLOAK-883
// realm.setSocialConfig(social);
realm.setDefaultLocale("en");
realm.setAccessCodeLifespanLogin(100);
realm.setInternationalizationEnabled(true);
realm.setRegistrationEmailAsUsername(true);
realm.setSupportedLocales(new HashSet<String>(Arrays.asList("en", "cz")));
realm.setEventsListeners(new HashSet<String>(Arrays.asList("jpa", "mongo", "foo")));
realm.setEventsExpiration(200);
realm.setEventsEnabled(true);
RealmModel persisted = realmManager.getRealm(realm.getId());
assertEquals(realm, persisted);
@ -62,8 +67,15 @@ public class ModelTest extends AbstractModelTest {
Assert.assertEquals(expected.getDefaultRoles(), actual.getDefaultRoles());
Assert.assertEquals(expected.getSmtpConfig(), actual.getSmtpConfig());
//FIXME: KEYCLOAK-883
// Assert.assertEquals(expected.getSocialConfig(), actual.getSocialConfig());
Assert.assertEquals(expected.getDefaultLocale(), actual.getDefaultLocale());
Assert.assertEquals(expected.getAccessCodeLifespanLogin(), actual.getAccessCodeLifespanLogin());
Assert.assertEquals(expected.isInternationalizationEnabled(), actual.isInternationalizationEnabled());
Assert.assertEquals(expected.isRegistrationEmailAsUsername(), actual.isRegistrationEmailAsUsername());
Assert.assertEquals(expected.getSupportedLocales(), actual.getSupportedLocales());
Assert.assertEquals(expected.getEventsListeners(), actual.getEventsListeners());
Assert.assertEquals(expected.getEventsExpiration(), actual.getEventsExpiration());
Assert.assertEquals(expected.isEventsEnabled(), actual.isEventsEnabled());
}
private RealmModel importExport(RealmModel src, String copyName) {