mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 10:46:10 +02:00
Fix registrar security console
The registrar security console failed because it assumed the email is a required field for the registrar, but it isn't (at least - create_registrar doesn't require an email, and update_registrar lets you remove the email). Fixed by allowing it to *remain* unset if it was unset originally, but if it was set - it's required. There are more fixes needed, but they aren't related to the email, so they will wait for the next CL ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=191623034
This commit is contained in:
parent
e816913c61
commit
ea891001d9
7 changed files with 44 additions and 14 deletions
|
@ -88,6 +88,8 @@ public final class RegistryTestServer {
|
|||
route("/registrar", google.registry.module.frontend.FrontendServlet.class),
|
||||
route("/registrar-settings",
|
||||
google.registry.module.frontend.FrontendServlet.class),
|
||||
route("/registrar-premium-price-ack",
|
||||
google.registry.module.frontend.FrontendServlet.class),
|
||||
route("/registrar-payment",
|
||||
google.registry.module.frontend.FrontendServlet.class),
|
||||
route("/registrar-payment-setup",
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.ui.server.registrar;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued;
|
||||
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
||||
|
@ -98,6 +99,16 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
|
|||
assertNoTasksEnqueued("sheet");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate_emptyJsonObject_emailFieldNotRequiredWhenEmpty() throws Exception {
|
||||
persistResource(loadRegistrar(CLIENT_ID).asBuilder().setEmailAddress(null).build());
|
||||
|
||||
Map<String, Object> response = action.handleJsonRequest(ImmutableMap.of(
|
||||
"op", "update",
|
||||
"args", ImmutableMap.of()));
|
||||
assertThat(response).containsEntry("status", "SUCCESS");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate_badEmail_errorEmailField() throws Exception {
|
||||
Map<String, Object> response = action.handleJsonRequest(ImmutableMap.of(
|
||||
|
|
|
@ -106,8 +106,12 @@ public class RegistrarSettingsActionTestCase {
|
|||
when(rsp.getWriter()).thenReturn(new PrintWriter(writer));
|
||||
when(req.getContentType()).thenReturn("application/json");
|
||||
when(req.getReader()).thenReturn(createJsonPayload(ImmutableMap.of("op", "read")));
|
||||
// We mock getRegistrarForAuthResult to reload the registrar each time it's called. Otherwise -
|
||||
// the result is out of date after mutations.
|
||||
// (for example, if someone wants to change the registrar to prepare for a test, the function
|
||||
// would still return the old value)
|
||||
when(sessionUtils.getRegistrarForAuthResult(req, action.authResult))
|
||||
.thenReturn(loadRegistrar(CLIENT_ID));
|
||||
.thenAnswer(x -> loadRegistrar(CLIENT_ID));
|
||||
when(modulesService.getVersionHostname("backend", null)).thenReturn("backend.hostname");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue