mirror of
https://github.com/google/nomulus.git
synced 2025-08-03 16:32:11 +02:00
Remove Registrar caching from all console actions
Caching turns out to be an anti-pattern for the console. If we use it, changes from the user just get obliterated by the older, cached version the next time the console refreshes (and it happens to refresh after every update). Caching is also not very useful here, as the amount of database access driven by the console is very small. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190650931
This commit is contained in:
parent
6dec95b980
commit
e1ad4d663c
10 changed files with 12 additions and 18 deletions
|
@ -19,7 +19,6 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
|||
import static google.registry.testing.ReflectiveFieldExtractor.extractField;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -94,7 +93,7 @@ public class RegistrarPaymentActionTest {
|
|||
when(braintreeGateway.transaction()).thenReturn(transactionGateway);
|
||||
when(transactionGateway.sale(any(TransactionRequest.class))).thenReturn(result);
|
||||
when(sessionUtils.getRegistrarForAuthResult(
|
||||
any(HttpServletRequest.class), any(AuthResult.class), anyBoolean()))
|
||||
any(HttpServletRequest.class), any(AuthResult.class)))
|
||||
.thenReturn(loadRegistrar("TheRegistrar"));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
|||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
@ -69,7 +68,7 @@ public class RegistrarPaymentSetupActionTest {
|
|||
.setBillingMethod(Registrar.BillingMethod.BRAINTREE)
|
||||
.build());
|
||||
when(sessionUtils.getRegistrarForAuthResult(
|
||||
any(HttpServletRequest.class), any(AuthResult.class), anyBoolean()))
|
||||
any(HttpServletRequest.class), any(AuthResult.class)))
|
||||
.thenReturn(registrar);
|
||||
when(braintreeGateway.clientToken()).thenReturn(clientTokenGateway);
|
||||
}
|
||||
|
@ -112,7 +111,7 @@ public class RegistrarPaymentSetupActionTest {
|
|||
.setBillingMethod(Registrar.BillingMethod.EXTERNAL)
|
||||
.build());
|
||||
when(sessionUtils.getRegistrarForAuthResult(
|
||||
any(HttpServletRequest.class), any(AuthResult.class), anyBoolean()))
|
||||
any(HttpServletRequest.class), any(AuthResult.class)))
|
||||
.thenReturn(registrar);
|
||||
assertThat(action.handleJsonRequest(ImmutableMap.of()))
|
||||
.containsExactly(
|
||||
|
|
|
@ -22,7 +22,6 @@ import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
|||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
@ -72,7 +71,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
|
|||
@Test
|
||||
public void testRead_notAuthorized_failure() throws Exception {
|
||||
when(sessionUtils.getRegistrarForAuthResult(
|
||||
any(HttpServletRequest.class), any(AuthResult.class), anyBoolean()))
|
||||
any(HttpServletRequest.class), any(AuthResult.class)))
|
||||
.thenThrow(new ForbiddenException("Not authorized to access Registrar Console"));
|
||||
assertThrows(ForbiddenException.class, () -> action.handleJsonRequest(ImmutableMap.of()));
|
||||
assertNoTasksEnqueued("sheet");
|
||||
|
|
|
@ -106,7 +106,7 @@ public class RegistrarSettingsActionTestCase {
|
|||
when(rsp.getWriter()).thenReturn(new PrintWriter(writer));
|
||||
when(req.getContentType()).thenReturn("application/json");
|
||||
when(req.getReader()).thenReturn(createJsonPayload(ImmutableMap.of("op", "read")));
|
||||
when(sessionUtils.getRegistrarForAuthResult(req, action.authResult, false))
|
||||
when(sessionUtils.getRegistrarForAuthResult(req, action.authResult))
|
||||
.thenReturn(loadRegistrar(CLIENT_ID));
|
||||
when(modulesService.getVersionHostname("backend", null)).thenReturn("backend.hostname");
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public class SecuritySettingsTest extends RegistrarSettingsActionTestCase {
|
|||
.setClientCertificate(SAMPLE_CERT, START_OF_TIME)
|
||||
.setFailoverClientCertificate(SAMPLE_CERT2, START_OF_TIME)
|
||||
.build());
|
||||
when(sessionUtils.getRegistrarForAuthResult(req, action.authResult, false))
|
||||
when(sessionUtils.getRegistrarForAuthResult(req, action.authResult))
|
||||
.thenReturn(initialRegistrar);
|
||||
Map<String, Object> jsonMap = initialRegistrar.toJsonMap();
|
||||
jsonMap.put("clientCertificate", null);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue