mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-06-06 12:41:38 +00:00
cleanup tests (format)
This commit is contained in:
@@ -93,8 +93,8 @@ async def test_auto_propagation_logic():
|
||||
# announce1 is 1 hop, but probe fails
|
||||
# announce3 is 2 hops, probe succeeds
|
||||
mock_hops.side_effect = lambda dh: 1 if dh == bytes.fromhex("aaaa1111") else 2
|
||||
mock_probe.side_effect = (
|
||||
lambda dh: False if dh == bytes.fromhex("aaaa1111") else True
|
||||
mock_probe.side_effect = lambda dh: (
|
||||
False if dh == bytes.fromhex("aaaa1111") else True
|
||||
)
|
||||
|
||||
await manager.check_and_update_propagation_node()
|
||||
|
||||
@@ -353,17 +353,19 @@ def test_markdown_renderer_fuzzing(text):
|
||||
@given(
|
||||
text=st.one_of(
|
||||
st.text(min_size=0, max_size=5000),
|
||||
st.sampled_from([
|
||||
"<script>alert(1)</script>",
|
||||
"[x](javascript:alert(1))",
|
||||
"[x](data:text/html,<script>alert(1)</script>)",
|
||||
"**" * 2000,
|
||||
"#" * 2000,
|
||||
"`" * 2000,
|
||||
"[](" * 500 + ")" * 500,
|
||||
"\x00\x01\x02\n\t",
|
||||
"\ufffd" * 100,
|
||||
]),
|
||||
st.sampled_from(
|
||||
[
|
||||
"<script>alert(1)</script>",
|
||||
"[x](javascript:alert(1))",
|
||||
"[x](data:text/html,<script>alert(1)</script>)",
|
||||
"**" * 2000,
|
||||
"#" * 2000,
|
||||
"`" * 2000,
|
||||
"[](" * 500 + ")" * 500,
|
||||
"\x00\x01\x02\n\t",
|
||||
"\ufffd" * 100,
|
||||
]
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_markdown_renderer_dangerous_patterns(text):
|
||||
|
||||
@@ -157,9 +157,7 @@ async def test_status_includes_sync_storage_and_confirmation_metrics(mock_app):
|
||||
if r.path == "/api/v1/lxmf/propagation-node/sync"
|
||||
)
|
||||
|
||||
mock_app.current_context.message_router.get_outbound_propagation_node.return_value = (
|
||||
b"somehash"
|
||||
)
|
||||
mock_app.current_context.message_router.get_outbound_propagation_node.return_value = b"somehash"
|
||||
mock_app.current_context.message_router.propagation_transfer_last_result = 8
|
||||
|
||||
with (
|
||||
@@ -213,9 +211,7 @@ async def test_status_hidden_metric_is_clamped_to_zero(mock_app):
|
||||
if r.path == "/api/v1/lxmf/propagation-node/sync"
|
||||
)
|
||||
|
||||
mock_app.current_context.message_router.get_outbound_propagation_node.return_value = (
|
||||
b"somehash"
|
||||
)
|
||||
mock_app.current_context.message_router.get_outbound_propagation_node.return_value = b"somehash"
|
||||
mock_app.current_context.message_router.propagation_transfer_last_result = 1
|
||||
|
||||
with (
|
||||
|
||||
@@ -77,7 +77,7 @@ class TestMarkdownRenderer(unittest.TestCase):
|
||||
cases = [
|
||||
"<script>alert(1)</script>",
|
||||
"<SCRIPT>alert(1)</SCRIPT>",
|
||||
"<script src=\"evil.js\"></script>",
|
||||
'<script src="evil.js"></script>',
|
||||
"</script><script>alert(1)</script>",
|
||||
]
|
||||
for s in cases:
|
||||
|
||||
@@ -290,4 +290,6 @@ def test_on_lxmf_sending_failed_no_propagation(mock_app):
|
||||
mock_app.on_lxmf_sending_state_updated = MagicMock()
|
||||
|
||||
mock_app.on_lxmf_sending_failed(mock_msg)
|
||||
mock_app.on_lxmf_sending_state_updated.assert_called_once_with(mock_msg, context=None)
|
||||
mock_app.on_lxmf_sending_state_updated.assert_called_once_with(
|
||||
mock_msg, context=None
|
||||
)
|
||||
|
||||
@@ -9,7 +9,16 @@ class TestBase64DecodeRisky(unittest.TestCase):
|
||||
from meshchatx.src.backend.meshchat_utils import parse_lxmf_display_name
|
||||
except ImportError:
|
||||
self.skipTest("meshchat_utils not importable")
|
||||
for bad in ["!!!", "\x00\x01", "a" * 10000, " ", "=", "===", "a\nb\tc", "\xff\xfe"]:
|
||||
for bad in [
|
||||
"!!!",
|
||||
"\x00\x01",
|
||||
"a" * 10000,
|
||||
" ",
|
||||
"=",
|
||||
"===",
|
||||
"a\nb\tc",
|
||||
"\xff\xfe",
|
||||
]:
|
||||
result = parse_lxmf_display_name(bad, default_value="Fallback")
|
||||
self.assertIsInstance(result, str)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user