mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 17:01:51 +02:00
Break SessionSource out of SessionMetadata and rename it EppRequestSource.
The "SessionSource" has nothing to do with sessions (and it's often used in sessionless contexts). What it does indicate is the endpoint used to make the request. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125295224
This commit is contained in:
parent
fd6c4888db
commit
2a3a3fbc30
25 changed files with 94 additions and 95 deletions
|
@ -44,7 +44,7 @@ public class EppConsoleActionTest extends ShardableTestCase {
|
|||
.build();
|
||||
|
||||
@Test
|
||||
public void testPassesArgumentsThrough() {
|
||||
public void doTest() {
|
||||
EppConsoleAction action = new EppConsoleAction();
|
||||
action.inputXmlBytes = INPUT_XML_BYTES;
|
||||
action.session = new BasicHttpSession();
|
||||
|
@ -57,6 +57,7 @@ public class EppConsoleActionTest extends ShardableTestCase {
|
|||
verify(action.eppRequestHandler).executeEpp(
|
||||
metadataCaptor.capture(),
|
||||
credentialsCaptor.capture(),
|
||||
eq(EppRequestSource.CONSOLE),
|
||||
eq(false),
|
||||
eq(false),
|
||||
eq(INPUT_XML_BYTES));
|
||||
|
|
|
@ -117,7 +117,13 @@ public class EppTestCase extends ShardableTestCase {
|
|||
handler.eppController = new EppController();
|
||||
handler.eppController.clock = clock;
|
||||
handler.eppController.metrics = mock(EppMetrics.class);
|
||||
handler.executeEpp(sessionMetadata, credentials, false, isSuperuser, inputXml.getBytes(UTF_8));
|
||||
handler.executeEpp(
|
||||
sessionMetadata,
|
||||
credentials,
|
||||
EppRequestSource.UNIT_TEST,
|
||||
false,
|
||||
isSuperuser,
|
||||
inputXml.getBytes(UTF_8));
|
||||
assertThat(response.getStatus()).isEqualTo(SC_OK);
|
||||
assertThat(response.getContentType()).isEqualTo(APPLICATION_EPP_XML_UTF8);
|
||||
String result = response.getPayload();
|
||||
|
|
|
@ -51,6 +51,7 @@ public class EppTlsActionTest extends ShardableTestCase {
|
|||
verify(action.eppRequestHandler).executeEpp(
|
||||
captor.capture(),
|
||||
same(action.tlsCredentials),
|
||||
eq(EppRequestSource.TLS),
|
||||
eq(false),
|
||||
eq(false),
|
||||
eq(INPUT_XML_BYTES));
|
||||
|
|
|
@ -42,6 +42,7 @@ public class EppToolActionTest {
|
|||
verify(action.eppRequestHandler).executeEpp(
|
||||
captor.capture(),
|
||||
isA(PasswordOnlyTransportCredentials.class),
|
||||
eq(EppRequestSource.TOOL),
|
||||
eq(isDryRun),
|
||||
eq(isSuperuser),
|
||||
eq(action.xml.getBytes(UTF_8)));
|
||||
|
|
|
@ -34,7 +34,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import google.registry.flows.SessionMetadata.SessionSource;
|
||||
import google.registry.flows.picker.FlowPicker;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.domain.GracePeriod;
|
||||
|
@ -92,13 +91,13 @@ public abstract class FlowTestCase<F extends Flow> {
|
|||
protected SessionMetadata sessionMetadata;
|
||||
protected FakeClock clock = new FakeClock(DateTime.now(UTC));
|
||||
protected TransportCredentials credentials = new PasswordOnlyTransportCredentials();
|
||||
protected EppRequestSource eppRequestSource = EppRequestSource.UNIT_TEST;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception {
|
||||
sessionMetadata = new TestSessionMetadata();
|
||||
sessionMetadata.setClientId("TheRegistrar");
|
||||
sessionMetadata.setServiceExtensionUris(ProtocolDefinition.getVisibleServiceExtensionUris());
|
||||
sessionMetadata.setSessionSource(SessionSource.NONE);
|
||||
ofy().saveWithoutBackup().entity(new ClaimsListSingleton()).now();
|
||||
inject.setStaticField(Ofy.class, "clock", clock); // For transactional flows.
|
||||
}
|
||||
|
@ -133,6 +132,7 @@ public abstract class FlowTestCase<F extends Flow> {
|
|||
getTrid(),
|
||||
sessionMetadata,
|
||||
credentials,
|
||||
eppRequestSource,
|
||||
commitMode.equals(CommitMode.DRY_RUN),
|
||||
userPrivileges.equals(UserPrivileges.SUPERUSER),
|
||||
"<xml></xml>".getBytes(),
|
||||
|
|
|
@ -47,12 +47,12 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.ImmutableSortedMap;
|
||||
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.LoggedInFlow.UndeclaredServiceExtensionException;
|
||||
import google.registry.flows.ResourceCreateFlow.ResourceAlreadyExistsException;
|
||||
import google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException;
|
||||
import google.registry.flows.ResourceFlow.BadCommandForRegistryPhaseException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.SessionMetadata.SessionSource;
|
||||
import google.registry.flows.domain.BaseDomainCreateFlow.AcceptedTooLongAgoException;
|
||||
import google.registry.flows.domain.BaseDomainCreateFlow.ClaimsPeriodEndedException;
|
||||
import google.registry.flows.domain.BaseDomainCreateFlow.ExpiredClaimException;
|
||||
|
@ -287,7 +287,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
|
||||
@Test
|
||||
public void testSuccess_anchorTenantViaExtension() throws Exception {
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL);
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_create_anchor_tenant.xml");
|
||||
persistContactsAndHosts();
|
||||
runFlowAssertResponse(readFile("domain_create_response.xml"));
|
||||
|
@ -335,7 +335,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
|
||||
@Test
|
||||
public void testSuccess_metadata() throws Exception {
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL);
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_create_metadata.xml");
|
||||
persistContactsAndHosts();
|
||||
doSuccessfulTest();
|
||||
|
@ -1086,7 +1086,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
public void testSuccess_qlpSunriseRegistration() throws Exception {
|
||||
createTld("tld", TldState.SUNRISE);
|
||||
setEppInput("domain_create_registration_qlp_sunrise.xml");
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL); // Only tools can pass in metadata.
|
||||
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
|
||||
persistContactsAndHosts();
|
||||
runFlowAssertResponse(readFile("domain_create_response.xml"));
|
||||
assertSuccessfulCreate("tld", true);
|
||||
|
@ -1098,7 +1098,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
createTld("tld", TldState.SUNRISE);
|
||||
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
|
||||
setEppInput("domain_create_registration_qlp_sunrise_encoded_signed_mark.xml");
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL); // Only tools can pass in metadata.
|
||||
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
|
||||
persistContactsAndHosts();
|
||||
runFlowAssertResponse(readFile("domain_create_response_encoded_signed_mark_name.xml"));
|
||||
assertSuccessfulCreate("tld", true);
|
||||
|
@ -1110,7 +1110,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
createTld("tld", TldState.SUNRISE);
|
||||
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
|
||||
setEppInput("domain_create_registration_qlp_sunrise_claims_notice.xml");
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL); // Only tools can pass in metadata.
|
||||
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
|
||||
persistContactsAndHosts();
|
||||
runFlowAssertResponse(readFile("domain_create_response_claims.xml"));
|
||||
assertSuccessfulCreate("tld", true);
|
||||
|
@ -1151,7 +1151,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
public void testSuccess_qlpSunrushRegistration() throws Exception {
|
||||
createTld("tld", TldState.SUNRUSH);
|
||||
setEppInput("domain_create_registration_qlp_sunrush.xml");
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL); // Only tools can pass in metadata.
|
||||
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
|
||||
persistContactsAndHosts();
|
||||
runFlowAssertResponse(readFile("domain_create_response.xml"));
|
||||
assertSuccessfulCreate("tld", true);
|
||||
|
@ -1163,7 +1163,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
createTld("tld", TldState.SUNRUSH);
|
||||
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
|
||||
setEppInput("domain_create_registration_qlp_sunrush_encoded_signed_mark.xml");
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL); // Only tools can pass in metadata.
|
||||
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
|
||||
persistContactsAndHosts();
|
||||
runFlowAssertResponse(readFile("domain_create_response_encoded_signed_mark_name.xml"));
|
||||
assertSuccessfulCreate("tld", true);
|
||||
|
@ -1175,7 +1175,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
createTld("tld", TldState.SUNRUSH);
|
||||
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
|
||||
setEppInput("domain_create_registration_qlp_sunrush_claims_notice.xml");
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL); // Only tools can pass in metadata.
|
||||
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
|
||||
persistContactsAndHosts();
|
||||
runFlowAssertResponse(readFile("domain_create_response_claims.xml"));
|
||||
assertSuccessfulCreate("tld", true);
|
||||
|
@ -1203,7 +1203,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
public void testSuccess_qlpLandrushRegistration() throws Exception {
|
||||
createTld("tld", TldState.LANDRUSH);
|
||||
setEppInput("domain_create_registration_qlp_landrush.xml");
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL); // Only tools can pass in metadata.
|
||||
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
|
||||
persistContactsAndHosts();
|
||||
runFlowAssertResponse(readFile("domain_create_response.xml"));
|
||||
assertSuccessfulCreate("tld", true);
|
||||
|
@ -1216,7 +1216,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
createTld("tld", TldState.LANDRUSH);
|
||||
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
|
||||
setEppInput("domain_create_registration_qlp_landrush_encoded_signed_mark.xml");
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL); // Only tools can pass in metadata.
|
||||
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
|
||||
persistContactsAndHosts();
|
||||
runFlow();
|
||||
}
|
||||
|
@ -1226,7 +1226,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
|||
createTld("tld", TldState.LANDRUSH);
|
||||
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
|
||||
setEppInput("domain_create_registration_qlp_landrush_claims_notice.xml");
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL); // Only tools can pass in metadata.
|
||||
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
|
||||
persistContactsAndHosts();
|
||||
runFlowAssertResponse(readFile("domain_create_response_claims.xml"));
|
||||
assertSuccessfulCreate("tld", true);
|
||||
|
|
|
@ -44,11 +44,11 @@ import com.google.common.collect.Iterables;
|
|||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
import google.registry.flows.ResourceMutateFlow.ResourceToMutateDoesNotExistException;
|
||||
import google.registry.flows.SessionMetadata.SessionSource;
|
||||
import google.registry.flows.SingleResourceFlow.ResourceStatusProhibitsOperationException;
|
||||
import google.registry.flows.domain.DomainDeleteFlow.DomainToDeleteHasHostsException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
|
||||
|
@ -582,7 +582,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
|
||||
@Test
|
||||
public void testSuccess_metadata() throws Exception {
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL);
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_delete_metadata.xml");
|
||||
setupSuccessfulTest();
|
||||
clock.advanceOneMilli();
|
||||
|
|
|
@ -42,6 +42,7 @@ import com.googlecode.objectify.Key;
|
|||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.ResourceCreateOrMutateFlow.OnlyToolCanPassMetadataException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
|
@ -49,7 +50,6 @@ import google.registry.flows.ResourceMutateFlow.ResourceToMutateDoesNotExistExce
|
|||
import google.registry.flows.ResourceUpdateFlow.AddRemoveSameValueEppException;
|
||||
import google.registry.flows.ResourceUpdateFlow.ResourceHasClientUpdateProhibitedException;
|
||||
import google.registry.flows.ResourceUpdateFlow.StatusNotClientSettableException;
|
||||
import google.registry.flows.SessionMetadata.SessionSource;
|
||||
import google.registry.flows.SingleResourceFlow.ResourceStatusProhibitsOperationException;
|
||||
import google.registry.flows.domain.BaseDomainUpdateFlow.EmptySecDnsUpdateException;
|
||||
import google.registry.flows.domain.BaseDomainUpdateFlow.MaxSigLifeChangeNotSupportedException;
|
||||
|
@ -411,7 +411,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
|
||||
@Test
|
||||
public void testSuccess_metadata() throws Exception {
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL);
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setEppInput("domain_update_metadata.xml");
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
@ -664,7 +664,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
|
||||
@Test
|
||||
public void testSuccess_addServerStatusBillingEvent() throws Exception {
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL);
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
doServerStatusBillingTest("domain_update_add_server_status.xml", true);
|
||||
|
@ -672,7 +672,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
|
||||
@Test
|
||||
public void testSuccess_noBillingOnPreExistingServerStatus() throws Exception {
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL);
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
DomainResource addStatusDomain = persistActiveDomain(getUniqueIdFromCommand());
|
||||
persistResource(
|
||||
addStatusDomain.asBuilder()
|
||||
|
@ -683,7 +683,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
|
||||
@Test
|
||||
public void testSuccess_removeServerStatusBillingEvent() throws Exception {
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL);
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistReferencedEntities();
|
||||
DomainResource removeStatusDomain = persistDomain();
|
||||
persistResource(
|
||||
|
@ -695,7 +695,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
|
||||
@Test
|
||||
public void testSuccess_changeServerStatusBillingEvent() throws Exception {
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL);
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistReferencedEntities();
|
||||
DomainResource changeStatusDomain = persistDomain();
|
||||
persistResource(
|
||||
|
@ -719,7 +719,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
|
||||
@Test
|
||||
public void testSuccess_noBillingEventOnServerStatusChangeNotFromRegistrar() throws Exception {
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL);
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
persistActiveDomain(getUniqueIdFromCommand());
|
||||
doServerStatusBillingTest("domain_update_add_server_status_non_registrar.xml", false);
|
||||
}
|
||||
|
|
|
@ -42,12 +42,12 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
|
||||
import google.registry.flows.ResourceMutateFlow.ResourceToMutateDoesNotExistException;
|
||||
import google.registry.flows.ResourceUpdateFlow.ResourceHasClientUpdateProhibitedException;
|
||||
import google.registry.flows.ResourceUpdateFlow.StatusNotClientSettableException;
|
||||
import google.registry.flows.SessionMetadata.SessionSource;
|
||||
import google.registry.flows.SingleResourceFlow.ResourceStatusProhibitsOperationException;
|
||||
import google.registry.flows.async.DnsRefreshForHostRenameAction;
|
||||
import google.registry.flows.host.HostFlowUtils.HostNameTooShallowException;
|
||||
|
@ -895,7 +895,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
persistActiveHost("ns1.example.tld");
|
||||
clock.advanceOneMilli();
|
||||
setEppInput("host_update_metadata.xml");
|
||||
sessionMetadata.setSessionSource(SessionSource.TOOL);
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
runFlowAssertResponse(readFile("host_update_response.xml"));
|
||||
assertAboutHistoryEntries()
|
||||
.that(getOnlyHistoryEntryOfType(reloadResourceByUniqueId(), HistoryEntry.Type.HOST_UPDATE))
|
||||
|
|
|
@ -30,6 +30,7 @@ import static org.joda.time.Duration.standardDays;
|
|||
|
||||
import com.googlecode.objectify.Key;
|
||||
|
||||
import google.registry.flows.EppRequestSource;
|
||||
import google.registry.flows.FlowRunner;
|
||||
import google.registry.flows.PasswordOnlyTransportCredentials;
|
||||
import google.registry.flows.SessionMetadata;
|
||||
|
@ -86,6 +87,7 @@ public class EppResourceUtilsTest {
|
|||
Trid.create(null, "server-trid"),
|
||||
sessionMetadata,
|
||||
new PasswordOnlyTransportCredentials(),
|
||||
EppRequestSource.UNIT_TEST,
|
||||
false,
|
||||
false,
|
||||
"<xml></xml>".getBytes(),
|
||||
|
|
|
@ -25,7 +25,6 @@ public class TestSessionMetadata extends SessionMetadata {
|
|||
|
||||
private final Map<String, Object> properties = new HashMap<>();
|
||||
private boolean isValid = true;
|
||||
private SessionSource sessionSource = SessionSource.NONE;
|
||||
|
||||
@Override
|
||||
protected void setProperty(String key, Object value) {
|
||||
|
@ -47,16 +46,6 @@ public class TestSessionMetadata extends SessionMetadata {
|
|||
isValid = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionSource getSessionSource() {
|
||||
return sessionSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSessionSource(SessionSource source) {
|
||||
sessionSource = source;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue