1
0
mirror of https://github.com/google/nomulus synced 2025-12-23 06:15:42 +00:00

Disable legacy registrar console (#2575)

This commit is contained in:
Lai Jiang
2024-10-01 15:42:35 -04:00
committed by GitHub
parent c68d54a5ed
commit 142c910e3b
5 changed files with 27 additions and 19 deletions

View File

@@ -3,4 +3,4 @@
<title>Nomulus</title>
<body lang="en-US">
If this page doesn't change automatically, please go
to <a href="/registrar">https://www.registry.google/registrar</a>
to <a href="/console">https://www.registry.google/console</a>

View File

@@ -20,7 +20,6 @@ import static google.registry.request.auth.AuthenticatedRegistrarAccessor.Role.A
import static google.registry.request.auth.AuthenticatedRegistrarAccessor.Role.OWNER;
import static google.registry.ui.server.SoyTemplateUtils.CSS_RENAMING_MAP_SUPPLIER;
import static jakarta.servlet.http.HttpServletResponse.SC_FORBIDDEN;
import static jakarta.servlet.http.HttpServletResponse.SC_PERMANENT_REDIRECT;
import static jakarta.servlet.http.HttpServletResponse.SC_SERVICE_UNAVAILABLE;
import com.google.common.base.Supplier;
@@ -30,7 +29,6 @@ import com.google.template.soy.data.SoyMapData;
import com.google.template.soy.tofu.SoyTofu;
import google.registry.config.RegistryConfig.Config;
import google.registry.model.common.FeatureFlag;
import google.registry.model.console.GlobalRole;
import google.registry.request.Action;
import google.registry.request.Action.GaeService;
import google.registry.request.Parameter;
@@ -44,7 +42,6 @@ import google.registry.util.RegistryEnvironment;
import java.io.IOException;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
import javax.inject.Inject;
/** Action that serves Registrar Console single HTML page (SPA). */
@@ -100,6 +97,18 @@ public final class ConsoleUiAction extends HtmlAction {
@Override
public void runAfterLogin(Map<String, Object> data) {
// This console is deprecated.
// Unless an explict "noredirect" URL parameter is included, it will redirect to the new
// console.
if (isNullOrEmpty(req.getParameter("noredirect"))) {
try {
response.sendRedirect("/console");
return;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
SoyMapData soyMapData = new SoyMapData();
data.forEach((key, value) -> soyMapData.put(key, value));
@@ -121,21 +130,6 @@ public final class ConsoleUiAction extends HtmlAction {
return;
}
// Set permanent redirect to the new console for tech support
if (isNullOrEmpty(req.getParameter("redirect"))
&& Stream.of(GlobalRole.SUPPORT_LEAD, GlobalRole.SUPPORT_AGENT)
.anyMatch(
globalRole ->
globalRole.equals(authResult.user().get().getUserRoles().getGlobalRole()))) {
response.setStatus(SC_PERMANENT_REDIRECT);
try {
response.sendRedirect("/console");
return;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
ImmutableSetMultimap<String, Role> roleMap = registrarAccessor.getAllRegistrarIdsWithRoles();
soyMapData.put("allClientIds", roleMap.keySet());
soyMapData.put("environment", RegistryEnvironment.get().toString());

View File

@@ -20,6 +20,7 @@ import static google.registry.request.auth.AuthenticatedRegistrarAccessor.Role.A
import static google.registry.request.auth.AuthenticatedRegistrarAccessor.Role.OWNER;
import static jakarta.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSetMultimap;
@@ -84,6 +85,7 @@ class ConsoleUiActionTest {
"NewRegistrar", ADMIN,
"AdminRegistrar", ADMIN));
RegistrarConsoleMetrics.consoleRequestMetric.reset();
when(request.getParameter("noredirect")).thenReturn("true");
}
@AfterEach
@@ -98,6 +100,14 @@ class ConsoleUiActionTest {
registrarId, explicitClientId, roles, status);
}
@Test
void testWebPage_redirect() {
when(request.getParameter("noredirect")).thenReturn(null);
action.run();
assertThat(response.getStatus()).isEqualTo(302);
assertThat(response.getPayload()).isEqualTo("Redirected to /console");
}
@Test
void testWebPage_disallowsIframe() {
action.run();

View File

@@ -43,12 +43,14 @@ import google.registry.testing.DatabaseHelper;
import java.util.Optional;
import java.util.UUID;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junitpioneer.jupiter.RetryingTest;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
/** Registrar Console Screenshot Differ tests. */
@Disabled
class RegistrarConsoleScreenshotTest extends WebDriverTestCase {
@RegisterExtension

View File

@@ -28,12 +28,14 @@ import google.registry.model.registrar.RegistrarPoc;
import google.registry.module.frontend.FrontendServlet;
import google.registry.server.RegistryTestServer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junitpioneer.jupiter.RetryingTest;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
/** WebDriver tests for Registrar Console UI. */
@Disabled
public class RegistrarConsoleWebTest extends WebDriverTestCase {
@RegisterExtension