This commit is contained in:
Ren RenJuan 2014-01-28 19:23:02 +00:00
parent c8a6ba960d
commit 3bdafc2a41
5 changed files with 401 additions and 23 deletions

View File

@ -60,7 +60,7 @@ XERCES_LIB = xerces-c
XERCES_INC_DIR = /opt/local/include/xercesc/
endif
SLIBS= -L/usr/lib $(BOSTLIB) $(LOG4LIB) $(ARTKLIB) -l boost_system -l boost_thread -l log4cpp -l ACTK1_0
SLIBS= -L/usr/lib $(BOSTLIB) $(LOG4LIB) $(ARTKLIB) -l boost_system -l boost_thread -l log4cpp -l ACTK1_0 -l jsoncpp
DLIBS= -L/usr/lib $(BOSTLIB) $(LOG4LIB) $(ARTKLIB) -l boost_system -l boost_thread -l log4cpp
SINCL= -I include -I /usr/include/log4cpp -I /usr/include/jsoncpp $(BOSINCL)
@ -77,7 +77,7 @@ CLFLAGS= -Wall -Wundef -Wpointer-arith -Wshadow \
-Wstrict-prototypes -Waggregate-return -Wno-implicit
ACOBJS= build/cliever.o build/mdLogger.o build/masterDaemonConfig.o build/masterDaemon.o \
build/mdHost.o build/mdState.o build/mdAusReg.o
build/mdHost.o build/mdState.o build/mdJSON.o build/mdAusReg.o
MDOBJS= build/md.o build/mdLogger.o build/masterDaemonConfig.o build/masterDaemon.o \
build/mdHost.o build/mdState.o
@ -121,8 +121,11 @@ build/mdState.o: server/mdState.cpp include/*.h
build/masterDaemon.o: server/masterDaemon.cpp include/*.h
$(CC) $(CFLAGS) server/masterDaemon.cpp -c -o build/masterDaemon.o $(SINCL) $(ARTKINCL)
build/mdJSON.o: server/mdJSON.cpp include/mdJSON.hpp
$(CC) $(CFLAGS) server/mdJSON.cpp -c -o build/mdJSON.o $(SINCL) $(ARTKINCL)
build/mdAusReg.o: server/mdAusReg.cpp include/*.h
$(CC) $(CFLAGS) server/mdAusReg.cpp -c -o build/mdAusReg.o $(SINCL) $(ARTKINCL) $(ARTKLIB) -l libACTK1_0.so
$(CC) $(CFLAGS) server/mdAusReg.cpp -c -o build/mdAusReg.o $(SINCL) $(ARTKINCL) $(ARTKLIB) -l libACTK1_0.so
build/ausreg-md: $(MDOBJS)
$(CC) $(CFLAGS) -o build/ausreg-md $(SINCL) $(LIBS) $(MDOBJS) $(DLIBS)

View File

@ -0,0 +1,313 @@
/*
* donutsOTEB.h
*
* Created on: Jan 28, 2014
* Author: jdaugherty
*/
#ifndef DONUTSOTEB_H_
#define DONUTSOTEB_H_
void ausRegEPPTK::doOTEB()
{
bool addDomains = false, debug=true, contactCreated = true, doTransfers = false,
transferGainer = false, doDPML=false;
int cmd=0;
const char *thatAccount="secura2-ote2", *thisAccount="secura1-ote";
string op("newInstance");
const string claims("claims"), dpml("custom"), landrush("landrush"), sunrise("sunrise");
LPCrtCmdExtension crtE1( &claims ), crtE2( &dpml );
Transaction thisTest;
scenario(thisConfig->tkScenario,thisConfig->cfg_path);
while(debug) { debug=false; // debugger needs this
try {
Timer::setTime("20140101.010101");
auto_ptr<SessionManager> manager(SessionManagerFactory::newInstance(&props));
auto_ptr<Session> sess(SessionFactory::newInstance(&props));
op = "startup";
manager->startup();
op = "run (keep-alive)";
manager->run();
sess->open();
theseLogs->logN(2,"OTE %s [Hello] (%d).",thisAccount,cmd++);
sess->writeXML(TEST_SE);
sess->read();
theseLogs->logN(1,"OTE Basic Access Setup (%d).",cmd++);
const std::string rrj("renjuan");
const std::string rrjPW("Ab9dW@rd");
const std::string rrjEmail("juan@acm.org");
const std::string rrjName("Ren Ren-Juan");
const std::string rrjCity("Niagara Falls");
const std::vector<std::string>
rrjCrib(1,"2926 2nd Strt");
const std::string rrjProv("NY");
const std::string rrjPC("14305");
const std::string rrjGuo("US");
const std::string rrjOrg("American Kybernetik");
const IntPostalInfo rrjPO(rrjName,rrjOrg,
rrjCrib,rrjCity,rrjProv,rrjPC,rrjGuo);
ContactCreateCommand oteCommand_0(rrj,rrjPW,&rrjPO,rrjEmail);
ContactCreateResponse oteResponse_0;
theseLogs->logN(1,"(skip) Create Contact(s).");
if (!contactCreated) try {
thisTest = Transaction(&oteCommand_0, &oteResponse_0);
manager->execute(thisTest);
}
catch(const std::exception e)
{
theseLogs->logN(1,"Case %d: %s.",cmd++,e.what());
}
catch(...)
{
theseLogs->logN(1,"Case %d Failed, harness catch.",cmd++);
}
theseLogs->logN(1,"Continue OTE Transactions.");
sleep(2);
theseLogs->logN(2,"(%d) Non-LPE check of %s",cmd++,name1);
DomainCheckCommand oteCommand_1(name1);
DomainCheckResponse oteResponse_1;
try {
thisTest = Transaction(&oteCommand_1, &oteResponse_1);
manager->execute(thisTest);
}
catch(...)
{
theseLogs->logN(0,"Case %d Failed, harness catch.",cmd++);
}
theseLogs->logN(2,"(%d) Perform Claims type Check of %s",cmd++,name3);
DomainCheckCommand oteCommand_2(name3);
LPChkCmdExtension chkE(&claims);
oteCommand_2.appendExtension(chkE);
DomainCheckResponse oteResponse_2;
LPChkRespExtension chkRspE;
oteResponse_2.registerExtension(&chkRspE);
try {
thisTest = Transaction(&oteCommand_2, &oteResponse_2);
manager->execute(thisTest);
theseLogs->logN(3,"(%d) Claims %s exist for %s.",
cmd,(chkRspE.doClaimsExist() ? "do" : " do not "),name3);
if (chkRspE.doClaimsExist())
theseLogs->logN(3,"(%d) claim: %s .",cmd,chkRspE.getClaimsKey());
}
catch (EPPException& e)
{ const char *eMsg = e.getMessage().c_str();
const char *opNow = op.c_str();
theseLogs->logN(2,"EPP Exception during OTE B (%s): %s .",opNow,eMsg);
throw e;
}
catch (...)
{
theseLogs->logN(1,"General Exception OTE B (%s).",op.c_str());
}
// Used in all of below
const std::string pw("Ab9dW@rd");
const std::string RID("renjuan");
std::vector<std::string> tech(1,std::string("renjuan") );
std::vector<std::string> admin(1,std::string("renjuan") );
std::vector<std::string> billing(1,std::string("renjuan") );
std::vector<std::string> ns(1,std::string("ns1.google.com") );;
if (addDomains) {
try {
if (1) {
theseLogs->logN(3," (%d) normal create %s in OTE %s.",cmd++, name5, thisAccount);
DomainCreateCommand
oteCommand_3(name5,pw,&RID, &tech, &ns, &admin, &billing);
DomainCreateResponse oteResponse_3;
thisTest = Transaction(&oteCommand_3, &oteResponse_3);
manager->execute(thisTest);
} if (1) {
theseLogs->logN(3," (%d) normal create %s in OTE %s.",cmd++, name4, thisAccount);
DomainCreateCommand
oteCommand_3a(name4,pw,&RID, &tech, &ns, &admin, &billing);
DomainCreateResponse oteResponse_3a;
thisTest = Transaction(&oteCommand_3a, &oteResponse_3a);
manager->execute(thisTest);
} if (0) {
theseLogs->logN(3," (%d) LPE create %s in OTE %s.",cmd++, name5, thisAccount);
DomainCreateCommand
oteCommand_3b(name5,pw,&RID, &tech, &ns, &admin, &billing);
oteCommand_3b.appendExtension(crtE1);
DomainCreateResponse oteResponse_3b;
thisTest = Transaction(&oteCommand_3b, &oteResponse_3b);
manager->execute(thisTest);
}
}
catch (EPPException& e)
{ const char *eMsg = e.getMessage().c_str();
const char *opNow = op.c_str();
theseLogs->logN(2,"EPP Exception during OTE B (%s): %s .",opNow,eMsg);
throw e;
}
catch (...)
{
theseLogs->logN(1,"General Exception OTE B (%s).",op.c_str());
}
}
if (doTransfers) {
DomainTransferRequestCommand
oteCommand_4a(name1,rrjPW);
DomainTransferApproveCommand
oteCommand_4b(name1,rrjPW);
DomainTransferResponse oteResponse_4;
DomainTransferRequestCommand
oteCommand_4c(name2,rrjPW);
DomainTransferApproveCommand
oteCommand_4d(name2,rrjPW);
DomainTransferResponse oteResponse_4a;
try {
theseLogs->logN(4," %s (%d) %s -> %s.", (transferGainer ? "Request" : "Approve") ,cmd++, name1,thatAccount);
thisTest = transferGainer ? Transaction(&oteCommand_4a, &oteResponse_4) :
Transaction(&oteCommand_4b, &oteResponse_4) ;
manager->execute(thisTest);
theseLogs->logN(4," %s (%d) %s -> %s.", (transferGainer ? "Request" : "Approve") ,cmd++, name2,thatAccount);
thisTest = transferGainer ? Transaction(&oteCommand_4c, &oteResponse_4a) :
Transaction(&oteCommand_4d, &oteResponse_4) ;
manager->execute(thisTest);
}
catch(...)
{
theseLogs->logN(0,"Case %d Failed, harness catch.",cmd++);
}
}
if (0) {
theseLogs->logN(2,"(%d) Sunrise create %s with ICANN SMD test data.",++cmd,name1);
DomainCreateCommand oteCommand_5(name1,pw,&RID, &tech, &ns, &admin, &billing);
oteCommand_5.appendExtension(crtE1);
DomainCreateResponse oteResponse_5;
try {
thisTest = Transaction(&oteCommand_5, &oteResponse_5);
manager->execute(thisTest);
}
catch (EPPException& e)
{ const char *eMsg = e.getMessage().c_str();
const char *opNow = op.c_str();
theseLogs->logN(2,"EPP Exception during OTE B (%s): %s .",opNow,eMsg);
throw e;
}
catch (...)
{
theseLogs->logN(1,"General Exception OTE B (%s).",op.c_str());
}
}
theseLogs->logN(2,"(%d) Create %s w Notice ID test data (TCN).",++cmd,name3);
string noticeID("d85159710000000000000008692"),
notAfter("2015-01-01T12:00:00Z"), acceptedDate("2014-01-27T19:00:00Z");
DomainCreateCommand oteCommand_6(name3,pw,&RID, &tech, &ns, &admin, &billing);
crtE1.setNoticeID(noticeID, notAfter, acceptedDate);
oteCommand_6.appendExtension(crtE1);
DomainCreateResponse oteResponse_6;
try {
thisTest = Transaction(&oteCommand_6, &oteResponse_6);
manager->execute(thisTest);
}
catch (EPPException& e)
{ const char *eMsg = e.getMessage().c_str();
const char *opNow = op.c_str();
theseLogs->logN(2,"EPP Exception during OTE B (%s): %s .",opNow,eMsg);
throw e;
}
catch (...)
{
theseLogs->logN(1,"General Exception OTE B (%s).",op.c_str());
}
if (doDPML) { std::string dpmlName("face.dpml.zone");
theseLogs->logN(2,"(%d) Create %s w ICANN SMD file.",++cmd,dpmlName.c_str());
DomainCreateCommand oteCommand_7(dpmlName,pw,&RID, &tech, &ns, &admin, &billing);
crtE2.setSMD();
oteCommand_7.appendExtension(crtE2);
DomainCreateResponse oteResponse_7;
try {
thisTest = Transaction(&oteCommand_7, &oteResponse_7);
manager->execute(thisTest);
}
catch (EPPException& e)
{ const char *eMsg = e.getMessage().c_str();
const char *opNow = op.c_str();
theseLogs->logN(2,"EPP Exception during OTE B (%s): %s .",opNow,eMsg);
throw e;
}
catch (...)
{
theseLogs->logN(1,"General Exception OTE B (%s).",op.c_str());
}
}
theseLogs->logN(0,"End OTE Session.");
sess->close();
manager->shutdown();
}
catch (EPPException& e)
{ const char *eMsg = e.getMessage().c_str();
const char *opNow = op.c_str();
theseLogs->logN(2,"Outer EPP Exception during OTE (%s): %s .",opNow,eMsg);
throw e;
}
catch (...)
{
theseLogs->logN(2,"Outer General Exception in OTE (%s).",op.c_str());
}
}// debug while
}
#endif /* DONUTSOTEB_H_ */

