X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2Ftesting%2FTestStep.cpp;h=fdbd7989fc8a3374e52dc728919f3028913cb7b8;hp=07ed685e44efd3dbc38c34e8a33b6bc492987a7b;hb=51a6c4b326153804233788bd8fda4966052d4288;hpb=2dc559e7fbe3f250f5aff1a23614181fc0b2e7f1 diff --git a/example/diameter/launcher/testing/TestStep.cpp b/example/diameter/launcher/testing/TestStep.cpp index 07ed685..fdbd798 100644 --- a/example/diameter/launcher/testing/TestStep.cpp +++ b/example/diameter/launcher/testing/TestStep.cpp @@ -353,41 +353,49 @@ throw() { bool TestStepSendxml::do_execute() throw() { bool success = false; - std::string failReason, s_warn; + std::string failReason; MyDiameterEntity *entity = a_originHost->getEntity(); // by default MyLocalServer *localServer = a_originHost->getDiameterServer(); // by default const TestStepWait *tsw = NULL; - - // Create comm message: anna::diameter::comm::Message *msg = a_originHost->createCommMessage(); - //msg->clearBody(); - msg->setBody(a_message); try { - // Update sequence for answers: - if (a_waitForRequestStepNumber != -1) { // is an answer: try to copy sequence information; alert about Session-Id discrepance - // Request which was received: - tsw = static_cast(a_testCase->getStep(a_waitForRequestStepNumber)); - const anna::DataBlock &request = tsw->getMsgDataBlock(); - anna::diameter::HopByHop hbh = anna::diameter::codec::functions::getHopByHop(request); - anna::diameter::EndToEnd ete = anna::diameter::codec::functions::getEndToEnd(request); + if (a_waitForRequestStepNumber != -1) { - // Update sequence: - anna::diameter::codec::functions::setHopByHop(a_message, hbh); - anna::diameter::codec::functions::setEndToEnd(a_message, ete); + // Referenced request in the 'wait for request step': + tsw = static_cast(a_testCase->getStep(a_waitForRequestStepNumber)); + const anna::DataBlock &referenceRequest = tsw->getMsgDataBlock(); + std::string sessionIdReferenceRequest = anna::diameter::helpers::base::functions::getSessionId(referenceRequest); + bool thisIsAnswer = anna::diameter::codec::functions::isRequest(getMsgDataBlock()); - // Check Session-Id for warning ... - std::string sessionIdAnswer = anna::diameter::helpers::base::functions::getSessionId(a_message); - std::string sessionIdRequest = anna::diameter::helpers::base::functions::getSessionId(request); + if (thisIsAnswer) { // is an answer: try to copy sequence information; alert about Session-Id discrepance + anna::diameter::HopByHop hbh = anna::diameter::codec::functions::getHopByHop(referenceRequest); + anna::diameter::EndToEnd ete = anna::diameter::codec::functions::getEndToEnd(referenceRequest); - if (sessionIdRequest != sessionIdAnswer) { - s_warn = anna::functions::asString("Sending an answer which Session-Id (%s) is different than supposed corresponding request (%s)", sessionIdAnswer.c_str(), sessionIdRequest.c_str()); - LOGWARNING(anna::Logger::warning(s_warn, ANNA_FILE_LOCATION)); - a_testCase->addDebugSummaryHint(s_warn); + // Update sequence: + anna::diameter::codec::functions::setHopByHop(a_message, hbh); + anna::diameter::codec::functions::setEndToEnd(a_message, ete); + } + + // Session-Id substitution: + std::string thisSessionId = anna::diameter::helpers::base::functions::getSessionId(getMsgDataBlock()); + if (thisSessionId != sessionIdReferenceRequest) { + static anna::diameter::codec::Message codecMsg; + codecMsg.decode(getMsgDataBlock()); + codecMsg.getAvp("Session-Id")->getUTF8String()->setValue(sessionIdReferenceRequest); + a_message = codecMsg.code(); + std::string trace = anna::functions::asString("Replacing %s Session-Id (%s) to set the corresponding request one (%s)", (thisIsAnswer ? "answer":"request"), thisSessionId.c_str(), sessionIdReferenceRequest.c_str()); + LOGDEBUG(anna::Logger::debug(trace, ANNA_FILE_LOCATION)); + a_testCase->addDebugSummaryHint(trace); } } + // Create comm message: + //msg->clearBody(); + msg->setBody(a_message); + + if (getType() == Type::Sendxml2e) { anna::diameter::comm::ClientSession *usedClientSession = NULL;