void testRLIwithAccountNumberAndPassword() { RliMessageHandler rlihandler(protocol_); VnocMessageSocketHandler<MockTcpConnection> handler(conn_); handler.setProtocol(protocol_); handler.start(); MSG_RLI rliMessage; unsigned char tmp[16] = {0}; srand((unsigned int)time(0)); for(int i = 0; i < 16; ++i) { tmp[i] = rand() % 256; } rliMessage.SetAccountNumber(tmp, 16); for(int i = 0; i < 16; ++i) { tmp[i] = rand() % 256; } rliMessage.SetPassword(tmp, 16); PackMessage packer; int len = packer.GetMessageLen(&rliMessage); char *buf = new char[len]; packer.Pack(&rliMessage, (byte *)buf, len); conn_->setRecv(buf, len); char *sendBuf = (char*)conn_->getSendBuf(); //return an ALI message with login-success CMessageParser parser; CMessage *msg = parser.Parse((byte*)sendBuf, conn_->getSendLen()); CPPUNIT_ASSERT(msg->GetMessageType() == MSG_ALI_TYPE); CPPUNIT_ASSERT(((MSG_ALI*)msg)->GetLoginResult() == 0); delete msg; delete buf; }
void MSGAPSParseTest() { byte testParamO [] = {0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02}; byte testParamT [] = {0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03}; byte testParamS [] = {0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04}; byte testAPS [] = {0x56, 0x00, 0x00,0x01, 0x00,0x00,0x00,0x35, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x19, 0x00,0x00,0x00,0x00, 0x01, 0x00,0x00,0x00,0x10, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x00,0x00, 0x43}; byte testPackAPS[100] = {0}; //APS CMessageParser msgParser; CMessage* msgAPS = msgParser.Parse(testAPS,sizeof(testAPS)); CPPUNIT_ASSERT(msgAPS->GetMessageType() == MSG_APS_TYPE);//验证消息类型是RPS MSG_APS* msg_aps = (MSG_APS *)msgAPS; CPPUNIT_ASSERT(msg_aps->GetSerial() == 1); CPPUNIT_ASSERT(memcmp(msg_aps->GetGUID(),testParamO,sizeof(byte) * 16) == 0); CPPUNIT_ASSERT(memcmp(msg_aps->GetMessageSynchro(),testParamO,sizeof(byte) * 16) == 0); delete msg_aps; }
void MSGRVCParseTest() { byte testParamO [] = {0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02}; byte testParamT [] = {0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03}; byte testParamS [] = {0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04}; byte testRVC [] = {0x56, 0x00, 0x00,0x01, 0x00,0x00,0x00,0x35, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x14, 0x00,0x00,0x00,0x00, 0x01, 0x00,0x00,0x00,0x10, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x00,0x00, 0x43}; byte testPackRVC[53] = {0}; CMessageParser msgParser; CMessage* msgRVC = msgParser.Parse(testRVC,sizeof(testRVC)); CPPUNIT_ASSERT(msgRVC->GetMessageType() == MSG_RVC_TYPE);//验证消息类型是RVC MSG_RVC* msg_rvc = (MSG_RVC *)msgRVC; CPPUNIT_ASSERT(msg_rvc->GetSerial() == 1); CPPUNIT_ASSERT(memcmp(msg_rvc->GetGUID(),testParamO,sizeof(byte) * 16) == 0); CPPUNIT_ASSERT(memcmp(msg_rvc->GetMachineAddress(),testParamO,16) == 0); delete msg_rvc; }
/** * Parse the Push SL message using XML parser. * If Push Message is an SLC then convert it first to text using * CWbxmlConverterUtil class. */ void CSLContentHandler::ParsePushMsgL() { __LOG_PTR_DEBUG("CSLContentHandler::ParsePushMsgL called") CMessageParser* myParser = CMessageParser::NewL ( *iMessage, *this, &sltagstable::Table, &slattributetable::Table, &slattributevaluetable::Table ); CleanupStack::PushL ( myParser ); myParser->ParseMessageL (); User::LeaveIfError ( myParser->LastError() ); CleanupStack::PopAndDestroy ( myParser ); // if 'action' attribute not specified, the value 'execute-low' is used. if( iPushMsgAction == KErrNotFound ) { iPushMsgAction= CSLPushMsgEntry::ESLPushMsgExecuteLow; } // 'href' attribute is mandatory, if not specified then leave with an error. if( !iHrefBuf ) { User::Leave(KErrCorrupt); } iState= ESearching; IdleComplete(); }
void testRVC() { RvcMessageHandler rvchandler(protocol_); VnocMessageSocketHandler<MockTcpConnection> handler(conn_); handler.setProtocol(protocol_); handler.start(); MSG_RVC rvcMessage; PackMessage packer; int len = packer.GetMessageLen(&rvcMessage); char *buf = new char[len]; packer.Pack(&rvcMessage, (byte *)buf, len); conn_->setRecv(buf, len); const char *sendBuf = conn_->getSendBuf(); //return an AVC message CMessageParser parser; CMessage *msg = parser.Parse((byte*)sendBuf, conn_->getSendLen()); CPPUNIT_ASSERT(msg->GetMessageType() == MSG_AVC_TYPE); delete msg; delete buf; }
void testRLIdefault() { RliMessageHandler rlihandler(protocol_); VnocMessageSocketHandler<MockTcpConnection> handler(conn_); handler.setProtocol(protocol_); handler.start(); MSG_RLI rliMessage; PackMessage packer; int len = packer.GetMessageLen(&rliMessage); char *buf = new char[len]; packer.Pack(&rliMessage, (byte *)buf, len); conn_->setRecv(buf, len); char *sendBuf = (char*)conn_->getSendBuf(); //return an ALI message with login-failure. CMessageParser parser; CMessage *msg = parser.Parse((byte*)sendBuf, conn_->getSendLen()); CPPUNIT_ASSERT(msg->GetMessageType() == MSG_ALI_TYPE); CPPUNIT_ASSERT(((MSG_ALI*)msg)->GetLoginResult() == 1); delete msg; delete buf; }
void CAdviceBoard::init() { CFCGIApp::init(); initDB(); CManagers::getInstance()->getSessionManager()->setUserType<CUser>(); // Paths INIT CPathsHelper* paths = CPathsHelper::getInstance(); // User content paths paths->addPath("app", "application/*"); paths->addPath("txt", "text/*"); paths->addPath("aud", "audio/*"); paths->addPath("img", "image/*"); paths->addPath("img/preview", "image/*"); paths->addPath("vid", "video/*"); // Site content paths (readonly) paths->addPath("", "image/vnd.microsoft.icon", true); paths->addPath("www", "application/*, text/*", true); paths->addPath("stl", "text/css", true); paths->addPath("scr", "text/javascript, application/x-shockwave-flash", true); paths->addPath("scr/jquery", "text/javascript", true); paths->addPath("img/previewicons", "image/*", true); paths->addPath("img/controls", "image/*", true); // Temlates INIT CTemplateHelper* templates = CTemplateHelper::getInstance(); const CPath* templatesDir = paths->getPath("www"); templates->loadTemplate(templatesDir, "header_t.html", "header"); templates->loadTemplate(templatesDir, "footer_t.html", "footer"); templates->loadTemplate(templatesDir, "content.html", "content"); templates->loadTemplate(templatesDir, "indexPage.html", "indexPage"); templates->loadTemplate(templatesDir, "post.html", "post"); templates->loadTemplate(templatesDir, "thread.html", "thread"); templates->loadTemplate(templatesDir, "controls.html", "controls"); templates->loadTemplate(templatesDir, "attach.html", "attach"); templates->loadTemplate(templatesDir, "survey.html", "survey"); templates->loadTemplate(templatesDir, "newsTemplate.html", "news"); templates->loadTemplate(templatesDir, "surveyResult.html", "surveyResult"); templates->loadTemplate(templatesDir, "surveyCreationForm.html", "surveysPage"); templates->loadTemplate(templatesDir, "leftPanel.html", "leftPanel"); templates->loadTemplate(templatesDir, "newThreadForm.html", "newThreadForm"); templates->loadTemplate(templatesDir, "newPostForm.html", "newPostForm"); templates->loadTemplate(templatesDir, "sessionPage.html", "sessionPage"); templates->loadTemplate(templatesDir, "settingsPage.html", "settingsPage"); templates->loadTemplate(templatesDir, "userPage.html", "userPage"); templates->loadTemplate(templatesDir, "editPage.html", "editPage"); templates->loadTemplate(templatesDir, "rulesPage.html", "rulesPage"); templates->loadTemplate(templatesDir, "helpPage.html", "helpPage"); // Parser INIT CMessageParser* messageParser = CMessageParser::getInstance(); messageParser->addAllowedTag("p"); messageParser->addAllowedTag("b"); messageParser->addAllowedTag("i"); messageParser->addAllowedTag("u"); messageParser->addAllowedTag("li"); messageParser->addAllowedTag("ol"); messageParser->addAllowedTag("ul"); messageParser->addAllowedTag("h1"); messageParser->addAllowedTag("h2"); messageParser->addAllowedTag("h3"); messageParser->addAllowedTag("br", false); // Page manager INIT CPageManager* pageManager = CManagers::getInstance()->getPageManager(); pageManager->setErrorPage(new CSiteErrorPage("errorPage","","")); pageManager->addPageType<CSiteIndexPage>("index"); pageManager->addPageType<CCatPage>("b"); pageManager->addPageType<CCatPage>("mu"); pageManager->addPageType<CCatPage>("tv"); pageManager->addPageType<CCatPage>("lor"); pageManager->addPageType<CCatPage>("bo"); pageManager->addPageType<CCatPage>("vg"); pageManager->addPageType<CCatPage>("a"); pageManager->addPageType<CCatPage>("sb"); pageManager->addPageType<CCatPage>("d"); pageManager->addPageType<CThreadPage>("thread"); pageManager->addPageType<CSessionsPage>("sessions"); pageManager->addPageType<CSettingsPage>("settings"); pageManager->addPageType<CFavoritesPage>("favorites"); pageManager->addPageType<CPremodPage>("premod"); pageManager->addPageType<CUserContentPage>("usercontent"); pageManager->addPageType<CComplainPage>("complains"); pageManager->addPageType<CEditPage>("edit"); pageManager->addPageType<CSurveyPage>("surveys"); pageManager->addPageType<CRulesPage>("ruuru"); pageManager->addPageType<CHelpPage>("help"); // Text helper INIT CTextHelper* textHelper = CTextHelper::getInstance(); }
void MSGALIParseTest() { byte testParamO [] = {0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02}; byte testParamT [] = {0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03}; byte testParamS [] = {0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04}; byte testALI [] = {0x56, 0x00, 0x00,0x01, 0x00,0x00,0x00,0x4E, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x17, 0x00,0x00,0x00,0x00, 0x03, 0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x10, 0x00,0x00,0x00,0x10, 0x1e, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x00,0x00, 0x43}; byte testPackALI[100] = {0}; CMessageParser msgParser; CMessage* msgALI = msgParser.Parse(testALI,sizeof(testALI)); CPPUNIT_ASSERT(msgALI->GetMessageType() == MSG_ALI_TYPE);//验证消息类型是ALI MSG_ALI* msg_ali = (MSG_ALI *)msgALI; CPPUNIT_ASSERT(msg_ali->GetSerial() == 1); CPPUNIT_ASSERT(memcmp(msg_ali->GetGUID(),testParamO,sizeof(byte) * 16) == 0); CPPUNIT_ASSERT(msg_ali->GetLoginResult() == 0x1E); CPPUNIT_ASSERT(memcmp(msg_ali->GetATLGUID(),testParamT,sizeof(byte) * 16) == 0); delete msg_ali; }
void MSGRPSParseTest() { byte testParamO [] = {0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02}; byte testParamT [] = {0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03}; byte testParamS [] = {0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04}; byte testRPS [] = {0x56, 0x00, 0x00,0x01, 0x00,0x00,0x00,0x67, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x18, 0x00,0x00,0x00,0x00, 0x05, 0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x10, 0x00,0x00,0x00,0x10, 0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x10, 0x01, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 'A', 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x00,0x00, 0x43}; byte testPackRPS[120] = {0}; //RPS CMessageParser msgParser; CMessage* msgRPS = msgParser.Parse(testRPS,sizeof(testRPS)); CPPUNIT_ASSERT(msgRPS->GetMessageType() == MSG_RPS_TYPE);//验证消息类型是RPS MSG_RPS* msg_rps = (MSG_RPS *)msgRPS; CPPUNIT_ASSERT(msg_rps->GetSerial() == 1); CPPUNIT_ASSERT(memcmp(msg_rps->GetGUID(),testParamO,sizeof(byte) * 16) == 0); CPPUNIT_ASSERT(msg_rps->GetRank() == 0x01); CPPUNIT_ASSERT(memcmp(msg_rps->GetNickname(),testParamO,sizeof(byte) * 16) == 0); CPPUNIT_ASSERT(memcmp(msg_rps->GetAutograph(),testParamT,sizeof(byte) * 16) == 0); CPPUNIT_ASSERT(msg_rps->GetHeadForm() == 'A'); CPPUNIT_ASSERT(memcmp(msg_rps->GetHeadPortrait(),testParamS,sizeof(byte) * 16) == 0); delete msg_rps; }
void MSGRLIParseTest() { byte testParamO [] = {0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02}; byte testParamT [] = {0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03}; byte testParamS [] = {0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04}; byte testRLI [] = {0x56, 0x00, 0x00,0x01, 0x00,0x00,0x00,0x5D, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x16, 0x00,0x00,0x00,0x00, 0x03, 0x00,0x00,0x00,0x10, 0x00,0x00,0x00,0x10, 0x00,0x00,0x00,0x10, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x00,0x00, 0x43}; byte testPackRLI[100] = {0}; //RLI CMessageParser msgParser; CMessage* msgRLI = msgParser.Parse(testRLI,sizeof(testRLI)); CPPUNIT_ASSERT(msgRLI->GetMessageType() == MSG_RLI_TYPE);//验证消息类型是RLI MSG_RLI* msg_rli = (MSG_RLI *)msgRLI; CPPUNIT_ASSERT(msg_rli->GetSerial() == 1); CPPUNIT_ASSERT(memcmp(msg_rli->GetGUID(),testParamO,sizeof(byte) * 16) == 0); CPPUNIT_ASSERT(memcmp(msg_rli->GetVerificationCode(),testParamO,sizeof(byte) * 16) == 0); CPPUNIT_ASSERT(memcmp(msg_rli->GetAccountNumber(),testParamT,16) == 0); CPPUNIT_ASSERT(memcmp(msg_rli->GetPassword(),testParamS,16) == 0); delete msg_rli; }
void MSGAVCParseTest() { byte testParamO [] = {0x01,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02}; byte testParamT [] = {0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03}; byte testParamS [] = {0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04, 0x04,0x04,0x04,0x04}; byte testAVC [] = {0x56, 0x00, 0x00,0x01, 0x00,0x00,0x00,0x3F, 0x01,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x15, 0x00,0x00,0x00,0x00, 0x03, 0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x10, 0x1e, 0x1e, 0x01,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02, 0x00,0x00, 0x43}; byte testPackAVC[63] = {0}; //AVC CMessageParser msgParser; CMessage* msgAVC = msgParser.Parse(testAVC,sizeof(testAVC)); CPPUNIT_ASSERT(msgAVC->GetMessageType() == MSG_AVC_TYPE);//验证消息类型是AVC MSG_AVC* msg_avc = (MSG_AVC *)msgAVC; CPPUNIT_ASSERT(msg_avc->GetSerial() == 1); CPPUNIT_ASSERT(memcmp(msg_avc->GetGUID(),testParamO,sizeof(byte) * 16) == 0); CPPUNIT_ASSERT(memcmp(msg_avc->GetCaptcha(),testParamO,16) == 0); CPPUNIT_ASSERT(msg_avc->GetLoginTag() == 0x1e); CPPUNIT_ASSERT(msg_avc->GetCaptchaType() == 0x1e); delete msg_avc; }