Tweak the registrar-ote-setup web console

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=227736173
This commit is contained in:
guyben 2019-01-03 13:05:21 -08:00 committed by Ben McIlwain
parent 338f7343ba
commit 2af24c945c
5 changed files with 71 additions and 19 deletions

View file

@ -54,6 +54,11 @@ tr.subsection h3::first-letter {
width: 170px;
}
.description ol {
list-style-type: decimal;
margin-left: 2em;
}
/* Setting groups and labels. */

View file

@ -98,6 +98,7 @@ public final class ConsoleOteSetupAction implements Runnable {
@Inject @Config("base64StringGenerator") StringGenerator passwordGenerator;
@Inject @Parameter("clientId") Optional<String> clientId;
@Inject @Parameter("email") Optional<String> email;
@Inject @Parameter("password") Optional<String> 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<String, String> clientIdToTld =
OteAccountBuilder.forClientId(clientId.get())
.addContact(email.get())

View file

@ -53,4 +53,10 @@ public final class RegistrarConsoleModule {
static String provideEmail(HttpServletRequest req) {
return extractRequiredParameter(req, "email");
}
@Provides
@Parameter("password")
static Optional<String> provideOptionalPassword(HttpServletRequest req) {
return extractOptionalParameter(req, "password");
}
}

View file

@ -76,9 +76,9 @@
<td class="{css('setting')}">
<textarea rows="7" cols="100" readonly>
{for $clientId in mapKeys($clientIdToTld)}
Login: {$clientId}{sp}
Password: {$password}{sp}
Tld: {$clientIdToTld[$clientId]}{\n}
Login: {$clientId}{sp}{sp}{sp}{sp}{sp}{sp}
Password: {$password}{sp}{sp}{sp}{sp}{sp}{sp}
TLD: {$clientIdToTld[$clientId]}{sp}{sp}{sp}{sp}{sp}{sp}{\n}
{/for}
</textarea>
</td>
@ -102,22 +102,34 @@
{@param? contactEmail: string} /** If set - an initial value to fill for the email. */
<form name="item" class="{css('item')}" method="post" action="/registrar-ote-setup">
<table>
{call registry.soy.forms.inputFieldRowWithValue}
{param label: 'Base clientId' /}
<tr class="{css('kd-settings-pane-section')}">
<td>
{call registry.soy.forms.inputFieldLabel}
{param label: 'Base client ID' /}
{/call}
</td>
<td class="{css('setting')}">
{call registry.soy.forms.inputFieldValue }
{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}
<span class="{css('description')}">
Must:
<ol type="1">
<li>consist of only lowercase letters, numbers, or hyphens,</li>
<li>start with a letter, and</li>
<li>be between 3 and 14 characters (inclusive).</li>
</ol>
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.
</span>
</td>
</tr>
{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}

View file

@ -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("<h1>OT&E successfully created for registrar myclientid!</h1>");
assertThat(response.getPayload())
.contains("SomePassword");
}
@Test
public void testPost_unauthorized() {
action.registrarAccessor =