5ad6beac98
Build and Test Quality Gate / Contract Web typecheck and build (pull_request) Successful in 6m23s
Security Quality Gate / npm audit, Bandit, pip-audit, detect-secrets (pull_request) Successful in 10m18s
Build and Test Quality Gate / Python tests and Contract API migration (pull_request) Failing after 42m22s
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
from types import ModuleType, SimpleNamespace
|
|
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def load_script(name: str, relative_path: str) -> ModuleType:
|
|
path = REPO_ROOT / relative_path
|
|
spec = importlib.util.spec_from_file_location(name, path)
|
|
assert spec and spec.loader
|
|
module = importlib.util.module_from_spec(spec)
|
|
sys.modules[name] = module
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
source_scan = load_script(
|
|
"yuqei_source_secret_scan",
|
|
"yuqei-infra/scripts/run-source-secret-scan.py",
|
|
)
|
|
|
|
|
|
def test_source_secret_scan_forces_utf8_for_detect_secrets(monkeypatch) -> None:
|
|
captured: dict[str, object] = {}
|
|
|
|
def fake_run(command, **kwargs):
|
|
captured["command"] = command
|
|
captured.update(kwargs)
|
|
return SimpleNamespace(
|
|
returncode=0,
|
|
stdout=json.dumps({"results": {}}),
|
|
stderr="",
|
|
)
|
|
|
|
monkeypatch.setattr(source_scan.subprocess, "run", fake_run)
|
|
|
|
assert source_scan._run_detect_secrets(False) == {"results": {}}
|
|
assert captured["env"]["PYTHONUTF8"] == "1"
|