Permalink
Browse files

RPE-918: Update to use unspec values for whois type

  • Loading branch information...
Thisara Rupasinghe
Thisara Rupasinghe committed Apr 18, 2017
1 parent fdee553 commit 0ef86c6c880f266221d4ec01c910c4c771b64922
@@ -4,4 +4,5 @@
artifacts
build
target
out
out
classes/*
@@ -1 +1 @@
toolkitVersion=3.7.3
toolkitVersion=3.7.4
@@ -1,7 +1,7 @@
[![Build Status](https://travis-ci.org/AusRegistry/ari-toolkit.png)](https://travis-ci.org/AusRegistry/ari-toolkit)
## Downloads
The latest ari-toolkit is available for download. [ari-toolkit v3.7.3](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.3/arjtk-3.7.3.jar) ([sources](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.3/arjtk-3.7.3-sources.jar) | [javadoc](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.3/arjtk-3.7.3-javadoc.jar))
The latest ari-toolkit is available for download. [ari-toolkit v3.7.4](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.4/arjtk-3.7.4.jar) ([sources](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.4/arjtk-3.7.4-sources.jar) | [javadoc](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.4/arjtk-3.7.4-javadoc.jar))
For more information, please read [Installation and Setup](#installation-and-setup).
@@ -43,7 +43,7 @@ This toolkit also provides a mechanism to perform the following Trademark Cleari
#### Direct download
Obtain the latest toolkit here: [Toolkit v3.7.3](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.3/arjtk-3.7.3.jar) ([sources](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.3/arjtk-3.7.3-sources.jar) | [javadoc](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.3/arjtk-3.7.3-javadoc.jar))
Obtain the latest toolkit here: [Toolkit v3.7.4](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.4/arjtk-3.7.4.jar) ([sources](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.4/arjtk-3.7.4-sources.jar) | [javadoc](http://ausregistry.github.com/repo/au/com/ausregistry/arjtk/3.7.4/arjtk-3.7.4-javadoc.jar))
#### Dependency Management
@@ -52,7 +52,7 @@ Use your build's dependency management tool to automatically download the toolki
* Repository: `http://ausregistry.github.com/repo/`
* groupId: `au.com.ausregistry`
* artifactId: `arjtk`
* version: `3.7.3`
* version: `3.7.4`
For example (using Maven):
@@ -67,7 +67,7 @@ For example (using Maven):
<dependency>
<groupId>au.com.ausregistry</groupId>
<artifactId>arjtk</artifactId>
<version>3.7.3</version>
<version>3.7.4</version>
</dependency>
</dependencies>
@@ -1,5 +1,6 @@
package com.ausregistry.jtoolkit2.se.unspec;
import com.ausregistry.jtoolkit2.ErrorPkg;
import com.ausregistry.jtoolkit2.se.Command;
import com.ausregistry.jtoolkit2.se.CommandExtension;
import com.ausregistry.jtoolkit2.se.ExtendedObjectType;
@@ -12,8 +13,8 @@
* Domain Name Unspec Extension.</p>
*
* <p>Use this to identify the unspec associated with this domain name as part of an EPP Domain Create
* command compliant with RFC5730 and RFC5731. The "extContact" value
* will be supplied.
* command compliant with RFC5730 and RFC5731. The "extContact" value or combination of WhoisType and Publish
* can be supplied depending on the usage.
* The response expected from a server should be handled by a Domain Create Response.</p>
*
* @see com.ausregistry.jtoolkit2.se.DomainCreateCommand
@@ -22,13 +23,27 @@
public class DomainCreateCommandUnspecExtension implements CommandExtension {
private static final long serialVersionUID = 5982521830455586062L;
private static final String FIELD_IDENTIFIER = "<<field>>";
private final String extContactId;
private String extContactId;
private WhoisType whoisType;
private Boolean publish;
public DomainCreateCommandUnspecExtension(String extContactId) {
this.extContactId = extContactId;
}
public DomainCreateCommandUnspecExtension(WhoisType whoisType, Boolean publish) {
if (whoisType != null) {
this.whoisType = whoisType;
} else {
throw new IllegalArgumentException(ErrorPkg.getMessage("neustar.unspec.whois.type", FIELD_IDENTIFIER,
"whoisType"));
}
this.publish = publish;
}
@Override
public void addToCommand(Command command) {
final XMLWriter xmlWriter = command.getXmlWriter();
@@ -37,8 +52,20 @@ public void addToCommand(Command command) {
final Element unspecElement = xmlWriter.appendChild(extensionElement, "extension",
ExtendedObjectType.UNSPEC.getURI());
StringBuilder unspecValue = new StringBuilder();
if (extContactId != null) {
unspecValue.append("extContact=" + extContactId);
} else {
if (whoisType != null) {
unspecValue.append("WhoisType=" + whoisType.name());
}
if (publish != null) {
unspecValue.append(" Publish=" + (publish ? "Y" : "N"));
}
}
xmlWriter.appendChild(unspecElement, "unspec", ExtendedObjectType.UNSPEC.getURI())
.setTextContent("extContact=" + extContactId);
.setTextContent(unspecValue.toString().trim());
}
@@ -12,8 +12,8 @@
* Domain Name Unspec Extension.</p>
*
* <p>Use this to identify the unspec associated with this domain name as part of an EPP Domain Update
* command compliant with RFC5730 and RFC5731. The "extContact" value
* will be supplied.
* command compliant with RFC5730 and RFC5731. The "extContact" value or combination of WhoisType and Publish
* can be supplied depending on the usage.
* The response expected from a server should be handled by a Domain Update Response.</p>
*
* @see com.ausregistry.jtoolkit2.se.DomainUpdateCommand
@@ -22,13 +22,21 @@
public class DomainUpdateCommandUnspecExtension implements CommandExtension {
private static final long serialVersionUID = 5982521830455586062L;
private static final String FIELD_IDENTIFIER = "<<field>>";
private final String extContactId;
private String extContactId;
private WhoisType whoisType;
private Boolean publish;
public DomainUpdateCommandUnspecExtension(String extContactId) {
this.extContactId = extContactId;
}
public DomainUpdateCommandUnspecExtension(WhoisType whoisType, Boolean publish) {
this.whoisType = whoisType;
this.publish = publish;
}
@Override
public void addToCommand(Command command) {
final XMLWriter xmlWriter = command.getXmlWriter();
@@ -37,9 +45,19 @@ public void addToCommand(Command command) {
final Element unspecElement = xmlWriter.appendChild(extensionElement, "extension",
ExtendedObjectType.UNSPEC.getURI());
xmlWriter.appendChild(unspecElement, "unspec", ExtendedObjectType.UNSPEC.getURI())
.setTextContent("extContact=" + extContactId);
StringBuilder unspecValue = new StringBuilder();
if (extContactId != null) {
unspecValue.append("extContact=" + extContactId);
} else {
if (whoisType != null) {
unspecValue.append("WhoisType=" + whoisType.name());
}
if (publish != null) {
unspecValue.append(" Publish=" + (publish ? "Y" : "N"));
}
}
xmlWriter.appendChild(unspecElement, "unspec", ExtendedObjectType.UNSPEC.getURI())
.setTextContent(unspecValue.toString().trim());
}
}
@@ -0,0 +1,6 @@
package com.ausregistry.jtoolkit2.se.unspec;
public enum WhoisType {
LEGAL,
NATURAL
}
@@ -124,6 +124,7 @@ se.ar.domainUndelete.name.missing=Domain name must be provided.
se.ar.domainUnrenew.missing_arg=Both domain name and current expiry date must be provided.
se.ar.domain.create.ietf.idn.table=Table must not be null or empty.
se.ar.domain.check.fee=Field '<<field>>' is required.
neustar.unspec.whois.type=Field '<<field>>' is required.
tmch.smd.expired=SignedMarkData is not valid after <<expiry-date>>.
tmch.smd.notYetValid=SignedMarkData is not valid before <<valid-from-date>>.
@@ -1,5 +1,9 @@
package com.ausregistry.jtoolkit2.se.unspec;
import static com.ausregistry.jtoolkit2.se.unspec.WhoisType.LEGAL;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import com.ausregistry.jtoolkit2.Timer;
import com.ausregistry.jtoolkit2.se.CLTRID;
import com.ausregistry.jtoolkit2.se.Command;
@@ -10,9 +14,6 @@
import org.junit.rules.ExpectedException;
import org.xml.sax.SAXException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class DomainCreateCommandUnspecExtensionTest {
@@ -26,33 +27,121 @@ public void setUp() throws Exception {
}
@Test
public void shouldCreateValidXmlWhenSupplyUnspecExtension() {
public void shouldCreateValidXmlWhenSupplyUnspecExtensionWithExtContact() {
final Command cmd = new DomainCreateCommand("jtkutest.com.au", "jtkUT3st");
final DomainCreateCommandUnspecExtension ext =
new DomainCreateCommandUnspecExtension("abc123");
try {
cmd.appendExtension(ext);
String expectedXml = getCommandXmlWithUnspec("extContact=abc123");
assertEquals(expectedXml, cmd.toXML());
} catch (SAXException saxe) {
fail(saxe.getMessage());
}
}
@Test
public void shouldCreateValidXmlWhenNullUnspecValueProvidedWithExtContact() {
final Command cmd = new DomainCreateCommand("jtkutest.com.au", "jtkUT3st");
final DomainCreateCommandUnspecExtension ext =
new DomainCreateCommandUnspecExtension(null);
try {
cmd.appendExtension(ext);
String expectedXml = getCommandXmlWithUnspec(null);
assertEquals(expectedXml, cmd.toXML());
} catch (SAXException saxe) {
fail(saxe.getMessage());
}
}
@Test
public void shouldCreateValidXmlWhenEmptyUnspecValueProvidedWithExtContact() {
final Command cmd = new DomainCreateCommand("jtkutest.com.au", "jtkUT3st");
final DomainCreateCommandUnspecExtension ext =
new DomainCreateCommandUnspecExtension("");
try {
cmd.appendExtension(ext);
String expectedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<epp xmlns=\"urn:ietf:params:xml:ns:epp-1.0\""
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ " xsi:schemaLocation=\"urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd\">"
+ "<command><create><create xmlns=\"urn:ietf:params:xml:ns:domain-1.0\" "
+ "xsi:schemaLocation=\"urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd\">"
+ "<name>jtkutest.com.au</name><authInfo><pw>jtkUT3st</pw></authInfo></create></create>"
+ "<extension>"
+ "<extension xmlns=\"urn:ietf:params:xml:ns:neulevel-1.0\">"
+ "<unspec>extContact=abc123</unspec>"
+ "</extension>"
+ "</extension>"
+ "<clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>";
String expectedXml = getCommandXmlWithUnspec("extContact=");
assertEquals(expectedXml, cmd.toXML());
} catch (SAXException saxe) {
fail(saxe.getMessage());
}
}
@Test
public void shouldFailWhenNullUnspecValuesProvidedWithWhoisType() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Field 'whoisType' is required.");
final Command cmd = new DomainCreateCommand("jtkutest.com.au", "jtkUT3st");
final DomainCreateCommandUnspecExtension ext =
new DomainCreateCommandUnspecExtension(null, null);
}
@Test
public void shouldCreateValidXmlWhenUnspecValuesProvidedForTypeButNullForPublishWithWhoisType() {
final Command cmd = new DomainCreateCommand("jtkutest.com.au", "jtkUT3st");
final DomainCreateCommandUnspecExtension ext =
new DomainCreateCommandUnspecExtension(LEGAL, null);
try {
cmd.appendExtension(ext);
String expectedXml = getCommandXmlWithUnspec("WhoisType=LEGAL");
assertEquals(expectedXml, cmd.toXML());
} catch (SAXException saxe) {
fail(saxe.getMessage());
}
}
@Test
public void shouldFailWhenUnspecValuesProvidedForPublishButNullForTypeWithWhoisType() {
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Field 'whoisType' is required.");
final Command cmd = new DomainCreateCommand("jtkutest.com.au", "jtkUT3st");
final DomainCreateCommandUnspecExtension ext =
new DomainCreateCommandUnspecExtension(null, true);
}
@Test
public void shouldCreateValidXmlWhenUnspecValuesProvidedForTypeAndPublishWithWhoisType() {
final Command cmd = new DomainCreateCommand("jtkutest.com.au", "jtkUT3st");
final DomainCreateCommandUnspecExtension ext =
new DomainCreateCommandUnspecExtension(LEGAL, false);
try {
cmd.appendExtension(ext);
String expectedXml = getCommandXmlWithUnspec("WhoisType=LEGAL Publish=N");
assertEquals(expectedXml, cmd.toXML());
} catch (SAXException saxe) {
fail(saxe.getMessage());
}
}
private String getCommandXmlWithUnspec(String unspec) {
String element;
if (unspec == null) {
element = "<unspec/>";
} else {
element = "<unspec>" + unspec + "</unspec>";
}
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<epp xmlns=\"urn:ietf:params:xml:ns:epp-1.0\""
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
+ " xsi:schemaLocation=\"urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd\">"
+ "<command><create><create xmlns=\"urn:ietf:params:xml:ns:domain-1.0\" "
+ "xsi:schemaLocation=\"urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd\">"
+ "<name>jtkutest.com.au</name><authInfo><pw>jtkUT3st</pw></authInfo></create></create>"
+ "<extension>"
+ "<extension xmlns=\"urn:ietf:params:xml:ns:neulevel-1.0\">"
+ element
+ "</extension>"
+ "</extension>"
+ "<clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>";
}
}
Oops, something went wrong.

0 comments on commit 0ef86c6

Please sign in to comment.