mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 16:37:13 +02:00
Add web console for creating registrars
This console is only to be used by Admins (either GAE admins for this project, or Support accounts). It is for "internal" use only, not for use by the registrars themselves. To prevent abuse, the registrar is created in a non-functional PENDING state and can only be made functional from the nomulus shell tool. While in "PENDING" state, the registrar can be updated from the registrar-console by admins. Also - moving all the web consoles to the same directory (moving the otesetup/* files into registrar/) ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=229681011
This commit is contained in:
parent
758dcb5c39
commit
9aa7b69921
20 changed files with 1277 additions and 138 deletions
|
@ -341,12 +341,6 @@ task soyToJava {
|
|||
dir: "${javaDir}/google/registry/ui/soy/registrar",
|
||||
include: ['**/*.soy']))
|
||||
|
||||
soyToJava('google.registry.ui.soy.otesetup',
|
||||
"${generatedDir}/google/registry/ui/soy/otesetup",
|
||||
fileTree(
|
||||
dir: "${javaDir}/google/registry/ui/soy/otesetup",
|
||||
include: ['**/*.soy']))
|
||||
|
||||
soyToJava('google.registry.ui.soy',
|
||||
"${generatedDir}/google/registry/ui/soy",
|
||||
files {
|
||||
|
|
|
@ -1381,6 +1381,14 @@ public final class RegistryConfig {
|
|||
}
|
||||
}
|
||||
|
||||
/** Returns a singleton random string generator that uses digits only. */
|
||||
@Singleton
|
||||
@Provides
|
||||
@Config("digitOnlyStringGenerator")
|
||||
public static StringGenerator provideDigitsOnlyStringGenerator(SecureRandom secureRandom) {
|
||||
return new RandomStringGenerator(StringGenerator.Alphabets.DIGITS_ONLY, secureRandom);
|
||||
}
|
||||
|
||||
/** Returns a singleton random string generator using Base58 encoding. */
|
||||
@Singleton
|
||||
@Provides
|
||||
|
|
|
@ -43,6 +43,12 @@
|
|||
<url-pattern>/registrar-ote-setup</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Registrar creation console. -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>frontend-servlet</servlet-name>
|
||||
<url-pattern>/registrar-create</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Security config -->
|
||||
<security-constraint>
|
||||
<web-resource-collection>
|
||||
|
|
|
@ -21,7 +21,6 @@ java_library(
|
|||
"//java/google/registry/request:modules",
|
||||
"//java/google/registry/request/auth",
|
||||
"//java/google/registry/ui",
|
||||
"//java/google/registry/ui/server/otesetup",
|
||||
"//java/google/registry/ui/server/registrar",
|
||||
"//java/google/registry/util",
|
||||
"@com_google_appengine_api_1_0_sdk",
|
||||
|
|
|
@ -25,7 +25,8 @@ import google.registry.monitoring.whitebox.WhiteboxModule;
|
|||
import google.registry.request.RequestComponentBuilder;
|
||||
import google.registry.request.RequestModule;
|
||||
import google.registry.request.RequestScope;
|
||||
import google.registry.ui.server.otesetup.ConsoleOteSetupAction;
|
||||
import google.registry.ui.server.registrar.ConsoleOteSetupAction;
|
||||
import google.registry.ui.server.registrar.ConsoleRegistrarCreatorAction;
|
||||
import google.registry.ui.server.registrar.ConsoleUiAction;
|
||||
import google.registry.ui.server.registrar.OteStatusAction;
|
||||
import google.registry.ui.server.registrar.RegistrarConsoleModule;
|
||||
|
@ -43,6 +44,7 @@ import google.registry.ui.server.registrar.RegistrarSettingsAction;
|
|||
})
|
||||
interface FrontendRequestComponent {
|
||||
ConsoleOteSetupAction consoleOteSetupAction();
|
||||
ConsoleRegistrarCreatorAction consoleRegistrarCreatorAction();
|
||||
ConsoleUiAction consoleUiAction();
|
||||
EppConsoleAction eppConsoleAction();
|
||||
EppTlsAction eppTlsAction();
|
||||
|
|
|
@ -329,7 +329,8 @@ public class AuthenticatedRegistrarAccessor {
|
|||
.load()
|
||||
.type(Registrar.class)
|
||||
.forEach(registrar -> {
|
||||
if (!Registrar.Type.REAL.equals(registrar.getType())) {
|
||||
if (registrar.getType() != Registrar.Type.REAL
|
||||
|| registrar.getState() == Registrar.State.PENDING) {
|
||||
builder.put(registrar.getClientId(), Role.OWNER);
|
||||
}
|
||||
builder.put(registrar.getClientId(), Role.ADMIN);
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
licenses(["notice"]) # Apache 2.0
|
||||
|
||||
java_library(
|
||||
name = "otesetup",
|
||||
srcs = glob(["*.java"]),
|
||||
resources = [
|
||||
"//java/google/registry/ui/css:registrar_bin.css.js",
|
||||
"//java/google/registry/ui/css:registrar_dbg.css.js",
|
||||
],
|
||||
deps = [
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/export/sheet",
|
||||
"//java/google/registry/flows",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/request",
|
||||
"//java/google/registry/request/auth",
|
||||
"//java/google/registry/security",
|
||||
"//java/google/registry/ui/forms",
|
||||
"//java/google/registry/ui/server",
|
||||
"//java/google/registry/ui/soy:soy_java_wrappers",
|
||||
"//java/google/registry/ui/soy/otesetup:soy_java_wrappers",
|
||||
"//java/google/registry/util",
|
||||
"//third_party/objectify:objectify-v4_1",
|
||||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_auto_value",
|
||||
"@com_google_code_findbugs_jsr305",
|
||||
"@com_google_dagger",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_monitoring_client_metrics",
|
||||
"@com_google_re2j",
|
||||
"@io_bazel_rules_closure//closure/templates",
|
||||
"@javax_inject",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
"@org_joda_money",
|
||||
],
|
||||
)
|
|
@ -12,7 +12,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.ui.server.otesetup;
|
||||
package google.registry.ui.server.registrar;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.net.HttpHeaders.LOCATION;
|
||||
import static com.google.common.net.HttpHeaders.X_FRAME_OPTIONS;
|
||||
|
@ -44,7 +45,7 @@ import google.registry.request.auth.AuthenticatedRegistrarAccessor;
|
|||
import google.registry.security.XsrfTokenManager;
|
||||
import google.registry.ui.server.SendEmailUtils;
|
||||
import google.registry.ui.server.SoyTemplateUtils;
|
||||
import google.registry.ui.soy.otesetup.ConsoleSoyInfo;
|
||||
import google.registry.ui.soy.registrar.OteSetupConsoleSoyInfo;
|
||||
import google.registry.util.StringGenerator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
|
@ -77,7 +78,7 @@ public final class ConsoleOteSetupAction implements Runnable {
|
|||
SoyTemplateUtils.createTofuSupplier(
|
||||
google.registry.ui.soy.ConsoleSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.FormsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.otesetup.ConsoleSoyInfo.getInstance());
|
||||
google.registry.ui.soy.registrar.OteSetupConsoleSoyInfo.getInstance());
|
||||
|
||||
@VisibleForTesting // webdriver and screenshot tests need this
|
||||
public static final Supplier<SoyCssRenamingMap> CSS_RENAMING_MAP_SUPPLIER =
|
||||
|
@ -145,7 +146,7 @@ public final class ConsoleOteSetupAction implements Runnable {
|
|||
response.setPayload(
|
||||
TOFU_SUPPLIER
|
||||
.get()
|
||||
.newRenderer(ConsoleSoyInfo.WHOAREYOU)
|
||||
.newRenderer(OteSetupConsoleSoyInfo.WHOAREYOU)
|
||||
.setCssRenamingMap(CSS_RENAMING_MAP_SUPPLIER.get())
|
||||
.setData(data)
|
||||
.render());
|
||||
|
@ -185,7 +186,7 @@ public final class ConsoleOteSetupAction implements Runnable {
|
|||
response.setPayload(
|
||||
TOFU_SUPPLIER
|
||||
.get()
|
||||
.newRenderer(ConsoleSoyInfo.RESULT_SUCCESS)
|
||||
.newRenderer(OteSetupConsoleSoyInfo.RESULT_SUCCESS)
|
||||
.setCssRenamingMap(CSS_RENAMING_MAP_SUPPLIER.get())
|
||||
.setData(data)
|
||||
.render());
|
||||
|
@ -196,7 +197,7 @@ public final class ConsoleOteSetupAction implements Runnable {
|
|||
response.setPayload(
|
||||
TOFU_SUPPLIER
|
||||
.get()
|
||||
.newRenderer(ConsoleSoyInfo.FORM_PAGE)
|
||||
.newRenderer(OteSetupConsoleSoyInfo.FORM_PAGE)
|
||||
.setCssRenamingMap(CSS_RENAMING_MAP_SUPPLIER.get())
|
||||
.setData(data)
|
||||
.render());
|
||||
|
@ -211,7 +212,7 @@ public final class ConsoleOteSetupAction implements Runnable {
|
|||
response.setPayload(
|
||||
TOFU_SUPPLIER
|
||||
.get()
|
||||
.newRenderer(ConsoleSoyInfo.FORM_PAGE)
|
||||
.newRenderer(OteSetupConsoleSoyInfo.FORM_PAGE)
|
||||
.setCssRenamingMap(CSS_RENAMING_MAP_SUPPLIER.get())
|
||||
.setData(data)
|
||||
.render());
|
|
@ -0,0 +1,369 @@
|
|||
// Copyright 2018 The Nomulus Authors. 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 google.registry.ui.server.registrar;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||
import static com.google.common.net.HttpHeaders.LOCATION;
|
||||
import static com.google.common.net.HttpHeaders.X_FRAME_OPTIONS;
|
||||
import static google.registry.model.common.GaeUserIdConverter.convertEmailAddressToGaeUserId;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_MOVED_TEMPORARILY;
|
||||
|
||||
import com.google.appengine.api.users.User;
|
||||
import com.google.appengine.api.users.UserService;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.Resources;
|
||||
import com.google.common.net.MediaType;
|
||||
import com.google.template.soy.shared.SoyCssRenamingMap;
|
||||
import com.google.template.soy.tofu.SoyTofu;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarAddress;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.Action.Method;
|
||||
import google.registry.request.Parameter;
|
||||
import google.registry.request.RequestMethod;
|
||||
import google.registry.request.Response;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.request.auth.AuthResult;
|
||||
import google.registry.request.auth.AuthenticatedRegistrarAccessor;
|
||||
import google.registry.security.XsrfTokenManager;
|
||||
import google.registry.ui.server.SendEmailUtils;
|
||||
import google.registry.ui.server.SoyTemplateUtils;
|
||||
import google.registry.ui.soy.registrar.RegistrarCreateConsoleSoyInfo;
|
||||
import google.registry.util.StringGenerator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
import javax.inject.Inject;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
|
||||
/**
|
||||
* Action that serves Registrar creation page.
|
||||
*
|
||||
* <p>This Action does 2 things: - for GET, just returns the form that asks for the required
|
||||
* information. - for POST, receives the information and creates the Registrar.
|
||||
*
|
||||
* <p>TODO(b/120201577): once we can have 2 different Actions with the same path (different
|
||||
* Methods), separate this class to 2 Actions.
|
||||
*/
|
||||
@Action(
|
||||
service = Action.Service.DEFAULT,
|
||||
path = ConsoleRegistrarCreatorAction.PATH,
|
||||
method = {Method.POST, Method.GET},
|
||||
auth = Auth.AUTH_PUBLIC)
|
||||
public final class ConsoleRegistrarCreatorAction implements Runnable {
|
||||
|
||||
private static final int PASSWORD_LENGTH = 16;
|
||||
private static final int PASSCODE_LENGTH = 5;
|
||||
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public static final String PATH = "/registrar-create";
|
||||
|
||||
private static final Supplier<SoyTofu> TOFU_SUPPLIER =
|
||||
SoyTemplateUtils.createTofuSupplier(
|
||||
google.registry.ui.soy.ConsoleSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.FormsSoyInfo.getInstance(),
|
||||
google.registry.ui.soy.registrar.RegistrarCreateConsoleSoyInfo.getInstance());
|
||||
|
||||
@VisibleForTesting // webdriver and screenshot tests need this
|
||||
public static final Supplier<SoyCssRenamingMap> CSS_RENAMING_MAP_SUPPLIER =
|
||||
SoyTemplateUtils.createCssRenamingMapSupplier(
|
||||
Resources.getResource("google/registry/ui/css/registrar_bin.css.js"),
|
||||
Resources.getResource("google/registry/ui/css/registrar_dbg.css.js"));
|
||||
|
||||
@Inject HttpServletRequest req;
|
||||
@Inject @RequestMethod Method method;
|
||||
@Inject Response response;
|
||||
@Inject AuthenticatedRegistrarAccessor registrarAccessor;
|
||||
@Inject UserService userService;
|
||||
@Inject XsrfTokenManager xsrfTokenManager;
|
||||
@Inject AuthResult authResult;
|
||||
@Inject RegistryEnvironment registryEnvironment;
|
||||
@Inject SendEmailUtils sendEmailUtils;
|
||||
@Inject @Config("logoFilename") String logoFilename;
|
||||
@Inject @Config("productName") String productName;
|
||||
@Inject @Config("base58StringGenerator") StringGenerator passwordGenerator;
|
||||
@Inject @Config("digitOnlyStringGenerator") StringGenerator passcodeGenerator;
|
||||
@Inject @Parameter("clientId") Optional<String> clientId;
|
||||
@Inject @Parameter("name") Optional<String> name;
|
||||
@Inject @Parameter("billingAccount") Optional<String> billingAccount;
|
||||
@Inject @Parameter("ianaId") Optional<Integer> ianaId;
|
||||
@Inject @Parameter("referralEmail") Optional<String> referralEmail;
|
||||
@Inject @Parameter("driveId") Optional<String> driveId;
|
||||
@Inject @Parameter("email") Optional<String> email;
|
||||
|
||||
// Address fields, some of which are required and others are optional.
|
||||
@Inject @Parameter("street1") Optional<String> street1;
|
||||
@Inject @Parameter("street2") Optional<String> optionalStreet2;
|
||||
@Inject @Parameter("street3") Optional<String> optionalStreet3;
|
||||
@Inject @Parameter("city") Optional<String> city;
|
||||
@Inject @Parameter("state") Optional<String> optionalState;
|
||||
@Inject @Parameter("zip") Optional<String> optionalZip;
|
||||
@Inject @Parameter("countryCode") Optional<String> countryCode;
|
||||
|
||||
@Inject @Parameter("password") Optional<String> optionalPassword;
|
||||
@Inject @Parameter("passcode") Optional<String> optionalPasscode;
|
||||
|
||||
@Inject ConsoleRegistrarCreatorAction() {}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
response.setHeader(X_FRAME_OPTIONS, "SAMEORIGIN"); // Disallow iframing.
|
||||
response.setHeader("X-Ui-Compatible", "IE=edge"); // Ask IE not to be silly.
|
||||
|
||||
logger.atInfo().log(
|
||||
"User %s is accessing the Registrar creation page. Method= %s",
|
||||
registrarAccessor.userIdForLogging(), method);
|
||||
if (!authResult.userAuthInfo().isPresent()) {
|
||||
response.setStatus(SC_MOVED_TEMPORARILY);
|
||||
String location;
|
||||
try {
|
||||
location = userService.createLoginURL(req.getRequestURI());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// UserServiceImpl.createLoginURL() throws IllegalArgumentException if underlying API call
|
||||
// returns an error code of NOT_ALLOWED. createLoginURL() assumes that the error is caused
|
||||
// by an invalid URL. But in fact, the error can also occur if UserService doesn't have any
|
||||
// user information, which happens when the request has been authenticated as internal. In
|
||||
// this case, we want to avoid dying before we can send the redirect, so just redirect to
|
||||
// the root path.
|
||||
location = "/";
|
||||
}
|
||||
response.setHeader(LOCATION, location);
|
||||
return;
|
||||
}
|
||||
User user = authResult.userAuthInfo().get().user();
|
||||
|
||||
// Using HashMap to allow null values
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("logoFilename", logoFilename);
|
||||
data.put("productName", productName);
|
||||
data.put("username", user.getNickname());
|
||||
data.put("logoutUrl", userService.createLogoutURL(PATH));
|
||||
data.put("xsrfToken", xsrfTokenManager.generateToken(user.getEmail()));
|
||||
response.setContentType(MediaType.HTML_UTF_8);
|
||||
|
||||
if (!registrarAccessor.isAdmin()) {
|
||||
response.setStatus(SC_FORBIDDEN);
|
||||
response.setPayload(
|
||||
TOFU_SUPPLIER
|
||||
.get()
|
||||
.newRenderer(RegistrarCreateConsoleSoyInfo.WHOAREYOU)
|
||||
.setCssRenamingMap(CSS_RENAMING_MAP_SUPPLIER.get())
|
||||
.setData(data)
|
||||
.render());
|
||||
return;
|
||||
}
|
||||
switch (method) {
|
||||
case POST:
|
||||
runPost(data);
|
||||
return;
|
||||
case GET:
|
||||
runGet(data);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPresent(Optional<?> value, String name) {
|
||||
checkState(value.isPresent(), "Missing value for %s", name);
|
||||
}
|
||||
|
||||
private static final Splitter LINE_SPLITTER =
|
||||
Splitter.onPattern("\r?\n").trimResults().omitEmptyStrings();
|
||||
|
||||
private static final Splitter ENTRY_SPLITTER =
|
||||
Splitter.on('=').trimResults().omitEmptyStrings().limit(2);
|
||||
|
||||
private static ImmutableMap<CurrencyUnit, String> parseBillingAccount(String billingAccount) {
|
||||
try {
|
||||
return LINE_SPLITTER.splitToList(billingAccount).stream()
|
||||
.map(ENTRY_SPLITTER::splitToList)
|
||||
.peek(
|
||||
list ->
|
||||
checkState(
|
||||
list.size() == 2,
|
||||
"Can't parse line %s. The format should be [currency]=[account ID]",
|
||||
list))
|
||||
.collect(
|
||||
toImmutableMap(
|
||||
list -> CurrencyUnit.of(Ascii.toUpperCase(list.get(0))), list -> list.get(1)));
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Error parsing billing accounts - " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void runPost(HashMap<String, Object> data) {
|
||||
try {
|
||||
|
||||
checkPresent(clientId, "clientId");
|
||||
checkPresent(name, "name");
|
||||
checkPresent(billingAccount, "billingAccount");
|
||||
checkPresent(ianaId, "ianaId");
|
||||
checkPresent(referralEmail, "referralEmail");
|
||||
checkPresent(driveId, "driveId");
|
||||
checkPresent(email, "email");
|
||||
checkPresent(street1, "street");
|
||||
checkPresent(city, "city");
|
||||
checkPresent(countryCode, "countryCode");
|
||||
|
||||
data.put("clientId", clientId.get());
|
||||
data.put("name", name.get());
|
||||
data.put("ianaId", ianaId.get());
|
||||
data.put("referralEmail", referralEmail.get());
|
||||
data.put("billingAccount", billingAccount.get());
|
||||
data.put("driveId", driveId.get());
|
||||
data.put("email", email.get());
|
||||
|
||||
data.put("street1", street1.get());
|
||||
optionalStreet2.ifPresent(street2 -> data.put("street2", street2));
|
||||
optionalStreet3.ifPresent(street3 -> data.put("street3", street3));
|
||||
data.put("city", city.get());
|
||||
optionalState.ifPresent(state -> data.put("state", state));
|
||||
optionalZip.ifPresent(zip -> data.put("zip", zip));
|
||||
data.put("countryCode", countryCode.get());
|
||||
|
||||
String gaeUserId =
|
||||
checkNotNull(
|
||||
convertEmailAddressToGaeUserId(email.get()),
|
||||
"Email address %s is not associated with any GAE ID",
|
||||
email.get());
|
||||
String password = optionalPassword.orElse(passwordGenerator.createString(PASSWORD_LENGTH));
|
||||
String phonePasscode =
|
||||
optionalPasscode.orElse(passcodeGenerator.createString(PASSCODE_LENGTH));
|
||||
Registrar registrar =
|
||||
new Registrar.Builder()
|
||||
.setClientId(clientId.get())
|
||||
.setRegistrarName(name.get())
|
||||
.setBillingAccountMap(parseBillingAccount(billingAccount.get()))
|
||||
.setIanaIdentifier(Long.valueOf(ianaId.get()))
|
||||
.setIcannReferralEmail(referralEmail.get())
|
||||
.setDriveFolderId(driveId.get())
|
||||
.setType(Registrar.Type.REAL)
|
||||
.setPassword(password)
|
||||
.setPhonePasscode(phonePasscode)
|
||||
.setState(Registrar.State.PENDING)
|
||||
.setLocalizedAddress(
|
||||
new RegistrarAddress.Builder()
|
||||
.setStreet(
|
||||
Stream.of(street1, optionalStreet2, optionalStreet3)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.collect(toImmutableList()))
|
||||
.setCity(city.get())
|
||||
.setState(optionalState.orElse(null))
|
||||
.setCountryCode(countryCode.get())
|
||||
.setZip(optionalZip.orElse(null))
|
||||
.build())
|
||||
.build();
|
||||
RegistrarContact contact =
|
||||
new RegistrarContact.Builder()
|
||||
.setParent(registrar)
|
||||
.setName(email.get())
|
||||
.setEmailAddress(email.get())
|
||||
.setGaeUserId(gaeUserId)
|
||||
.build();
|
||||
ofy()
|
||||
.transact(
|
||||
() -> {
|
||||
checkState(
|
||||
!Registrar.loadByClientId(registrar.getClientId()).isPresent(),
|
||||
"Registrar with client ID %s already exists",
|
||||
registrar.getClientId());
|
||||
ofy().save().entities(registrar, contact);
|
||||
});
|
||||
data.put("password", password);
|
||||
data.put("passcode", phonePasscode);
|
||||
|
||||
sendExternalUpdates();
|
||||
response.setPayload(
|
||||
TOFU_SUPPLIER
|
||||
.get()
|
||||
.newRenderer(RegistrarCreateConsoleSoyInfo.RESULT_SUCCESS)
|
||||
.setCssRenamingMap(CSS_RENAMING_MAP_SUPPLIER.get())
|
||||
.setData(data)
|
||||
.render());
|
||||
} catch (Throwable e) {
|
||||
logger.atWarning().withCause(e).log(
|
||||
"Failed to create registrar. clientId: %s, data: %s", clientId.get(), data);
|
||||
data.put("errorMessage", e.getMessage());
|
||||
response.setPayload(
|
||||
TOFU_SUPPLIER
|
||||
.get()
|
||||
.newRenderer(RegistrarCreateConsoleSoyInfo.FORM_PAGE)
|
||||
.setCssRenamingMap(CSS_RENAMING_MAP_SUPPLIER.get())
|
||||
.setData(data)
|
||||
.render());
|
||||
}
|
||||
}
|
||||
|
||||
private void runGet(HashMap<String, Object> data) {
|
||||
// set the values to pre-fill, if given
|
||||
data.put("clientId", clientId.orElse(null));
|
||||
data.put("name", name.orElse(null));
|
||||
data.put("ianaId", ianaId.orElse(null));
|
||||
data.put("referralEmail", referralEmail.orElse(null));
|
||||
data.put("driveId", driveId.orElse(null));
|
||||
data.put("email", email.orElse(null));
|
||||
|
||||
response.setPayload(
|
||||
TOFU_SUPPLIER
|
||||
.get()
|
||||
.newRenderer(RegistrarCreateConsoleSoyInfo.FORM_PAGE)
|
||||
.setCssRenamingMap(CSS_RENAMING_MAP_SUPPLIER.get())
|
||||
.setData(data)
|
||||
.render());
|
||||
}
|
||||
|
||||
private String toEmailLine(Optional<?> value, String name) {
|
||||
return String.format(" %s: %s\n", name, value.orElse(null));
|
||||
}
|
||||
private void sendExternalUpdates() {
|
||||
if (!sendEmailUtils.hasRecepients()) {
|
||||
return;
|
||||
}
|
||||
String environment = Ascii.toLowerCase(String.valueOf(registryEnvironment));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder
|
||||
.append(
|
||||
String.format(
|
||||
"The following registrar was created in %s by %s:\n",
|
||||
environment, registrarAccessor.userIdForLogging()))
|
||||
.append(toEmailLine(clientId, "clientId"))
|
||||
.append(toEmailLine(name, "name"))
|
||||
.append(toEmailLine(billingAccount, "billingAccount"))
|
||||
.append(toEmailLine(ianaId, "ianaId"))
|
||||
.append(toEmailLine(referralEmail, "referralEmail"))
|
||||
.append(toEmailLine(driveId, "driveId"))
|
||||
.append(String.format("Gave user %s web access to the registrar\n", email.get()));
|
||||
sendEmailUtils.sendEmail(
|
||||
String.format("Registrar %s created in %s", clientId.get(), environment),
|
||||
builder.toString());
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.ui.server.registrar;
|
||||
|
||||
|
||||
import static google.registry.request.RequestParameters.extractOptionalIntParameter;
|
||||
import static google.registry.request.RequestParameters.extractOptionalParameter;
|
||||
import static google.registry.request.RequestParameters.extractRequiredParameter;
|
||||
|
||||
|
@ -42,6 +43,36 @@ public final class RegistrarConsoleModule {
|
|||
return extractRequiredParameter(req, PARAM_CLIENT_ID);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("ianaId")
|
||||
static Optional<Integer> provideOptionalIanaId(HttpServletRequest req) {
|
||||
return extractOptionalIntParameter(req, "ianaId");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("billingAccount")
|
||||
static Optional<String> provideOptionalBillingAccount(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "billingAccount");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("name")
|
||||
static Optional<String> provideOptionalName(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "name");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("driveId")
|
||||
static Optional<String> provideOptionalDriveId(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "driveId");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("referralEmail")
|
||||
static Optional<String> provideOptionalReferralEmail(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "referralEmail");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("email")
|
||||
static Optional<String> provideOptionalEmail(HttpServletRequest req) {
|
||||
|
@ -54,9 +85,57 @@ public final class RegistrarConsoleModule {
|
|||
return extractRequiredParameter(req, "email");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("street1")
|
||||
static Optional<String> provideOptionalStreet1(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "street1");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("street2")
|
||||
static Optional<String> provideOptionalStreet2(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "street2");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("street3")
|
||||
static Optional<String> provideOptionalStreet3(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "street3");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("city")
|
||||
static Optional<String> provideOptionalCity(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "city");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("state")
|
||||
static Optional<String> provideOptionalState(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "state");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("zip")
|
||||
static Optional<String> provideOptionalZip(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "zip");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("countryCode")
|
||||
static Optional<String> provideOptionalCountryCode(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "countryCode");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("password")
|
||||
static Optional<String> provideOptionalPassword(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "password");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Parameter("passcode")
|
||||
static Optional<String> provideOptionalPasscode(HttpServletRequest req) {
|
||||
return extractOptionalParameter(req, "passcode");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package(
|
||||
default_visibility = ["//java/google/registry:registry_project"],
|
||||
)
|
||||
|
||||
licenses(["notice"]) # Apache 2.0
|
||||
|
||||
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_java_template_library", "closure_js_template_library")
|
||||
|
||||
closure_js_template_library(
|
||||
name = "otesetup",
|
||||
srcs = glob(["*.soy"]),
|
||||
data = ["//java/google/registry/ui/css:registrar_raw"],
|
||||
globals = "//java/google/registry/ui:globals.txt",
|
||||
deps = ["//java/google/registry/ui/soy"],
|
||||
)
|
||||
|
||||
closure_java_template_library(
|
||||
name = "soy_java_wrappers",
|
||||
srcs = glob(["*.soy"]),
|
||||
java_package = "google.registry.ui.soy.otesetup",
|
||||
)
|
|
@ -8,7 +8,13 @@ load("@io_bazel_rules_closure//closure:defs.bzl", "closure_java_template_library
|
|||
|
||||
closure_js_template_library(
|
||||
name = "registrar",
|
||||
srcs = glob(["*.soy"]),
|
||||
srcs = glob(
|
||||
["*.soy"],
|
||||
exclude = [
|
||||
"OteSetupConsole.soy",
|
||||
"RegistrarCreateConsole.soy",
|
||||
],
|
||||
),
|
||||
data = ["//java/google/registry/ui/css:registrar_raw"],
|
||||
globals = "//java/google/registry/ui:globals.txt",
|
||||
deps = ["//java/google/registry/ui/soy"],
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
{namespace registry.soy.registrar.console}
|
||||
{namespace registry.soy.registrar.otesetup}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@
|
|||
{call registry.soy.console.googlebar data="all" /}
|
||||
<div id="reg-content-and-footer">
|
||||
<div id="reg-content">
|
||||
<h1>OT&E Setup Page</h1>
|
||||
<h1>Setup OT&E</h1>
|
||||
{if isNonnull($errorMessage)}
|
||||
<h2 class="{css('kd-errormessage')}">Failed: {$errorMessage}</h2>
|
||||
{/if}
|
360
java/google/registry/ui/soy/registrar/RegistrarCreateConsole.soy
Normal file
360
java/google/registry/ui/soy/registrar/RegistrarCreateConsole.soy
Normal file
|
@ -0,0 +1,360 @@
|
|||
// Copyright 2018 The Nomulus Authors. 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.
|
||||
|
||||
{namespace registry.soy.registrar.registrarcreate}
|
||||
|
||||
|
||||
/**
|
||||
* Main page for the registrar creation. Holds a form with the required data.
|
||||
*/
|
||||
{template .formPage}
|
||||
{@param xsrfToken: string} /** Security token. */
|
||||
{@param username: string} /** Arbitrary username to display. */
|
||||
{@param logoutUrl: string} /** Generated URL for logging out of Google. */
|
||||
{@param productName: string} /** Name to display for this software product. */
|
||||
{@param logoFilename: string}
|
||||
{@param? errorMessage: string} /** If set - display the error message above the form. */
|
||||
{@param? clientId: string} /** If set - an initial value for the client ID. */
|
||||
{@param? name: string} /** If set - an initial value for the Registrar name. */
|
||||
{@param? billingAccount: string} /** If set - the billing accounts data. */
|
||||
{@param? ianaId: int} /** If set - an initial value for the IANA ID. */
|
||||
{@param? referralEmail: string} /** If set - an initial value for the ICANN referral email. */
|
||||
{@param? driveId: string} /** If set - an initial value for the DRIVE ID. */
|
||||
{@param? email: string} /** If set - an initial value for the email. */
|
||||
{@param? street1: string} /** If set - the first line of the street address. */
|
||||
{@param? street2: string} /** If set - the second line of the street address. */
|
||||
{@param? street3: string} /** If set - the third line of the street address. */
|
||||
{@param? city: string} /** If set - the address city. */
|
||||
{@param? state: string} /** If set - the state/region of the address. */
|
||||
{@param? countryCode: string} /** If set - the 2 letter country code. */
|
||||
{@param? zip: string} /** If set - the zip code of the address. */
|
||||
|
||||
{call registry.soy.console.header}
|
||||
{param app: 'registrar' /}
|
||||
{param subtitle: 'Create Registrar' /}
|
||||
{/call}
|
||||
{call registry.soy.console.googlebar data="all" /}
|
||||
<div id="reg-content-and-footer">
|
||||
<div id="reg-content">
|
||||
<h1>Create Registrar</h1>
|
||||
{if isNonnull($errorMessage)}
|
||||
<h2 class="{css('kd-errormessage')}">Failed: {$errorMessage}</h2>
|
||||
{/if}
|
||||
{call .form_ data="all" /}
|
||||
</div>
|
||||
{call registry.soy.console.footer /}
|
||||
</div>
|
||||
{/template}
|
||||
|
||||
|
||||
/**
|
||||
* Result page for a successful registrar creation.
|
||||
*/
|
||||
{template .resultSuccess}
|
||||
{@param clientId: string} /** The clientId of the registrar. */
|
||||
{@param email: string} /** The email of the account with web access to the registrar. */
|
||||
{@param passcode: string} /** The phone passcode for this registrar. */
|
||||
{@param password: string} /** The password given for the created registrars. */
|
||||
{@param username: string} /** Arbitrary username to display. */
|
||||
{@param logoutUrl: string} /** Generated URL for logging out of Google. */
|
||||
{@param productName: string} /** Name to display for this software product. */
|
||||
{@param logoFilename: string}
|
||||
|
||||
{call registry.soy.console.header}
|
||||
{param app: 'registrar' /}
|
||||
{param subtitle: 'Create Registrar' /}
|
||||
{/call}
|
||||
{call registry.soy.console.googlebar data="all" /}
|
||||
<div id="reg-content-and-footer">
|
||||
<div id="reg-content" class="{css('item')} {css('registrar')}">
|
||||
<h1>Successfully created Registrar {$clientId}</h1>
|
||||
<table>
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'Client ID' /}
|
||||
{param name: 'clientId' /}
|
||||
{param value: $clientId /}
|
||||
{param description kind="text"}
|
||||
The registrar's Client ID
|
||||
{/param}
|
||||
{param readonly: true /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'EPP password' /}
|
||||
{param name: 'password' /}
|
||||
{param value: $password /}
|
||||
{param description kind="text"}
|
||||
The password used to for EPP login.
|
||||
{/param}
|
||||
{param readonly: true /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'Phone passcode' /}
|
||||
{param name: 'passcode' /}
|
||||
{param value: $passcode /}
|
||||
{param description kind="text"}
|
||||
Passcode used for phone authentication.
|
||||
{/param}
|
||||
{param readonly: true /}
|
||||
{/call}
|
||||
<tr>
|
||||
<td>
|
||||
<label class="{css('setting-label')}">Registrar credentials</label>
|
||||
<span class="{css('description')}">Copy and paste this into an email to the registrars</span>
|
||||
</td>
|
||||
<td class="{css('setting')}">
|
||||
<textarea rows="5" cols="30" readonly>
|
||||
Login: {$clientId}{\n}
|
||||
Password: {$password}{\n}
|
||||
Phone passcode: {$passcode}{\n}
|
||||
</textarea>
|
||||
</td>
|
||||
</table>
|
||||
Gave <label>{$email}</label> web-console access to this registrar.
|
||||
<h1>You may want to set additional values using the web console:</h1>
|
||||
<span class="{css('description')}">
|
||||
<ol type="1">
|
||||
<li>phone number, email, URL on the {sp}
|
||||
<a href="/registrar?clientId={$clientId}#whois-settings" target="_blank">WHOIS page</a>
|
||||
<li>allowed TLDs on the {sp}
|
||||
<a href="/registrar?clientId={$clientId}#admin-settings" target="_blank">admin page</a>
|
||||
<li>certificate, IP whitelist on the {sp}
|
||||
<a href="/registrar?clientId={$clientId}#security-settings" target="_blank">security page</a>
|
||||
</ol>
|
||||
</span>
|
||||
</div>
|
||||
{call registry.soy.console.footer /}
|
||||
</div>
|
||||
{/template}
|
||||
|
||||
|
||||
/** Form for getting registrar info. */
|
||||
{template .form_ visibility="private"}
|
||||
{@param xsrfToken: string} /** Security token. */
|
||||
{@param? clientId: string} /** If set - an initial value for the client ID. */
|
||||
{@param? name: string} /** If set - an initial value for the Registrar name. */
|
||||
{@param? billingAccount: string} /** If set - the billing accounts data. */
|
||||
{@param? ianaId: int} /** If set - an initial value for the IANA ID. */
|
||||
{@param? referralEmail: string} /** If set - an initial value for the ICANN referral email. */
|
||||
{@param? driveId: string} /** If set - an initial value for the DRIVE ID. */
|
||||
{@param? email: string} /** If set - an initial value for the email. */
|
||||
{@param? street1: string} /** If set - the first line of the street address. */
|
||||
{@param? street2: string} /** If set - the second line of the street address. */
|
||||
{@param? street3: string} /** If set - the third line of the street address. */
|
||||
{@param? city: string} /** If set - the address city. */
|
||||
{@param? state: string} /** If set - the state/region of the address. */
|
||||
{@param? countryCode: string} /** If set - the 2 letter country code. */
|
||||
{@param? zip: string} /** If set - the zip code of the address. */
|
||||
|
||||
<form name="item" class="{css('item')}" method="post" action="/registrar-create">
|
||||
<table>
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'Client ID' /}
|
||||
{param name: 'clientId' /}
|
||||
{param value: $clientId /}
|
||||
{param placeholder: 'required' /}
|
||||
{param description kind="text"}
|
||||
Client identifier of the registrar account.
|
||||
{/param}
|
||||
{param required: true /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'Name' /}
|
||||
{param name: 'name' /}
|
||||
{param value: $name /}
|
||||
{param placeholder: 'required' /}
|
||||
{param description kind="text"}
|
||||
Name of the registrar.
|
||||
{/param}
|
||||
{param required: true /}
|
||||
{/call}
|
||||
<tr class="{css('kd-settings-pane-section')}">
|
||||
<td>
|
||||
{call registry.soy.forms.inputFieldLabel}
|
||||
{param label: 'Billing accounts' /}
|
||||
{param description kind="text"}
|
||||
Registrar billing account IDs.
|
||||
Each currency in a separate line in the format
|
||||
[currency]=[account ID].
|
||||
{/param}
|
||||
{/call}
|
||||
</td>
|
||||
<td class="{css('setting')}">
|
||||
<textarea
|
||||
name="billingAccount"
|
||||
id="billingAccount"
|
||||
rows="4"
|
||||
cols="50"
|
||||
placeholder=
|
||||
"Example:{\n}
|
||||
USD=billing-id-for-usd{\n}
|
||||
JPY=billing-id-for-yen{\n}"
|
||||
required>{$billingAccount ?: ''}</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'IANA ID' /}
|
||||
{param name: 'ianaId' /}
|
||||
{param value: $ianaId /}
|
||||
{param placeholder: 'required' /}
|
||||
{param description kind="text"}
|
||||
Registrar IANA ID.
|
||||
{/param}
|
||||
{param required: true /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'ICANN referral email' /}
|
||||
{param name: 'referralEmail' /}
|
||||
{param value: $referralEmail /}
|
||||
{param placeholder: 'required' /}
|
||||
{param description kind="text"}
|
||||
ICANN referral email, as specified in registrar contract.
|
||||
{/param}
|
||||
{param required: true /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'DRIVE ID' /}
|
||||
{param name: 'driveId' /}
|
||||
{param value: $driveId /}
|
||||
{param placeholder: 'required' /}
|
||||
{param description kind="text"}
|
||||
Id of this registrar's folder in Drive.
|
||||
{/param}
|
||||
{param required: true /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'Delegated email' /}
|
||||
{param name: 'email' /}
|
||||
{param value: $email /}
|
||||
{param placeholder: 'required' /}
|
||||
{param description kind="text"}
|
||||
The email we created for the registrar.
|
||||
Will be granted web-console access to the registrar.
|
||||
{/param}
|
||||
{param required: true /}
|
||||
{/call}
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<hr>
|
||||
<h1>Contact Info</h1>
|
||||
</td>
|
||||
</tr>
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'Street address' /}
|
||||
{param name: 'street1' /}
|
||||
{param value: $street1 /}
|
||||
{param placeholder: 'required' /}
|
||||
{param required: true /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: '' /}
|
||||
{param name: 'street2' /}
|
||||
{param value: $street2 /}
|
||||
{param placeholder: 'optional' /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: '' /}
|
||||
{param name: 'street3' /}
|
||||
{param value: $street3 /}
|
||||
{param placeholder: 'optional' /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'City' /}
|
||||
{param name: 'city' /}
|
||||
{param value: $city /}
|
||||
{param placeholder: 'required' /}
|
||||
{param required: true /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'State/region' /}
|
||||
{param name: 'state' /}
|
||||
{param value: $state /}
|
||||
{param placeholder: 'optional' /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'Zip/postal code' /}
|
||||
{param name: 'zip' /}
|
||||
{param value: $zip /}
|
||||
{param placeholder: 'optional' /}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'Country Code' /}
|
||||
{param name: 'countryCode' /}
|
||||
{param value: $countryCode /}
|
||||
{param placeholder: 'required' /}
|
||||
{param required: true /}
|
||||
{/call}
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<hr>
|
||||
<h1>Optional fields</h1>
|
||||
Don't fill unless you have a good reason to.
|
||||
</td>
|
||||
</tr>
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'EPP password' /}
|
||||
{param name: 'password' /}
|
||||
{param placeholder: 'optional' /}
|
||||
{param description kind="text"}
|
||||
The password used to for EPP login. Leave blank to auto-generate.
|
||||
{/param}
|
||||
{/call}
|
||||
{call registry.soy.forms.inputFieldRowWithValue}
|
||||
{param label: 'Phone passcode' /}
|
||||
{param name: 'passcode' /}
|
||||
{param placeholder: 'optional' /}
|
||||
{param description kind="text"}
|
||||
The passcode used for phone authentication. Leave blank to auto-generate.
|
||||
{/param}
|
||||
{/call}
|
||||
{call registry.soy.forms.submitRow}
|
||||
{param label: 'create' /}
|
||||
{/call}
|
||||
</table>
|
||||
<input type="hidden" name="xsrfToken" value="{$xsrfToken}">
|
||||
</form>
|
||||
{/template}
|
||||
|
||||
|
||||
/**
|
||||
* Who goes thar?!
|
||||
*/
|
||||
{template .whoareyou}
|
||||
{@param username: string} /** Arbitrary username to display. */
|
||||
{@param logoutUrl: string} /** Generated URL for logging out of Google. */
|
||||
{@param logoFilename: string}
|
||||
{@param productName: string}
|
||||
{call registry.soy.console.header}
|
||||
{param app: 'registrar' /}
|
||||
{param subtitle: 'Not Authorized' /}
|
||||
{/call}
|
||||
<div class="{css('whoAreYou')}">
|
||||
<a class="{css('logo')}" href="/registrar">
|
||||
<img src="/assets/images/{$logoFilename}" alt="{$productName}">
|
||||
</a>
|
||||
<h1>You need permission</h1>
|
||||
<p>
|
||||
Only {$productName} Admins have access to this page.
|
||||
You are signed in as <strong>{$username}</strong>.
|
||||
<div>
|
||||
<a href="{$logoutUrl}"
|
||||
class="{css('kd-button')} {css('kd-button-submit')}"
|
||||
tabindex="-1">Logout and switch to another account</a>{sp}
|
||||
<a href="/registrar"
|
||||
class="{css('kd-button')} {css('kd-button-submit')}"
|
||||
tabindex="-1">Go to the Registrar web console</a>
|
||||
</div>
|
||||
</div>
|
||||
{/template}
|
||||
|
||||
|
|
@ -36,6 +36,9 @@ public abstract class StringGenerator implements Serializable {
|
|||
/** An alphanumeric alphabet that omits visually similar characters. */
|
||||
public static final String BASE_58 =
|
||||
"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
||||
|
||||
/** Digit-only alphabet. */
|
||||
public static final String DIGITS_ONLY = "0123456789";
|
||||
}
|
||||
|
||||
protected String alphabet;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
PATH CLASS METHODS OK AUTH_METHODS MIN USER_POLICY
|
||||
/_dr/epp EppTlsAction POST n INTERNAL,API APP PUBLIC
|
||||
/registrar ConsoleUiAction GET n INTERNAL,API,LEGACY NONE PUBLIC
|
||||
/registrar-create ConsoleRegistrarCreatorAction POST,GET n INTERNAL,API,LEGACY NONE PUBLIC
|
||||
/registrar-ote-setup ConsoleOteSetupAction POST,GET n INTERNAL,API,LEGACY NONE PUBLIC
|
||||
/registrar-ote-status OteStatusAction POST n API,LEGACY USER PUBLIC
|
||||
/registrar-settings RegistrarSettingsAction POST n API,LEGACY USER PUBLIC
|
||||
|
|
|
@ -86,7 +86,8 @@ public final class RegistryTestServer {
|
|||
// Registrar Console
|
||||
route("/registrar", FrontendServlet.class),
|
||||
route("/registrar-settings", FrontendServlet.class),
|
||||
route("/registrar-ote-setup", FrontendServlet.class));
|
||||
route("/registrar-ote-setup", FrontendServlet.class),
|
||||
route("/registrar-create", FrontendServlet.class));
|
||||
|
||||
private static final ImmutableList<Class<? extends Filter>> FILTERS = ImmutableList.of(
|
||||
ObjectifyFilter.class,
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
package(
|
||||
default_testonly = 1,
|
||||
default_visibility = ["//java/google/registry:registry_project"],
|
||||
)
|
||||
|
||||
licenses(["notice"]) # Apache 2.0
|
||||
|
||||
load("//java/com/google/testing/builddefs:GenTestRules.bzl", "GenTestRules")
|
||||
|
||||
java_library(
|
||||
name = "otesetup",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/google/registry/config",
|
||||
"//java/google/registry/model",
|
||||
"//java/google/registry/request",
|
||||
"//java/google/registry/request/auth",
|
||||
"//java/google/registry/security",
|
||||
"//java/google/registry/ui/server",
|
||||
"//java/google/registry/ui/server/otesetup",
|
||||
"//java/google/registry/util",
|
||||
"//javatests/google/registry/testing",
|
||||
"//third_party/objectify:objectify-v4_1",
|
||||
"@com_google_appengine_api_1_0_sdk",
|
||||
"@com_google_flogger",
|
||||
"@com_google_flogger_system_backend",
|
||||
"@com_google_guava",
|
||||
"@com_google_guava_testlib",
|
||||
"@com_google_monitoring_client_contrib",
|
||||
"@com_google_truth",
|
||||
"@com_google_truth_extensions_truth_java8_extension",
|
||||
"@com_googlecode_json_simple",
|
||||
"@javax_servlet_api",
|
||||
"@joda_time",
|
||||
"@junit",
|
||||
"@org_joda_money",
|
||||
"@org_mockito_all",
|
||||
],
|
||||
)
|
||||
|
||||
GenTestRules(
|
||||
name = "GeneratedTestRules",
|
||||
test_files = glob(["*Test.java"]),
|
||||
deps = [":otesetup"],
|
||||
)
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.ui.server.otesetup;
|
||||
package google.registry.ui.server.registrar;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.LOCATION;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
@ -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");
|
||||
|
||||
|
@ -116,7 +117,7 @@ public final class ConsoleOteSetupActionTest {
|
|||
@Test
|
||||
public void testGet_authorized() {
|
||||
action.run();
|
||||
assertThat(response.getPayload()).contains("<h1>OT&E Setup Page</h1>");
|
||||
assertThat(response.getPayload()).contains("<h1>Setup OT&E</h1>");
|
||||
}
|
||||
|
||||
@Test
|
|
@ -0,0 +1,417 @@
|
|||
// Copyright 2018 The Nomulus Authors. 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 google.registry.ui.server.registrar;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.LOCATION;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.common.GaeUserIdConverter.convertEmailAddressToGaeUserId;
|
||||
import static google.registry.model.registrar.Registrar.loadByClientId;
|
||||
import static google.registry.testing.DatastoreHelper.persistPremiumList;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_MOVED_TEMPORARILY;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.appengine.api.users.User;
|
||||
import com.google.appengine.api.users.UserServiceFactory;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarAddress;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.request.Action.Method;
|
||||
import google.registry.request.auth.AuthLevel;
|
||||
import google.registry.request.auth.AuthResult;
|
||||
import google.registry.request.auth.AuthenticatedRegistrarAccessor;
|
||||
import google.registry.request.auth.UserAuthInfo;
|
||||
import google.registry.security.XsrfTokenManager;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.DeterministicStringGenerator;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.MockitoJUnitRule;
|
||||
import google.registry.ui.server.SendEmailUtils;
|
||||
import google.registry.util.SendEmailService;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.mockito.Mock;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public final class ConsoleRegistrarCreatorActionTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngineRule = AppEngineRule.builder()
|
||||
.withDatastore()
|
||||
.build();
|
||||
|
||||
@Rule public final MockitoJUnitRule mocks = MockitoJUnitRule.create();
|
||||
|
||||
private final FakeResponse response = new FakeResponse();
|
||||
private final ConsoleRegistrarCreatorAction action = new ConsoleRegistrarCreatorAction();
|
||||
private final User user = new User("marla.singer@example.com", "gmail.com", "12345");
|
||||
|
||||
@Mock HttpServletRequest request;
|
||||
@Mock SendEmailService emailService;
|
||||
Message message;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
persistPremiumList("default_sandbox_list", "sandbox,USD 1000");
|
||||
|
||||
action.req = request;
|
||||
action.method = Method.GET;
|
||||
action.response = response;
|
||||
action.registrarAccessor =
|
||||
AuthenticatedRegistrarAccessor.createForTesting(
|
||||
ImmutableSetMultimap.of("unused", AuthenticatedRegistrarAccessor.Role.ADMIN));
|
||||
action.userService = UserServiceFactory.getUserService();
|
||||
action.xsrfTokenManager = new XsrfTokenManager(new FakeClock(), action.userService);
|
||||
action.authResult = AuthResult.create(AuthLevel.USER, UserAuthInfo.create(user, false));
|
||||
action.registryEnvironment = RegistryEnvironment.UNITTEST;
|
||||
action.sendEmailUtils =
|
||||
new SendEmailUtils(
|
||||
"outgoing@registry.example",
|
||||
"UnitTest Registry",
|
||||
ImmutableList.of("notification@test.example", "notification2@test.example"),
|
||||
emailService);
|
||||
action.logoFilename = "logo.png";
|
||||
action.productName = "Nomulus";
|
||||
|
||||
action.clientId = Optional.empty();
|
||||
action.name = Optional.empty();
|
||||
action.billingAccount = Optional.empty();
|
||||
action.ianaId = Optional.empty();
|
||||
action.referralEmail = Optional.empty();
|
||||
action.driveId = Optional.empty();
|
||||
action.email = Optional.empty();
|
||||
|
||||
action.street1 = Optional.empty();
|
||||
action.optionalStreet2 = Optional.empty();
|
||||
action.optionalStreet3 = Optional.empty();
|
||||
action.city = Optional.empty();
|
||||
action.optionalState = Optional.empty();
|
||||
action.optionalZip = Optional.empty();
|
||||
action.countryCode = Optional.empty();
|
||||
|
||||
action.optionalPassword = Optional.empty();
|
||||
action.optionalPasscode = Optional.empty();
|
||||
|
||||
action.passwordGenerator = new DeterministicStringGenerator("abcdefghijklmnopqrstuvwxyz");
|
||||
action.passcodeGenerator = new DeterministicStringGenerator("314159265");
|
||||
|
||||
message = new MimeMessage(Session.getDefaultInstance(new Properties(), null));
|
||||
when(emailService.createMessage()).thenReturn(message);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoUser_redirect() {
|
||||
when(request.getRequestURI()).thenReturn("/test");
|
||||
action.authResult = AuthResult.NOT_AUTHENTICATED;
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(SC_MOVED_TEMPORARILY);
|
||||
assertThat(response.getHeaders().get(LOCATION)).isEqualTo("/_ah/login?continue=%2Ftest");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet_authorized() {
|
||||
action.run();
|
||||
assertThat(response.getPayload()).contains("<h1>Create Registrar</h1>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet_authorized_onProduction() {
|
||||
action.registryEnvironment = RegistryEnvironment.PRODUCTION;
|
||||
action.run();
|
||||
assertThat(response.getPayload()).contains("<h1>Create Registrar</h1>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet_unauthorized() {
|
||||
action.registrarAccessor =
|
||||
AuthenticatedRegistrarAccessor.createForTesting(ImmutableSetMultimap.of());
|
||||
action.run();
|
||||
assertThat(response.getPayload()).contains("<h1>You need permission</h1>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPost_authorized_minimalAddress() throws Exception {
|
||||
action.clientId = Optional.of("myclientid");
|
||||
action.name = Optional.of("registrar name");
|
||||
action.billingAccount = Optional.of("USD=billing-account");
|
||||
action.ianaId = Optional.of(12321);
|
||||
action.referralEmail = Optional.of("icann@example.com");
|
||||
action.driveId = Optional.of("drive-id");
|
||||
action.email = Optional.of("myclientid@registry.example");
|
||||
|
||||
action.street1 = Optional.of("my street");
|
||||
action.city = Optional.of("my city");
|
||||
action.countryCode = Optional.of("CC");
|
||||
|
||||
|
||||
action.method = Method.POST;
|
||||
action.run();
|
||||
|
||||
assertThat(response.getPayload())
|
||||
.contains("<h1>Successfully created Registrar myclientid</h1>");
|
||||
|
||||
assertThat(message.getSubject()).isEqualTo("Registrar myclientid created in unittest");
|
||||
assertThat(message.getContent())
|
||||
.isEqualTo(
|
||||
""
|
||||
+ "The following registrar was created in unittest by TestUserId:\n"
|
||||
+ " clientId: myclientid\n"
|
||||
+ " name: registrar name\n"
|
||||
+ " billingAccount: USD=billing-account\n"
|
||||
+ " ianaId: 12321\n"
|
||||
+ " referralEmail: icann@example.com\n"
|
||||
+ " driveId: drive-id\n"
|
||||
+ "Gave user myclientid@registry.example web access to the registrar\n");
|
||||
Registrar registrar = loadByClientId("myclientid").orElse(null);
|
||||
assertThat(registrar).isNotNull();
|
||||
assertThat(registrar.getClientId()).isEqualTo("myclientid");
|
||||
assertThat(registrar.getBillingAccountMap())
|
||||
.containsExactly(CurrencyUnit.USD, "billing-account");
|
||||
|
||||
assertThat(registrar.getDriveFolderId()).isEqualTo("drive-id");
|
||||
assertThat(registrar.getIanaIdentifier()).isEqualTo(12321L);
|
||||
assertThat(registrar.getIcannReferralEmail()).isEqualTo("icann@example.com");
|
||||
assertThat(registrar.testPassword("abcdefghijklmnop")).isTrue();
|
||||
assertThat(registrar.getPhonePasscode()).isEqualTo("31415");
|
||||
assertThat(registrar.getState()).isEqualTo(Registrar.State.PENDING);
|
||||
assertThat(registrar.getType()).isEqualTo(Registrar.Type.REAL);
|
||||
|
||||
assertThat(registrar.getLocalizedAddress()).isEqualTo(new RegistrarAddress.Builder()
|
||||
.setStreet(ImmutableList.of("my street"))
|
||||
.setCity("my city")
|
||||
.setCountryCode("CC")
|
||||
.build());
|
||||
|
||||
assertThat(registrar.getContacts())
|
||||
.containsExactly(
|
||||
new RegistrarContact.Builder()
|
||||
.setParent(registrar)
|
||||
.setGaeUserId("-1509175207")
|
||||
.setGaeUserId(convertEmailAddressToGaeUserId("myclientid@registry.example"))
|
||||
.setName("myclientid@registry.example")
|
||||
.setEmailAddress("myclientid@registry.example")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPost_authorized_allAddress() throws Exception {
|
||||
action.clientId = Optional.of("myclientid");
|
||||
action.name = Optional.of("registrar name");
|
||||
action.billingAccount = Optional.of("USD=billing-account");
|
||||
action.ianaId = Optional.of(12321);
|
||||
action.referralEmail = Optional.of("icann@example.com");
|
||||
action.driveId = Optional.of("drive-id");
|
||||
action.email = Optional.of("myclientid@registry.example");
|
||||
|
||||
action.street1 = Optional.of("my street");
|
||||
action.optionalStreet2 = Optional.of("more street");
|
||||
action.optionalStreet3 = Optional.of("final street");
|
||||
action.city = Optional.of("my city");
|
||||
action.optionalState = Optional.of("province");
|
||||
action.optionalZip = Optional.of("12345-678");
|
||||
action.countryCode = Optional.of("CC");
|
||||
|
||||
|
||||
action.method = Method.POST;
|
||||
action.run();
|
||||
|
||||
assertThat(response.getPayload())
|
||||
.contains("<h1>Successfully created Registrar myclientid</h1>");
|
||||
|
||||
Registrar registrar = loadByClientId("myclientid").orElse(null);
|
||||
assertThat(registrar).isNotNull();
|
||||
assertThat(registrar.getLocalizedAddress()).isEqualTo(new RegistrarAddress.Builder()
|
||||
.setStreet(ImmutableList.of("my street", "more street", "final street"))
|
||||
.setCity("my city")
|
||||
.setState("province")
|
||||
.setZip("12345-678")
|
||||
.setCountryCode("CC")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPost_authorized_multipleBillingLines() throws Exception {
|
||||
action.clientId = Optional.of("myclientid");
|
||||
action.name = Optional.of("registrar name");
|
||||
action.ianaId = Optional.of(12321);
|
||||
action.referralEmail = Optional.of("icann@example.com");
|
||||
action.driveId = Optional.of("drive-id");
|
||||
action.email = Optional.of("myclientid@registry.example");
|
||||
|
||||
action.street1 = Optional.of("my street");
|
||||
action.city = Optional.of("my city");
|
||||
action.countryCode = Optional.of("CC");
|
||||
|
||||
action.method = Method.POST;
|
||||
|
||||
action.billingAccount =
|
||||
Optional.of(
|
||||
""
|
||||
+ "JPY=billing-account-yen\n"
|
||||
+ " Usd = billing-account-usd \r\n"
|
||||
+ "\n"
|
||||
+ " \n"
|
||||
+ "eur=billing-account-eur\n");
|
||||
action.run();
|
||||
|
||||
assertThat(response.getPayload())
|
||||
.contains("<h1>Successfully created Registrar myclientid</h1>");
|
||||
|
||||
Registrar registrar = loadByClientId("myclientid").orElse(null);
|
||||
assertThat(registrar).isNotNull();
|
||||
assertThat(registrar.getBillingAccountMap())
|
||||
.containsExactly(
|
||||
CurrencyUnit.JPY, "billing-account-yen",
|
||||
CurrencyUnit.USD, "billing-account-usd",
|
||||
CurrencyUnit.EUR, "billing-account-eur");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPost_authorized_repeatingCurrency_fails() throws Exception {
|
||||
action.clientId = Optional.of("myclientid");
|
||||
action.name = Optional.of("registrar name");
|
||||
action.ianaId = Optional.of(12321);
|
||||
action.referralEmail = Optional.of("icann@example.com");
|
||||
action.driveId = Optional.of("drive-id");
|
||||
action.email = Optional.of("myclientid@registry.example");
|
||||
|
||||
action.street1 = Optional.of("my street");
|
||||
action.city = Optional.of("my city");
|
||||
action.countryCode = Optional.of("CC");
|
||||
|
||||
action.method = Method.POST;
|
||||
|
||||
action.billingAccount =
|
||||
Optional.of(
|
||||
""
|
||||
+ "JPY=billing-account-1\n"
|
||||
+ "jpy=billing-account-2\n");
|
||||
action.run();
|
||||
|
||||
assertThat(response.getPayload())
|
||||
.contains(
|
||||
"Failed: Error parsing billing accounts - Multiple entries with same key:"
|
||||
+ " JPY=billing-account-2 and JPY=billing-account-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPost_authorized_badCurrency_fails() throws Exception {
|
||||
action.clientId = Optional.of("myclientid");
|
||||
action.name = Optional.of("registrar name");
|
||||
action.ianaId = Optional.of(12321);
|
||||
action.referralEmail = Optional.of("icann@example.com");
|
||||
action.driveId = Optional.of("drive-id");
|
||||
action.email = Optional.of("myclientid@registry.example");
|
||||
|
||||
action.street1 = Optional.of("my street");
|
||||
action.city = Optional.of("my city");
|
||||
action.countryCode = Optional.of("CC");
|
||||
|
||||
action.method = Method.POST;
|
||||
|
||||
action.billingAccount =
|
||||
Optional.of(
|
||||
""
|
||||
+ "JPY=billing-account-1\n"
|
||||
+ "xyz=billing-account-2\n"
|
||||
+ "usd=billing-account-3\n");
|
||||
action.run();
|
||||
|
||||
assertThat(response.getPayload())
|
||||
.contains("Failed: Error parsing billing accounts - Unknown currency 'XYZ'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPost_authorized_badBillingLine_fails() throws Exception {
|
||||
action.clientId = Optional.of("myclientid");
|
||||
action.name = Optional.of("registrar name");
|
||||
action.ianaId = Optional.of(12321);
|
||||
action.referralEmail = Optional.of("icann@example.com");
|
||||
action.driveId = Optional.of("drive-id");
|
||||
action.email = Optional.of("myclientid@registry.example");
|
||||
|
||||
action.street1 = Optional.of("my street");
|
||||
action.city = Optional.of("my city");
|
||||
action.countryCode = Optional.of("CC");
|
||||
|
||||
action.method = Method.POST;
|
||||
|
||||
action.billingAccount =
|
||||
Optional.of(
|
||||
""
|
||||
+ "JPY=billing-account-1\n"
|
||||
+ "some bad line\n"
|
||||
+ "usd=billing-account-2\n");
|
||||
action.run();
|
||||
|
||||
assertThat(response.getPayload())
|
||||
.contains(
|
||||
"Failed: Error parsing billing accounts - Can't parse line [some bad line]."
|
||||
+ " The format should be [currency]=[account ID]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPost_authorized_setPassword() throws Exception {
|
||||
action.clientId = Optional.of("myclientid");
|
||||
action.name = Optional.of("registrar name");
|
||||
action.billingAccount = Optional.of("USD=billing-account");
|
||||
action.ianaId = Optional.of(12321);
|
||||
action.referralEmail = Optional.of("icann@example.com");
|
||||
action.driveId = Optional.of("drive-id");
|
||||
action.email = Optional.of("myclientid@registry.example");
|
||||
|
||||
action.street1 = Optional.of("my street");
|
||||
action.city = Optional.of("my city");
|
||||
action.countryCode = Optional.of("CC");
|
||||
|
||||
action.optionalPassword = Optional.of("SomePassword");
|
||||
action.optionalPasscode = Optional.of("10203");
|
||||
|
||||
action.method = Method.POST;
|
||||
action.run();
|
||||
|
||||
assertThat(response.getPayload())
|
||||
.contains("<h1>Successfully created Registrar myclientid</h1>");
|
||||
|
||||
Registrar registrar = loadByClientId("myclientid").orElse(null);
|
||||
assertThat(registrar).isNotNull();
|
||||
assertThat(registrar.testPassword("SomePassword")).isTrue();
|
||||
assertThat(registrar.getPhonePasscode()).isEqualTo("10203");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPost_unauthorized() {
|
||||
action.registrarAccessor =
|
||||
AuthenticatedRegistrarAccessor.createForTesting(ImmutableSetMultimap.of());
|
||||
action.clientId = Optional.of("myclientid");
|
||||
action.email = Optional.of("myclientid@registry.example");
|
||||
action.method = Method.POST;
|
||||
action.run();
|
||||
assertThat(response.getPayload()).contains("<h1>You need permission</h1>");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue