@@ -287,6 +287,34 @@ BOOST_AUTO_TEST_CASE(ClientDetectsMapBufferOverflow)
287287 BOOST_TEST (client.GetState () == ClientState::Stopped);
288288}
289289
290+ BOOST_AUTO_TEST_CASE (ClientReportsWrongPasswordResponse)
291+ {
292+ GameClient client;
293+ GameMessageInterface& clientMsgInterface = client;
294+ MockClientInterface callbacks;
295+ client.SetInterface (&callbacks);
296+ TestServer server;
297+ const auto serverPort = server.tryListen ();
298+ BOOST_TEST_REQUIRE (serverPort >= 0 );
299+ const auto serverType = rttr::test::randomEnum<ServerType>();
300+ mock::sequence s;
301+ MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::Initiated).once ();
302+ MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::VerifyServer).once ();
303+ MOCK_EXPECT (callbacks.CI_NextConnectState ).in (s).with (ConnectState::QueryPw).once ();
304+ MOCK_EXPECT (callbacks.CI_Error ).in (s).with (ClientError::WrongPassword).once ();
305+
306+ BOOST_TEST_REQUIRE (client.Connect (" localhost" , rttr::test::randString (10 ), serverType, serverPort, false , false ));
307+ clientMsgInterface.OnGameMessage (GameMessage_Player_Id (1 ));
308+ clientMsgInterface.OnGameMessage (GameMessage_Server_TypeOK (GameMessage_Server_TypeOK::StatusCode::Ok, " " ));
309+ BOOST_TEST_REQUIRE (boost::dynamic_pointer_cast<GameMessage_Server_Type>(client.GetMainPlayer ().sendQueue .pop ()));
310+ BOOST_TEST_REQUIRE (
311+ boost::dynamic_pointer_cast<GameMessage_Server_Password>(client.GetMainPlayer ().sendQueue .pop ()));
312+
313+ clientMsgInterface.OnGameMessage (GameMessage_Server_Password (" false" ));
314+
315+ BOOST_TEST (client.GetState () == ClientState::Stopped);
316+ }
317+
290318using namespace std ::chrono_literals;
291319
292320BOOST_AUTO_TEST_CASE (CanSetNewSpeed)
0 commit comments