123 lines
5.4 KiB
C++
123 lines
5.4 KiB
C++
#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 <iostream>
|
|
|
|
using namespace std;
|
|
|
|
void testSimpleUpdate()
|
|
{
|
|
Timer::setTime("20140101.010101");
|
|
CLTRID::setClID("ACTKUTST");
|
|
|
|
DomainUpdateCommand cmd("ACTKUTST.mop.biz");
|
|
const string xml(cmd.toXML());
|
|
ASSERT_EQ(xml, "<?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><update><update xmlns=\"urn:ietf:params:xml:ns:domain-1.0\" xsi:schemaLocation=\"urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd\"><name>ACTKUTST.mop.biz</name></update></update><clTRID>ACTKUTST.20140101.010101.0</clTRID></command></epp>");
|
|
|
|
}
|
|
|
|
void testFullUpdate()
|
|
{
|
|
Timer::setTime("20140101.010101");
|
|
CLTRID::setClID("ACTKUTST");
|
|
|
|
const char* addNsText[] = { "ns1.ACTKUTST.mop.biz", "ns2.ACTKUTST.mop.biz" };
|
|
const vector<string> addNs(addNsText, addNsText + 2);
|
|
|
|
const vector<string> addTechContacts(1, "JTKCON");
|
|
const vector<string> addAdminContacts(1, "JTKCON2");
|
|
const vector<string> addBillingContacts(1, "JTKCON3");
|
|
|
|
|
|
vector<Status> 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.ACTKUTST.mop.biz", "ns4.ACTKUTST.mop.biz" };
|
|
const vector<string> remNs(remNsText, remNsText + 2);
|
|
|
|
const vector<string> remTechContacts(1, "JTKCON2");
|
|
const vector<string> remAdminContacts(1, "JTKCON");
|
|
|
|
const char* remStatusText[] = { "clientDeleteProhibited" };
|
|
const vector<Status> remStatus(remStatusText, remStatusText + 1 );
|
|
|
|
const DomainRem rem(
|
|
&remNs,
|
|
&remTechContacts,
|
|
&remAdminContacts,
|
|
NULL,
|
|
&remStatus);
|
|
|
|
const string name("ACTKUTST.mop.biz");
|
|
const string pw("jtkUT3st");
|
|
const string registrantID("JTKCON");
|
|
|
|
DomainUpdateCommand cmd("ACTKUTST.mop.biz", &pw, &add, &rem, ®istrantID);
|
|
|
|
const string xml(cmd.toXML());
|
|
ASSERT_EQ(xml, "<?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><update><update xmlns=\"urn:ietf:params:xml:ns:domain-1.0\" xsi:schemaLocation=\"urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd\"><name>ACTKUTST.mop.biz</name><add><ns><hostObj>ns1.ACTKUTST.mop.biz</hostObj><hostObj>ns2.ACTKUTST.mop.biz</hostObj></ns><contact type=\"tech\">JTKCON</contact><contact type=\"admin\">JTKCON2</contact><contact type=\"billing\">JTKCON3</contact><status s=\"clientHold\">non-payment</status></add><rem><ns><hostObj>ns3.ACTKUTST.mop.biz</hostObj><hostObj>ns4.ACTKUTST.mop.biz</hostObj></ns><contact type=\"tech\">JTKCON2</contact><contact type=\"admin\">JTKCON</contact><status s=\"clientDeleteProhibited\"></status></rem><chg><registrant>JTKCON</registrant><authInfo><pw>jtkUT3st</pw></authInfo></chg></update></update><clTRID>ACTKUTST.20140101.010101.0</clTRID></command></epp>");
|
|
}
|
|
|
|
void testSyncExpiryDateExtension(void)
|
|
{
|
|
Timer::setTime("20140101.010101");
|
|
CLTRID::setClID("ACTKUTST");
|
|
|
|
DomainUpdateCommand cmd("ACTKUTST.mop.biz");
|
|
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,
|
|
"<?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><update><update xmlns=\"urn:ietf:params:xml:ns:domain-1.0\" xsi:schemaLocation=\"urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd\"><name>ACTKUTST.mop.biz</name></update></update><extension><update xmlns=\"urn:X-ac:params:xml:ns:sync-1.0\"><exDate>2005-04-03T22:00:00.0Z</exDate></update></extension><clTRID>ACTKUTST.20140101.010101.0</clTRID></command></epp>");
|
|
}
|
|
|
|
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();
|
|
}
|