mirror of
https://github.com/google/nomulus
synced 2026-02-08 05:50:24 +00:00
Add more absent clTrid unit tests
In RFC 5730, clTrid is specified as optional. We ran into an error earlier this year in which a registrar was not passing a client transaction id and we didn't handle it correctly. So, this CL adds some tests of common EPP operations verify that they work correctly when the clTrid is not specified. This also slightly improves some flow logic to make it more obvious at first glance that clTrid is indeed optional. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=202000845
This commit is contained in:
@@ -156,7 +156,8 @@ public class FlowModule {
|
||||
@FlowScope
|
||||
Trid provideTrid(EppInput eppInput, ServerTridProvider serverTridProvider) {
|
||||
return Trid.create(
|
||||
eppInput.getCommandWrapper().getClTrid(), serverTridProvider.createServerTrid());
|
||||
eppInput.getCommandWrapper().getClTrid().orElse(null),
|
||||
serverTridProvider.createServerTrid());
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -124,9 +124,8 @@ public final class AsyncFlowEnqueuer {
|
||||
.param(PARAM_SERVER_TRANSACTION_ID, trid.getServerTransactionId())
|
||||
.param(PARAM_IS_SUPERUSER, Boolean.toString(isSuperuser))
|
||||
.param(PARAM_REQUESTED_TIME, now.toString());
|
||||
if (trid.getClientTransactionId().isPresent()) {
|
||||
task.param(PARAM_CLIENT_TRANSACTION_ID, trid.getClientTransactionId().get());
|
||||
}
|
||||
trid.getClientTransactionId()
|
||||
.ifPresent(clTrid -> task.param(PARAM_CLIENT_TRANSACTION_ID, clTrid));
|
||||
addTaskToQueueWithRetry(asyncDeletePullQueue, task);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ package google.registry.model.eppcommon;
|
||||
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.googlecode.objectify.annotation.Embed;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import java.util.Optional;
|
||||
@@ -40,6 +39,7 @@ public class Trid extends ImmutableObject {
|
||||
|
||||
/** The client transaction id, if provided by the client, otherwise null. */
|
||||
@XmlElement(name = "clTRID", namespace = "urn:ietf:params:xml:ns:epp-1.0")
|
||||
@Nullable
|
||||
String clientTransactionId;
|
||||
|
||||
public String getServerTransactionId() {
|
||||
@@ -50,7 +50,6 @@ public class Trid extends ImmutableObject {
|
||||
return Optional.ofNullable(clientTransactionId);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static Trid create(@Nullable String clientTransactionId, String serverTransactionId) {
|
||||
checkArgumentNotNull(serverTransactionId, "serverTransactionId cannot be null");
|
||||
Trid instance = new Trid();
|
||||
|
||||
@@ -366,10 +366,15 @@ public class EppInput extends ImmutableObject {
|
||||
@XmlElementWrapper
|
||||
List<CommandExtension> extension;
|
||||
|
||||
String clTRID;
|
||||
@Nullable String clTRID;
|
||||
|
||||
public String getClTrid() {
|
||||
return clTRID;
|
||||
/**
|
||||
* Returns the client transaction ID.
|
||||
*
|
||||
* <p>This is optional (i.e. it may not be specified) per RFC 5730.
|
||||
*/
|
||||
public Optional<String> getClTrid() {
|
||||
return Optional.ofNullable(clTRID);
|
||||
}
|
||||
|
||||
public InnerCommand getCommand() {
|
||||
|
||||
Reference in New Issue
Block a user