35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from gpu_rent.config import load_config
|
|
from gpu_rent.ssh_keys import ensure_ed25519, public_path
|
|
|
|
|
|
def test_load_config_missing_auth(monkeypatch, tmp_path):
|
|
monkeypatch.setenv("HOME", str(tmp_path))
|
|
monkeypatch.setenv("USERPROFILE", str(tmp_path))
|
|
for key in (
|
|
"OS_AUTH_URL",
|
|
"OS_USER_DOMAIN_NAME",
|
|
"OS_USERNAME",
|
|
"OS_PASSWORD",
|
|
"OS_PROJECT_ID",
|
|
"OS_REGION_NAME",
|
|
"GPU_RENT_AZ",
|
|
):
|
|
monkeypatch.delenv(key, raising=False)
|
|
cfg = load_config(require_auth=False)
|
|
assert not cfg.auth_ok
|
|
assert "OS_USERNAME" in cfg.missing
|
|
assert cfg.data_volume_size_gb == 100
|
|
|
|
|
|
def test_ssh_key_generate(tmp_path):
|
|
private = tmp_path / "id_ed25519"
|
|
got, pub = ensure_ed25519(private)
|
|
assert got == private
|
|
assert pub == public_path(private)
|
|
assert private.is_file()
|
|
assert pub.is_file()
|
|
text = pub.read_text(encoding="utf-8")
|
|
assert text.startswith("ssh-ed25519")
|
|
ensure_ed25519(private)
|
|
assert private.read_bytes()
|