add tests and config

This commit is contained in:
Fredrick Amnehagen 2026-02-05 11:33:31 +01:00
parent db843ceec8
commit a7d97227d3
2 changed files with 67 additions and 0 deletions

22
config.yaml Normal file
View file

@ -0,0 +1,22 @@
# LoopAware Infra CLI Configuration
# Proxmox/DNS Management
proxmox:
host: "10.32.2.1"
user: "root"
dnsmasq_lxc_id: "11209"
ssh_key: "~/.ssh/id_ed25519_no_pass"
# Ingress Management (HAProxy)
haproxy:
host: "10.32.1.20"
user: "root"
ssh_key: "~/.ssh/id_ed25519_no_pass"
config_dir: "/etc/haproxy/conf.d"
dynamic_dir: "/etc/haproxy/dynamic"
# Router Management (OpenWrt)
router:
host: "10.32.0.1"
user: "root"
ssh_key: "~/.ssh/id_ed25519_no_pass"

45
tests/test_cli.py Normal file
View file

@ -0,0 +1,45 @@
import pytest
import subprocess
import os
import uuid
# Use the bin/infra wrapper for testing
CLI_BIN = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "bin", "infra"))
CONFIG_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "config.yaml"))
def run_infra(cmd, env=None):
full_cmd = [CLI_BIN, "--config", CONFIG_PATH] + cmd
return subprocess.run(full_cmd, capture_output=True, text=True, env=env)
@pytest.fixture
def unique_id():
return str(uuid.uuid4())[:8]
def test_dns_cli(unique_id):
mac = f"aa:bb:cc:dd:ee:{unique_id[:2]}"
ip = "10.32.70.210"
hostname = f"test-cli-{unique_id}"
# Add
res = run_infra(["dns", "add-host", mac, ip, hostname])
assert res.returncode == 0
# List
res = run_infra(["dns", "list"])
assert mac in res.stdout
# Remove
res = run_infra(["dns", "remove-host", mac])
assert res.returncode == 0
def test_ingress_cli(unique_id):
domain = f"test-cli-{unique_id}.loopaware.com"
ip = "10.32.70.211"
# Add
res = run_infra(["ingress", "add", domain, ip, "80"])
assert res.returncode == 0
# Remove
res = run_infra(["ingress", "remove", domain])
assert res.returncode == 0