mirror of
https://github.com/google/nomulus.git
synced 2025-08-02 07:52:11 +02:00
Refactor SessionUtil, and Add dropdown menu to switch clientId
SessionUtil is renames AuthenticatedRegistrarAccessor, as it's used to access a registrar for an authenticated user. It will now be injected with the AuthResult instead of receiving it in every function call, since there's only one "legal" AuthResult to use. The AccessType names are changed from READ_ONLY/READ_WRITE to READ/UPDATE, as it was confusing that a user could have both READ_ONLY AND READ_WRITE access to the same registrar. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=216958306
This commit is contained in:
parent
bec7a91cfc
commit
8d93cd8edf
19 changed files with 539 additions and 388 deletions
|
@ -49,7 +49,7 @@ import google.registry.testing.AppEngineRule;
|
|||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.InjectRule;
|
||||
import google.registry.ui.server.registrar.SessionUtils;
|
||||
import google.registry.ui.server.registrar.AuthenticatedRegistrarAccessor;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -75,7 +75,8 @@ public class RdapEntityActionTest {
|
|||
|
||||
private final FakeResponse response = new FakeResponse();
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01TZ"));
|
||||
private final SessionUtils sessionUtils = mock(SessionUtils.class);
|
||||
private final AuthenticatedRegistrarAccessor registrarAccessor =
|
||||
mock(AuthenticatedRegistrarAccessor.class);
|
||||
private final RdapMetrics rdapMetrics = mock(RdapMetrics.class);
|
||||
|
||||
private RdapEntityAction action;
|
||||
|
@ -176,18 +177,18 @@ public class RdapEntityActionTest {
|
|||
action.formatOutputParam = Optional.empty();
|
||||
action.rdapJsonFormatter = RdapTestHelper.getTestRdapJsonFormatter();
|
||||
action.rdapWhoisServer = null;
|
||||
action.sessionUtils = sessionUtils;
|
||||
action.registrarAccessor = registrarAccessor;
|
||||
action.authResult = AUTH_RESULT;
|
||||
action.rdapMetrics = rdapMetrics;
|
||||
}
|
||||
|
||||
private void login(String registrar) {
|
||||
when(sessionUtils.guessClientIdForUser(AUTH_RESULT)).thenReturn(registrar);
|
||||
when(registrarAccessor.guessClientId()).thenReturn(registrar);
|
||||
}
|
||||
|
||||
private void loginAsAdmin() {
|
||||
action.authResult = AUTH_RESULT_ADMIN;
|
||||
when(sessionUtils.guessClientIdForUser(AUTH_RESULT_ADMIN)).thenReturn("irrelevant");
|
||||
when(registrarAccessor.guessClientId()).thenReturn("irrelevant");
|
||||
}
|
||||
|
||||
private Object generateActualJson(String name) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue