mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-06 07:55:10 +00:00
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -44,13 +44,6 @@ def test_a_vault_that_fails_is_left_out_and_named_with_its_error() -> None:
|
||||
assert isinstance(failed["gone"], ValueError)
|
||||
|
||||
|
||||
def test_an_entry_without_a_type_fails_like_any_other() -> None:
|
||||
vaults, failed = load_config_vaults("EXAMPLE", [{"name": "untyped"}, {"type": "API", "name": "ok"}])
|
||||
|
||||
assert [v.name for v in vaults] == ["ok"]
|
||||
assert list(failed) == ["untyped"]
|
||||
|
||||
|
||||
def test_a_critical_vault_that_fails_raises() -> None:
|
||||
with pytest.raises(ValueError):
|
||||
load_config_vaults("EXAMPLE", [{"type": "Missing", "name": "gone"}], critical={"missing"})
|
||||
@@ -104,34 +97,3 @@ def test_server_vaults_read_the_global_decrypt_labs_key(monkeypatch: pytest.Monk
|
||||
vaults = server_keys.load_server_vaults("EXAMPLE")
|
||||
|
||||
assert [v.kwargs.get("token") for v in vaults] == ["global"]
|
||||
|
||||
|
||||
def test_the_health_probe_reports_the_load_error_without_logging_it(
|
||||
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
from unshackle.core.api import handlers
|
||||
|
||||
class Broken:
|
||||
def __init__(self, name: str, **kwargs: Any) -> None:
|
||||
raise ConnectionError("cannot reach the vault")
|
||||
|
||||
monkeypatch.setitem(vaults_module.MODULES, "Broken", Broken)
|
||||
monkeypatch.setattr(config, "key_vaults", [{"type": "Broken", "name": "down"}])
|
||||
|
||||
with caplog.at_level("ERROR"):
|
||||
checks = {c["id"]: c for c in handlers.run_health_checks()}
|
||||
|
||||
assert checks["vault:down"]["status"] == "fail"
|
||||
assert checks["vault:down"]["detail"] == "ConnectionError: cannot reach the vault"
|
||||
assert not caplog.records
|
||||
|
||||
|
||||
def test_kv_names_the_vault_that_failed(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
import click
|
||||
|
||||
from unshackle.commands.kv import load_vaults
|
||||
|
||||
monkeypatch.setattr(config, "key_vaults", [{"type": "Missing", "name": "gone"}])
|
||||
|
||||
with pytest.raises(click.ClickException, match=r"Failed to load vault \(gone\)"):
|
||||
load_vaults(["gone"])
|
||||
|
||||
Reference in New Issue
Block a user