`, "That username is already in use.",
`
root
`, `name="username" value="taken"`} {
if !strings.Contains(body, want) {
t.Errorf("the refused form is missing %q", want)
}
}
// The create form comes back the same way, with what was typed.
rec = send(h.HandleUserNew, &root, "POST", "/server/users/new", nil, url.Values{"username": {"fresh"}, "password": {"short"}, "role": {"domain"}})
body = rec.Body.String()
if rec.Code != http.StatusBadRequest || !strings.Contains(body, "password must be at least") ||
!strings.Contains(body, `
Create user
`) || !strings.Contains(body, `name="username" value="fresh"`) {
t.Errorf("a refused create form = %d:\n%s", rec.Code, body)
}
}
// ---- Delete a user
func TestUserDeletePageNamesTheAssignmentsAndRefusalsStayOnTheForm(t *testing.T) {
h, st := inboundHandlers(t)
out1, _ := st.AddDomain("out.example.com", "mail")
in1, _ := st.AddInboundDomain("in.example.com")
root := userWith(t, st, "root", store.RoleGlobal, store.Reach{})
u := userWith(t, st, "shop", store.RoleDomain, store.Reach{DomainIDs: []int64{out1.ID}, InboundDomainIDs: []int64{in1.ID}})
path := "/server/users/" + idStr(u.ID) + "/delete"
body := send(h.HandleUserDeleteConfirm, &root, "GET", path, map[string]string{"uid": idStr(u.ID)}, nil).Body.String()
for _, want := range []string{
`
Delete shop
`, `
`,
`remove the assignments to out.example.com (outbound) and to in.example.com (inbound).`,
`