proxmox_key_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // proxmox_key_test.go — #1879: la clave de caché de los clientes PVE tiene que
  2. // incluir los ajustes TLS. Con solo url/token/secret, editar caPem,
  3. // fingerprintSha256 o insecure no recreaba el cliente y el cambio no surtía
  4. // efecto hasta reiniciar el servicio.
  5. package adapters
  6. import (
  7. "testing"
  8. "github.com/gnacho/netpulse/server-go/internal/pve"
  9. )
  10. func TestPveClientsKeyIncludesTLS(t *testing.T) {
  11. base := pve.Instance{ID: "ofi", Name: "PVE", Config: pve.Config{
  12. URL: "https://192.168.10.200:8006", TokenID: "netpulse@pve!netpulse", Secret: "s3cret",
  13. }}
  14. withCA := base
  15. withCA.CAPEM = "-----BEGIN CERTIFICATE-----\nAAA\n-----END CERTIFICATE-----"
  16. withFP := base
  17. withFP.FingerprintSHA256 = "EE:2A:D0:F1"
  18. withInsecure := base
  19. withInsecure.Insecure = true
  20. key := pveClientsKey([]pve.Instance{base})
  21. for name, inst := range map[string]pve.Instance{
  22. "caPem": withCA,
  23. "fingerprint": withFP,
  24. "insecure": withInsecure,
  25. } {
  26. if got := pveClientsKey([]pve.Instance{inst}); got == key {
  27. t.Errorf("%s no cambia la clave de caché: %q", name, got)
  28. }
  29. }
  30. // Misma config → misma clave (no se recrean clientes en cada sondeo).
  31. if got := pveClientsKey([]pve.Instance{base}); got != key {
  32. t.Errorf("clave inestable: %q != %q", got, key)
  33. }
  34. }