package authguard

import "testing"

func TestNormalizeConfigUsesDefaults(t *testing.T) {
	cfg := normalizeConfig(Config{})
	if cfg.IdentifierMaxFailures != DefaultConfig().IdentifierMaxFailures {
		t.Fatalf("expected identifier default, got %d", cfg.IdentifierMaxFailures)
	}
	if cfg.LockoutDuration != DefaultConfig().LockoutDuration {
		t.Fatalf("expected lockout default, got %s", cfg.LockoutDuration)
	}
}

func TestNormalizeEventDecisionRequiresNoteForTerminalStatus(t *testing.T) {
	params := EventDecisionParams{
		EventID:     "11111111-1111-1111-1111-111111111111",
		AdminUserID: "22222222-2222-2222-2222-222222222222",
		Status:      "resolved",
	}
	if err := normalizeEventDecision(&params); err == nil {
		t.Fatal("expected missing resolution note error")
	}

	params.ResolutionNote = "Reviewed and closed"
	if err := normalizeEventDecision(&params); err != nil {
		t.Fatalf("expected valid decision, got %v", err)
	}
}

func TestNormalizeIdentifier(t *testing.T) {
	got := normalizeIdentifier(" Demo@Example.COM ")
	if got != "demo@example.com" {
		t.Fatalf("expected normalized email, got %q", got)
	}
}
