359 lines
12 KiB
C
359 lines
12 KiB
C
/*
|
|
* donutsOTEB.h
|
|
*
|
|
* Created on: Jan 28, 2014
|
|
* Author: jdaugherty
|
|
*/
|
|
|
|
#ifndef REGISTRYOTE_H_
|
|
#define REGISTRYOTB_H_
|
|
|
|
ACTx *inProgress;
|
|
|
|
int nCases,thisCase;
|
|
|
|
testDescs theseSpecs;
|
|
testCases theseCases;
|
|
testFuncs theseFuncs;
|
|
|
|
Json::Value theseParms;
|
|
|
|
|
|
bool acTkInitialised = false, fatal = false, done = false, transferGainer,
|
|
bindError;
|
|
|
|
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;
|
|
|
|
commandFrame *ctxt;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
inline bool checkAndSetStr(string &target,const char *jsonName,const char *defaultValue,bool required) {
|
|
|
|
bool value = true;
|
|
|
|
if (!theseParms.isMember(jsonName)) {
|
|
if (required) {
|
|
theseLogs->logN(2,"%d - no '%s' string field",thisCase+1,jsonName);
|
|
ACPRODINOTE::bindError = true;
|
|
value = false;
|
|
}
|
|
}
|
|
|
|
// TODO: Check string type
|
|
|
|
target = theseParms.get(jsonName,defaultValue).asString();
|
|
return value;
|
|
|
|
}
|
|
|
|
inline bool checkNameOK() {
|
|
|
|
if (!theseParms.isMember("name")) {
|
|
theseLogs->logN(1,"%d - no 'name' field",thisCase+1);
|
|
ACPRODINOTE::bindError = true;
|
|
return false;
|
|
}
|
|
|
|
ctxt->shitName = theseParms.get("name","noname").asString();
|
|
thisName = ctxt->shitName.c_str();
|
|
return true;
|
|
|
|
}
|
|
|
|
inline bool checkContOK() {
|
|
|
|
bool value = checkAndSetStr(ctxt->ctc,"cont_id","renjuan",true);
|
|
|
|
ctxt->thisDesc = theseSpecs[thisCase].case_desc;
|
|
|
|
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);
|
|
|
|
return value;
|
|
}
|
|
|
|
inline bool checkPWDOK() {
|
|
|
|
return checkAndSetStr(ctxt->pw,"cont_pw","Ab9dW@rd",true);
|
|
|
|
}
|
|
|
|
inline bool checkPhaseOK() {
|
|
|
|
return checkAndSetStr(ctxt->thisLaunchPhase,"launch_phase","sunrise",true);
|
|
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
inline void newCommandFrame() {
|
|
|
|
ctxt = new commandFrame();
|
|
|
|
ctxt->ctcOrg = string("American Kybernetik");
|
|
ctxt->ctcProv = string("NY");
|
|
ctxt->ctcPC = string("14305");
|
|
|
|
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");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void check() { newCommandFrame();
|
|
|
|
if (checkNameOK()) {
|
|
|
|
TxQ <DomainCheckCommand , DomainCheckResponse, LPChkCmdExtension, LPChkRespExtension > *txq;
|
|
txq = new TxQ<DomainCheckCommand , DomainCheckResponse, LPChkCmdExtension, LPChkRespExtension>
|
|
(thisName,thisDesc);
|
|
|
|
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 );
|
|
|
|
}
|
|
}
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
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();
|
|
|
|
if (checkNameOK() && checkContOK())
|
|
{
|
|
TxQ <DomainCreateCommand , DomainCreateResponse, LPCrtCmdExtension, LPCrtRespExtension > *txq;
|
|
txq = new TxQ<DomainCreateCommand , DomainCreateResponse, LPCrtCmdExtension, LPCrtRespExtension >
|
|
( ctxt->shitName, ctxt->pw, &ctxt->RID );
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void createClaimOverride() { newCommandFrame();
|
|
|
|
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);
|
|
|
|
txq->ce->setNoticeID(ctxt->noticeID, ctxt->notAfter, ctxt->acceptedDate);
|
|
txq->c->appendExtension(*txq->ce);
|
|
|
|
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);
|
|
|
|
}
|
|
}
|
|
|
|
void createContact() { newCommandFrame();
|
|
|
|
if (checkContOK() ) {
|
|
|
|
TxQ <ContactCreateCommand , ContactCreateResponse, CommandExtension, ResponseExtension > *txq;
|
|
txq = new TxQ<ContactCreateCommand , ContactCreateResponse, CommandExtension, ResponseExtension >
|
|
(ctxt->ctc,ctxt->ctcPW,&ctxt->ctcPO,ctxt->ctcEmail);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void dpmlCreate() { newCommandFrame();
|
|
|
|
if (checkNameOK() && checkPhaseOK() && checkSMD()) {
|
|
|
|
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);
|
|
|
|
txq->ce->setSMD(ctxt->smdData);
|
|
txq->c->appendExtension(*txq->ce);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void sunriseCreate() { newCommandFrame();
|
|
|
|
if (checkNameOK() && checkPhaseOK() && checkSMD()) {
|
|
|
|
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);
|
|
|
|
txq->ce->setSMD(ctxt->smdData);
|
|
txq->c->appendExtension(*txq->ce);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void transfer() { newCommandFrame();
|
|
|
|
if (checkNameOK() && checkAndSetBool(transferGainer,"isGainer",true,true)) {
|
|
|
|
if (transferGainer) {
|
|
|
|
TxQ <DomainTransferRequestCommand , DomainTransferResponse, CommandExtension, ResponseExtension > *txq;
|
|
txq = new TxQ<DomainTransferRequestCommand , DomainTransferResponse, CommandExtension, ResponseExtension>
|
|
(ctxt->shitName,ctxt->pw,thisDesc);
|
|
|
|
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);
|
|
|
|
} else {
|
|
|
|
TxQ < DomainTransferApproveCommand , DomainTransferResponse, CommandExtension, ResponseExtension > *txq;
|
|
txq = new TxQ< DomainTransferApproveCommand , DomainTransferResponse, CommandExtension, ResponseExtension >
|
|
(ctxt->shitName,ctxt->pw,thisDesc);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // transfer
|
|
|
|
int setFuncs() {
|
|
|
|
theseFuncs["case00"] = createContact;
|
|
theseFuncs["case01"] = check;
|
|
theseFuncs["case02"] = checkClaims;
|
|
theseFuncs["case03"] = create;
|
|
theseFuncs["case04"] = sunriseCreate;
|
|
theseFuncs["case05"] = createClaimOverride;
|
|
theseFuncs["case06"] = transfer;
|
|
|
|
theseLogs->logN(1,"%d test case backends available for scripting",theseFuncs.size());
|
|
}
|
|
|
|
|
|
#endif /* REGISTRY_X */
|