}
+ {@param username: string} /** Arbitrary username to display. */
+ {@param logoutUrl: string} /** Generated URL for logging out of Google. */
{call registry.soy.console.header}
{param app: 'registrar' /}
{param subtitle: 'Please Login' /}
@@ -110,13 +114,12 @@
The account you are logged in as is not associated with Google
Registry. Please contact your customer service representative or
switch to an account associated with Google Registry.
- {if isNonnull($user['name'])}
- You are signed in as {$user['name']}.
- {/if}
+
+ You are signed in as {$username}.
{/template}
diff --git a/javatests/com/google/domain/registry/server/RegistryTestServer.java b/javatests/com/google/domain/registry/server/RegistryTestServer.java
index 8990c771b..53a78c586 100644
--- a/javatests/com/google/domain/registry/server/RegistryTestServer.java
+++ b/javatests/com/google/domain/registry/server/RegistryTestServer.java
@@ -69,8 +69,7 @@ public final class RegistryTestServer {
com.google.domain.registry.module.backend.BackendServlet.class),
// Registrar Console
- route("/registrar",
- com.google.domain.registry.ui.server.registrar.ConsoleUiServlet.class),
+ route("/registrar", com.google.domain.registry.module.frontend.FrontendServlet.class),
route("/registrar-settings",
com.google.domain.registry.ui.server.registrar.RegistrarServlet.class),
route("/registrar-payment",
diff --git a/javatests/com/google/domain/registry/ui/js/registrar/console_test.js b/javatests/com/google/domain/registry/ui/js/registrar/console_test.js
index 23e6649b7..da671d7f4 100644
--- a/javatests/com/google/domain/registry/ui/js/registrar/console_test.js
+++ b/javatests/com/google/domain/registry/ui/js/registrar/console_test.js
@@ -46,11 +46,10 @@ function setUp() {
stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo);
var testElt = goog.dom.getElement('test');
goog.soy.renderElement(testElt, registry.soy.registrar.console.main, {
- user: {
- id: 'pmy@google.com',
- actionHref: 'blah'
- },
xsrfToken: test.testXsrfToken,
+ username: 'blah',
+ logoutUrl: 'omg',
+ isAdmin: true,
clientId: test.testClientId
});
registry.registrar.ConsoleTestUtil.setup(test);
diff --git a/javatests/com/google/domain/registry/ui/js/registrar/contact_settings_test.js b/javatests/com/google/domain/registry/ui/js/registrar/contact_settings_test.js
index 03a52398d..9f1d6fb50 100644
--- a/javatests/com/google/domain/registry/ui/js/registrar/contact_settings_test.js
+++ b/javatests/com/google/domain/registry/ui/js/registrar/contact_settings_test.js
@@ -45,12 +45,10 @@ function setUp() {
registry.testing.addToDocument('');
testContact = createTestContact();
goog.soy.renderElement($('test'), registry.soy.registrar.console.main, {
- user: {
- id: 'test@acme.com',
- actionHref: 'blah',
- actionName: 'omg'
- },
xsrfToken: test.testXsrfToken,
+ username: 'blah',
+ logoutUrl: 'omg',
+ isAdmin: true,
clientId: test.testClientId
});
stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo);
diff --git a/javatests/com/google/domain/registry/ui/js/registrar/contact_test.js b/javatests/com/google/domain/registry/ui/js/registrar/contact_test.js
index 7221c4992..127246645 100644
--- a/javatests/com/google/domain/registry/ui/js/registrar/contact_test.js
+++ b/javatests/com/google/domain/registry/ui/js/registrar/contact_test.js
@@ -36,11 +36,10 @@ function setUp() {
registry.testing.addToDocument('');
registry.testing.addToDocument('');
goog.soy.renderElement($('test'), registry.soy.registrar.console.main, {
- user: {
- id: 'test1.ui@example.com',
- actionHref: 'blah'
- },
xsrfToken: 'test',
+ username: 'blah',
+ logoutUrl: 'omg',
+ isAdmin: true,
clientId: 'daddy'
});
registry.registrar.ConsoleTestUtil.setup(test);
diff --git a/javatests/com/google/domain/registry/ui/js/registrar/domain_test.js b/javatests/com/google/domain/registry/ui/js/registrar/domain_test.js
index 5d33228a1..0e09ac20f 100644
--- a/javatests/com/google/domain/registry/ui/js/registrar/domain_test.js
+++ b/javatests/com/google/domain/registry/ui/js/registrar/domain_test.js
@@ -43,12 +43,10 @@ function setUp() {
registry.testing.addToDocument('');
goog.soy.renderElement($('test'), registry.soy.registrar.console.main, {
xsrfToken: 'ignore',
- clientId: 'ignore',
- user: {
- id: 'jart@google.com',
- actionHref: 'https://justinetunney.com',
- actionName: 'gtfo'
- }
+ username: 'jart',
+ logoutUrl: 'https://justinetunney.com',
+ isAdmin: true,
+ clientId: 'ignore'
});
stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo);
diff --git a/javatests/com/google/domain/registry/ui/js/registrar/host_test.js b/javatests/com/google/domain/registry/ui/js/registrar/host_test.js
index 349c2d3b4..b7d950831 100644
--- a/javatests/com/google/domain/registry/ui/js/registrar/host_test.js
+++ b/javatests/com/google/domain/registry/ui/js/registrar/host_test.js
@@ -43,12 +43,10 @@ function setUp() {
registry.testing.addToDocument('');
goog.soy.renderElement($('test'), registry.soy.registrar.console.main, {
xsrfToken: 'ignore',
- clientId: 'ignore',
- user: {
- id: 'test2.ui@example.com',
- actionHref: 'https://example.com',
- actionName: 'gtfo'
- }
+ username: 'jart',
+ logoutUrl: 'https://example.com',
+ isAdmin: true,
+ clientId: 'ignore'
});
stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo);
diff --git a/javatests/com/google/domain/registry/ui/js/registrar/security_settings_test.js b/javatests/com/google/domain/registry/ui/js/registrar/security_settings_test.js
index a057a0024..045176f37 100644
--- a/javatests/com/google/domain/registry/ui/js/registrar/security_settings_test.js
+++ b/javatests/com/google/domain/registry/ui/js/registrar/security_settings_test.js
@@ -50,11 +50,9 @@ function setUp() {
registry.testing.addToDocument('');
registry.testing.addToDocument('');
goog.soy.renderElement($('test'), registry.soy.registrar.console.main, {
- user: {
- id: 'test@acme.com',
- actionHref: 'blah',
- actionName: 'omg'
- },
+ username: 'jart',
+ logoutUrl: 'https://example.com',
+ isAdmin: true,
xsrfToken: test.testXsrfToken,
clientId: test.testClientId
});
diff --git a/javatests/com/google/domain/registry/ui/js/registrar/whois_settings_test.js b/javatests/com/google/domain/registry/ui/js/registrar/whois_settings_test.js
index 0a07a26d7..a00de47a4 100644
--- a/javatests/com/google/domain/registry/ui/js/registrar/whois_settings_test.js
+++ b/javatests/com/google/domain/registry/ui/js/registrar/whois_settings_test.js
@@ -44,12 +44,10 @@ function setUp() {
registry.testing.addToDocument('');
registry.testing.addToDocument('');
goog.soy.renderElement($('test'), registry.soy.registrar.console.main, {
- user: {
- id: 'test1.ui@example.com',
- actionHref: 'blah',
- actionName: 'omg'
- },
xsrfToken: test.testXsrfToken,
+ username: 'blah',
+ logoutUrl: 'omg',
+ isAdmin: true,
clientId: test.testClientId
});
stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo);
diff --git a/javatests/com/google/domain/registry/ui/server/registrar/BUILD b/javatests/com/google/domain/registry/ui/server/registrar/BUILD
index e7d12b53e..92589da94 100644
--- a/javatests/com/google/domain/registry/ui/server/registrar/BUILD
+++ b/javatests/com/google/domain/registry/ui/server/registrar/BUILD
@@ -11,6 +11,7 @@ java_library(
"//java/com/google/common/base",
"//java/com/google/common/collect",
"//java/com/google/common/io",
+ "//java/com/google/common/net",
"//java/com/google/common/testing",
"//java/com/google/domain/registry/config",
"//java/com/google/domain/registry/export/sheet",
@@ -31,8 +32,6 @@ java_library(
"//third_party/java/objectify:objectify-v4_1",
"//third_party/java/servlet/servlet_api",
"//third_party/java/truth",
-
- "//third_party/closure/templates",
],
)
diff --git a/javatests/com/google/domain/registry/ui/server/registrar/ConsoleUiActionTest.java b/javatests/com/google/domain/registry/ui/server/registrar/ConsoleUiActionTest.java
new file mode 100644
index 000000000..40179f9a2
--- /dev/null
+++ b/javatests/com/google/domain/registry/ui/server/registrar/ConsoleUiActionTest.java
@@ -0,0 +1,101 @@
+// Copyright 2016 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.domain.registry.ui.server.registrar;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import com.google.appengine.api.users.UserServiceFactory;
+import com.google.common.net.MediaType;
+import com.google.domain.registry.testing.AppEngineRule;
+import com.google.domain.registry.testing.FakeResponse;
+import com.google.domain.registry.testing.UserInfo;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import javax.servlet.http.HttpServletRequest;
+
+/** Unit tests for {@link ConsoleUiAction}. */
+@RunWith(MockitoJUnitRunner.class)
+public class ConsoleUiActionTest {
+
+ @Rule
+ public final AppEngineRule appEngineRule = AppEngineRule.builder()
+ .withDatastore()
+ .withUserService(UserInfo.create("marla.singer@example.com", "12345"))
+ .build();
+
+ @Mock
+ private SessionUtils sessionUtils;
+
+ private final FakeResponse response = new FakeResponse();
+ private final ConsoleUiAction action = new ConsoleUiAction();
+
+ @Before
+ public void setUp() throws Exception {
+ action.enabled = true;
+ action.response = response;
+ action.sessionUtils = sessionUtils;
+ action.userService = UserServiceFactory.getUserService();
+ when(sessionUtils.checkRegistrarConsoleLogin(any(HttpServletRequest.class))).thenReturn(true);
+ when(sessionUtils.getRegistrarClientId(any(HttpServletRequest.class)))
+ .thenReturn("TheRegistrar");
+ }
+
+ @Test
+ public void webPage_disallowsIframe() throws Exception {
+ action.run();
+ assertThat(response.getHeaders()).containsEntry("X-Frame-Options", "SAMEORIGIN");
+ }
+
+ @Test
+ public void webPage_setsHtmlUtf8ContentType() throws Exception {
+ action.run();
+ assertThat(response.getContentType()).isEqualTo(MediaType.HTML_UTF_8);
+ }
+
+ @Test
+ public void webPage_containsUserNickname() throws Exception {
+ action.run();
+ assertThat(response.getPayload()).contains("marla.singer");
+ }
+
+ @Test
+ public void userHasAccessAsTheRegistrar_showsRegistrarConsole() throws Exception {
+ action.run();
+ assertThat(response.getPayload()).contains("Registrar Console");
+ assertThat(response.getPayload()).contains("reg-content-and-footer");
+ }
+
+ @Test
+ public void consoleDisabled_showsDisabledPage() throws Exception {
+ action.enabled = false;
+ action.run();
+ assertThat(response.getPayload()).contains("Console is disabled
");
+ }
+
+ @Test
+ public void userDoesntHaveAccessToAnyRegistrar_showsWhoAreYouPage() throws Exception {
+ when(sessionUtils.checkRegistrarConsoleLogin(any(HttpServletRequest.class))).thenReturn(false);
+ action.run();
+ assertThat(response.getPayload()).contains("You need permission
");
+ }
+}
diff --git a/javatests/com/google/domain/registry/ui/server/registrar/ConsoleUiServletTest.java b/javatests/com/google/domain/registry/ui/server/registrar/ConsoleUiServletTest.java
deleted file mode 100644
index 7a3e647af..000000000
--- a/javatests/com/google/domain/registry/ui/server/registrar/ConsoleUiServletTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.domain.registry.ui.server.registrar;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.when;
-
-import com.google.domain.registry.config.TestRegistryConfig;
-import com.google.domain.registry.testing.AppEngineRule;
-import com.google.domain.registry.testing.RegistryConfigRule;
-import com.google.domain.registry.testing.UserInfo;
-import com.google.domain.registry.ui.soy.registrar.ConsoleSoyInfo;
-import com.google.template.soy.data.SoyMapData;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/** Unit tests for {@link ConsoleUiServlet}. */
-@RunWith(MockitoJUnitRunner.class)
-public class ConsoleUiServletTest {
-
- @Rule
- public AppEngineRule appEngineRule = AppEngineRule.builder()
- .withUserService(UserInfo.create("foo@bar.com", "12345"))
- .build();
-
- @Rule
- public final RegistryConfigRule configRule = new RegistryConfigRule();
-
- @Mock
- HttpServletRequest req;
-
- @Mock
- HttpServletResponse rsp;
-
- final ConsoleUiServlet servlet = new ConsoleUiServlet();
-
- final StringWriter stringWriter = new StringWriter();
-
- @Before
- public void setUp() throws Exception {
- when(req.getMethod()).thenReturn("GET");
- when(rsp.getWriter()).thenReturn(new PrintWriter(stringWriter));
- when(req.getRequestURI()).thenReturn("/registrar");
- }
-
- @Test
- public void testTofuCompilation() throws Exception {
- ConsoleUiServlet.TOFU_SUPPLIER.get();
- }
-
- @Test
- public void testTofuRender() throws Exception {
- SoyMapData data = new SoyMapData();
- SoyMapData user = new SoyMapData();
- user.put("name", "lol");
- user.put("actionName", "lol");
- user.put("actionHref", "lol");
- data.put("user", user);
- ConsoleUiServlet.TOFU_SUPPLIER.get()
- .newRenderer(ConsoleSoyInfo.WHOAREYOU)
- .setCssRenamingMap(ConsoleUiServlet.CSS_RENAMING_MAP_SUPPLIER.get())
- .setData(data)
- .render();
- }
-
- @Test
- public void testGet_consoleDisabled() throws Exception {
- configRule.override(new TestRegistryConfig() {
- @Override
- public boolean isRegistrarConsoleEnabled() {
- return false;
- }});
- servlet.service(req, rsp);
- assertThat(stringWriter.toString()).contains("Console is disabled");
- }
-}