forked from kenzuya/unshackle
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -31,18 +31,6 @@ def parked_host(calls: list, status: int = 200, body: bytes = PARKED_PAGE) -> Ca
|
||||
return parked
|
||||
|
||||
|
||||
def test_an_unreachable_json_vault_fails_the_push(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
vault = HTTP("json", "https://vault.invalid/rpc", "token", api_mode="json")
|
||||
|
||||
def down(method: str, params: dict) -> dict:
|
||||
raise ConnectionError("vault is down")
|
||||
|
||||
monkeypatch.setattr(vault, "request", down)
|
||||
vaults = Vaults("SVC")
|
||||
vaults.vaults = [vault]
|
||||
assert vaults.add_keys({KID: KEY}) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"mode, status, body",
|
||||
[
|
||||
@@ -119,13 +107,6 @@ def test_a_json_vault_error_reply_to_a_single_push_stays_a_quiet_false(
|
||||
assert not caplog.records
|
||||
|
||||
|
||||
def test_a_json_vault_with_a_broken_url_warns_on_a_single_push(caplog: pytest.LogCaptureFixture) -> None:
|
||||
_, vaults = one_json_vault("vault.example/rpc")
|
||||
with caplog.at_level(logging.WARNING):
|
||||
assert vaults.add_key(KID, KEY) == 0
|
||||
assert [r.getMessage().split(":")[0] for r in caplog.records] == ["Failed to add key to Vault 'EXAMPLE'"]
|
||||
|
||||
|
||||
def test_a_json_vault_that_is_down_fails_the_service_list(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
vault, _ = one_json_vault()
|
||||
monkeypatch.setattr(vault.session, "post", no_answer)
|
||||
@@ -156,43 +137,6 @@ def query_vault() -> HTTP:
|
||||
return HTTP("EXAMPLE", "https://vault.example/", password="tok", username="user")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"vault, call",
|
||||
[
|
||||
pytest.param(query_vault(), lambda v: v.get_key(KID, "SVC"), id="query-get_key"),
|
||||
pytest.param(query_vault(), lambda v: list(v.get_keys("SVC")), id="query-get_keys"),
|
||||
pytest.param(query_vault(), lambda v: v.add_key("SVC", KID, KEY), id="query-add_key"),
|
||||
pytest.param(query_vault(), lambda v: v.add_keys("SVC", {KID: KEY}), id="query-add_keys"),
|
||||
pytest.param(query_vault(), lambda v: list(v.get_services()), id="query-get_services"),
|
||||
pytest.param(
|
||||
HTTP("EXAMPLE", "https://vault.example/", api_key="tok", api_mode="decrypt_labs"),
|
||||
lambda v: v.get_key(KID, "SVC"),
|
||||
id="decrypt_labs-get_key",
|
||||
),
|
||||
pytest.param(API("api", "https://api.example/", "tok"), lambda v: v.add_key("SVC", KID, KEY), id="api-add_key"),
|
||||
pytest.param(
|
||||
API("api", "https://api.example/", "tok"), lambda v: list(v.get_services()), id="api-get_services"
|
||||
),
|
||||
pytest.param(
|
||||
API("api", "https://api.example/", "tok"),
|
||||
lambda v: v.flag_bad_key("SVC", KID, KEY, "api"),
|
||||
id="api-flag_bad_key",
|
||||
),
|
||||
pytest.param(
|
||||
API("api", "https://api.example/", "tok"), lambda v: v.unflag_bad_key(KID, KEY), id="api-unflag_bad_key"
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_a_vault_still_rate_limited_after_the_retries_raises(
|
||||
vault: HTTP | API, call: Callable[[Any], object], monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
monkeypatch.setattr(vault.session, "get", rate_limited)
|
||||
monkeypatch.setattr(vault.session, "post", rate_limited)
|
||||
monkeypatch.setattr(vault.session, "delete", rate_limited)
|
||||
with pytest.raises(RateLimited):
|
||||
call(vault)
|
||||
|
||||
|
||||
def answers(*replies: bytes) -> Callable[..., requests.Response]:
|
||||
queue = list(replies)
|
||||
return lambda *a, **kw: fake_response(200, queue.pop(0), "application/json")
|
||||
|
||||
Reference in New Issue
Block a user