Keep pre-rebrand discovery installs compatible

This commit is contained in:
Alexander Sellite 2026-08-25 22:18:43 -04:00
parent de454ff48a
commit ee3982e428
8 changed files with 154 additions and 16 deletions

View file

@ -0,0 +1,43 @@
from __future__ import annotations
import os
import unittest
from unittest.mock import patch
from straywild_discovery.server import ServerConfig
class ServerConfigCompatibilityTests(unittest.TestCase):
def test_legacy_environment_remains_accepted(self) -> None:
with patch.dict(
os.environ,
{
"NETFISHING_DISCOVERY_HOST": "127.0.0.9",
"NETFISHING_DISCOVERY_PORT": "7791",
"NETFISHING_DISCOVERY_BUILD_REVISION": "legacy-config",
},
clear=True,
):
config = ServerConfig.from_environment()
self.assertEqual(config.bind_host, "127.0.0.9")
self.assertEqual(config.bind_port, 7791)
self.assertEqual(config.build_revision, "legacy-config")
def test_straywild_environment_wins_over_legacy_names(self) -> None:
with patch.dict(
os.environ,
{
"straywild_DISCOVERY_HOST": "127.0.0.8",
"NETFISHING_DISCOVERY_HOST": "127.0.0.9",
"straywild_DISCOVERY_PORT": "7792",
"NETFISHING_DISCOVERY_PORT": "7791",
},
clear=True,
):
config = ServerConfig.from_environment()
self.assertEqual(config.bind_host, "127.0.0.8")
self.assertEqual(config.bind_port, 7792)
if __name__ == "__main__":
unittest.main()

View file

@ -77,6 +77,27 @@ class SocialRegistryTests(unittest.TestCase):
[],
)
def test_presence_keeps_pre_rebrand_friend_channels_reachable(self) -> None:
write_token = "c" * 64
legacy_channel = capability_id("NETFISHING_PRESENCE_V1:", write_token)
channels = self.social.publish_presence(
"203.0.113.10",
{
"write_tokens": [write_token],
"online": True,
"display_name": "Voyager",
"room_id": self.room.room_id,
"game_version": GAME_VERSION,
"protocol_version": PROTOCOL_VERSION,
},
)
self.assertIn(legacy_channel, channels)
presence = self.social.query_presence(
[legacy_channel], GAME_VERSION, PROTOCOL_VERSION, self.rooms
)
self.assertEqual(len(presence), 1)
self.assertEqual(presence[0]["channel"], legacy_channel)
def test_invitation_requires_a_current_live_poll(self) -> None:
inbox_token = "b" * 64
with self.assertRaisesRegex(