This commit is contained in:
Ren RenJuan 2014-01-29 00:02:24 +00:00
parent 3bdafc2a41
commit 5df36b62f5
6 changed files with 356 additions and 25 deletions

View File

@ -6,8 +6,13 @@
#include <iostream>
#include <string>
#ifndef MD_JSON
static int g_numErrors = 0;
int TEST_errorCount() { return g_numErrors; }
#else
extern int g_numErrors;
int TEST_errorCount();
#endif
#define ASSERT_STR_EQ(got, expect) ASSERT_EQ(std::string(got), std::string(expect))
@ -38,7 +43,9 @@ int TEST_errorCount() { return g_numErrors; }
<< ") for (" << #got" != "#expect")" << std::endl; }
#define FAIL(msg) std::cerr << __FILE__ << ":" << __LINE__ << ": " << msg << std::endl
#ifdef MD_JSON
int TEST_run(void (*test)());
#else
int TEST_run(void (*test)())
{
try
@ -62,4 +69,5 @@ int TEST_run(void (*test)())
}
return g_numErrors;
}
#endif
#endif // __TEST_HPP

View File

@ -0,0 +1,308 @@
/*
* donutsOTEB.h
*
* Created on: Jan 28, 2014
* Author: jdaugherty
*/
#ifndef REGISTRYOTE_H_
#define REGISTRYOTB_H_
namespace AC_OTE {
static TestEnvironment props;
static std::string TEST_SE =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><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\"><hello/></epp>";
auto_ptr<SessionManager> manager(SessionManagerFactory::newInstance(&props));
auto_ptr<Session> sess(SessionFactory::newInstance(&props));
bool acTkInitialised = false, fatal = false, done = false;
const char *thisRegistry="Donuts", *thatAccount="secura2-ote2", *thisAccount="secura1-ote";
char *thisName;
int cmd=0;
string op("newInstance");
const string claims("claims"), dpml("custom"), landrush("landrush"), sunrise("sunrise");
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 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") );;
const IntPostalInfo rrjPO(rrjName,rrjOrg,
rrjCrib,rrjCity,rrjProv,rrjPC,rrjGuo);
LPCrtCmdExtension crtE1( &claims ), crtE2( &dpml );
Transaction thisTest;
void check() {
theseLogs->logN(2,"(%d) Unextended check of %s",cmd++,thisName);
DomainCheckCommand oteCommand_1(thisName);
DomainCheckResponse oteResponse_1;
try {
thisTest = Transaction(&oteCommand_1, &oteResponse_1);
manager->execute(thisTest);
}
catch(...)
{
theseLogs->logN(0,"Case %d Failed, fatal to suite.",cmd++);
fatal = true;
}
}
void checkClaims() {
theseLogs->logN(2,"(%d) Perform Claims type Check of %s",cmd++,thisName);
DomainCheckCommand oteCommand_2(thisName);
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 "),thisName);
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 (%s): %s .",opNow,eMsg);
throw e;
}
catch (...)
{
theseLogs->logN(1,"General Exception OTE B (%s).",op.c_str());
}
}
void create() {
theseLogs->logN(3," (%d) normal create %s in OTE %s.",cmd++, thisName, thisAccount);
DomainCreateCommand
oteCommand_3(thisName,pw,&RID, &tech, &ns, &admin, &billing);
DomainCreateResponse oteResponse_3;
thisTest = Transaction(&oteCommand_3, &oteResponse_3);
manager->execute(thisTest);
}
void createClaimOverride() {
theseLogs->logN(2,"(%d) Create %s w Notice ID test data (TCN).",++cmd,thisName);
string noticeID("d85159710000000000000008692"),
notAfter("2015-01-01T12:00:00Z"), acceptedDate("2014-01-27T19:00:00Z");
DomainCreateCommand oteCommand_6(thisName,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());
}
}
void createContact() {
ContactCreateCommand oteCommand_0(rrj,rrjPW,&rrjPO,rrjEmail);
ContactCreateResponse oteResponse_0;
theseLogs->logN(1,"(skip) Create Contact(s).");
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++);
}
}
void dpmlCreate() { 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());
}
}
void sunriseCreate() {
theseLogs->logN(2,"(%d) Sunrise create %s with ICANN SMD test data.",++cmd,thisName);
DomainCreateCommand oteCommand_5(thisName,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());
}
}
void transfer(bool &transferGainer) {
DomainTransferRequestCommand
oteCommand_4a(thisName,rrjPW);
DomainTransferApproveCommand
oteCommand_4b(thisName,rrjPW);
DomainTransferResponse oteResponse_4;
try {
theseLogs->logN(4," %s (%d) %s -> %s.", (transferGainer ? "Request" : "Approve") ,cmd++, thisName,thatAccount);
thisTest = transferGainer ? Transaction(&oteCommand_4a, &oteResponse_4) :
Transaction(&oteCommand_4b, &oteResponse_4) ;
manager->execute(thisTest);
}
catch(...)
{
theseLogs->logN(0,"Case %d Failed, non fatal.",cmd++);
}
} // transfer
} // AC_OTE
using namespace AC_OTE;
bool walkDontRun() {
}
bool walkAndRun() {
}
bool ausRegEPPTK::registryXOTE()
{
if (!acTkInitialised) {
scenario(thisConfig->tkScenario,thisConfig->cfg_path);
acTkInitialised = true;
}
while(!done) {
try {
Timer::setTime("20140101.010101");
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();
// Walk the JSON tree from "testSuite00" and do any setup of
// recognized variables, announce the test case.
// No problem so far so do again this time to execute
theseLogs->logN(0,"End OTE Session.");
theseLogs->logN(0,"Restart with toolkit scenario >= 5 for production ops.");
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 /* REGISTRY_X */

View File

@ -1,4 +1,4 @@
#ifdef MD_AUSREG
#if defined(MD_AUSREG) || defined(MD_JSON)
#include "se/PollRequestCommand.hpp"
#include "se/PollResponse.hpp"
#include "session/Transaction.hpp"
@ -10,7 +10,7 @@
#include "common/init.hpp"
#ifdef MD_AUSREG
#if defined(MD_AUSREG) || defined(MD_JSON)
#include "common/Test.hpp"
#include <pthread.h>
#include <memory>
@ -22,6 +22,10 @@ class ausRegEPPTK {
friend class masterDaemon;
private:
bool didDie; // Json fatal error
public: int tkScenario;
int daysRunning;
@ -35,5 +39,8 @@ class ausRegEPPTK {
void doOTEB();
void doOTEC();
void doOTEP();
bool registryXOTE();
bool walkDontRun();
bool walkAndRun();
};

View File

@ -14,9 +14,14 @@ private:
std::string path;
public:
bool fatal;
mdJSON (char *fileName);
~mdJSON();
bool run(bool parseOnly);
bool parse();
bool didDie() {return fatal;}
void die(){ fatal = true;}
};

View File

@ -168,10 +168,18 @@ void ausRegEPPTK::doOTEC() {
}
i += EVENT_SIZE + event->len;
if (actionableFileEvent) { mdJSON scriptor(event->name);
if (scriptor.run(false)) {
if (!scriptor.run(true)) { monitoring = false;
theseLogs->logN(1, "Run of %s failed. ,/json monitoring stops.\n", event->name );
if (scriptor.parse()) {
if (registryXOTE()) {
if (didDie) {
monitoring = false;
theseLogs->logN(1, "Run of %s fatal error. ./json monitoring stops.\n", event->name );
theseLogs->logN(0, "Restart process to resume operations." );
} else {
theseLogs->logN(1, "Run of %s has errors ./json monitoring continues.\n", event->name );
}
} else
theseLogs->logN(1, " %s completed OK. ./json monitoring continues. \n", event->name );
}
else {
theseLogs->logN(1, "Parse of %s failed. ,/json monitoring continues.\n", event->name );

View File

@ -4,7 +4,7 @@
* Created on: Jan 28, 2014
* Author: jdaugherty
*/
#define MD_JSON
#include "cliever-md.h"
#include "session/SessionFactory.hpp"
#include "session/SessionManagerProperties.hpp"
@ -33,8 +33,12 @@
#include <json/json.h>
#include <stdio.h>
static Json::Value root;
using namespace std;
#include "RegistryXOTE.h"
static std::string
readInputTestFile( const char *path )
{
@ -54,11 +58,8 @@ readInputTestFile( const char *path )
return text;
}
static bool
parseValueTree( const std::string &input, const std::string &kind, Json::Value &root, const Json::Features &features,
bool parseOnly )
parseValueTree( const std::string &input, const std::string &kind, Json::Value &root, const Json::Features &features)
{
Json::Reader reader( features );
bool parsingSuccessful = reader.parse( input, root );
@ -70,14 +71,9 @@ parseValueTree( const std::string &input, const std::string &kind, Json::Value
return true;
}
if ( !parseOnly )
{
}
return false;
}
bool mdJSON::run(bool parseOnly)
bool mdJSON::parse()
{
bool value = false;
Json::Features features;
@ -91,8 +87,7 @@ bool mdJSON::run(bool parseOnly)
return 3;
}
Json::Value root;
value = parseValueTree( input, "input", root, features, parseOnly );
return parseValueTree( input, "input", root, features );
}
catch ( const std::exception &e )