View File

@ -11,14 +11,13 @@
class mdJSON {
private:
static bool parsedOK;
std::string script;
std::string path;
public:
mdJSON(char *fileName);
~mdJSON();
bool run();
bool didParseOK();
mdJSON(char *fileName);
~mdJSON();
bool run(bool parseOnly);
};
#endif /* MDJSON_HPP_ */

View File

@ -168,8 +168,8 @@ void ausRegEPPTK::doOTEC() {
}
i += EVENT_SIZE + event->len;
if (actionableFileEvent) { mdJSON scriptor(event->name);
if (scriptor.didParseOK()) {
if (!scriptor.run()) { monitoring = false;
if (scriptor.run(false)) {
if (!scriptor.run(true)) { monitoring = false;
theseLogs->logN(1, "Run of %s failed. ,/json monitoring stops.\n", event->name );
}
}

View File

@ -29,27 +29,90 @@
#include "se/DomainTransferResponse.hpp"
#include "mdJSON.hpp"
#include <algorithm> // sort
#include <json/json.h>
#include <stdio.h>
using namespace std;
static std::string
readInputTestFile( const char *path )
{
FILE *file = fopen( path, "rb" );
if ( !file )
return std::string("");
fseek( file, 0, SEEK_END );
long size = ftell( file );
fseek( file, 0, SEEK_SET );
std::string text;
char *buffer = new char[size+1];
buffer[size] = 0;
if ( fread( buffer, 1, size, file ) == (unsigned long)size )
text = buffer;
fclose( file );
delete[] buffer;
return text;
}
static bool
parseValueTree( const std::string &input, const std::string &kind, Json::Value &root, const Json::Features &features,
bool parseOnly )
{
Json::Reader reader( features );
bool parsingSuccessful = reader.parse( input, root );
if ( !parsingSuccessful )
{
theseLogs->logN(2, "Failed to parse %s file: \n%s\n",
kind.c_str(),
reader.getFormattedErrorMessages().c_str() );
return true;
}
if ( !parseOnly )
{
}
return false;
}
bool mdJSON::run(bool parseOnly)
{
bool value = false;
Json::Features features;
try
{
std::string input = readInputTestFile( path.c_str() );
if ( input.empty() )
{
theseLogs->logN(1, "Failed to read input or empty input: %s\n", path.c_str() );
return 3;
}
Json::Value root;
value = parseValueTree( input, "input", root, features, parseOnly );
}
catch ( const std::exception &e )
{
theseLogs->logN(1, "Unhandled exception:\n%s\n", e.what() );
value = true;
}
return value;
}
mdJSON::mdJSON(char *fileName) {
script = string(fileName);
path = string(fileName);
}
mdJSON::~mdJSON() {
// TODO Auto-generated destructor stub
}
mdJSON::mdJSON(char *script) {
}
bool mdJSON::run() {
}
bool mdJSON::didParseOK() {
done: return true;
}