- Added configuration options for requiring human approval before applying LLM-generated MCP patches. - Updated Docker setup to include skills directory. - Integrated skills management into the backend, allowing for procedural guides and skill matching. - Refactored database initialization to apply Alembic migrations. - Enhanced task approval process to handle MCP patch applications with optional approval. - Introduced new schemas for skills and updated existing APIs to support skills functionality. This commit lays the groundwork for improved agent capabilities and better management of MCP development processes.
77 lines
2.6 KiB
Python
77 lines
2.6 KiB
Python
"""Tests for device default credentials from env."""
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
os.environ.setdefault("SECRET_KEY", "test-secret-key-for-unit-tests-only")
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def device_env(monkeypatch: pytest.MonkeyPatch):
|
|
monkeypatch.setenv("DEVICE_SSH_USERNAME", "shipadmin")
|
|
monkeypatch.setenv("DEVICE_SSH_PASSWORD", "ssh-secret")
|
|
monkeypatch.delenv("DEVICE_PROXMOX_USERNAME", raising=False)
|
|
monkeypatch.setenv("DEVICE_PFSENSE_PORT", "40443")
|
|
monkeypatch.setenv("DEVICE_PFSENSE_API_KEY", "pf-key-123")
|
|
monkeypatch.setenv("DEVICE_PROXMOX_PASSWORD", "pve-pass")
|
|
monkeypatch.setenv("DEVICE_PROXMOX_TOKEN_ID", "root@pam!agentic")
|
|
monkeypatch.setenv("DEVICE_PROXMOX_TOKEN_SECRET", "token-uuid")
|
|
from app.config import get_settings
|
|
|
|
get_settings.cache_clear()
|
|
|
|
|
|
def test_ssh_slot_uses_global_fallback():
|
|
from app.inventory_catalog import catalog_by_key
|
|
from app.services.device_defaults import resolve_slot_defaults
|
|
|
|
entry = catalog_by_key()["docker_vm"]
|
|
d = resolve_slot_defaults("docker_vm", entry)
|
|
assert d.username == "shipadmin"
|
|
assert d.secret == "ssh-secret"
|
|
assert d.secret_kind == "password"
|
|
|
|
|
|
def test_per_slot_overrides_global():
|
|
from app.inventory_catalog import catalog_by_key
|
|
from app.services.device_defaults import resolve_slot_defaults
|
|
|
|
entry = catalog_by_key()["proxmox"]
|
|
d = resolve_slot_defaults("proxmox", entry)
|
|
assert d.secret == "pve-pass"
|
|
assert d.username == "shipadmin"
|
|
|
|
|
|
def test_api_key_slot():
|
|
from app.inventory_catalog import catalog_by_key
|
|
from app.services.device_defaults import resolve_slot_defaults
|
|
|
|
entry = catalog_by_key()["pfsense"]
|
|
d = resolve_slot_defaults("pfsense", entry)
|
|
assert d.secret == "pf-key-123"
|
|
assert d.secret_kind == "api_key"
|
|
assert d.port == 40443
|
|
|
|
|
|
def test_merge_keeps_existing_secret():
|
|
from app.inventory_catalog import catalog_by_key
|
|
from app.services.device_defaults import merge_selection_with_defaults
|
|
|
|
entry = catalog_by_key()["docker_vm"]
|
|
port, user, secret = merge_selection_with_defaults(
|
|
"docker_vm", entry, port=None, username=None, secret=None, existing_secret="stored"
|
|
)
|
|
assert secret == "stored"
|
|
assert user == "shipadmin"
|
|
|
|
|
|
def test_proxmox_api_defaults_from_env():
|
|
from app.services.device_defaults import proxmox_api_configured, resolve_proxmox_api_defaults
|
|
|
|
ctx = resolve_proxmox_api_defaults("10.20.30.254")
|
|
assert ctx["proxmox_api_url"] == "https://10.20.30.254:8006"
|
|
assert ctx["proxmox_token_id"] == "root@pam!agentic"
|
|
assert proxmox_api_configured(ctx)
|