|
|
@ -132,7 +132,25 @@ impl<DA: DataAccess> ServerState for LoginServerState<DA> { |
|
|
|
mod test {
|
|
|
|
use std::time::SystemTime;
|
|
|
|
use super::*;
|
|
|
|
use elseware::utf8_to_array;
|
|
|
|
|
|
|
|
const LOGIN_PACKET: RecvLoginPacket = RecvLoginPacket::Login(Login {
|
|
|
|
flag: 0,
|
|
|
|
tag: 65536,
|
|
|
|
guildcard: 0,
|
|
|
|
version: 65,
|
|
|
|
unknown1: [0, 0, 0, 255, 0, 14],
|
|
|
|
team: 0,
|
|
|
|
username: [116, 101, 115, 116, 117, 115, 101, 114, 0, 0, 0, 0, 0, 0, 0, 0], // utf8_to_array!("testuser", 16),
|
|
|
|
unknown2: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
password: [109, 121, 112, 97, 115, 115, 119, 111, 114, 100, 0, 0, 0, 0, 0, 0], // utf8_to_array!("mypassword", 16),
|
|
|
|
unknown3: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
hwinfo: [129, 1, 1, 1, 1, 1, 1, 1],
|
|
|
|
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
});
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_correct_login() {
|
|
|
@ -157,25 +175,7 @@ mod test { |
|
|
|
|
|
|
|
let mut server = LoginServerState::new(TestData {});
|
|
|
|
|
|
|
|
let send = server.handle(ClientId(1), &RecvLoginPacket::Login(Login {
|
|
|
|
flag: 0,
|
|
|
|
tag: 65536,
|
|
|
|
guildcard: 0,
|
|
|
|
version: 65,
|
|
|
|
unknown1: [0, 0, 0, 255, 0, 14],
|
|
|
|
team: 0,
|
|
|
|
username: utf8_to_array!("testuser", 16),
|
|
|
|
unknown2: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
password: utf8_to_array!("mypassword", 16),
|
|
|
|
unknown3: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
hwinfo: [129, 1, 1, 1, 1, 1, 1, 1],
|
|
|
|
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
|
|
|
|
})).unwrap().collect::<Vec<_>>();
|
|
|
|
let send = server.handle(ClientId(1), &LOGIN_PACKET).unwrap().collect::<Vec<_>>();
|
|
|
|
assert!(send == vec![
|
|
|
|
(ClientId(1), SendLoginPacket::LoginResponse(LoginResponse {
|
|
|
|
flag: 0,
|
|
|
@ -207,26 +207,8 @@ mod test { |
|
|
|
}
|
|
|
|
|
|
|
|
let mut server = LoginServerState::new(TestData {});
|
|
|
|
let send = server.handle(ClientId(1), &LOGIN_PACKET).unwrap().collect::<Vec<_>>();
|
|
|
|
|
|
|
|
let send = server.handle(ClientId(1), &RecvLoginPacket::Login(Login {
|
|
|
|
flag: 0,
|
|
|
|
tag: 65536,
|
|
|
|
guildcard: 0,
|
|
|
|
version: 65,
|
|
|
|
unknown1: [0, 0, 0, 255, 0, 14],
|
|
|
|
team: 0,
|
|
|
|
username: utf8_to_array!("testuser", 16),
|
|
|
|
unknown2: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
password: utf8_to_array!("mypassword", 16),
|
|
|
|
unknown3: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
hwinfo: [129, 1, 1, 1, 1, 1, 1, 1],
|
|
|
|
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
|
|
|
|
})).unwrap().collect::<Vec<_>>();
|
|
|
|
assert!(send == vec![
|
|
|
|
(ClientId(1), SendLoginPacket::LoginResponse(LoginResponse {
|
|
|
|
flag: 0,
|
|
|
@ -262,26 +244,8 @@ mod test { |
|
|
|
}
|
|
|
|
|
|
|
|
let mut server = LoginServerState::new(TestData {});
|
|
|
|
let send = server.handle(ClientId(1), &LOGIN_PACKET).unwrap().collect::<Vec<_>>();
|
|
|
|
|
|
|
|
let send = server.handle(ClientId(1), &RecvLoginPacket::Login(Login {
|
|
|
|
flag: 0,
|
|
|
|
tag: 65536,
|
|
|
|
guildcard: 0,
|
|
|
|
version: 65,
|
|
|
|
unknown1: [0, 0, 0, 255, 0, 14],
|
|
|
|
team: 0,
|
|
|
|
username: utf8_to_array!("testuser", 16),
|
|
|
|
unknown2: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
password: utf8_to_array!("mypassword", 16),
|
|
|
|
unknown3: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
hwinfo: [129, 1, 1, 1, 1, 1, 1, 1],
|
|
|
|
security_data: [74, 97, 107, 101, 115, 101, 114, 118, 50, 48, 50, 48, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
|
|
|
|
|
|
})).unwrap().collect::<Vec<_>>();
|
|
|
|
assert!(send == vec![
|
|
|
|
(ClientId(1), SendLoginPacket::LoginResponse(LoginResponse {
|
|
|
|
flag: 0,
|
|
|
|