Allow AppEngineConnection to target services other than "tools"

This change required several things:
- Separating out the interfaces that merely do HTTP calls to the backend from those
  that require the remote API (only load the remote API for the latter).  Only the
  tools service provides the remote api endpoint.
- Removing the XSRF token as an authentication mechanism (with OAUTH, we no longer
  need this, and trying to provide it requires initialization of the datastore
  code which requires the remote API)

I can't think of a compelling unit test for this beyond what already exists.
Tested:
  Verified that:
  - nomulus tool commands (e.g. "list_tlds") work against the tools service as they
    currently do
  - The "curl" command hits endpoints on "tools" by default.
  - We can use --server to specify endpoints on the default service.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=211510454
This commit is contained in:
mmuller 2018-09-04 13:12:03 -07:00 committed by jianglai
parent 8d131a52bd
commit e43349592d
52 changed files with 112 additions and 116 deletions

View file

@ -19,7 +19,6 @@ import static com.google.common.base.Suppliers.memoize;
import static com.google.common.net.HttpHeaders.X_REQUESTED_WITH; import static com.google.common.net.HttpHeaders.X_REQUESTED_WITH;
import static com.google.common.net.MediaType.JSON_UTF_8; import static com.google.common.net.MediaType.JSON_UTF_8;
import static google.registry.security.JsonHttp.JSON_SAFETY_PREFIX; import static google.registry.security.JsonHttp.JSON_SAFETY_PREFIX;
import static google.registry.security.XsrfTokenManager.X_CSRF_TOKEN;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.api.client.http.ByteArrayContent; import com.google.api.client.http.ByteArrayContent;
@ -37,7 +36,7 @@ import com.google.common.net.MediaType;
import com.google.re2j.Matcher; import com.google.re2j.Matcher;
import com.google.re2j.Pattern; import com.google.re2j.Pattern;
import google.registry.security.XsrfTokenManager; import google.registry.security.XsrfTokenManager;
import google.registry.tools.ServerSideCommand.Connection; import google.registry.tools.CommandWithConnection.Connection;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.Map; import java.util.Map;
@ -95,7 +94,6 @@ class AppEngineConnection implements Connection {
: requestFactory.buildGetRequest(url); : requestFactory.buildGetRequest(url);
HttpHeaders headers = request.getHeaders(); HttpHeaders headers = request.getHeaders();
headers.setCacheControl("no-cache"); headers.setCacheControl("no-cache");
headers.put(X_CSRF_TOKEN, ImmutableList.of(xsrfToken.get()));
headers.put(X_REQUESTED_WITH, ImmutableList.of("RegistryTool")); headers.put(X_REQUESTED_WITH, ImmutableList.of("RegistryTool"));
request.setHeaders(headers); request.setHeaders(headers);
request.setFollowRedirects(false); request.setFollowRedirects(false);

View file

@ -20,7 +20,6 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import google.registry.export.DatastoreBackupInfo; import google.registry.export.DatastoreBackupInfo;
import google.registry.export.DatastoreBackupService; import google.registry.export.DatastoreBackupService;
import google.registry.tools.Command.RemoteApiCommand;
import javax.inject.Inject; import javax.inject.Inject;
/** /**

View file

@ -19,12 +19,4 @@ public interface Command {
/** Performs the command. */ /** Performs the command. */
void run() throws Exception; void run() throws Exception;
/**
* Marker interface for commands that use the remote api.
*
* <p>Just implementing this is sufficient to use the remote api; {@link RegistryTool} will
* install it as needed.
*/
interface RemoteApiCommand extends Command {}
} }

View file

@ -0,0 +1,43 @@
// 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.tools;
import com.google.common.net.MediaType;
import java.io.IOException;
import java.util.Map;
import javax.annotation.Nullable;
/** A command that can send HTTP requests to a backend module. */
interface CommandWithConnection extends Command {
/** An http connection to AppEngine. */
interface Connection {
void prefetchXsrfToken();
/** Send a POST request. TODO(mmuller): change to sendPostRequest() */
String send(
String endpoint, Map<String, ?> params, MediaType contentType, @Nullable byte[] payload)
throws IOException;
String sendGetRequest(String endpoint, Map<String, ?> params) throws IOException;
Map<String, Object> sendJson(String endpoint, Map<String, ?> object) throws IOException;
String getServerUrl();
}
void setConnection(Connection connection);
}

View file

@ -21,7 +21,6 @@ import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.google.common.collect.Iterators; import com.google.common.collect.Iterators;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainResource;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.util.Clock; import google.registry.util.Clock;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;

View file

