4b6817381b
Benchmark image — build + push to ECR (any adapter) / build + push (push) Waiting to run
CI / quality (ubuntu-latest) (push) Waiting to run
CI / test (tools-runtime) (push) Waiting to run
CI / test (e2e-general) (push) Waiting to run
CI / test (cli-runtime) (push) Waiting to run
CI / test (e2e-provider-and-openclaw) (push) Waiting to run
CI / test (integrations-and-misc) (push) Waiting to run
CI / coverage-report (push) Blocked by required conditions
CI / test-kubernetes (push) Waiting to run
CI / should-run-thorough (push) Waiting to run
CI / test-thorough (cloudwatch-demo) (push) Blocked by required conditions
CI / test-thorough (flink-ecs) (push) Blocked by required conditions
CI / test-thorough (upstream-lambda) (push) Blocked by required conditions
CI / test-thorough (prefect-ecs-fargate) (push) Blocked by required conditions
CodeQL / Analyze (python) (push) Waiting to run
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Blocked by required conditions
Release / publish-release (push) Blocked by required conditions
Release / publish-main-release (push) Blocked by required conditions
Release / prepare (push) Waiting to run
Release / verify (push) Blocked by required conditions
Release / build-python-dist (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Blocked by required conditions
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Blocked by required conditions
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Waiting to run
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Waiting to run
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
103 lines
3.1 KiB
Python
103 lines
3.1 KiB
Python
"""Tests for Helm investigation tools and evidence mapping."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
import pytest
|
|
|
|
from integrations.helm.tools import (
|
|
HelmGetReleaseManifestTool,
|
|
HelmGetReleaseValuesTool,
|
|
HelmListReleasesTool,
|
|
HelmReleaseStatusTool,
|
|
)
|
|
|
|
|
|
class _FakeHelmClient:
|
|
@property
|
|
def is_configured(self) -> bool:
|
|
return True
|
|
|
|
def list_releases(self, **kwargs: Any) -> dict[str, Any]:
|
|
return {
|
|
"success": True,
|
|
"error": "",
|
|
"releases": [{"name": "demo", "namespace": "demo"}],
|
|
**kwargs,
|
|
}
|
|
|
|
def release_status(self, release: str, namespace: str) -> dict[str, Any]:
|
|
return {
|
|
"success": True,
|
|
"error": "",
|
|
"status": {
|
|
"name": release,
|
|
"namespace": namespace,
|
|
"info": {"status": "deployed"},
|
|
},
|
|
}
|
|
|
|
def release_history(self, _release: str, _namespace: str, **kwargs: Any) -> dict[str, Any]:
|
|
del kwargs
|
|
return {
|
|
"success": True,
|
|
"error": "",
|
|
"history": [{"revision": 1, "status": "deployed"}],
|
|
}
|
|
|
|
def get_values(self, _release: str, _namespace: str, **kwargs: Any) -> dict[str, Any]:
|
|
del kwargs
|
|
return {"success": True, "error": "", "values": {"image": {"tag": "1.0"}}}
|
|
|
|
def get_manifest(self, _release: str, _namespace: str) -> dict[str, Any]:
|
|
return {
|
|
"success": True,
|
|
"error": "",
|
|
"manifest": "apiVersion: v1\nkind: Service",
|
|
"truncated": False,
|
|
}
|
|
|
|
|
|
_HELM_SOURCE = {
|
|
"helm_path": "helm",
|
|
"kube_context": "",
|
|
"kubeconfig": "",
|
|
"default_namespace": "demo",
|
|
"release_name": "demo",
|
|
"namespace": "demo",
|
|
"integration_id": "h1",
|
|
"connection_verified": True,
|
|
}
|
|
|
|
|
|
def test_helm_list_tool_is_available_and_lists(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
# Patch where the name is used — HelmTools binds the import at load time.
|
|
monkeypatch.setattr(
|
|
"integrations.helm.tools.helm_client_for_run",
|
|
lambda *_a, **_k: _FakeHelmClient(),
|
|
)
|
|
tool = HelmListReleasesTool()
|
|
assert tool.is_available({"helm": _HELM_SOURCE}) is True
|
|
params = tool.extract_params({"helm": {**_HELM_SOURCE, "release_name": ""}})
|
|
result = tool.run(**params)
|
|
assert result["available"] is True
|
|
assert result["releases"][0]["name"] == "demo"
|
|
|
|
|
|
def test_helm_release_tools_require_release_name() -> None:
|
|
src = {**_HELM_SOURCE, "release_name": ""}
|
|
assert HelmReleaseStatusTool().is_available({"helm": src}) is False
|
|
assert HelmGetReleaseValuesTool().is_available({"helm": src}) is False
|
|
|
|
|
|
def test_helm_get_manifest_tool_returns_yaml(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setattr(
|
|
"integrations.helm.tools.helm_client_for_run",
|
|
lambda *_a, **_k: _FakeHelmClient(),
|
|
)
|
|
tool = HelmGetReleaseManifestTool()
|
|
result = tool.run(**tool.extract_params({"helm": _HELM_SOURCE}))
|
|
assert result["available"] is True
|
|
assert "kind: Service" in result["manifest"]
|