parent
e5408884f6
commit
44aae52fb4
2 changed files with 27 additions and 1 deletions
|
@ -158,7 +158,7 @@ public class KeycloakErrorHandler implements ExceptionMapper<Throwable> {
|
|||
|
||||
attributes.put("realm", realm);
|
||||
attributes.put("url", new UrlBean(realm, theme, session.getContext().getUri().getBaseUri(), null));
|
||||
attributes.put("locale", new LocaleBean(realm, locale, session.getContext().getUri().getBaseUriBuilder(), messagesBundle));
|
||||
attributes.put("locale", new LocaleBean(realm, locale, session.getContext().getUri().getRequestUriBuilder(), messagesBundle));
|
||||
|
||||
|
||||
String errorKey = statusCode == 404 ? Messages.PAGE_NOT_FOUND : Messages.INTERNAL_SERVER_ERROR;
|
||||
|
|
|
@ -23,6 +23,8 @@ import org.keycloak.testsuite.arquillian.annotation.UncaughtServerErrorExpected;
|
|||
import org.keycloak.testsuite.pages.ErrorPage;
|
||||
import org.keycloak.util.JsonSerialization;
|
||||
import org.keycloak.utils.MediaType;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
|
@ -32,6 +34,7 @@ import java.net.URI;
|
|||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -203,6 +206,29 @@ public class UncaughtErrorPageTest extends AbstractKeycloakTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void switchLocale() throws MalformedURLException {
|
||||
RealmResource testRealm = realmsResouce().realm("master");
|
||||
RealmRepresentation rep = testRealm.toRepresentation();
|
||||
rep.setInternationalizationEnabled(true);
|
||||
rep.setDefaultLocale("en");
|
||||
HashSet<String> supported = new HashSet<>();
|
||||
supported.add("en");
|
||||
supported.add("de");
|
||||
rep.setSupportedLocales(supported);
|
||||
testRealm.update(rep);
|
||||
|
||||
try {
|
||||
checkPageNotFound("/auth/realms/master/nosuch");
|
||||
String url = driver.findElement(By.xpath("//a[text()='Deutsch']")).getAttribute("href");
|
||||
driver.navigate().to(url);
|
||||
errorPage.assertCurrent();
|
||||
} finally {
|
||||
rep.setInternationalizationEnabled(false);
|
||||
testRealm.update(rep);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPageNotFound(String path) throws MalformedURLException {
|
||||
URI uri = suiteContext.getAuthServerInfo().getUriBuilder().path(path).build();
|
||||
driver.navigate().to(uri.toURL());
|
||||
|
|
Loading…
Reference in a new issue