diff --git a/tests/data/test-data.sql b/tests/data/test-data.sql index 4d9c2f5c5..f9add180f 100644 --- a/tests/data/test-data.sql +++ b/tests/data/test-data.sql @@ -1,4 +1,5 @@ insert into login (id, login, email, password, steamid, create_time) values + (10, 'friends', 'friends@example.com', SHA2('friends', 256), null, '2000-01-01 00:00:00'), (50, 'player_service1', 'ps1@example.com', SHA2('player_service1', 256), null, '2000-01-01 00:00:00'), (51, 'player_service2', 'ps2@example.com', SHA2('player_service2', 256), null, '2000-01-01 00:00:00'), (52, 'player_service3', 'ps3@example.com', SHA2('player_service3', 256), null, '2000-01-01 00:00:00'), @@ -69,7 +70,8 @@ insert into game_player_stats (gameId, playerId, AI, faction, color, team, place delete from friends_and_foes where user_id = 1 and subject_id = 2; insert into friends_and_foes (user_id, subject_id, status) values - (2, 1, 'FRIEND'); + (2, 1, 'FRIEND'), + (10, 1, 'FRIEND'); insert into `mod` (id, display_name, author) values diff --git a/tests/integration_tests/test_server.py b/tests/integration_tests/test_server.py index 555e41ae2..e25cdec29 100644 --- a/tests/integration_tests/test_server.py +++ b/tests/integration_tests/test_server.py @@ -203,6 +203,42 @@ async def test_game_info_not_broadcast_to_foes(lobby_server): await asyncio.wait_for(read_until_command(proto2, "game_info"), 0.2) +async def test_game_info_broadcast_to_friends(lobby_server): + # test is the friend of friends + _, _, proto1 = await connect_and_sign_in( + ("friends", "friends"), lobby_server + ) + _, _, proto2 = await connect_and_sign_in( + ("test", "test_password"), lobby_server + ) + _, _, proto3 = await connect_and_sign_in( + ("Rhiza", "puff_the_magic_dragon"), lobby_server + ) + await read_until_command(proto1, "game_info") + await read_until_command(proto2, "game_info") + await read_until_command(proto3, "game_info") + + await proto1.send_message({ + "command": "game_host", + "title": "Friends Only", + "mod": "faf", + "visibility": "friends" + }) + + # The host and his friend should see the game + msg = await read_until_command(proto1, "game_info") + msg2 = await read_until_command(proto2, "game_info") + + assert msg == msg2 + assert msg["featured_mod"] == "faf" + assert msg["title"] == "Friends Only" + assert msg["visibility"] == "friends" + + # However, the other person should not see the game + with pytest.raises(asyncio.TimeoutError): + await asyncio.wait_for(read_until_command(proto3, "game_info"), 0.2) + + @pytest.mark.parametrize("user", [ ("test", "test_password"), ("ban_revoked", "ban_revoked"),