package view import ( "strings" "testing" "time" ) // ---- Outbound domains // The global role adds and deletes domains; a domain administrator sees the // list alone, so the page has no add box, no Delete link, and numbers the table // box 01. func TestOutDomainsOffersAddAndDeleteToTheGlobalRoleOnly(t *testing.T) { out := renderSignedIn(t, "out-domains", outDomainsFixture()) pageHas(t, "Outbound domains", out, `

Outbound domains

`, `

Add a domain

`, `action="/outbound/domains"`, `name="name"`, `href="/server/backup#import"`, `30 days`, `>Delete`, `href="/outbound/domains/2/delete"`, `3 domains · DNS cached a few minutes`, "1 284 msg · peak 96/h", `class="sp-muted sp-mono">sp2025<`, `SPF`, `DMARC`, ) p := NewOutDomains(Meta{User: "ops", HasOutbound: true}, false, 30).WithRows([]OutDomainRow{ {Name: "example.org", Href: "/outbound/domains/1", Selector: "sp2026", Apps: 1, Activity: "—", DNS: []Tag{{Status: "ok", Label: "DKIM"}}}, }) out = renderSignedIn(t, "out-domains", p) pageHas(t, "Outbound domains", out, `01

Domains

`, `1 domain · DNS cached`) pageLacks(t, "Outbound domains", out, `Add a domain`, `name="name"`, `>Delete`, `/delete`) } func TestOutDomainsEmptyAndRefused(t *testing.T) { p := NewOutDomains(admin(), true, 30).WithRows(nil).WithResult("", "That domain is already configured.", "example.org") out := renderSignedIn(t, "out-domains", p) pageHas(t, "Outbound domains", out, `No outbound domains yet. Add the first one above.`, `
`, `That domain is already configured.`, `value="example.org"`, `0 domains`) pageLacks(t, "Outbound domains", out, ``, `Domain deleted.`) } func TestOutDomainsEscapesWhatPeopleTyped(t *testing.T) { p := NewOutDomains(admin(), true, 30).WithRows([]OutDomainRow{ {Name: ``, Href: "/outbound/domains/1", Selector: `">`}, }).WithResult("", "bad", `">`) out := renderSignedIn(t, "out-domains", p) pageLacks(t, "Outbound domains", out, ``, false, "h", false, []string{``}) pageLacks(t, "New password", renderSignedIn(t, "out-app-created", p), `x`, `