Make async flow logic handle missing client transaction IDs

Per EPP RFC 5730, the <clTRID> element is optional. However, we weren't handling
it not being specified in asynchronous contact/host deletions because we were
adding it directly as a parameter value on a task, which does not allow null and
thus threw a NullPointerException.

This fixes handling for nulls (the parameter isn't set at all) and adds a test.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=194123259
This commit is contained in:
mcilwain 2018-04-24 12:01:05 -07:00 committed by jianglai
parent f56355c9e8
commit 33505f4df7
16 changed files with 196 additions and 47 deletions

View file

@ -15,6 +15,7 @@
package google.registry.testing;
import static com.google.appengine.tools.development.testing.LocalTaskQueueTestConfig.getLocalTaskQueue;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Predicates.in;
import static com.google.common.base.Predicates.not;
@ -104,8 +105,7 @@ public class TaskQueueHelper {
}
public TaskMatcher payload(String payload) {
checkState(
expected.params.isEmpty(), "Cannot add a payload to a TaskMatcher with params.");
checkState(expected.params.isEmpty(), "Cannot add a payload to a TaskMatcher with params");
expected.payload = payload;
return this;
}
@ -122,16 +122,16 @@ public class TaskQueueHelper {
}
public TaskMatcher param(String key, String value) {
checkState(
expected.payload == null, "Cannot add params to a TaskMatcher with a payload.");
checkState(expected.payload == null, "Cannot add params to a TaskMatcher with a payload");
checkNotNull(value, "Test error: A task can never have a null value, so don't assert it");
expected.params.put(key, value);
return this;
}
public TaskMatcher etaDelta(Duration lowerBound, Duration upperBound) {
checkState(!lowerBound.isShorterThan(Duration.ZERO), "lowerBound must be non-negative.");
checkState(!lowerBound.isShorterThan(Duration.ZERO), "lowerBound must be non-negative");
checkState(
upperBound.isLongerThan(lowerBound), "upperBound must be greater than lowerBound.");
upperBound.isLongerThan(lowerBound), "upperBound must be greater than lowerBound");
expected.etaDeltaLowerBound = lowerBound.getStandardSeconds();
expected.etaDeltaUpperBound = upperBound.getStandardSeconds();
return this;