Don't add all claims data to NORDN verify task

This claims data can exceed the maximum size of a task, causing the NORDN upload
to error out.  It also wasn't even being used anyway. This data is already
logged during the upload and there's no reason to log it as well during the
verify, because there is already a unique actionLogId that can be used to tie
the verify task back to the upload task.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=196521160
This commit is contained in:
mcilwain 2018-05-14 09:50:52 -07:00 committed by jianglai
parent c25f765fc5
commit de5645abd9
5 changed files with 5 additions and 30 deletions

View file

@ -153,17 +153,15 @@ public final class NordnUploadAction implements Runnable {
actionLogId),
req, rsp);
}
getQueue(NordnVerifyAction.QUEUE).add(makeVerifyTask(new URL(location.get()), csvData));
getQueue(NordnVerifyAction.QUEUE).add(makeVerifyTask(new URL(location.get())));
}
private TaskOptions makeVerifyTask(URL url, String csvData) {
// This task doesn't technically need csvData. The only reason it's passed along is in case the
// upload is rejected, in which case csvData will be logged so that it may be uploaded manually.
private TaskOptions makeVerifyTask(URL url) {
// The actionLogId is used to uniquely associate the verify task back to the upload task.
return withUrl(NordnVerifyAction.PATH)
.header(NordnVerifyAction.URL_HEADER, url.toString())
.header(NordnVerifyAction.HEADER_ACTION_LOG_ID, actionLogId)
.param(RequestParameters.PARAM_TLD, tld)
.param(NordnVerifyAction.PARAM_CSV_DATA, csvData)
.countdownMillis(VERIFY_DELAY.getMillis());
}
}

View file

@ -27,7 +27,6 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.io.ByteSource;
import google.registry.request.Action;
import google.registry.request.Header;
import google.registry.request.HttpException.BadRequestException;
import google.registry.request.HttpException.ConflictException;
import google.registry.request.Parameter;
import google.registry.request.RequestParameters;
@ -60,8 +59,6 @@ import javax.inject.Inject;
)
public final class NordnVerifyAction implements Runnable {
public static final String PARAM_CSV_DATA = "csvData";
static final String PATH = "/_dr/task/nordnVerify";
static final String QUEUE = "marksdb";
static final String URL_HEADER = "X-DomainRegistry-Nordn-Url";
@ -75,7 +72,6 @@ public final class NordnVerifyAction implements Runnable {
@Inject @Header(URL_HEADER) URL url;
@Inject @Header(HEADER_ACTION_LOG_ID) String actionLogId;
@Inject @Parameter(RequestParameters.PARAM_TLD) String tld;
@Inject @Parameter(PARAM_CSV_DATA) String csvData;
@Inject NordnVerifyAction() {}
@Override
@ -99,10 +95,6 @@ public final class NordnVerifyAction implements Runnable {
*/
@VisibleForTesting
LordnLog verify() throws IOException {
if (csvData.isEmpty()) {
throw new BadRequestException(
String.format("LORDN verify task %s: Missing CSV payload.", actionLogId));
}
logger.infofmt("LORDN verify task %s: Sending request to URL %s.", actionLogId, url);
HTTPRequest req = new HTTPRequest(url, GET, validateCertificate().setDeadline(60d));
lordnRequestInitializer.initialize(req, tld);

View file

@ -64,10 +64,4 @@ public final class TmchModule {
static String provideActionLogId(HttpServletRequest req) {
return extractRequiredHeader(req, NordnVerifyAction.HEADER_ACTION_LOG_ID);
}
@Provides
@Parameter(NordnVerifyAction.PARAM_CSV_DATA)
static String provideCsvData(HttpServletRequest req) {
return extractRequiredParameter(req, NordnVerifyAction.PARAM_CSV_DATA);
}
}

View file

@ -167,8 +167,7 @@ public class NordnUploadActionTest {
assertTasksEnqueued(NordnVerifyAction.QUEUE, new TaskMatcher()
.url(NordnVerifyAction.PATH)
.header(NordnVerifyAction.URL_HEADER, LOCATION_URL)
.header(CONTENT_TYPE, FORM_DATA.toString())
.param(NordnVerifyAction.PARAM_CSV_DATA, CLAIMS_CSV));
.header(CONTENT_TYPE, FORM_DATA.toString()));
}
@Test
@ -185,8 +184,7 @@ public class NordnUploadActionTest {
assertTasksEnqueued(NordnVerifyAction.QUEUE, new TaskMatcher()
.url(NordnVerifyAction.PATH)
.header(NordnVerifyAction.URL_HEADER, LOCATION_URL)
.header(CONTENT_TYPE, FORM_DATA.toString())
.param(NordnVerifyAction.PARAM_CSV_DATA, SUNRISE_CSV));
.header(CONTENT_TYPE, FORM_DATA.toString()));
}
@Test

View file

@ -52,12 +52,6 @@ import org.mockito.Mock;
@RunWith(JUnit4.class)
public class NordnVerifyActionTest {
private static final String CSV_DATA = "1,2012-08-16T00:00:00.0Z,3\n"
+ "roid,domain-name,SMD-id,registrar-id,registration-datetime,application-datetime\n"
+ "SH8013-REP,example1.gtld,1-2,9999,2012-08-15T13:20:00.0Z,2012-07-15T00:50:00.0Z\n"
+ "EK77-REP,example2.gtld,2-2,9999,2012-08-15T14:00:03.0Z\n"
+ "HB800-REP,example3.gtld,3-2,9999,2012-08-15T15:40:00.0Z\n";
private static final String LOG_ACCEPTED = "1,2012-08-16T02:15:00.0Z,2012-08-16T00:00:00.0Z,"
+ "0000000000000478Nzs+3VMkR8ckuUynOLmyeqTmZQSbzDuf/R50n2n5QX4=,accepted,no-warnings,1\n"
+ "roid,result-code\n"
@ -105,7 +99,6 @@ public class NordnVerifyActionTest {
persistResource(Registry.get("gtld").asBuilder().setLordnUsername("lolcat").build());
lordnRequestInitializer.marksdbLordnPassword = Optional.of("attack");
action.tld = "gtld";
action.csvData = CSV_DATA;
action.fetchService = fetchService;
action.lordnRequestInitializer = lordnRequestInitializer;
action.response = response;