@ -24,7 +24,6 @@ import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.google.template.soy.data.SoyMapData; import com.google.template.soy.data.SoyMapData;
import google.registry.model.pricing.PremiumPricingEngine.DomainPrices; import google.registry.model.pricing.PremiumPricingEngine.DomainPrices;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.soy.DomainCreateSoyInfo; import google.registry.tools.soy.DomainCreateSoyInfo;
import google.registry.util.StringGenerator; import google.registry.util.StringGenerator;
import javax.inject.Inject; import javax.inject.Inject;

View file

@ -25,7 +25,7 @@ import com.google.common.net.MediaType;
import java.util.List; import java.util.List;
@Parameters(separators = " =", commandDescription = "Send an HTTP command to the nomulus server.") @Parameters(separators = " =", commandDescription = "Send an HTTP command to the nomulus server.")
class CurlCommand implements ServerSideCommand { class CurlCommand implements CommandWithConnection {
private Connection connection; private Connection connection;
// HTTP Methods that are acceptable for use as values for --method. // HTTP Methods that are acceptable for use as values for --method.

View file

@ -23,7 +23,6 @@ import com.beust.jcommander.Parameters;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.registry.label.PremiumList; import google.registry.model.registry.label.PremiumList;
import google.registry.tools.Command.RemoteApiCommand;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**

View file

@ -23,7 +23,6 @@ import google.registry.model.domain.DomainResource;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldType; import google.registry.model.registry.Registry.TldType;
import google.registry.tools.Command.RemoteApiCommand;
/** /**
* Command to delete the {@link Registry} associated with the specified TLD in Datastore. * Command to delete the {@link Registry} associated with the specified TLD in Datastore.

View file

@ -18,7 +18,6 @@ import static google.registry.util.DomainNameUtils.canonicalizeDomainName;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;

View file

@ -32,7 +32,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.util.NonFinalForTesting; import google.registry.util.NonFinalForTesting;
import google.registry.util.Retrier; import google.registry.util.Retrier;
import google.registry.util.StringGenerator; import google.registry.util.StringGenerator;

View file

@ -36,7 +36,6 @@ import google.registry.model.smd.SignedMark;
import google.registry.model.smd.SignedMarkRevocationList; import google.registry.model.smd.SignedMarkRevocationList;
import google.registry.model.tmch.ClaimsListShard; import google.registry.model.tmch.ClaimsListShard;
import google.registry.tmch.TmchXmlSignature; import google.registry.tmch.TmchXmlSignature;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import google.registry.util.Clock; import google.registry.util.Clock;
import google.registry.util.Idn; import google.registry.util.Idn;

View file

@ -47,7 +47,6 @@ import google.registry.model.eppcommon.PhoneNumber;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.RegistrarAddress; import google.registry.model.registrar.RegistrarAddress;
import google.registry.model.registrar.RegistrarContact; import google.registry.model.registrar.RegistrarContact;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;

View file

@ -27,7 +27,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainResource;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import google.registry.util.Clock; import google.registry.util.Clock;
import java.net.InetAddress; import java.net.InetAddress;

View file

@ -30,7 +30,6 @@ import com.google.appengine.api.taskqueue.Queue;
import com.google.appengine.api.taskqueue.TaskOptions; import com.google.appengine.api.taskqueue.TaskOptions;
import google.registry.model.rde.RdeMode; import google.registry.model.rde.RdeMode;
import google.registry.rde.RdeStagingAction; import google.registry.rde.RdeStagingAction;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.DateTimeParameter; import google.registry.tools.params.DateTimeParameter;
import google.registry.util.AppEngineServiceUtils; import google.registry.util.AppEngineServiceUtils;
import java.util.List; import java.util.List;

View file

@ -23,7 +23,6 @@ import com.beust.jcommander.Parameters;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainResource;
import google.registry.tmch.LordnTask; import google.registry.tmch.LordnTask;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;

View file

@ -24,7 +24,6 @@ import com.beust.jcommander.Parameters;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainApplication;
import google.registry.tools.Command.RemoteApiCommand;
import java.util.List; import java.util.List;
import org.joda.time.DateTime; import org.joda.time.DateTime;

View file

@ -26,7 +26,6 @@ import com.beust.jcommander.internal.Sets;
import com.google.common.base.Ascii; import com.google.common.base.Ascii;
import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.launch.ApplicationStatus; import google.registry.model.domain.launch.ApplicationStatus;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import google.registry.util.Idn; import google.registry.util.Idn;
import java.nio.file.Files; import java.nio.file.Files;

View file

@ -22,7 +22,6 @@ import com.beust.jcommander.Parameters;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.io.Files; import com.google.common.io.Files;
import google.registry.model.tmch.ClaimsListShard; import google.registry.model.tmch.ClaimsListShard;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;

View file

@ -21,7 +21,6 @@ import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.tools.Command.RemoteApiCommand;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.joda.time.DateTime; import org.joda.time.DateTime;

View file

@ -26,7 +26,6 @@ import com.beust.jcommander.Parameters;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.CommandUtilities.ResourceType; import google.registry.tools.CommandUtilities.ResourceType;
import google.registry.xml.XmlTransformer; import google.registry.xml.XmlTransformer;
import org.joda.time.DateTime; import org.joda.time.DateTime;

View file

@ -18,7 +18,6 @@ import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import google.registry.keyring.api.KeySerializer; import google.registry.keyring.api.KeySerializer;
import google.registry.keyring.api.Keyring; import google.registry.keyring.api.Keyring;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.KeyringKeyName; import google.registry.tools.params.KeyringKeyName;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import java.io.FileOutputStream; import java.io.FileOutputStream;

View file

@ -19,7 +19,6 @@ import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.tools.Command.RemoteApiCommand;
import java.util.List; import java.util.List;
/** Command to show a registrar record. */ /** Command to show a registrar record. */

View file

@ -21,7 +21,6 @@ import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.tools.Command.RemoteApiCommand;
import java.util.List; import java.util.List;
/** /**

View file

@ -19,7 +19,6 @@ import static google.registry.model.registry.Registries.assertTldsExist;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.tools.Command.RemoteApiCommand;
import java.util.List; import java.util.List;
/** Command to show a TLD record. */ /** Command to show a TLD record. */

View file

@ -22,7 +22,6 @@ import com.beust.jcommander.Parameters;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import google.registry.keyring.api.KeyModule.Key; import google.registry.keyring.api.KeyModule.Key;
import google.registry.rde.Ghostryde; import google.registry.rde.Ghostryde;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View file

@ -26,7 +26,6 @@ import google.registry.model.common.Cursor.CursorType;
import google.registry.model.registry.Registries; import google.registry.model.registry.Registries;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldType; import google.registry.model.registry.Registry.TldType;
import google.registry.tools.Command.RemoteApiCommand;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;

View file

@ -23,7 +23,6 @@ import com.beust.jcommander.Parameter;
import com.google.common.base.VerifyException; import com.google.common.base.VerifyException;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.tools.Command.RemoteApiCommand;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View file

@ -31,7 +31,6 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.tools.Command.RemoteApiCommand;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;

View file

@ -21,7 +21,6 @@ import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
import google.registry.rde.PendingDeposit; import google.registry.rde.PendingDeposit;
import google.registry.rde.PendingDepositChecker; import google.registry.rde.PendingDepositChecker;
import google.registry.tools.Command.RemoteApiCommand;
import javax.inject.Inject; import javax.inject.Inject;
/** Command to show what escrow deposits are pending generation on the server. */ /** Command to show what escrow deposits are pending generation on the server. */

View file

@ -29,7 +29,6 @@ import com.beust.jcommander.ParametersDelegate;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import google.registry.model.ofy.ObjectifyService; import google.registry.model.ofy.ObjectifyService;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.ParameterFactory; import google.registry.tools.params.ParameterFactory;
import java.security.Security; import java.security.Security;
import java.util.Map; import java.util.Map;
@ -59,6 +58,8 @@ final class RegistryCli implements AutoCloseable, CommandRunner {
@ParametersDelegate @ParametersDelegate
private LoggingParameters loggingParams = new LoggingParameters(); private LoggingParameters loggingParams = new LoggingParameters();
RegistryToolComponent component;
// These are created lazily on first use. // These are created lazily on first use.
private AppEngineConnection connection; private AppEngineConnection connection;
private RemoteApiInstaller installer; private RemoteApiInstaller installer;
@ -76,6 +77,10 @@ final class RegistryCli implements AutoCloseable, CommandRunner {
this.commands = commands; this.commands = commands;
Security.addProvider(new BouncyCastleProvider()); Security.addProvider(new BouncyCastleProvider());
component = DaggerRegistryToolComponent.builder()
.flagsModule(new AppEngineConnectionFlags.FlagsModule(appEngineConnectionFlags))
.build();
} }
// The <? extends Class<? extends Command>> wildcard looks a little funny, but is needed so that // The <? extends Class<? extends Command>> wildcard looks a little funny, but is needed so that
@ -165,48 +170,43 @@ final class RegistryCli implements AutoCloseable, CommandRunner {
} }
} }
private void runCommand(Command command) throws Exception { private AppEngineConnection getConnection() {
// Create the main component and use it to inject the command class.
RegistryToolComponent component = DaggerRegistryToolComponent.builder()
.flagsModule(new AppEngineConnectionFlags.FlagsModule(appEngineConnectionFlags))
.build();
injectReflectively(RegistryToolComponent.class, component, command);
if (!(command instanceof RemoteApiCommand)) {
// TODO(mmuller): this should be in the try/catch LoginRequiredException in case future
// commands use our credential.
command.run();
return;
}
// Get the App Engine connection, advise the user if they are not currently logged in.. // Get the App Engine connection, advise the user if they are not currently logged in..
if (connection == null) { if (connection == null) {
connection = component.appEngineConnection(); connection = component.appEngineConnection();
} }
return connection;
}
if (command instanceof ServerSideCommand) { private void runCommand(Command command) throws Exception {
((ServerSideCommand) command).setConnection(connection); injectReflectively(RegistryToolComponent.class, component, command);
if (command instanceof CommandWithConnection) {
((CommandWithConnection) command).setConnection(getConnection());
} }
// RemoteApiCommands need to have the remote api installed to work. // RemoteApiCommands need to have the remote api installed to work.
if (installer == null) { if (command instanceof RemoteApiCommand) {
installer = new RemoteApiInstaller(); if (installer == null) {
RemoteApiOptions options = new RemoteApiOptions(); installer = new RemoteApiInstaller();
options.server(connection.getServer().getHost(), connection.getServer().getPort()); RemoteApiOptions options = new RemoteApiOptions();
if (connection.isLocalhost()) { options.server(
// Use dev credentials for localhost. getConnection().getServer().getHost(), getConnection().getServer().getPort());
options.useDevelopmentServerCredential(); if (getConnection().isLocalhost()) {
} else { // Use dev credentials for localhost.
options.useApplicationDefaultCredential(); options.useDevelopmentServerCredential();
} else {
options.useApplicationDefaultCredential();
}
installer.install(options);
} }
installer.install(options);
}
// Ensure that all entity classes are loaded before command code runs. // Ensure that all entity classes are loaded before command code runs.
ObjectifyService.initOfy(); ObjectifyService.initOfy();
// Make sure we start the command with a clean cache, so that any previous command won't // Make sure we start the command with a clean cache, so that any previous command won't
// interfere with this one. // interfere with this one.
ofy().clearSessionCache(); ofy().clearSessionCache();
}
command.run(); command.run();
} }

View file

@ -0,0 +1,23 @@
// 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.
/**
* Marker interface for commands that use the remote api.
*
* <p>Just implementing this is sufficient to use the remote api; {@link RegistryTool} will
* install it as needed.
*/
package google.registry.tools;
interface RemoteApiCommand extends Command {}

View file

@ -23,7 +23,6 @@ import com.googlecode.objectify.Key;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.RegistrarContact; import google.registry.model.registrar.RegistrarContact;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.tools.Command.RemoteApiCommand;
/** /**
* Command to re-save all environment entities to ensure that they have valid commit logs. * Command to re-save all environment entities to ensure that they have valid commit logs.

View file

@ -17,7 +17,6 @@ package google.registry.tools;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import google.registry.rde.RdeReporter; import google.registry.rde.RdeReporter;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;

View file

@ -14,31 +14,6 @@
package google.registry.tools; package google.registry.tools;
import com.google.common.net.MediaType;
import google.registry.tools.Command.RemoteApiCommand;
import java.io.IOException;
import java.util.Map;
import javax.annotation.Nullable;
/** A command that executes on the server. */ /** A command that executes on the server. */
interface ServerSideCommand extends RemoteApiCommand { interface ServerSideCommand extends CommandWithConnection, RemoteApiCommand {
/** An http connection to AppEngine. */
interface Connection {
void prefetchXsrfToken();
/** Send a POST request. TODO(mmuller): change to sendPostRequest() */
String send(
String endpoint, Map<String, ?> params, MediaType contentType, @Nullable byte[] payload)
throws IOException;
String sendGetRequest(String endpoint, Map<String, ?> params) throws IOException;
Map<String, Object> sendJson(String endpoint, Map<String, ?> object) throws IOException;
String getServerUrl();
}
void setConnection(Connection connection);
} }

View file

@ -26,7 +26,6 @@ import com.google.re2j.Pattern;
import google.registry.config.RegistryEnvironment; import google.registry.config.RegistryEnvironment;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.registry.Registry.TldState; import google.registry.model.registry.Registry.TldState;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import google.registry.util.StringGenerator; import google.registry.util.StringGenerator;
import java.nio.file.Path; import java.nio.file.Path;

View file

@ -25,7 +25,6 @@ import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.launch.LaunchNotice.InvalidChecksumException; import google.registry.model.domain.launch.LaunchNotice.InvalidChecksumException;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.tools.Command.RemoteApiCommand;
import org.joda.time.DateTime; import org.joda.time.DateTime;
/** Command to update the claims notice on a domain application. */ /** Command to update the claims notice on a domain application. */

View file

@ -21,7 +21,6 @@ import static google.registry.keyring.api.KeySerializer.deserializeString;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import google.registry.keyring.kms.KmsUpdater; import google.registry.keyring.kms.KmsUpdater;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.KeyringKeyName; import google.registry.tools.params.KeyringKeyName;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import java.nio.file.Files; import java.nio.file.Files;

View file

@ -30,7 +30,6 @@ import google.registry.model.domain.DomainApplication;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.model.smd.EncodedSignedMark; import google.registry.model.smd.EncodedSignedMark;
import google.registry.model.smd.SignedMark; import google.registry.model.smd.SignedMark;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;

View file

@ -23,7 +23,6 @@ import com.google.common.base.Joiner;
import com.google.common.io.Files; import com.google.common.io.Files;
import google.registry.model.tmch.ClaimsListShard; import google.registry.model.tmch.ClaimsListShard;
import google.registry.tmch.ClaimsListParser; import google.registry.tmch.ClaimsListParser;
import google.registry.tools.Command.RemoteApiCommand;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -26,7 +26,6 @@ import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import google.registry.flows.TlsCredentials; import google.registry.flows.TlsCredentials;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.tools.params.PathParameter; import google.registry.tools.params.PathParameter;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;

View file

@ -17,7 +17,6 @@ package google.registry.tools;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import google.registry.tools.Command.RemoteApiCommand;
import google.registry.whois.Whois; import google.registry.whois.Whois;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;

View file

@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.testing.UriParameters; import google.registry.testing.UriParameters;
import google.registry.tools.ServerSideCommand.Connection; import google.registry.tools.CommandWithConnection.Connection;
import java.io.File; import java.io.File;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;

View file

@ -28,7 +28,7 @@ import com.beust.jcommander.ParameterException;
import com.google.common.base.VerifyException; import com.google.common.base.VerifyException;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.tools.ServerSideCommand.Connection; import google.registry.tools.CommandWithConnection.Connection;
import google.registry.tools.server.CreatePremiumListAction; import google.registry.tools.server.CreatePremiumListAction;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;

View file

@ -34,7 +34,7 @@ import com.google.common.collect.Range;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.testing.CertificateSamples; import google.registry.testing.CertificateSamples;
import google.registry.tools.ServerSideCommand.Connection; import google.registry.tools.CommandWithConnection.Connection;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
import org.joda.money.CurrencyUnit; import org.joda.money.CurrencyUnit;

View file

@ -21,7 +21,7 @@ import static org.mockito.Mockito.verify;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.tools.ServerSideCommand.Connection; import google.registry.tools.CommandWithConnection.Connection;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mock; import org.mockito.Mock;

View file

@ -22,7 +22,7 @@ import static org.mockito.Mockito.verify;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.tools.ServerSideCommand.Connection; import google.registry.tools.CommandWithConnection.Connection;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;

View file

@ -28,7 +28,7 @@ import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.tools.ServerSideCommand.Connection; import google.registry.tools.CommandWithConnection.Connection;
import google.registry.tools.server.ToolsTestData; import google.registry.tools.server.ToolsTestData;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.Map; import java.util.Map;

View file

@ -28,7 +28,7 @@ import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.tools.ServerSideCommand.Connection; import google.registry.tools.CommandWithConnection.Connection;
import java.util.Optional; import java.util.Optional;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;

View file

@ -24,7 +24,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.tools.ServerSideCommand.Connection; import google.registry.tools.CommandWithConnection.Connection;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;

View file

@ -23,7 +23,7 @@ import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.net.MediaType; import com.google.common.net.MediaType;
import google.registry.tools.ServerSideCommand.Connection; import google.registry.tools.CommandWithConnection.Connection;
import google.registry.tools.server.UpdatePremiumListAction; import google.registry.tools.server.UpdatePremiumListAction;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;

View file

@ -27,7 +27,7 @@ import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.tools.ServerSideCommand.Connection; import google.registry.tools.CommandWithConnection.Connection;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mock; import org.mockito.Mock;