Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

759 B
Raw Blame
package configapi

import (
	"testing"

	"github.com/rcourtman/pulse-go-rewrite/internal/config"
)

func TestGenerateSetupTokenRecord(t *testing.T) {
	tempDir := t.TempDir()
	cfg := &config.Config{
		DataPath:   tempDir,
		ConfigPath: tempDir,
	}

	handler := newTestConfigHandlers(t, cfg)

	// Test 1: Basic generation
	token := handler.generateSetupTokenRecord()
	if len(token) != 32 { // 16 bytes hex encoded = 32 chars
		t.Errorf("expected token length 32, got %d", len(token))
	}

	// Verify uniqueness
	token2 := handler.generateSetupTokenRecord()
	if token == token2 {
		t.Error("generated setup tokens should be unique (random)")
	}

	// Storage is handled by HandleSetupScriptURL, not generateSetupTokenRecord.
	// So we don't verify storage here.
}