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:
guyben 2018-10-12 19:54:53 -07:00 committed by Ben McIlwain
parent bec7a91cfc
commit 8d93cd8edf
19 changed files with 539 additions and 388 deletions

View file

@ -33,7 +33,7 @@ import google.registry.request.auth.UserAuthInfo;
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.Optional;
import org.joda.time.DateTime;
import org.json.simple.JSONValue;
@ -52,7 +52,8 @@ public class RdapHelpActionTest {
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 User user = new User("rdap.user@example.com", "gmail.com", "12345");
private final UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false);
private final RdapMetrics rdapMetrics = mock(RdapMetrics.class);
@ -67,7 +68,7 @@ public class RdapHelpActionTest {
action.clock = clock;
action.fullServletPath = "https://example.tld/rdap";
action.requestMethod = Action.Method.GET;
action.sessionUtils = sessionUtils;
action.registrarAccessor = registrarAccessor;
action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo);
action.includeDeletedParam = Optional.empty();
action.registrarParam = Optional.empty();