Files
member-console/internal/server/operator_enrollment_revoke_render_test.go
T
cgalo5758 8e7e0dd04d Harden container, OIDC auth, and error handling
Run Docker runtime stage as non-root user app (UID 65532).

Add styled full-page 404/500 error rendering for navigation requests
while preserving plain-text responses for HTMX partials.

Reuse recent unconsumed OIDC login state to avoid state mismatch on
parallel login hits, and merge resource_access in role extraction.

Re-level template headings, add autocomplete tokens, and resolve
catalog resource display names.

Self-label test-stack secrets and document CSRF secret rotation.
2026-07-31 23:27:15 -05:00

31 lines
1.1 KiB
Go

package server
import (
"strings"
"testing"
)
// TestOrgEnrollmentRevokeConfirm_NamesTargetOrFallsBack covers the
// empty-ProductName confirm body (hardening-polish): a live grant whose
// product lookup produced no name must fall back to a whole phrase, never
// render "Revoke for this organization" with a dangling gap.
func TestOrgEnrollmentRevokeConfirm_NamesTargetOrFallsBack(t *testing.T) {
data := onePoolFixture()
data.Grants = []GrantViewModel{
{GrantID: "g-named", ProductName: "Standard Plan", GrantReason: "purchase", DeliveryState: "live"},
{GrantID: "g-unnamed", ProductName: "", GrantReason: "purchase", DeliveryState: "live"},
}
body := renderOrgEnrollment(t, data)
if !strings.Contains(body, "Revoke Standard Plan for this organization?") {
t.Errorf("named grant should interpolate the product name into the confirm body")
}
if !strings.Contains(body, "Revoke this grant for this organization?") {
t.Errorf("unnamed grant should fall back to the generic confirm phrase")
}
if strings.Contains(body, "Revoke for this organization") {
t.Errorf("confirm body rendered the dangling empty-name phrase")
}
}