package main
import (
"bytes"
"net/url"
"strings"
"testing"
"time"
)
// Agent-written text cannot become Markdown in the report: no link, image,
// emphasis or HTML through a session title.
func TestReportTextCannotBecomeMarkdown(t *testing.T) {
got := mdText("[click](http://evil.example)
**loud** `x` # h")
for _, bad := range []string{"[click](", "
") {
t.Error("an agent's title went into the report as markup")
}
}
func TestTheConsoleHandsTheReportOverAsAFile(t *testing.T) {
homeTestWorld(t, true)
u := uiTestServer(t)
w := uiPost(t, u.handler(), "/machine/report", url.Values{}, uiSignedIn(t, u))
if cd := w.Header().Get("Content-Disposition"); !strings.HasPrefix(cd, "attachment;") {
t.Errorf("Content-Disposition %q", cd)
}
if !strings.Contains(w.Body.String(), "## Summary") {
t.Errorf("body %q", firstLines(w.Body.String()))
}
}