Merge pull request #1738 from gerbermichi/locale
KEYCLOAK-1962 update realm overwrites supported locales with empty list
This commit is contained in:
commit
a6556a49c2
3 changed files with 38 additions and 4 deletions
|
@ -629,12 +629,16 @@ public class RealmRepresentation {
|
|||
}
|
||||
|
||||
public Set<String> getSupportedLocales() {
|
||||
if(supportedLocales == null){
|
||||
supportedLocales = new HashSet<String>();
|
||||
}
|
||||
return supportedLocales;
|
||||
}
|
||||
|
||||
public void addSupportedLocales(String locale) {
|
||||
if(supportedLocales == null){
|
||||
supportedLocales = new HashSet<>();
|
||||
}
|
||||
supportedLocales.add(locale);
|
||||
}
|
||||
|
||||
public void setSupportedLocales(Set<String> supportedLocales) {
|
||||
this.supportedLocales = supportedLocales;
|
||||
}
|
||||
|
|
|
@ -212,7 +212,10 @@ public class ModelToRepresentation {
|
|||
}
|
||||
|
||||
rep.setInternationalizationEnabled(realm.isInternationalizationEnabled());
|
||||
rep.getSupportedLocales().addAll(realm.getSupportedLocales());
|
||||
if(realm.getSupportedLocales() != null){
|
||||
rep.setSupportedLocales(new HashSet<String>());
|
||||
rep.getSupportedLocales().addAll(realm.getSupportedLocales());
|
||||
}
|
||||
rep.setDefaultLocale(realm.getDefaultLocale());
|
||||
if (internal) {
|
||||
exportAuthenticationFlows(realm, rep);
|
||||
|
|
|
@ -15,6 +15,8 @@ import java.io.IOException;
|
|||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -102,6 +104,31 @@ public class RealmTest extends AbstractClientTest {
|
|||
assertEquals(Boolean.FALSE, rep.isEditUsernameAllowed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateRealmWithNewRepresentation() {
|
||||
// first change
|
||||
RealmRepresentation rep = new RealmRepresentation();
|
||||
rep.setEditUsernameAllowed(true);
|
||||
rep.setSupportedLocales(new HashSet<>(Arrays.asList("en", "de")));
|
||||
|
||||
realm.update(rep);
|
||||
|
||||
rep = realm.toRepresentation();
|
||||
|
||||
assertEquals(Boolean.TRUE, rep.isEditUsernameAllowed());
|
||||
assertEquals(2, rep.getSupportedLocales().size());
|
||||
|
||||
// second change
|
||||
rep = new RealmRepresentation();
|
||||
rep.setEditUsernameAllowed(false);
|
||||
|
||||
realm.update(rep);
|
||||
|
||||
rep = realm.toRepresentation();
|
||||
assertEquals(Boolean.FALSE, rep.isEditUsernameAllowed());
|
||||
assertEquals(2, rep.getSupportedLocales().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRealmRepresentation() {
|
||||
RealmRepresentation rep = realm.toRepresentation();
|
||||
|
|
Loading…
Reference in a new issue