From 2af24c945cc07d018cbe87780adb5c0f0f40d991 Mon Sep 17 00:00:00 2001 From: guyben Date: Thu, 3 Jan 2019 13:05:21 -0800 Subject: [PATCH] Tweak the registrar-ote-setup web console ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=227736173 --- java/google/registry/ui/css/forms.css | 5 ++ .../otesetup/ConsoleOteSetupAction.java | 3 +- .../registrar/RegistrarConsoleModule.java | 6 ++ .../registry/ui/soy/otesetup/Console.soy | 57 +++++++++++++------ .../otesetup/ConsoleOteSetupActionTest.java | 19 +++++++ 5 files changed, 71 insertions(+), 19 deletions(-) diff --git a/java/google/registry/ui/css/forms.css b/java/google/registry/ui/css/forms.css index f1844a4fa..29c5ca559 100644 --- a/java/google/registry/ui/css/forms.css +++ b/java/google/registry/ui/css/forms.css @@ -54,6 +54,11 @@ tr.subsection h3::first-letter { width: 170px; } +.description ol { + list-style-type: decimal; + margin-left: 2em; +} + /* Setting groups and labels. */ diff --git a/java/google/registry/ui/server/otesetup/ConsoleOteSetupAction.java b/java/google/registry/ui/server/otesetup/ConsoleOteSetupAction.java index 6b9ada0a5..6af97abf8 100644 --- a/java/google/registry/ui/server/otesetup/ConsoleOteSetupAction.java +++ b/java/google/registry/ui/server/otesetup/ConsoleOteSetupAction.java @@ -98,6 +98,7 @@ public final class ConsoleOteSetupAction implements Runnable { @Inject @Config("base64StringGenerator") StringGenerator passwordGenerator; @Inject @Parameter("clientId") Optional clientId; @Inject @Parameter("email") Optional email; + @Inject @Parameter("password") Optional optionalPassword; @Inject ConsoleOteSetupAction() {} @@ -170,7 +171,7 @@ public final class ConsoleOteSetupAction implements Runnable { data.put("contactEmail", email.get()); try { - String password = passwordGenerator.createString(PASSWORD_LENGTH); + String password = optionalPassword.orElse(passwordGenerator.createString(PASSWORD_LENGTH)); ImmutableMap clientIdToTld = OteAccountBuilder.forClientId(clientId.get()) .addContact(email.get()) diff --git a/java/google/registry/ui/server/registrar/RegistrarConsoleModule.java b/java/google/registry/ui/server/registrar/RegistrarConsoleModule.java index d14e89b8b..f4b7d55b1 100644 --- a/java/google/registry/ui/server/registrar/RegistrarConsoleModule.java +++ b/java/google/registry/ui/server/registrar/RegistrarConsoleModule.java @@ -53,4 +53,10 @@ public final class RegistrarConsoleModule { static String provideEmail(HttpServletRequest req) { return extractRequiredParameter(req, "email"); } + + @Provides + @Parameter("password") + static Optional provideOptionalPassword(HttpServletRequest req) { + return extractOptionalParameter(req, "password"); + } } diff --git a/java/google/registry/ui/soy/otesetup/Console.soy b/java/google/registry/ui/soy/otesetup/Console.soy index e96adf4a1..10a477e6d 100644 --- a/java/google/registry/ui/soy/otesetup/Console.soy +++ b/java/google/registry/ui/soy/otesetup/Console.soy @@ -76,9 +76,9 @@ @@ -102,22 +102,34 @@ {@param? contactEmail: string} /** If set - an initial value to fill for the email. */
+ + + + {call registry.soy.forms.inputFieldRowWithValue} - {param label: 'Base clientId' /} - {param name: 'clientId' /} - {param value: $baseClientId /} - {param placeholder: 'registrar\'s ID' /} - {param description kind="text"} - must 1) consist of only lowercase letters, numbers, or hyphens, - 2) start with a letter, and 3) be between 3 and 14 characters (inclusive). - We require 1 and 2 since the registrar name will be used to create TLDs, - and we require 3 since we append \"-[1234]\" to the name to create client - IDs which are required by the EPP XML schema to be between 3-16 chars. - {/param} - {param readonly: false /} - {/call} - {call registry.soy.forms.inputFieldRowWithValue} - {param label: 'contact email' /} + {param label: 'Contact email' /} {param name: 'email' /} {param value: $contactEmail /} {param placeholder: 'registrar\'s assigned email' /} @@ -126,6 +138,15 @@ {/param} {param readonly: false /} {/call} + {call registry.soy.forms.inputFieldRowWithValue} + {param label: 'Password (optional)' /} + {param name: 'password' /} + {param placeholder: 'Optional password' /} + {param description kind="text"} + The password used to for EPP login. Leave blank to auto-generate a password. + {/param} + {param readonly: false /} + {/call} {call registry.soy.forms.submitRow} {param label: 'create' /} {/call} diff --git a/javatests/google/registry/ui/server/otesetup/ConsoleOteSetupActionTest.java b/javatests/google/registry/ui/server/otesetup/ConsoleOteSetupActionTest.java index 79e0f79d2..da34d9d0e 100644 --- a/javatests/google/registry/ui/server/otesetup/ConsoleOteSetupActionTest.java +++ b/javatests/google/registry/ui/server/otesetup/ConsoleOteSetupActionTest.java @@ -97,6 +97,7 @@ public final class ConsoleOteSetupActionTest { action.productName = "Nomulus"; action.clientId = Optional.empty(); action.email = Optional.empty(); + action.optionalPassword = Optional.empty(); action.passwordGenerator = new DeterministicStringGenerator("abcdefghijklmnopqrstuvwxyz"); message = new MimeMessage(Session.getDefaultInstance(new Properties(), null)); @@ -160,6 +161,24 @@ public final class ConsoleOteSetupActionTest { + "Gave user contact@registry.example web access to these Registrars\n"); } + @Test + public void testPost_authorized_setPassword() throws Exception { + action.clientId = Optional.of("myclientid"); + action.email = Optional.of("contact@registry.example"); + action.optionalPassword = Optional.of("SomePassword"); + action.method = Method.POST; + action.run(); + + // We just check some samples to make sure OteAccountBuilder was called successfully. We aren't + // checking that all the entities are there or that they have the correct values. + assertThat(loadByClientId("myclientid-4").get().testPassword("SomePassword")) + .isTrue(); + assertThat(response.getPayload()) + .contains("

OT&E successfully created for registrar myclientid!

"); + assertThat(response.getPayload()) + .contains("SomePassword"); + } + @Test public void testPost_unauthorized() { action.registrarAccessor =
+ {call registry.soy.forms.inputFieldLabel} + {param label: 'Base client ID' /} + {/call} + + {call registry.soy.forms.inputFieldValue } + {param name: 'clientId' /} + {param value: $baseClientId /} + {param placeholder: 'registrar\'s ID' /} + {param readonly: false /} + {/call} + + Must: +
    +
  1. consist of only lowercase letters, numbers, or hyphens,
  2. +
  3. start with a letter, and
  4. +
  5. be between 3 and 14 characters (inclusive).
  6. +
+ We require 1 and 2 since the registrar name will be used to create TLDs, and we + require 3 since we append "-[12345]" to the name to create client IDs which are + required by the EPP XML schema to be between 3-16 chars. +
+