mirror of
https://github.com/usestrix/strix.git
synced 2026-11-15 09:11:26 +00:00
test: check the telemetry label for a cloned repository
Review feedback on #1470: the tests covered is_whitebox_scan and the runner, but not what telemetry_start reports. Assert the is_whitebox label sent to both sinks for a cloned repository, one that was not cloned, and a web target. The cloned case fails with the old rule (type == local_code only). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TavwVMH7PvrD68JTDfd6Hb
This commit is contained in:
parent
edbb8fd908
commit
b9c1c0d0b3
1 changed files with 32 additions and 0 deletions
|
|
@ -2,11 +2,14 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from strix.core.targets import is_whitebox_scan
|
||||
from strix.interface import scan_setup
|
||||
|
||||
|
||||
def _web() -> dict[str, Any]:
|
||||
|
|
@ -45,3 +48,32 @@ def test_source_in_front_of_the_agent_makes_the_scan_whitebox(
|
|||
|
||||
def test_a_target_without_details_does_not_break_the_check() -> None:
|
||||
assert is_whitebox_scan([{"type": "repository"}]) is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("targets", "expected"),
|
||||
[
|
||||
pytest.param([_repo()], True, id="cloned-repository"),
|
||||
pytest.param([_repo(cloned=False)], False, id="repository-that-was-not-cloned"),
|
||||
pytest.param([_web()], False, id="web-only"),
|
||||
],
|
||||
)
|
||||
def test_telemetry_labels_the_scan_from_the_same_check(
|
||||
monkeypatch: pytest.MonkeyPatch, targets: list[dict[str, Any]], *, expected: bool
|
||||
) -> None:
|
||||
started: list[dict[str, Any]] = []
|
||||
recorder = SimpleNamespace(start=lambda **kwargs: started.append(kwargs))
|
||||
monkeypatch.setattr(scan_setup, "posthog", recorder)
|
||||
monkeypatch.setattr(scan_setup, "scarf", recorder)
|
||||
monkeypatch.setattr(
|
||||
scan_setup, "load_settings", lambda: SimpleNamespace(llm=SimpleNamespace(model="m"))
|
||||
)
|
||||
monkeypatch.setattr(scan_setup.codex, "auth_mode", lambda _model: "api_key")
|
||||
args = argparse.Namespace(
|
||||
scan_mode="standard", targets_info=targets, non_interactive=True, instruction=None
|
||||
)
|
||||
|
||||
scan_setup.telemetry_start(args)
|
||||
|
||||
# Reported once to each sink, with the label the runner uses for the root agent.
|
||||
assert [call["is_whitebox"] for call in started] == [expected, expected]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue