#include "se/DomainUpdateCommand.hpp" #include "se/DomainUpdateSyncCommandExtension.hpp" #include "se/CLTRID.hpp" #include "se/EPPDateFormatter.hpp" #include "se/DomainAdd.hpp" #include "se/Status.hpp" #include "se/DomainRem.hpp" #include "se/IllegalArgException.hpp" #include "xml/XMLParser.hpp" #include "common/init.hpp" #include "session/Timer.hpp" #include "common/Test.hpp" #include "common/ErrorPkg.hpp" #include using namespace std; void testSimpleUpdate() { Timer::setTime("20070101.010101"); CLTRID::setClID("JTKUTEST"); DomainUpdateCommand cmd("jtkutest.com.au"); const string xml(cmd.toXML()); ASSERT_EQ(xml, "jtkutest.com.auJTKUTEST.20070101.010101.0"); } void testFullUpdate() { Timer::setTime("20070101.010101"); CLTRID::setClID("JTKUTEST"); const char* addNsText[] = { "ns1.jtkutest.com.au", "ns2.jtkutest.com.au" }; const vector addNs(addNsText, addNsText + 2); const vector addTechContacts(1, "JTKCON"); const vector addAdminContacts(1, "JTKCON2"); const vector addBillingContacts(1, "JTKCON3"); vector addStatus; addStatus.push_back(Status("clientHold", "non-payment")); // Could take the address of temporaries here since we 'know' DomainAdd // only dereferences during construction and does so to deep copy, but // this is more conventional. const DomainAdd add( &addNs, &addTechContacts, &addAdminContacts, &addBillingContacts, &addStatus); const char* remNsText[] = { "ns3.jtkutest.com.au", "ns4.jtkutest.com.au" }; const vector remNs(remNsText, remNsText + 2); const vector remTechContacts(1, "JTKCON2"); const vector remAdminContacts(1, "JTKCON"); const char* remStatusText[] = { "clientDeleteProhibited" }; const vector remStatus(remStatusText, remStatusText + 1 ); const DomainRem rem( &remNs, &remTechContacts, &remAdminContacts, NULL, &remStatus); const string name("jtkutest.com.au"); const string pw("jtkUT3st"); const string registrantID("JTKCON"); DomainUpdateCommand cmd("jtkutest.com.au", &pw, &add, &rem, ®istrantID); const string xml(cmd.toXML()); ASSERT_EQ(xml, "jtkutest.com.auns1.jtkutest.com.auns2.jtkutest.com.auJTKCONJTKCON2JTKCON3non-paymentns3.jtkutest.com.auns4.jtkutest.com.auJTKCON2JTKCONJTKCONjtkUT3stJTKUTEST.20070101.010101.0"); } void testSyncExpiryDateExtension(void) { Timer::setTime("20070101.010101"); CLTRID::setClID("JTKUTEST"); DomainUpdateCommand cmd("jtkutest.com.au"); XMLGC::XMLGregorianCalendar *newExpiryDate = EPPDateFormatter::fromXSDateTime("2005-04-03T22:00:00.0Z"); DomainUpdateSyncCommandExtension extension(newExpiryDate); cmd.appendExtension(extension); const string xml(cmd.toXML()); delete newExpiryDate; ASSERT_EQ(xml, "jtkutest.com.au2005-04-03T22:00:00.0ZJTKUTEST.20070101.010101.0"); } void testSyncExpiryDateExtensionWithNullDate(void) { try { DomainUpdateSyncCommandExtension extension(NULL); FAIL("Null exDate should have generated an exception"); } catch (IllegalArgException &e) { ASSERT_EQ(e.getMessage(), ErrorPkg::getMessage("se.domain.update.sync.exDate.missing")); } } int main(int argc, char* argv[]) { init("./etc/toolkit2.conf"); TEST_run(testSimpleUpdate); TEST_run(testFullUpdate); TEST_run(testSyncExpiryDateExtension); TEST_run(testSyncExpiryDateExtensionWithNullDate); return TEST_errorCount(); }