Permalink
Browse files

Handle empty array of extURIs passed to LoginCommand

  • Loading branch information...
Bernie Schelberg
Bernie Schelberg committed Mar 9, 2016
1 parent b24673e commit ce265c1770736fd091fd01d1fdd71efd8d58bd6d
@@ -114,7 +114,6 @@
<suppress checks="LineLengthCheck" files="HostCreateResponseTest\.java" />
<suppress checks="LineLengthCheck" files="HostDeleteCommandTest\.java" />
<suppress checks="LineLengthCheck" files="HostUpdateCommandTest\.java" />
<suppress checks="LineLengthCheck" files="LoginCommandTest\.java" />
<suppress checks="LineLengthCheck" files="LogoutCommandTest\.java" />
<suppress checks="LineLengthCheck" files="PollAckCommandTest\.java" />
<suppress checks="LineLengthCheck" files="PollRequestCommandTest\.java" />
@@ -77,7 +77,7 @@ public LoginCommand(String clID, String password, String newPassword,
xmlWriter.appendChild(svcs, "objURI").setTextContent(objURI);
}
if (extURIs == null) {
if (extURIs == null || extURIs.length == 0) {
return;
}
@@ -39,7 +39,15 @@ public void testLoginCommandStringString() {
Command cmd = new LoginCommand("JTKUTEST", "1234abcd!@#$JTK");
try {
String xml = cmd.toXML();
assertEquals("<?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><login><clID>JTKUTEST</clID><pw>1234abcd!@#$JTK</pw><options><version>1.0</version><lang>en</lang></options><svcs><objURI>urn:ietf:params:xml:ns:domain-1.0</objURI><objURI>urn:ietf:params:xml:ns:host-1.0</objURI><objURI>urn:ietf:params:xml:ns:contact-1.0</objURI></svcs></login><clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>", xml);
assertEquals("<?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><login><clID>JTKUTEST</clID><pw>1234abcd!@#$JTK</pw>" +
"<options><version>1.0</version><lang>en</lang></options>" +
"<svcs><objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>" +
"<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>" +
"<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI></svcs></login>" +
"<clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>", xml);
} catch (SAXException saxe) {
fail(saxe.getMessage());
}
@@ -51,7 +59,16 @@ public void testLoginCommandStringStringStringArrayStringArray() {
objURIs, extURIs);
try {
String xml = cmd.toXML();
assertEquals("<?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><login><clID>JTKUTEST</clID><pw>1234abcd!@#$JTK</pw><options><version>1.0</version><lang>en</lang></options><svcs><objURI>urn:ietf:params:xml:ns:domain-1.0</objURI><objURI>urn:ietf:params:xml:ns:host-1.0</objURI><objURI>urn:ietf:params:xml:ns:contact-1.0</objURI><svcExtension><extURI>urn:au:params:xml:ns:auext-1.0</extURI></svcExtension></svcs></login><clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>", xml);
assertEquals("<?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><login><clID>JTKUTEST</clID><pw>1234abcd!@#$JTK</pw>" +
"<options><version>1.0</version><lang>en</lang></options>" +
"<svcs><objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>" +
"<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>" +
"<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>" +
"<svcExtension><extURI>urn:au:params:xml:ns:auext-1.0</extURI></svcExtension></svcs></login>" +
"<clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>", xml);
} catch (SAXException saxe) {
fail(saxe.getMessage());
}
@@ -63,7 +80,16 @@ public void testLoginCommandStringStringStringStringStringArrayStringArray() {
objURIs, extURIs);
try {
String xml = cmd.toXML();
assertEquals("<?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><login><clID>JTKUTEST</clID><pw>1234abcd!@#$JTK</pw><options><version>1.0</version><lang>fr</lang></options><svcs><objURI>urn:ietf:params:xml:ns:domain-1.0</objURI><objURI>urn:ietf:params:xml:ns:host-1.0</objURI><objURI>urn:ietf:params:xml:ns:contact-1.0</objURI><svcExtension><extURI>urn:au:params:xml:ns:auext-1.0</extURI></svcExtension></svcs></login><clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>", xml);
assertEquals("<?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><login><clID>JTKUTEST</clID><pw>1234abcd!@#$JTK</pw>" +
"<options><version>1.0</version><lang>fr</lang></options>" +
"<svcs><objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>" +
"<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>" +
"<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>" +
"<svcExtension><extURI>urn:au:params:xml:ns:auext-1.0</extURI></svcExtension></svcs></login>" +
"<clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>", xml);
} catch (SAXException saxe) {
fail(saxe.getMessage());
}
@@ -75,7 +101,16 @@ public void testLoginCommandStringStringStringStringStringStringArrayStringArray
"n(-w18PW*", "1.0", "fr", objURIs, extURIs);
try {
String xml = cmd.toXML();
assertEquals("<?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><login><clID>JTKUTEST</clID><pw>1234abcd!@#$JTK</pw><newPW>n(-w18PW*</newPW><options><version>1.0</version><lang>fr</lang></options><svcs><objURI>urn:ietf:params:xml:ns:domain-1.0</objURI><objURI>urn:ietf:params:xml:ns:host-1.0</objURI><objURI>urn:ietf:params:xml:ns:contact-1.0</objURI><svcExtension><extURI>urn:au:params:xml:ns:auext-1.0</extURI></svcExtension></svcs></login><clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>", xml);
assertEquals("<?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><login><clID>JTKUTEST</clID><pw>1234abcd!@#$JTK</pw><newPW>n(-w18PW*</newPW>" +
"<options><version>1.0</version><lang>fr</lang></options>" +
"<svcs><objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>" +
"<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>" +
"<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>" +
"<svcExtension><extURI>urn:au:params:xml:ns:auext-1.0</extURI></svcExtension></svcs></login>" +
"<clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>", xml);
} catch (SAXException saxe) {
fail(saxe.getMessage());
}
@@ -92,7 +127,16 @@ public void testLoginCommandSecDnsExtension() {
objURIs, secDnsExtURIs);
try {
String xml = cmd.toXML();
assertEquals("<?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><login><clID>JTKUTEST</clID><pw>1234abcd!@#$JTK</pw><options><version>1.0</version><lang>en</lang></options><svcs><objURI>urn:ietf:params:xml:ns:domain-1.0</objURI><objURI>urn:ietf:params:xml:ns:host-1.0</objURI><objURI>urn:ietf:params:xml:ns:contact-1.0</objURI><svcExtension><extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI></svcExtension></svcs></login><clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>", xml);
assertEquals("<?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><login><clID>JTKUTEST</clID><pw>1234abcd!@#$JTK</pw>" +
"<options><version>1.0</version><lang>en</lang></options><svcs>" +
"<objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>" +
"<objURI>urn:ietf:params:xml:ns:host-1.0</objURI>" +
"<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>" +
"<svcExtension><extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI></svcExtension></svcs></login>" +
"<clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>", xml);
} catch (SAXException saxe) {
fail(saxe.getMessage());
}
@@ -111,5 +155,21 @@ public void testLoginCommandSecDnsExtensionNotProvided() {
}
}
@Test
public void emptyArrayOfEstUrisShouldBeIgnored() throws SAXException {
Command cmd = new LoginCommand("JTKUTEST", "password", objURIs, new String[0]);
String xml = cmd.toXML();
assertEquals("<?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><login><clID>JTKUTEST</clID><pw>password</pw>" +
"<options><version>1.0</version><lang>en</lang></options><svcs>" +
"<objURI>urn:ietf:params:xml:ns:domain-1.0</objURI><objURI>urn:ietf:params:xml:ns:host-1.0</objURI>" +
"<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI></svcs></login>" +
"<clTRID>JTKUTEST.20070101.010101.0</clTRID></command></epp>", xml);
}
}

0 comments on commit ce265c1

Please sign in to comment.