예제 #1
0
 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;
 }
예제 #2
0
    void testRVC()
    {
        RvcMessageHandler rvcHandler(protocol_);
        VnocMessageSocketHandler<MockTcpConnection> handler(conn_);
        handler.setProtocol(protocol_);
        handler.start();
        char rvc[]={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,

            0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,
            0x00,0x00,0x00,0x00,

            0x00,0x00,
            0x43};
        conn_->setRecv(rvc, sizeof(rvc));
        const char *sendBuf = conn_->getSendBuf();
        //return a AVC message
        CPPUNIT_ASSERT(sendBuf[24]==0x15);
    }
예제 #3
0
    void testRLI()
    {
        char 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};
        RliMessageHandler rvcHandler(protocol_);
        VnocMessageSocketHandler<MockTcpConnection> handler(conn_);
        handler.setProtocol(protocol_);
        handler.start();
        conn_->setRecv(testRLI, sizeof(testRLI));
        const char *sendBuf = conn_->getSendBuf();
        //return an AVC message
        CPPUNIT_ASSERT(sendBuf[24]==0x17);
    }
예제 #4
0
 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;
 }
예제 #5
0
 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;
 }