Fix WHOIS formatting to match format from RA

Our whois format was flagged as wrong in the .meet PDT. Although
we had followed the AWIP samples from ICANN, the definitive list
of field names is from Specification 4 of our contract, available at
https://newgtlds.icann.org/sites/default/files/agreements/agreement-approved-09jan14-en.htm
and indeed our fields are incorrect. (The remaining formatting issues
are ambiguous but the PDT testers' interpretation is probably correct.)

Since the footer format is now somewhat more complicated, I also denormalized
the disclaimer field into all of the testdata files. (I spent some time
debugging an extra newline between the content and the disclaimer, and
it would have been far clearer to solve if the files had been this way.)
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=120338930
This commit is contained in:
cgoldfeder 2016-04-20 08:23:16 -07:00 committed by Justine Tunney
parent c99711c7e3
commit 4e6c8ec6fe
21 changed files with 347 additions and 113 deletions

View file

@ -49,11 +49,11 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
/** Prefix for status value URLs. */
private static final String ICANN_STATUS_URL_PREFIX = "https://www.icann.org/epp#";
private static final String ICANN_STATUS_URL_PREFIX = "https://icann.org/epp#";
/** Message required to be appended to all domain WHOIS responses. */
private static final String ICANN_AWIP_INFO_MESSAGE =
"For more information on Whois status codes, please visit https://icann.org/epp";
"For more information on Whois status codes, please visit https://icann.org/epp\r\n";
/** Domain which was the target of this WHOIS command. */
private final DomainResource domain;
@ -70,14 +70,14 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
return new DomainEmitter()
.emitField("Domain Name",
maybeFormatHostname(domain.getFullyQualifiedDomainName(), preferUnicode))
.emitField("Registry Domain ID", domain.getRepoId())
.emitField("Registrar WHOIS Server", registrar.getWhoisServer())
.emitField("Registrar URL", registrar.getReferralUrl())
.emitField("Domain ID", domain.getRepoId())
.emitField("WHOIS Server", registrar.getWhoisServer())
.emitField("Referral URL", registrar.getReferralUrl())
.emitField("Updated Date", getFormattedString(domain.getLastEppUpdateTime()))
.emitField("Creation Date", getFormattedString(domain.getCreationTime()))
.emitField("Registrar Registration Expiration Date",
.emitField("Registry Expiry Date",
getFormattedString(domain.getRegistrationExpirationTime()))
.emitField("Registrar", registrar.getRegistrarName())
.emitField("Sponsoring Registrar", registrar.getRegistrarName())
.emitField("Sponsoring Registrar IANA ID",
registrar.getIanaIdentifier() == null ? null : registrar.getIanaIdentifier().toString())
.emitStatusValues(domain.getStatusValues(), domain.getGracePeriods())
@ -94,8 +94,9 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
return maybeFormatHostname(host.getFullyQualifiedHostName(), preferUnicode);
}})
.emitField("DNSSEC", isNullOrEmpty(domain.getDsData()) ? "unsigned" : "signedDelegation")
.emitLastUpdated(getTimestamp())
.emitAwipMessage()
.emitFooter(getTimestamp())
.emitFooter()
.toString();
}
@ -138,7 +139,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
domain.getFullyQualifiedDomainName(), contact.getLinked());
return this;
}
emitField("Registry " + contactType, "ID", contactResource.getContactId());
emitField(contactType, "ID", contactResource.getContactId());
PostalInfo postalInfo = chooseByUnicodePreference(
preferUnicode,
contactResource.getLocalizedPostalInfo(),

View file

@ -46,7 +46,8 @@ final class NameserverWhoisResponse extends WhoisResponseImpl {
@Override
public String getPlainTextOutput(boolean preferUnicode) {
BasicEmitter emitter = new BasicEmitter();
for (HostResource host : hosts) {
for (int i = 0; i < hosts.size(); i++) {
HostResource host = hosts.get(i);
Registrar registrar = getRegistrar(host.getCurrentSponsorClientId());
emitter
.emitField("Server Name", maybeFormatHostname(
@ -58,10 +59,12 @@ final class NameserverWhoisResponse extends WhoisResponseImpl {
return InetAddresses.toAddrString(addr);
}})
.emitField("Registrar", registrar.getRegistrarName())
.emitField("Registrar WHOIS Server", registrar.getWhoisServer())
.emitField("Registrar URL", registrar.getReferralUrl())
.emitNewline();
.emitField("WHOIS Server", registrar.getWhoisServer())
.emitField("Referral URL", registrar.getReferralUrl());
if (i < hosts.size() - 1) {
emitter.emitNewline();
}
}
return emitter.emitFooter(getTimestamp()).toString();
return emitter.emitLastUpdated(getTimestamp()).emitFooter().toString();
}
}

View file

@ -58,11 +58,12 @@ class RegistrarWhoisResponse extends WhoisResponseImpl {
registrar.getPhoneNumber(),
registrar.getFaxNumber(),
registrar.getEmailAddress())
.emitField("Registrar WHOIS Server", registrar.getWhoisServer())
.emitField("Registrar URL", registrar.getReferralUrl())
.emitField("WHOIS Server", registrar.getWhoisServer())
.emitField("Referral URL", registrar.getReferralUrl())
.emitRegistrarContacts("Admin", contacts, AdminOrTech.ADMIN)
.emitRegistrarContacts("Technical", contacts, AdminOrTech.TECH)
.emitFooter(getTimestamp())
.emitLastUpdated(getTimestamp())
.emitFooter()
.toString();
}

View file

@ -62,10 +62,10 @@ public final class WhoisException extends Exception implements WhoisResponse {
@Override
public String getPlainTextOutput(boolean preferUnicode) {
String footer = new WhoisResponseImpl.BasicEmitter()
.emitNewline()
.emitFooter(getTimestamp())
return new WhoisResponseImpl.BasicEmitter()
.emitRawLine(getMessage())
.emitLastUpdated(getTimestamp())
.emitFooter()
.toString();
return getMessage() + footer;
}
}

View file

@ -159,14 +159,20 @@ abstract class WhoisResponseImpl implements WhoisResponse {
}
/** Returns raw text that should be appended to the end of ALL WHOIS responses. */
E emitFooter(DateTime timestamp) {
emitField(ICANN_REPORTING_URL_FIELD, ICANN_REPORTING_URL);
E emitLastUpdated(DateTime timestamp) {
// We are assuming that our WHOIS database is always completely up to date, since it's
// querying the live backend datastore.
stringBuilder.append(String.format(
">>> Last update of WHOIS database: %s <<<\r\n\r\n%s\r\n",
UtcDateTimeAdapter.getFormattedString(timestamp),
DISCLAIMER));
stringBuilder
.append(">>> Last update of WHOIS database: ")
.append(UtcDateTimeAdapter.getFormattedString(timestamp))
.append(" <<<\r\n\r\n");
return thisCastToDerived();
}
/** Returns raw text that should be appended to the end of ALL WHOIS responses. */
E emitFooter() {
emitField(ICANN_REPORTING_URL_FIELD, ICANN_REPORTING_URL);
stringBuilder.append("\r\n").append(DISCLAIMER).append("\r\n");
return thisCastToDerived();
}