DRDE/ACTK1_0/OTE/OteLPECreateCommandTest.cpp

87 lines
4.5 KiB
C++
Raw Normal View History

2014-01-15 23:53:32 +00:00
#include "common/init.hpp"
#include "common/Test.hpp"
#include "session/Timer.hpp"
2014-01-17 01:46:48 +00:00
#include "se/CLTRID.hpp"
2014-01-15 18:29:15 +00:00
#include "se/ContactCheckCommand.hpp"
2014-01-15 21:41:16 +00:00
#include "OTE/OteLPECreateCommand.hpp"
2014-01-15 18:29:15 +00:00
using namespace std;
void doWork()
{
2014-01-16 20:28:52 +00:00
init("./etc/toolkit2.conf");
2014-01-15 18:29:15 +00:00
const string registrantName = "AusRegistry";
const string registrantID = "01241326211";
const string registrantIDType = "Trade License";
const string eligibilityType = "Trade License (IT)";
const int policyReason = 1;
const string eligibilityName = "Blah";
const string eligibilityID = "1231239523";
const string eligibilityIDType = "Trademark";
/**
* Test that the XML string generated for a minimal create domain command
* matches the expected XML for an EPP create domain command with those
* parameters.
*/
{
2014-01-18 20:35:18 +00:00
Timer::setTime("20140101.010101");
2014-01-15 18:29:15 +00:00
CLTRID::setClID("JTKUTEST");
vector<string> techIds;
techIds.push_back("JTKCON2");
string registrant("JTKCON");
2014-01-15 23:39:12 +00:00
OteLPECreateCommand cmd("jtkutest.co.ae", "jtkUT3st", &registrant, &techIds,
2014-01-15 18:29:15 +00:00
eligibilityType, policyReason, registrantName);
const string xml(cmd.toXML());
ASSERT_EQ(xml,
2014-01-18 20:35:18 +00:00
"<?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.co.ae</name><registrant>JTKCON</registrant><contact type=\"tech\">JTKCON2</contact><authInfo><pw>jtkUT3st</pw></authInfo></create></create><extension><create xmlns=\"urn:X-ae:params:xml:ns:aeext-1.0\" xsi:schemaLocation=\"urn:X-ae:params:xml:ns:aeext-1.0 aeext-1.0.xsd\"><aeProperties><registrantName>AusRegistry</registrantName><eligibilityType>Trade License (IT)</eligibilityType><policyReason>1</policyReason></aeProperties></create></extension><clTRID>JTKUTEST.20140101.010101.0</clTRID></command></epp>");
2014-01-15 18:29:15 +00:00
}
/**
* Test that the XML string generated for a sample create domain command
* specified with all available parameters matches the expected XML for
* an EPP create domain command with those parameters.
*
*/
{
2014-01-18 20:35:18 +00:00
Timer::setTime("20140101.010101");
2014-01-15 18:29:15 +00:00
CLTRID::setClID("JTKUTEST");
vector<string> techIds;
techIds.push_back("JTKCON2");
vector<string> adminContacts;
adminContacts.push_back("JTKCON");
adminContacts.push_back("JTKCON2");
string registrant("JTKCON");
vector<string> nameServers;
nameServers.push_back("ns1.ausregistry.net");
nameServers.push_back("ns2.ausregistry.net");
Period period(48, PeriodUnit::MONTHS());
OteLPECreateCommand cmd(
2014-01-15 23:39:12 +00:00
"jtkutest.co.ae", "jtkUT3st", &registrant,
2014-01-15 18:29:15 +00:00
&techIds, &adminContacts,
NULL, &nameServers, &period,
eligibilityType, policyReason,
registrantName, &registrantID,
&registrantIDType, &eligibilityName,
&eligibilityID, &eligibilityIDType);
const string xml(cmd.toXML());
2014-01-18 20:35:18 +00:00
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><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.co.ae</name><period unit=\"m\">48</period><ns><hostObj>ns1.ausregistry.net</hostObj><hostObj>ns2.ausregistry.net</hostObj></ns><registrant>JTKCON</registrant><contact type=\"admin\">JTKCON</contact><contact type=\"admin\">JTKCON2</contact><contact type=\"tech\">JTKCON2</contact><authInfo><pw>jtkUT3st</pw></authInfo></create></create><extension><create xmlns=\"urn:X-ae:params:xml:ns:aeext-1.0\" xsi:schemaLocation=\"urn:X-ae:params:xml:ns:aeext-1.0 aeext-1.0.xsd\"><aeProperties><registrantName>AusRegistry</registrantName><registrantID type=\"Trade License\">01241326211</registrantID><eligibilityType>Trade License (IT)</eligibilityType><eligibilityName>Blah</eligibilityName><eligibilityID type=\"Trademark\">1231239523</eligibilityID><policyReason>1</policyReason></aeProperties></create></extension><clTRID>JTKUTEST.20140101.010101.0</clTRID></command></epp>");
2014-01-15 18:29:15 +00:00
}
}
int main(int argc, char* argv[])
{
TEST_run(doWork);
return TEST_errorCount();
}