From 99433ac290303a13722b0e7a9fa5bee4261f7eb7 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 4 Oct 2023 18:08:19 +0200 Subject: [PATCH] test_vms_api: supply age key for secret creation --- pkgs/clan-cli/tests/test_vms_api.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkgs/clan-cli/tests/test_vms_api.py b/pkgs/clan-cli/tests/test_vms_api.py index 32b74576c..02bf655db 100644 --- a/pkgs/clan-cli/tests/test_vms_api.py +++ b/pkgs/clan-cli/tests/test_vms_api.py @@ -1,10 +1,15 @@ import os from pathlib import Path +from typing import TYPE_CHECKING import pytest from api import TestClient +from cli import Cli from httpx import SyncByteStream +if TYPE_CHECKING: + from age_keys import KeyPair + @pytest.mark.impure def test_inspect(api: TestClient, test_flake_with_core: Path) -> None: @@ -33,7 +38,16 @@ def test_incorrect_uuid(api: TestClient) -> None: @pytest.mark.skipif(not os.path.exists("/dev/kvm"), reason="Requires KVM") @pytest.mark.impure -def test_create(api: TestClient, test_flake_with_core: Path) -> None: +def test_create( + api: TestClient, + monkeypatch: pytest.MonkeyPatch, + test_flake_with_core: Path, + age_keys: list["KeyPair"], +) -> None: + monkeypatch.chdir(test_flake_with_core) + monkeypatch.setenv("SOPS_AGE_KEY", age_keys[0].privkey) + cli = Cli() + cli.run(["secrets", "users", "add", "user1", age_keys[0].pubkey]) print(f"flake_url: {test_flake_with_core} ") response = api.post( "/api/vms/create",