#include "xml/XMLParser.hpp" #include "common/init.hpp" #include "common/Test.hpp" #include "session/Timer.hpp" #include "se/DomainKVCommandExtension.hpp" #include "se/DomainInfoResponse.hpp" #include "se/DomainInfoKVResponseExtension.hpp" #include "se/CLTRID.hpp" using namespace std; void checkKeyValueList(const DomainInfoKVResponseExtension &kvExtension, const std::string &listName); void testNonExistentListName() { DomainInfoResponse response; DomainInfoKVResponseExtension kvExtension; response.registerExtension(&kvExtension); const std::string xml = "Command completed successfullyexample.com.aeD0000003-AREXAMPLEEXAMPLEns1.example.com.aens2.example.com.aens1.example.com.aens2.exmaple.com.aeRegistrarRegistrar2006-02-09T15:44:58.0Z2008-02-10T00:00:00.0Z0192pqowRegistrantName Pty. Ltd.Trade License123456789TrademarkRegistrant EligiTrademark9876543212ABC-12345805"; auto_ptr parser(new XMLParser); auto_ptr doc(parser->parse(xml)); response.fromXML(doc.get()); ASSERT_EQ(kvExtension.isInitialised(), true); ASSERT_EQ(kvExtension.getItem("nonExistentListName", "registrantIDValue"), ""); } void testNonExistentItem() { DomainInfoResponse response; DomainInfoKVResponseExtension kvExtension; response.registerExtension(&kvExtension); const std::string xml = "Command completed successfullyexample.com.aeD0000003-AREXAMPLEEXAMPLEns1.example.com.aens2.example.com.aens1.example.com.aens2.exmaple.com.aeRegistrarRegistrar2006-02-09T15:44:58.0Z2008-02-10T00:00:00.0Z0192pqowRegistrantName Pty. Ltd.Trade License123456789TrademarkRegistrant EligiTrademark9876543212ABC-12345805"; auto_ptr parser(new XMLParser); auto_ptr doc(parser->parse(xml)); response.fromXML(doc.get()); ASSERT_EQ(kvExtension.isInitialised(), true); ASSERT_EQ(kvExtension.getItem("au", "nonExistentItem"), ""); } void testNotInitialisedWhenNoKVExtensionPresent() { DomainInfoResponse response; DomainInfoKVResponseExtension kvExtension; response.registerExtension(&kvExtension); const std::string xml = "Command completed successfullyviewdomain.registrar.auD604E5509E82DF9F3105B7E182BB4DF28-ARCON-1CON-1EPPEPP2010-08-12T00:33:20.0Z2012-08-12T00:33:21.0Z123paSSword My Registrant123456789Company1TESTER1.20100812.003321.19223372036854778924"; auto_ptr parser(new XMLParser); auto_ptr doc(parser->parse(xml)); response.fromXML(doc.get()); ASSERT_EQ(kvExtension.isInitialised(), false); } void testSingleKVList() { DomainInfoResponse response; DomainInfoKVResponseExtension kvExtension; response.registerExtension(&kvExtension); const std::string xml = "Command completed successfullyexample.com.aeD0000003-AREXAMPLEEXAMPLEns1.example.com.aens2.example.com.aens1.example.com.aens2.exmaple.com.aeRegistrarRegistrar2006-02-09T15:44:58.0Z2008-02-10T00:00:00.0Z0192pqowRegistrantName Pty. Ltd.Trade License123456789TrademarkRegistrant EligiTrademark9876543212ABC-12345805"; auto_ptr parser(new XMLParser); auto_ptr doc(parser->parse(xml)); response.fromXML(doc.get()); checkKeyValueList(kvExtension, "au"); } void testMultipleKVList() { DomainInfoResponse response; DomainInfoKVResponseExtension kvExtension; response.registerExtension(&kvExtension); const std::string xml = "Command completed successfullyexample.com.aeD0000003-AREXAMPLEEXAMPLEns1.example.com.aens2.example.com.aens1.example.com.aens2.exmaple.com.aeRegistrarRegistrar2006-02-09T15:44:58.0Z2008-02-10T00:00:00.0Z0192pqowRegistrantName Pty. Ltd.Trade License123456789TrademarkRegistrant EligiTrademark9876543212RegistrantName Pty. Ltd.Trade License123456789TrademarkRegistrant EligiTrademark9876543212ABC-12345805"; auto_ptr parser(new XMLParser); auto_ptr doc(parser->parse(xml)); response.fromXML(doc.get()); checkKeyValueList(kvExtension, "ae"); checkKeyValueList(kvExtension, "au"); } void checkKeyValueList(const DomainInfoKVResponseExtension &kvExtension, const std::string &listName) { ASSERT_EQ(kvExtension.getItem(listName, "registrantIDValue"), "123456789"); ASSERT_EQ(kvExtension.getItem(listName, "registrantName"), "RegistrantName Pty. Ltd."); ASSERT_EQ(kvExtension.getItem(listName, "registrantIDType"), "Trade License"); ASSERT_EQ(kvExtension.getItem(listName, "eligibilityType"), "Trademark"); ASSERT_EQ(kvExtension.getItem(listName, "eligibilityName"), "Registrant Eligi"); ASSERT_EQ(kvExtension.getItem(listName, "eligibilityIDValue"), "987654321"); ASSERT_EQ(kvExtension.getItem(listName, "eligibilityIDType"), "Trademark"); ASSERT_EQ(kvExtension.getItem(listName, "policyReason"), "2"); } int main(int argc, char* argv[]) { init("./etc/toolkit2.conf"); TEST_run(testNonExistentListName); TEST_run(testNonExistentItem); TEST_run(testNotInitialisedWhenNoKVExtensionPresent); TEST_run(testSingleKVList); TEST_run(testMultipleKVList); return TEST_errorCount(); }