-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProtocolTest.cpp
129 lines (100 loc) · 5.53 KB
/
ProtocolTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <cppunit/extensions/HelperMacros.h>
#include "ProtocolTest.h"
#include "Msnp.cpp"
#include "Notification.cpp"
#include "Msnp8.cpp"
CPPUNIT_TEST_SUITE_REGISTRATION( ProtocolTest );
using namespace std;
void ProtocolTest::receive(string msg){
this->msn->execute(msg);
}
void ProtocolTest::send(string msg){
CPPUNIT_ASSERT_EQUAL(msg, this->mockConnection->sended);
}
void ProtocolTest::TestChallenger(void) {
string chl = "29409134351025259292";
string digest = this->msn->challenger(chl);
CPPUNIT_ASSERT_EQUAL(chl, digest);
}
void ProtocolTest::TestSession(void) {
//Sends the MSN Client version
//$this->send("VER 1 MSNP8 CVR0\r\n");
//Acknowledge
this->receive("VER 1 MSNP8 CVR0\r\n");
this->send("CVR 2 0x0409 win 4.10 i386 MSNMSGR 6.0.0602 MSMSGS dvader@empire.com\r\n");
//Client sends information
this->receive("CVR 2 6.0.0602 1.0.000 http://download.microsoft.com/download/8/a/4/\r\n");
this->send("USR 3 TWN I dvader@empire.com\r\n");
//Redirect
this->receive("XFR 3 NS 207.46.106.118:1863 0 207.46.104.20:1863\r\n");
this->send("VER 4 MSNP8 CVR0\r\n");
//TODO: CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid host", "207.46.106.118",this->mockConnection->host);
//cout << this->mockConnection->host;
//CPPUNIT_ASSERT_EQUAL("207.46.106.118",this->mockConnection->host);
// this->assertEquals("1863",this->mockConnection->port, "Invalid port");
this->receive("VER 4 MSNP8 CVR0\r\n");
this->send("CVR 5 0x0409 win 4.10 i386 MSNMSGR 6.0.0602 MSMSGS dvader@empire.com\r\n");
this->receive("CVR 5 6.0.0602 6.0.0602 1.0.0000 http://download.microsoft.com/download/8/a/4/8a42bcae-f533-4468-b871-d2bc8dd32e9e/SETUP9x.EXE http://messenger.msn.com\r\n");
this->send("USR 6 TWN I dvader@empire.com\r\n");
this->receive("USR 6 TWN S lc=1033,id=507,tw=40,fs=1,ru=http%3A%2F%2Fmessenger%2Emsn%2Ecom,ct=1062764229,kpp=1,kv=5,ver=2.1.0173.1,tpf=43f8a4c8ed940c04e3740be46c4d1619\r\n");
this->send("USR 7 TWN S t=53*1hAu8ADuD3TEwdXoOMi08sD*2!cMrntTwVMTjoB3p6stWTqzbkKZPVQzA5NOt19SLI60PY!b8K4YhC!Ooo5ug$$&p=5eKBBC!yBH6ex5mftp!a9DrSb0B3hU8aqAWpaPn07iCGBw5akemiWSd7t2ot!okPvIR!Wqk!MKvi1IMpxfhkao9wpxlMWYAZ!DqRfACmyQGG112Bp9xrk04!BVBUa9*H9mJLoWw39m63YQRE1yHnYNv08nyz43D3OnMcaCoeSaEHVM7LpR*LWDme29qq2X3j8N\r\n");
/*
$this->assertFalse($this->_mockClient->logged, "User not logged, ConnectionListener::onLogged shoudn't be called");
//Logged
$this->receive("USR 7 OK dvader@empire.com Dart%20Vader 1 0\r\n");
$this->assertTrue($this->_mockClient->logged, "User logged, ConnectionListener::onLogged should be called");
$this->send("SYN 1 0\r\n");
$this->receive("SYN 8 27 5 4\r\n");
$this->receive("GTC A\r\n");
$this->receive("BLP AL\r\n");
$this->receive("PRP PHH O1%20234\r\n");
$this->receive("PRP PHM 56%20789\r\n");
$this->assertEquals($this->_mockClient->group, null);
$this->receive("LSG 0 Sifth\r\n");
$this->assertEquals($this->_mockClient->group['group_id'], '0');
$this->assertEquals($this->_mockClient->group['name'], 'Sifth');
$this->receive("LSG 1 Jedis\r\n");
$this->assertEquals($this->_mockClient->group['group_id'], '1');
$this->assertEquals($this->_mockClient->group['name'], 'Jedis');
//Add Emperor as a contact
$this->assertEquals($this->_mockClient->contact, null);
$this->receive("LST emperor@empire.com Emperor 13 0\r\n");
$this->assertEquals($this->_mockClient->contact['user'], 'emperor@empire.com');
$this->assertEquals($this->_mockClient->contact['nick'], 'Emperor');
$this->assertEquals($this->_mockClient->contact['lists'], '13');
$this->assertEquals($this->_mockClient->contact['groups'], '0');
$this->receive("BPR MOB Y\r\n");
//Add Luke as a contact
$this->receive("LST luke@rebels.org Luke 3 1\r\n");
$this->assertEquals($this->_mockClient->contact['user'], 'luke@rebels.org');
$this->assertEquals($this->_mockClient->contact['nick'], 'Luke');
$this->assertEquals($this->_mockClient->contact['lists'], '3'); //Luke dosen't have Vader in their list! Bastard!!
$this->assertEquals($this->_mockClient->contact['groups'], '1');
$this->send("CHG 9 NLN 0\r\n");
$this->receive("CHG 9 NLN 0\r\n");
//Initial Presence
$this->receive("ILN 9 NLN emperor@empire.com Emperor 24\r\n");
$this->receive("ILN 9 IDL luke@rebels.org Luke 268435492\r\n");
//Challenger
$this->receive("CHL 0 29409134351025259292\r\n");
$this->send("QRY 10 msmsgs@msnmsgr.com 32\r\nd0c1178c689350104350d99f8c36ed9c");
//Presence
$this->receive("NLN NLN luke@rebels.org Luke%20JediMaster 268435492\r\n");//Available
$this->receive("NLN BSY luke@rebels.org Luke%20JediMaster 268435492\r\n");//Busy
$this->receive("NLN IDL luke@rebels.org Luke%20JediMaster 268435492\r\n");//Idle
$this->receive("NLN BRB luke@rebels.org Luke%20JediMaster 268435492\r\n");//Be Right Back
$this->receive("NLN AWY luke@rebels.org Luke%20JediMaster 268435492\r\n");//Away
$this->receive("NLN PHN luke@rebels.org Luke%20JediMaster 268435492\r\n");//On the Phone
$this->receive("NLN LUN luke@rebels.org Luke%20JediMaster 268435492\r\n");//Out to lunch
$this->receive("FLN luke@rebels.org\r\n");
$this->receive("FLN emperor@empire.com\r\n");
// Call
$this->receive("RNG 876505971 65.54.228.15:1863 CKI 4216622.2513084 emperor@empire.com Emperor");
//$this->assertEquals("876505971", $this->mockCall->call);
//$this->assertEquals("65.54.228.15", $this->mockCall->server);
//$this->assertEquals(1863, $this->mockCall->port);
//$this->assertEquals("4216622.2513084", $this->mockCall->cki);
//$this->assertEquals("emperor@empire.com", $this->mockCall->username);
//$this->assertEquals("Emperor", $this->mockCall->nick);
*/
}