mirror of
https://github.com/google/nomulus
synced 2026-09-20 06:54:43 +00:00
Rename AppEngineConnection to ServiceConnection (#1857)
It doesn't actually use any App Engine libraries or code -- it's just a generic connection with authentication to a service. This also involves changing that block of config to be "gcpProject" instead of "appEngine" since it's more generic. Note: this will require an internal PR as well to change the corresponding private config block
This commit is contained in:
@@ -54,8 +54,7 @@ import org.mockito.Mock;
|
||||
/** Unit tests for {@link CreateRegistrarCommand}. */
|
||||
class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand> {
|
||||
|
||||
@Mock private AppEngineConnection connection;
|
||||
|
||||
@Mock private ServiceConnection connection;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.mockito.Mock;
|
||||
/** Unit tests for {@link CreateRegistrarGroupsCommand}. */
|
||||
class CreateRegistrarGroupsCommandTest extends CommandTestCase<CreateRegistrarGroupsCommand> {
|
||||
|
||||
@Mock private AppEngineConnection connection;
|
||||
@Mock private ServiceConnection connection;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
|
||||
@@ -40,8 +40,8 @@ import org.mockito.quality.Strictness;
|
||||
/** Unit tests for {@link CurlCommand}. */
|
||||
class CurlCommandTest extends CommandTestCase<CurlCommand> {
|
||||
|
||||
@Mock private AppEngineConnection connection;
|
||||
@Mock private AppEngineConnection connectionForService;
|
||||
@Mock private ServiceConnection connection;
|
||||
@Mock private ServiceConnection connectionForService;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
|
||||
@@ -36,9 +36,8 @@ import org.mockito.ArgumentCaptor;
|
||||
/**
|
||||
* Class for verifying EPP commands sent to the server via the tool endpoint.
|
||||
*
|
||||
* <p>Provides its own (mock) {@link AppEngineConnection} that will be monitored for EPP
|
||||
* transmission. This Connection needs to be registered with the tool endpoint - something like
|
||||
* this:
|
||||
* <p>Provides its own (mock) {@link ServiceConnection} that will be monitored for EPP transmission.
|
||||
* This Connection needs to be registered with the tool endpoint - something like this:
|
||||
*
|
||||
* <pre>{@code
|
||||
* SomeToolCommand command = ...;
|
||||
@@ -49,7 +48,7 @@ import org.mockito.ArgumentCaptor;
|
||||
*/
|
||||
public class EppToolVerifier {
|
||||
|
||||
private final AppEngineConnection connection = mock(AppEngineConnection.class);
|
||||
private final ServiceConnection connection = mock(ServiceConnection.class);
|
||||
|
||||
private String registrarId;
|
||||
private boolean superuser;
|
||||
@@ -196,7 +195,7 @@ public class EppToolVerifier {
|
||||
}
|
||||
|
||||
/** Returns the (mock) Connection that is being monitored by this verifier. */
|
||||
private AppEngineConnection getConnection() {
|
||||
private ServiceConnection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -33,11 +33,11 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/** Unit tests for {@link google.registry.tools.AppEngineConnection}. */
|
||||
/** Unit tests for {@link ServiceConnection}. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
final class AppEngineConnectionTest {
|
||||
final class GcpProjectConnectionTest {
|
||||
|
||||
private AppEngineConnection connection;
|
||||
private ServiceConnection connection;
|
||||
private TestHttpTransport httpTransport;
|
||||
private TestLowLevelHttpRequest lowLevelHttpRequest;
|
||||
@Mock LowLevelHttpResponse lowLevelHttpResponse;
|
||||
@@ -84,7 +84,7 @@ final class AppEngineConnectionTest {
|
||||
.thenReturn(new ByteArrayInputStream("MyContent".getBytes(UTF_8)));
|
||||
when(lowLevelHttpResponse.getStatusCode()).thenReturn(200);
|
||||
|
||||
connection = new AppEngineConnection();
|
||||
connection = new ServiceConnection();
|
||||
httpTransport = new TestHttpTransport();
|
||||
connection.requestFactory = httpTransport.createRequestFactory();
|
||||
}
|
||||
@@ -37,7 +37,7 @@ import org.mockito.Mock;
|
||||
public abstract class ListObjectsCommandTestCase<C extends ListObjectsCommand>
|
||||
extends CommandTestCase<C> {
|
||||
|
||||
@Mock AppEngineConnection connection;
|
||||
@Mock ServiceConnection connection;
|
||||
|
||||
/** Where to find the servlet task; set by the subclass. */
|
||||
abstract String getTaskPath();
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.mockito.Mock;
|
||||
/** Unit tests for {@link LoadTestCommand}. */
|
||||
class LoadTestCommandTest extends CommandTestCase<LoadTestCommand> {
|
||||
|
||||
@Mock private AppEngineConnection connection;
|
||||
@Mock private ServiceConnection connection;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
|
||||
@@ -53,8 +53,8 @@ public class RequestFactoryModuleTest {
|
||||
@Test
|
||||
void test_provideHttpRequestFactory_localhost() throws Exception {
|
||||
// Make sure that localhost creates a request factory with an initializer.
|
||||
boolean origIsLocal = RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal;
|
||||
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = true;
|
||||
boolean origIsLocal = RegistryConfig.CONFIG_SETTINGS.get().gcpProject.isLocal;
|
||||
RegistryConfig.CONFIG_SETTINGS.get().gcpProject.isLocal = true;
|
||||
try {
|
||||
HttpRequestFactory factory =
|
||||
RequestFactoryModule.provideHttpRequestFactory(credentialsBundle);
|
||||
@@ -64,7 +64,7 @@ public class RequestFactoryModuleTest {
|
||||
initializer.initialize(request);
|
||||
verifyNoInteractions(httpRequestInitializer);
|
||||
} finally {
|
||||
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = origIsLocal;
|
||||
RegistryConfig.CONFIG_SETTINGS.get().gcpProject.isLocal = origIsLocal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ public class RequestFactoryModuleTest {
|
||||
void test_provideHttpRequestFactory_remote() throws Exception {
|
||||
when(credentialsBundle.getHttpRequestInitializer()).thenReturn(httpRequestInitializer);
|
||||
// Make sure that example.com creates a request factory with the UNITTEST client id but no
|
||||
boolean origIsLocal = RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal;
|
||||
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = false;
|
||||
boolean origIsLocal = RegistryConfig.CONFIG_SETTINGS.get().gcpProject.isLocal;
|
||||
RegistryConfig.CONFIG_SETTINGS.get().gcpProject.isLocal = false;
|
||||
try {
|
||||
HttpRequestFactory factory =
|
||||
RequestFactoryModule.provideHttpRequestFactory(credentialsBundle);
|
||||
@@ -86,7 +86,7 @@ public class RequestFactoryModuleTest {
|
||||
assertThat(request.getReadTimeout()).isEqualTo(REQUEST_TIMEOUT_MS);
|
||||
verifyNoMoreInteractions(httpRequestInitializer);
|
||||
} finally {
|
||||
RegistryConfig.CONFIG_SETTINGS.get().appEngine.isLocal = origIsLocal;
|
||||
RegistryConfig.CONFIG_SETTINGS.get().gcpProject.isLocal = origIsLocal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.mockito.quality.Strictness;
|
||||
/** Unit tests for {@link VerifyOteCommand}. */
|
||||
class VerifyOteCommandTest extends CommandTestCase<VerifyOteCommand> {
|
||||
|
||||
@Mock private AppEngineConnection connection;
|
||||
@Mock private ServiceConnection connection;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user