Ejemplo n.º 1
0
int UpdateResponseTest(EppParser& parser, DOMNode* n)
{
	EppDomain domain("UPDATE-RESPONSE-TEST.BIZ");
	EppAuthInfo authInfo(EppAuthInfo::TYPE_PW, "3fooBar");
	domain.setAuthInfo(authInfo);

	EppResult result(EppError::CODE_NO_ERROR);
	EppValueReason reason0("Value0", "Reason0", "en");
	EppValueReason reason4("Value4");
	result.addValue(reason0);
	result.addValue("Value1");
	result.addValue("Value2");
	result.addValue("Value3");
	result.addValue(reason4);
	EppTransactionId trid("CLIENT-XID", "SERVER-ID");

	EppResponse rsp;
	rsp.addResult(result);
	rsp.setTransactionId(trid);

	//EppResponseDataUpdateDomain eppCommand("RENEW-RESPONSE-TEST.BIZ", time(0));
	//rsp.setResponseData(&eppCommand);


	EppResponseDataRenewDomain eppCommand("UPDATE-RESPONSE-TEST.BIZ", time(0));
	rsp.setResponseData(&eppCommand);

	
	EppResponseUpdateFee* feeExt = new EppResponseUpdateFee();
	feeExt->setCurrency("RND");

	EppFeeFee *fee2 = new EppFeeFee();
	fee2->setDescription("SOME Fee");
	fee2->setRefundable("1");
	fee2->setFee(5.00);
	feeExt->addFee(fee2);

	feeExt->setBalance("1000");
	feeExt->setCreditLimit("5000");
	rsp.addExtension(feeExt);

	DOMString orig = rsp.toString();

	parser.parse(orig);
	n = parser.getRootNode();

	EppResponse * newRsp = EppResponse::fromXML(*n);
	DOMString again = newRsp->toString();

	delete newRsp;
	
	doValidate(orig, again, __FUNCTION__);
	return 0;

}
Ejemplo n.º 2
0
EppResponse * EppResponse::fromXML( const DOMNode& root )
{
	unsigned int i;
	EppResponse * rsp = null;
	DOMNode* response;
	bool found = false;

	DOMNodeList* list = root.getChildNodes();
	for( i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();

		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( name.equals("response") )
		{
			response = node;
			found = true;
			break;
		}
	}

	if( found == false )
	{
		return null;
	}

	rsp = new EppResponse();
	list = response->getChildNodes();
	for( i = 0; i < list->getLength(); i++ )
	{
		DOMNode* node = list->item(i);
		DOMString name = node->getLocalName();
		if( name.isNull() )
		{
			name = node->getNodeName();
		}
		if( name.isNull() )
		{
			continue;
		}
		if( name.equals("result") )
		{
			EppResult * r = EppResult::fromXML(*node);
			if( r != null )
			{
				rsp->result->addElement(r);
			}
		}
		else if( name.equals("msgQ") )
		{
			DOMElement * elm = (DOMElement *) node;
			DOMString id = elm->getAttribute(XS("id"));
			if( id.isNotNull() && id.length() > 0 )
			{
				rsp->msgId = id;
			}
			DOMString str = elm->getAttribute(XS("count"));
			if( str.isNotNull() && str.length() > 0 )
			{
				char * p = str.transcode();
				if( p != null )
				{
					rsp->msgQCount = atoi(p);
					XercesString::Delete(p);
				}
			}

			DOMNodeList* qlist = node->getChildNodes();
			for( unsigned int j = 0; j < qlist->getLength(); j++ )
			{
				node = qlist->item(j);
				name = node->getLocalName();

				if( name.isNull() )
				{
					name = node->getNodeName();
				}
				if( name.isNull() )
				{
					continue;
				}
				if( name.equals("qDate") )
				{
					rsp->msgQDate = EppUtil::getDate(*node);
				}
				else if( name.equals("msg") )
				{
					rsp->msgQText = EppUtil::getText(*node);
				}
			}
		}
		else if( name.equals("resData") )
		{
			if( rsp->resData == null )
			{
				rsp->resData = EppResponseData::fromXML(*node);
				rsp->freeable = true;
			}
		}
		else if( name.equals("extension") )
		{
			DOMNodeList* clist = node->getChildNodes();
			for( unsigned int j = 0; j < clist->getLength(); j++ )
			{
				DOMNode* cnode   = clist->item(j);
				DOMString prefix = cnode->getPrefix();
				DOMString cname  = cnode->getLocalName();

				if( cname.isNull() )
				{
					cname = cnode->getNodeName();
				}
				if( cname.isNull() )
				{
					continue;
				}
				if(     cname.equals("neulevel:extension")
					|| (    (prefix.isNotNull()) && prefix.equals("neulevel")
					&& (cname.isNotNull()) && cname.equals("extension") ) )
				{
					EppUnspec * unspec = EppUnspec::fromXML(*cnode);
					if( unspec != null )
					{
						rsp->addExtension(unspec);
					}
				}
				else if( cname.isNotNull() )
				{
					EppExtension * ext = EppExtension::fromXML(*cnode);
					if( ext != null )
					{
						rsp->addExtension(ext);
					}
					// else other extension
				}
				else
				{
					// other extensions
				}
			}
		}
		else if( name.equals("trID") )
		{
			if( rsp->trID == null )
			{
				rsp->trID = EppTransactionId::fromXML(*node);
			}
		}
	}

	return rsp;
}
Ejemplo n.º 3
0
int CheckResponseTest(EppParser& parser, DOMNode* n)
{
	EppResponse rsp;
	

	EppResult result(EppError::CODE_NO_ERROR);
	//EppValueReason reason0("Value0", "Reason0", "en_US");
	EppValueReason reason0("Value0", "Reason0", "en");
	EppValueReason reason4("Value4");
	result.addValue(reason0);
	result.addValue("Value1");
	result.addValue("Value2");
	result.addValue("Value3");
	result.addValue(reason4);
	EppTransactionId trid("CLIENT-XID", "SERVER-ID");

	rsp.addResult(result);
	rsp.setTransactionId(trid);

	EppResponseDataCheckDomain eppCommand;
	eppCommand.add("DOMAIN1.CLUB", DOMString(EppResponseDataCheck::FOUND));
	eppCommand.add("DOMAIN2.CLUB", DOMString(EppResponseDataCheck::NOT_FOUND));
	eppCommand.add("DOMAIN3.CLUB", DOMString(EppResponseDataCheck::FOUND));
	rsp.setResponseData(&eppCommand);


	EppResponseCheckFee* feeExt = new EppResponseCheckFee();
	{
		{
			EppResponseCheckFeeType* element = new  EppResponseCheckFeeType();
			element->setName("CHECK-RESPOSNSE-FEE-DOMAIN1.CLUB");
			element->setCurrency("USD");

			EppFeeCommand* command = new EppFeeCommand();
			command->setCommand("create");
			command->setPhase("sunrise");
			element->setCommand(command);
			
			EppPeriod* period = new EppPeriod();
			period->setUnit('y');
			period->setValue(1);
			element->setPeriod(period);
		
			EppFeeFee *fee1 = new EppFeeFee();
			fee1->setApplied("delayed");
			fee1->setDescription("Application Fee");
			fee1->setRefundable("0");
			fee1->setFee(5.002);
			fee1->setGracePeriod("P15D");
			element->addFee(fee1);
			
			EppFeeFee *fee2 = new EppFeeFee();
			fee2->setDescription("Registration Fee");
			fee2->setRefundable("1");
			fee2->setFee(5.003);
			element->addFee(fee2);
			feeExt->add(element);
		}
		{
			EppResponseCheckFeeType* element = new  EppResponseCheckFeeType();
			element->setName("CHECK-RESPOSNSE-FEE-DOMAIN2.CLUB");
			element->setCurrency("EUR");

			EppFeeCommand* command = new EppFeeCommand();
			command->setCommand("create");
			command->setPhase("claims");
			command->setSubPhase("landrush");
			element->setCommand(command);
			
			EppPeriod* period = new EppPeriod();
			period->setUnit('y');
			period->setValue(2);
			element->setPeriod(period);
		
			EppFeeFee *fee1 = new EppFeeFee();
			fee1->setFee(5.004);
			element->addFee(fee1);
			feeExt->add(element);
		}
		{
			EppResponseCheckFeeType* element = new  EppResponseCheckFeeType();
			element->setName("CHECK-RESPOSNSE-FEE-DOMAIN3.CLUB");
			element->setCurrency("EUR");

			EppFeeCommand* command = new EppFeeCommand();
			command->setCommand("transfer");
			element->setCommand(command);
			
			EppPeriod* period = new EppPeriod();
			period->setUnit('y');
			period->setValue(2);
			element->setPeriod(period);
		
			EppFeeFee *fee1 = new EppFeeFee();
			fee1->setApplied("immediate");
			fee1->setDescription("Transfer Fee");
			fee1->setFee(2.505);
			element->addFee(fee1);
			
			EppFeeFee *fee2 = new EppFeeFee();
			fee2->setDescription("Renewal Fee");
			fee2->setFee(10.00);
			element->addFee(fee2);
			feeExt->add(element);
		}
		
		{
			EppResponseCheckFeeType* element = new  EppResponseCheckFeeType();
			element->setName("CHECK-RESPOSNSE-FEE-DOMAIN4.CLUB");
			element->setCurrency("GBP");

			EppFeeCommand* command = new EppFeeCommand();
			command->setCommand("restore");
			element->setCommand(command);
			
			EppPeriod* period = new EppPeriod();
			period->setUnit('y');
			period->setValue(1);
			element->setPeriod(period);
		
			EppFeeFee *fee1 = new EppFeeFee();
			fee1->setDescription("Restore Fee");
			fee1->setFee(25);
			element->addFee(fee1);
			
			EppFeeFee *fee2 = new EppFeeFee();
			fee2->setDescription("Renewal Fee");
			fee2->setFee(5.00);
			element->addFee(fee2);
			
			element->setFeeClass("premium-tier1");
			feeExt->add(element);
		}
	}

	rsp.addExtension(feeExt);

	DOMString orig = rsp.toString();

	parser.parse(orig);


	n = parser.getRootNode();
	EppResponse * newRsp = (EppResponse *) EppResponse::fromXML(*n);
	DOMString again = newRsp->toString();

	delete newRsp;
	

	doValidate(orig, again, __FUNCTION__);
	return 0;
}
Ejemplo n.º 4
0
int InfoResponseTest(EppParser& parser, DOMNode* n)
{
	EppDomain domain("INFO-RESPONSE-TEST.BIZ");
	domain.setRoid("ROID-ROID");

	EppStatus st(EppDomain::STATUS_CLIENT_UPDATE_PROHIBITED);
	domain.addStatus(st);

	domain.setClientId("123");

	EppResult result(EppError::CODE_NO_ERROR);
	//EppValueReason reason0("Value0", "Reason0", "en_US");
	EppValueReason reason0("Value0", "Reason0", "en");
	EppValueReason reason4("Value4");
	result.addValue(reason0);
	result.addValue("Value1");
	result.addValue("Value2");
	result.addValue("Value3");
	result.addValue(reason4);
	EppTransactionId trid("CLIENT-XID", "SERVER-ID");

	EppResponse rsp;
	rsp.addResult(result);
	rsp.setTransactionId(trid);
	EppResponseDataInfo infData(&domain);
	rsp.setResponseData(&infData);

	EppResponseInfoFee* feeExt = new EppResponseInfoFee();
	feeExt->setCurrency("RND");

	EppFeeCommand* command = new EppFeeCommand();
	command->setCommand("NEWEPPCOMMAND");
	command->setPhase("new-sunrise");
	feeExt->setCommand(command);

	EppPeriod* period = new EppPeriod();
	period->setUnit('m');
	period->setValue(11);
	feeExt->setPeriod(period);

	EppFeeFee *fee2 = new EppFeeFee();
	fee2->setDescription("SOME Fee");
	fee2->setRefundable("1");
	fee2->setFee(5.01);
	feeExt->addFee(fee2);

	rsp.addExtension(feeExt);

	DOMString orig = rsp.toString();

	parser.parse(orig);
	n = parser.getRootNode();

	EppResponse * newRsp = EppResponse::fromXML(*n);
	DOMString again = newRsp->toString();

	delete newRsp;
	
	doValidate(orig, again, __FUNCTION__);
	return 0;
}
int runEppTestChangePoll(EppParser & parser)
{
	// tests on helper classes define as part of ChangePollExtension implementation
	{
		//EppReason test
		EppReason* r = new EppReason();
		r->setReason("test reason");
		r->setLanguage("en-US");
		cout<<endl <<"EppReason=" << r->toString();
		delete r;
		
		//EppChangePollOperation test
		EppChangePollOperation* op = new EppChangePollOperation();
		op->setOperation("delete");
		op->setSubOperation("purge");
		cout<<endl <<"EppChangePollOperation=" << op->toString();
		delete op;
	}

	DOMNode* n;

	EppDomain domain("DOMAIN.BIZ");
	domain.setRoid("TESTROID-12345");
	EppStatus st(EppDomain::STATUS_OK);
	domain.addStatus(st);
	domain.setClientId("testID");
	EppResult result(EppError::CODE_NO_ERROR);
	EppValueReason reason0("TestValue0", "TestReason0", "en-US");
	EppValueReason reason4("Value4");
	result.addValue(reason0);
	result.addValue("Value1");
	result.addValue("Value2");
	result.addValue("Value3");
	result.addValue(reason4);
	EppTransactionId trid("CLIENT-XID", "SERVER-ID");
	EppResponse rsp;
	rsp.addResult(result);
	rsp.setTransactionId(trid);

	EppResponseDataInfo infData(&domain);
	rsp.setResponseData(&infData);
	EppChangePollExt* ext = new EppChangePollExt();
	ext->setState("after");
	EppChangePollOperation *operation = new EppChangePollOperation();
	operation->setOperation("delete");
	operation->setSubOperation("purge");
	ext->setOperation(operation);
	ext->setWho("you");
	ext->setDate(time_t(0) + (30* 3600 * 24));
	ext->setSvTRID("x1y2z3");
	ext->setReason(new EppReason("Example-Reason-EN", "en-US"));

	rsp.addExtension(ext);

	DOMString orig = rsp.toString();

	parser.parse(orig);
	n = parser.getRootNode();
	EppResponse * newRsp = EppResponse::fromXML(*n);

	DOMString again = newRsp->toString();

	if ( orig.equals(again) )
	{
		std::cout<<endl
			 <<"Original=" <<endl<<orig<<endl
			 <<"PASSED: "  <<__FILE__<<endl;
	}
	else
	{
		std::cout<<endl
			 <<"Original=" <<endl<<orig<<endl
			 <<"Again="    <<endl<<again<<endl
		  	 <<"FAILED : " <<__FILE__<<endl;
	}
	delete newRsp;

	return 0;
}
Ejemplo n.º 6
0
int runEppTestSecDns(EppParser& parser)
{


	DOMNode* n;

	EppDomain domain("DOMAIN.BIZ");
	EppAuthInfo authInfo(EppAuthInfo::TYPE_PW, "3fooBar");
	domain.setAuthInfo(authInfo);
	EppCommandCreate create(&domain, "ABC-DEF-XXXX-ID");

	EppCommandCreateSecDns * createSecDns = new EppCommandCreateSecDns();
	EppSecDnsDsData ds0;
	EppSecDnsDsData ds1;
	time_t cal = ::time(0);

	char * str0 = "ABCDEF012345789";
	char * str1 = "012345789ABCDEF";

	ds0.setKeyTag(12345);
	ds0.setAlgorithm(3);
	ds0.setDigestType(1);
	//ds0.setDigest((unsigned char *) str0, 16);
	//ds0.setStartDate(cal);
	//ds0.setEndDate(cal + 86400 * 365);

	ds1.setKeyTag(54321);
	ds1.setAlgorithm(3);
	ds1.setDigestType(1);
	//ds1.setDigest((unsigned char *) str1, 16);
	//ds1.setStartDate(cal + 86400 * 365);
	//ds1.setEndDate(cal + 86400 * 730);
	//ds1.setValidationInterval("P60D");

	createSecDns->add(ds0);
	createSecDns->add(ds1);

	create.addExtension(createSecDns);

	cout << create.toString() << endl;
	parser.parse(create.toString());
	n = parser.getRootNode();
	EppCommandCreate * newCreate = (EppCommandCreate *) EppCommand::fromXML(*n);
	cout << newCreate->toString() << endl;
	delete newCreate;

	EppCommandUpdateDomain updateDomainAdd("DOMAIN.BIZ");
	updateDomainAdd.setClientTransactionId("CLINET-XID");

	EppCommandUpdateSecDns * addSecDns = new EppCommandUpdateSecDns();
	addSecDns->add(ds0);
	addSecDns->add(ds1);
	updateDomainAdd.addExtension(addSecDns);

	cout << updateDomainAdd.toString() << endl;
	parser.parse(updateDomainAdd.toString());
	n = parser.getRootNode();
	EppCommandUpdate * newUpdateDomainAdd = (EppCommandUpdate *) EppCommand::fromXML(*n);
	cout << newUpdateDomainAdd->toString() << endl;
	delete newUpdateDomainAdd;

	EppCommandUpdateDomain updateDomainChg("DOMAIN.BIZ");
	updateDomainChg.setClientTransactionId("CLINET-XID");

	EppCommandUpdateSecDns * chgSecDns = new EppCommandUpdateSecDns();
	chgSecDns->change(ds0);
	chgSecDns->change(ds1);
	updateDomainChg.addExtension(chgSecDns);

	cout << updateDomainChg.toString() << endl;
	parser.parse(updateDomainChg.toString());
	n = parser.getRootNode();
	EppCommandUpdate * newUpdateDomainChg = (EppCommandUpdate *) EppCommand::fromXML(*n);
	cout << newUpdateDomainChg->toString() << endl;
	delete newUpdateDomainChg;

	EppCommandUpdateDomain updateDomainRem("DOMAIN.BIZ");
	updateDomainRem.setClientTransactionId("CLINET-XID");

	EppCommandUpdateSecDns * remSecDns = new EppCommandUpdateSecDns();
	updateDomainRem.addExtension(remSecDns);

	cout << updateDomainRem.toString() << endl;
	parser.parse(updateDomainRem.toString());
	n = parser.getRootNode();
	EppCommandUpdate * newUpdateDomainRem = (EppCommandUpdate *) EppCommand::fromXML(*n);
	cout << newUpdateDomainRem->toString() << endl;
	delete newUpdateDomainRem;

	EppResult result(EppError::CODE_NO_ERROR);
	EppValueReason reason0("Value0", "Reason0", "en_US");
	EppValueReason reason4("Value4");
	result.addValue(reason0);
	result.addValue("Value1");
	result.addValue("Value2");
	result.addValue("Value3");
	result.addValue(reason4);
	EppTransactionId trid("CLIENT-XID", "SERVER-ID");
	EppResponse rsp;
	rsp.addResult(result);
	rsp.setTransactionId(trid);
	EppResponseDataInfo infData(&domain);
	rsp.setResponseData(&infData);

	EppResponseDataInfoSecDns * infSecDns = new EppResponseDataInfoSecDns();
	infSecDns->add(ds0);
	infSecDns->add(ds1);
	rsp.addExtension(infSecDns);

	cout << rsp.toString() << endl;
	parser.parse(rsp.toString());
	n = parser.getRootNode();
	EppResponse * newRsp = EppResponse::fromXML(*n);
	cout << newRsp->toString() << endl;
	delete newRsp;

	return 0;
}