DRDE/AusRegCliever/include/AC_OTE.h

359 lines
12 KiB
C
Raw Normal View History

2014-01-29 00:02:24 +00:00
/*
* donutsOTEB.h
*
* Created on: Jan 28, 2014
* Author: jdaugherty
*/
#ifndef REGISTRYOTE_H_
#define REGISTRYOTB_H_
2014-02-04 19:58:44 +00:00
ACTx *inProgress;
2014-01-29 00:02:24 +00:00
2014-01-31 23:38:13 +00:00
int nCases,thisCase;
2014-01-29 02:48:14 +00:00
2014-02-04 19:58:44 +00:00
testDescs theseSpecs;
2014-01-29 18:10:26 +00:00
testCases theseCases;
testFuncs theseFuncs;
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
Json::Value theseParms;
2014-01-31 23:38:13 +00:00
bool acTkInitialised = false, fatal = false, done = false, transferGainer,
bindError;
2014-02-04 19:58:44 +00:00
const string claims("claims"), dpml("custom"), landrush("landrush"), sunrise("sunrise");
const char *thisName = "registrar.ote", *thisDesc;
string thisRegistry("Unknown"), thatAccount("Unknown"), thisAccount("Unknown");
int debug=1000;
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
commandFrame *ctxt;
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
inline bool checkAndSetBool(bool &target,const char *jsonName,const bool defaultValue,bool required) {
bool value = true;
if (!theseParms.isMember(jsonName)) {
if (required) {
theseLogs->logN(2,"%d - no '%s' boolean field",thisCase+1,jsonName);
ACPRODINOTE::bindError = true;
value = false;
}
}
// TODO: Check bool type
target = theseParms.get(jsonName,defaultValue).asBool();
return value;
}
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
inline bool checkAndSetStr(string &target,const char *jsonName,const char *defaultValue,bool required) {
2014-01-29 11:44:52 +00:00
2014-02-04 19:58:44 +00:00
bool value = true;
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
if (!theseParms.isMember(jsonName)) {
if (required) {
theseLogs->logN(2,"%d - no '%s' string field",thisCase+1,jsonName);
ACPRODINOTE::bindError = true;
value = false;
}
}
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
// TODO: Check string type
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
target = theseParms.get(jsonName,defaultValue).asString();
return value;
}
2014-01-31 23:38:13 +00:00
inline bool checkNameOK() {
2014-02-04 19:58:44 +00:00
if (!theseParms.isMember("name")) {
theseLogs->logN(1,"%d - no 'name' field",thisCase+1);
2014-01-31 23:38:13 +00:00
ACPRODINOTE::bindError = true;
return false;
}
2014-02-04 19:58:44 +00:00
ctxt->shitName = theseParms.get("name","noname").asString();
thisName = ctxt->shitName.c_str();
2014-01-31 23:38:13 +00:00
return true;
}
inline bool checkContOK() {
2014-02-04 19:58:44 +00:00
bool value = checkAndSetStr(ctxt->ctc,"cont_id","renjuan",true);
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
ctxt->thisDesc = theseSpecs[thisCase].case_desc;
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
value = value ? true : checkAndSetStr(ctxt->ctc,"cont_name","renjuan",true);
value = value ? true : checkAndSetStr(ctxt->ctcPW,"cont_pw","Ab9dW@rd",true);
value = value ? true : checkAndSetStr(ctxt->ctcEmail,"cont_email","juan@acm.org",true);
checkAndSetStr(ctxt->ctcName,"cont_name","Ren Ren-Juan",false);
checkAndSetStr(ctxt->ctcCity,"cont_city","Niagara Falls",false);
checkAndSetStr(ctxt->ctcProv,"cont_province","NY",false);
checkAndSetStr(ctxt->ctcPC,"cont_postal_code","14305",false);
checkAndSetStr(ctxt->ctcGuo,"cont_guo","US",false);
checkAndSetStr(ctxt->ctcOrg,"cont_org","American Kybernetik",false);
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
return value;
2014-01-31 23:38:13 +00:00
}
2014-02-04 19:58:44 +00:00
inline bool checkPWDOK() {
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
return checkAndSetStr(ctxt->pw,"cont_pw","Ab9dW@rd",true);
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
}
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
inline bool checkPhaseOK() {
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
return checkAndSetStr(ctxt->thisLaunchPhase,"launch_phase","sunrise",true);
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
}
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
inline bool checkSMD() {
#define MAX_SMD_SIZE (64*1024)
bool value = checkAndSetStr(ctxt->smdFileName,"smd_data","",true);
if (value) { string fullPath = ctxt->smdPath + theseParms.get("smd_data","").asString();
if( access( fullPath.c_str(), R_OK ) != -1 ) {struct stat st; int result,size; char *buffer;
stat(fullPath.c_str(), &st);
size = st.st_size;
if (!size || size > MAX_SMD_SIZE) {
theseLogs->logN(2,"%d - '%s' zero size or too big ",thisCase+1,fullPath.c_str() );
value = false;
goto done;
}
FILE *file;
buffer = (char *)malloc(size);
if (file = fopen(fullPath.c_str(), "r"))
{result = fread (buffer,1,size,file);
fclose(file);
if (result != size)
{theseLogs->logN(2,"%d - error reading '%s' ",thisCase+1,fullPath.c_str() ); value = false;}
else ctxt->smdData = string(buffer);
}
theseLogs->logN(3,"%d - %d bytes SMD data read from '%s' ",thisCase+1,size,fullPath.c_str() );
} else {
value = false;
theseLogs->logN(2,"%d - can't read SMD data from '%s' ",thisCase+1,fullPath.c_str() );
}
}
done: return value;
}
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
inline void newCommandFrame() {
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
ctxt = new commandFrame();
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
ctxt->ctcOrg = string("American Kybernetik");
ctxt->ctcProv = string("NY");
ctxt->ctcPC = string("14305");
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
ctxt->thisDesc = theseSpecs[thisCase].case_desc;
thisDesc = ctxt->thisDesc.c_str();
if (!theseParms.isMember("dryrun")) { // TODO: Check bool type
ctxt->thisDryRun = theseParms.get("dryrun",false).asBool();
theseLogs->logN(0," ... this case disabled transactioning");
}
2014-01-29 00:02:24 +00:00
}
2014-02-04 19:58:44 +00:00
void check() { newCommandFrame();
2014-01-30 02:30:49 +00:00
2014-01-31 23:38:13 +00:00
if (checkNameOK()) {
2014-01-30 02:30:49 +00:00
2014-02-04 19:58:44 +00:00
TxQ <DomainCheckCommand , DomainCheckResponse, LPChkCmdExtension, LPChkRespExtension > *txq;
txq = new TxQ<DomainCheckCommand , DomainCheckResponse, LPChkCmdExtension, LPChkRespExtension>
(thisName,thisDesc);
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
txq->set(ctxt,theseSpecs[thisCase].case_name.c_str());
theseLogs->logN(2,"%d .. Queue Unextended IETF Standard check of %s",thisCase+1,thisName);
acq.push( txq );
2014-01-31 23:38:13 +00:00
}
2014-02-04 19:58:44 +00:00
}
void finishCase02() {
TxQ <DomainCheckCommand , DomainCheckResponse, LPChkCmdExtension, LPChkRespExtension > *txq;
txq = (TxQ<DomainCheckCommand, DomainCheckResponse, LPChkCmdExtension, LPChkRespExtension>*) inProgress;
LPChkRespExtension *lpce = (LPChkRespExtension *)txq->ce;
theseLogs->logN(2," Claims %s exist for %s.",
(lpce->doClaimsExist() ? "do" : " do not "), txq->ctx->shitName.c_str());
if (lpce->doClaimsExist())
theseLogs->logN(2," claim: %s .",lpce->getClaimsKey());
2014-01-29 00:02:24 +00:00
}
2014-02-04 19:58:44 +00:00
void checkClaims() { newCommandFrame();
if (checkNameOK()) {
TxQ <DomainCheckCommand , DomainCheckResponse, LPChkCmdExtension, LPChkRespExtension > *txq;
txq = new TxQ<DomainCheckCommand , DomainCheckResponse, LPChkCmdExtension, LPChkRespExtension >
(&claims, thisName, thisDesc);
txq->c->appendExtension(*txq->ce);
txq->r->registerExtension(txq->re);
txq->set(ctxt,theseSpecs[thisCase].case_name.c_str());
txq->finisher = finishCase02;
theseLogs->logN(2,"%d .. Queue Claims type Check of %s",thisCase+1,thisName);
acq.push(txq);
}
}
void create() { newCommandFrame();
2014-01-29 00:02:24 +00:00
2014-01-31 23:38:13 +00:00
if (checkNameOK() && checkContOK())
{
2014-02-04 19:58:44 +00:00
TxQ <DomainCreateCommand , DomainCreateResponse, LPCrtCmdExtension, LPCrtRespExtension > *txq;
txq = new TxQ<DomainCreateCommand , DomainCreateResponse, LPCrtCmdExtension, LPCrtRespExtension >
( ctxt->shitName, ctxt->pw, &ctxt->RID );
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
txq->set(ctxt,theseSpecs[thisCase].case_name.c_str());
theseLogs->logN(3,"%d .. Queue default create of %s ( %s ).",thisCase+1, thisName, thisAccount.c_str());
acq.push(txq);
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
}
2014-01-31 23:38:13 +00:00
2014-01-29 00:02:24 +00:00
}
2014-02-04 19:58:44 +00:00
void createClaimOverride() { newCommandFrame();
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
if (checkNameOK() && checkPhaseOK()
&& checkAndSetStr(ctxt->noticeID,"noticeID","d85159710000000000000008692",true)
&& checkAndSetStr(ctxt->notAfter,"notAfter","2015-01-01T12:00:00Z",true)
&& checkAndSetStr(ctxt->acceptedDate,"acceptedDate","2014-01-27T19:00:00Z",true) )
{
TxQ <DomainCreateCommand , DomainCreateResponse, LPCrtCmdExtension, LPCrtRespExtension > *txq;
txq = new TxQ<DomainCreateCommand , DomainCreateResponse, LPCrtCmdExtension, LPCrtRespExtension >
(ctxt->shitName, ctxt->pw, &ctxt->RID, &ctxt->tech, &ctxt->ns, &ctxt->admin, &ctxt->billing, NULL, &ctxt->thisLaunchPhase);
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
txq->ce->setNoticeID(ctxt->noticeID, ctxt->notAfter, ctxt->acceptedDate);
txq->c->appendExtension(*txq->ce);
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
txq->set(ctxt,theseSpecs[thisCase].case_name.c_str());
theseLogs->logN(2,"%d .. Queue create %s w Notice ID test data (TCN).",thisCase+1,thisName);
acq.push(txq);
2014-01-31 23:38:13 +00:00
}
2014-01-29 00:02:24 +00:00
}
2014-02-04 19:58:44 +00:00
void createContact() { newCommandFrame();
if (checkContOK() ) {
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
TxQ <ContactCreateCommand , ContactCreateResponse, CommandExtension, ResponseExtension > *txq;
txq = new TxQ<ContactCreateCommand , ContactCreateResponse, CommandExtension, ResponseExtension >
(ctxt->ctc,ctxt->ctcPW,&ctxt->ctcPO,ctxt->ctcEmail);
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
txq->set(ctxt,theseSpecs[thisCase].case_name.c_str());
theseLogs->logN(2,"%d .. Queue create contact %s.",thisCase+1, ctxt->ctc.c_str());
acq.push(txq);
}
2014-01-29 00:02:24 +00:00
}
2014-02-04 19:58:44 +00:00
void dpmlCreate() { newCommandFrame();
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
if (checkNameOK() && checkPhaseOK() && checkSMD()) {
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
TxQ <DomainCreateCommand , DomainCreateResponse, LPCrtCmdExtension, LPCrtRespExtension > *txq;
txq = new TxQ<DomainCreateCommand , DomainCreateResponse, LPCrtCmdExtension, LPCrtRespExtension >
(ctxt->shitName, ctxt->pw, ctxt->RID, ctxt->tech, ctxt->ns, ctxt->admin, ctxt->billing);
2014-01-30 02:30:49 +00:00
2014-02-04 19:58:44 +00:00
txq->ce->setSMD(ctxt->smdData);
txq->c->appendExtension(*txq->ce);
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
txq->set(ctxt,theseSpecs[thisCase].case_name.c_str());
theseLogs->logN(2,"(%d) Queue DPML block create %s w boitedetest.smd data.",thisCase+1,thisName);
acq.push(txq);
2014-01-31 23:38:13 +00:00
}
2014-01-29 00:02:24 +00:00
2014-01-29 11:44:52 +00:00
}
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
void sunriseCreate() { newCommandFrame();
if (checkNameOK() && checkPhaseOK() && checkSMD()) {
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
TxQ <DomainCreateCommand , DomainCreateResponse, LPCrtCmdExtension, LPCrtRespExtension > *txq;
txq = new TxQ<DomainCreateCommand , DomainCreateResponse, LPCrtCmdExtension, LPCrtRespExtension >
(ctxt->shitName, ctxt->pw, &ctxt->RID, &ctxt->tech, &ctxt->ns, &ctxt->admin, &ctxt->billing, NULL, &ctxt->thisLaunchPhase);
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
txq->ce->setSMD(ctxt->smdData);
txq->c->appendExtension(*txq->ce);
2014-01-30 02:30:49 +00:00
2014-02-04 19:58:44 +00:00
txq->set(ctxt,theseSpecs[thisCase].case_name.c_str());
theseLogs->logN(2,"%d .. Queue Sunrise create %s with ICANN SMD test data.",thisCase+1,thisName);
acq.push(txq);
2014-01-29 00:02:24 +00:00
2014-01-31 23:38:13 +00:00
}
2014-01-29 00:02:24 +00:00
}
2014-02-04 19:58:44 +00:00
void transfer() { newCommandFrame();
if (checkNameOK() && checkAndSetBool(transferGainer,"isGainer",true,true)) {
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
if (transferGainer) {
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
TxQ <DomainTransferRequestCommand , DomainTransferResponse, CommandExtension, ResponseExtension > *txq;
txq = new TxQ<DomainTransferRequestCommand , DomainTransferResponse, CommandExtension, ResponseExtension>
(ctxt->shitName,ctxt->pw,thisDesc);
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
txq->set(ctxt,theseSpecs[thisCase].case_name.c_str());
theseLogs->logN(4,"%d .. Queue %s %s -> %s.", (transferGainer ? "Request" : "Approve") ,thisCase+1,
ctxt->shitName.c_str(),thatAccount.c_str(),thisAccount.c_str());
acq.push(txq);
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
} else {
2014-01-29 00:02:24 +00:00
2014-02-04 19:58:44 +00:00
TxQ < DomainTransferApproveCommand , DomainTransferResponse, CommandExtension, ResponseExtension > *txq;
txq = new TxQ< DomainTransferApproveCommand , DomainTransferResponse, CommandExtension, ResponseExtension >
(ctxt->shitName,ctxt->pw,thisDesc);
2014-01-31 23:38:13 +00:00
2014-02-04 19:58:44 +00:00
txq->set(ctxt,theseSpecs[thisCase].case_name.c_str());
theseLogs->logN(4,"%d .. Queue %s %s -> %s.", thisCase+1, (transferGainer ? "Request" : "Approve") ,
ctxt->shitName.c_str(),thisAccount.c_str() ,thatAccount.c_str());
acq.push(txq);
}
2014-01-29 00:02:24 +00:00
2014-01-31 23:38:13 +00:00
}
2014-01-29 00:02:24 +00:00
} // transfer
2014-01-29 02:48:14 +00:00
int setFuncs() {
2014-01-29 00:02:24 +00:00
2014-01-29 02:48:14 +00:00
theseFuncs["case00"] = createContact;
theseFuncs["case01"] = check;
theseFuncs["case02"] = checkClaims;
theseFuncs["case03"] = create;
2014-01-29 11:44:52 +00:00
theseFuncs["case04"] = sunriseCreate;
2014-01-30 02:30:49 +00:00
theseFuncs["case05"] = createClaimOverride;
2014-01-29 11:44:52 +00:00
theseFuncs["case06"] = transfer;
2014-02-04 19:58:44 +00:00
theseLogs->logN(1,"%d test case backends available for scripting",theseFuncs.size());
2014-01-29 11:44:52 +00:00
}
2014-01-29 00:02:24 +00:00
#endif /* REGISTRY_X */