console: /fleet/legal gates operators first and tightens the SVG check
Review fix round 1 for Task 3. Both writes now run operatorOnly before reading the body, so a non-operator gets the plain 404 for a bad or missing token, an oversize body and a broken multipart body. A logo's elements must all be in the SVG namespace, attributes only in none, xlink, xml or xmlns; src and any backslash in a value are refused. A dpa's page address must start with https://.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/console/oplegal.go+33 −14internal/console/oplegal_test.go+79 −0
Intent
<task-notification> <task-id>a5dd48625b19a7127</task-id> <tool-use-id>toolu_012EPjntAxx8pbjQc443Pe4G</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/260ddc60-0dfc-4cf8-8857-7688d6275097/tasks/a5dd48625b19a7127.output</output-file> <status>completed</status> <summary>Agent "Implement Task 3: /fleet/legal" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE. Commit 61ef5ba1, "console: /fleet/legal publishes documents and sets the letterhead". Not pushed. git printed the known stale packed-refs.lock error; `git log -1` shows the commit is there. Tests: all 11 new `TestOpLegal*` tests pass. The copy gate (with DPA-C44 to C93 added), the styleguide test, the operator-shell, route, parity and perf census tests, and the three new claim probes also pass. Build, vet and gofmt are clean. I did not run the full console package, the full claim door run or the perf walk; CI runs those. Choices that need a ruling: - **Fetch error:** the "which" placeholder is the address that failed, e.g. "Couldn't fetch https://example.com/dpa/9/agreement.html: status 404." - **Publish banner:** the document name is lower-cased mid-sentence: "Published data processing agreement version 1." - **Logo removal:** saving the letterhead without a new logo keeps the current one, so a logo can't be removed once set. - **Extra refusals:** a DPA text that isn't UTF-8 is refused with the {what} wording "text that isn't UTF-8", which I wrote. The SVG logo check also refuses more than the ruling lists: animation elements, `xml:base`, external `url()`, stylesheet instructions and DOCTYPEs that define entities or attributes. - **Missing fields:** these reuse an existing sentence, "Could not read the form. Please try again." To let a parked step-up replay keep an uploaded logo, the handler copies the logo into the form as base64 before the step-up. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/dpa-and-retention/.superpowers/sdd/2026-11-25-dpa-acceptance/task-3-report.md</result> <usage><subagent_tokens>266454</subagent_tokens><tool_uses>101</tool_uses><duration_ms>1620922</duration_ms></usage> </task-notification>
<task-notification> <task-id>a31154e34b4ca7b53</task-id> <tool-use-id>toolu_017TPch5nLFjyJrDA9FmuJmi</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/260ddc60-0dfc-4cf8-8857-7688d6275097/tasks/a31154e34b4ca7b53.output</output-file> <status>completed</status> <summary>Agent "Review Task 3 (spec + quality)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>### Spec Compliance - ✅ Routes `GET /fleet/legal`, `/fleet/legal/publish` and `/fleet/legal/letterhead` are registered (routedecls.go:152-154). The two writes have no method in the pattern, as the alert doors do, and a non-POST gets the plain 404 (oplegal.go:287-290). - ✅ The rail entry sits after "backups" with deck label C44 "Legal" (opshell.go:44). - ✅ Publish follows the rulings (oplegal.go:403-430): - The first dpa gets `NeedsNotice=false` and `EffectiveAt=PublishedAt`. - The first terms or privacy row is a baseline with the date the operator types. - A later row with "no notice" ticked gets `EffectiveAt=now`. - A later dpa is refused unless its date is at least published + 35 days (oplegal.go:423). The date field is pre-filled with the first allowed day (oplegal.go:159-166). - A later terms or privacy row gets `NeedsNotice=true` and a NULL date. - ✅ A dpa needs `body_url` (oplegal.go:384). Only `body_url` is fetched; the body must be UTF-8 and pass `canonicalAgreement`, is stored exactly as fetched, and its SHA-256 is pinned. Terms and privacy are fetched and only the digest is kept (oplegal.go:432-455). A duplicate version is refused before any fetch (oplegal.go:397-402), and the store's own check covers a race (oplegal.go:457). - ✅ Every write is audited through `auditSystem`: `legal.publish` (oplegal.go:465) and `legal.letterhead` (oplegal.go:581). - ✅ Letterhead: field limits, control-character check, `canonicalAddress` for the privacy email, a PNG by magic bytes, and a 200 KB limit (204800 bytes) (oplegal.go:534-602). The page says why nothing renders when there is no letterhead (template:10-12, C46). - ✅ All operator strings go through html/template, and the agreement body is never on this page (template:20, 77). The list shows account, legal name, country, version accepted, version in force, accepted by, and when (oplegal.go:231-237). - ✅ Copy: I checked all 50 strings, C44 to C93, mechanically against oplegal.go, ops_legal.html and opshell.go, and every one is present. The fill functions for C68, C69 and C71 match the deck text (oplegal.go:57-75). There are no em dashes. All 50 ids are in `dpaCopyBuilt` (approved_dpa_copy_test.go:25-35). - ✅ Every brief test exists, plus extra ones for CSRF, the logo check, the date floor and the copy (oplegal_test.go:155-638). - ❌ Spec §3.6 says the SVG has "no external refs", but `svgLogoOK` lets external references through. Details under Important 1. - ⚠️ Cannot verify from the diff whether the census, perf and full claim-door runs pass. The report says they were not run locally; CI runs them. **Named risk checks** - **(a) Gate order.** The code runs: method, session (404), body read under a 1 MiB cap, CSRF, `operatorOnly`, `allowWrite` (oplegal.go:286-318). `requireFreshAuth` comes last in both handlers (oplegal.go:361, 527). CSRF is checked before anything can park a step-up. The letterhead's logo check (oplegal.go:524) runs before the step-up, but it only refuses; it writes nothing. A non-operator with a valid token gets the byte-identical 404, and the test asserts it (oplegal_test.go:162-166). That 404 does **not** come before form parsing, though. See Important 2. - **(b) Step-up stash.** `stashRequest` copies `r.PostForm` (stepup.go:351-372), so the base64 logo set with `r.PostForm.Set` at oplegal.go:500 is saved. Size: a 200 KB logo becomes about 273 KB of base64 in one `pending_actions` row. There is no size cap in `StashPendingAction` (stepup.go:190-205). The row lives 10 minutes and expired rows are deleted on the next stash. Each park also uses one `allowWrite` token. That is acceptable for an operator-only page. - **(b) Replay.** The replay goes back through the router (stepup.go:459-503), so every gate runs again. The logo is decoded and checked again (oplegal.go:553-563), and the fetch and canonical check run after the step-up passes (oplegal.go:436-453). Nothing from the first attempt is trusted. The replayed body (about 273 KB, urlencoded) fits under the 1 MiB cap. - **(c) SVG check.** - Refused, by checking each attribute's local name: `xl:href` and other prefixes, `<image href>`, `<a xlink:href=javascript:>`, `<use href=external>`, CDATA script, `<set>`/`<animate>`, an internal DTD subset, entities (the strict parser rejects them, so nothing expands), `xml-stylesheet`, and `xml:base`. - Accepted, confirmed with a scratch copy of the function: XHTML-namespace elements carrying `src`, `action` or `http-equiv`; a root `<svg>` declared in the XHTML namespace; and `fill="\75 rl(https://...)"`, a CSS escape that spells `url(`. - Serving: this diff never serves the logo. Spec §3.8 plans to embed it as a `data:` image in the PDF HTML, and browsers do not run scripts or load external resources for an SVG shown as an image there. - **(d) Multipart limits.** `MaxBytesReader` is set before `ParseMultipartForm(1 MiB)` (oplegal.go:295-298), and the logo read is capped at 200 KB + 1 (oplegal.go:490). The publish handler has no `RemoveAll`, but net/http removes the temporary files when the handler returns. - **(e) Fetch.** It runs inside the request with `r.Context()` plus a 10 s timeout (oplegal.go:436), on the guarded client with a 10 s overall deadline (legalfetch.go:33-38). Errors are reduced to a category and do not include the resolved address (legalfetch.go:73-88). - **(f) Copy is verbatim.** See the copy item above. ### Strengths - The logo replay is well built. `legalFoldLogo` deletes any `logo_data` the client sent with a multipart upload and replaces it with the real file (oplegal.go:479, 500). The value is then checked the same way on every path, and the test proves the replay stores the same bytes (oplegal_test.go:561-572). - The SVG check goes beyond the ruling on purpose: animation elements, `xml:base`, `url()` in attributes, processing instructions and DTD internal subsets are all refused. There are 21 refusal cases in the test. - Publish does not fetch on the parked request; the test asserts zero hits on the site (oplegal_test.go:540-542). - The duplicate version is checked before the date check and before the fetch, and the store's error covers a race. ### Issues #### Critical (Must Fix) None. #### Important (Should Fix) 1. **The SVG check lets external references through** (oplegal.go:636-658, 674-686). It looks only at local names and never checks namespaces, so these pass: - `<h:img xmlns:h="http://www.w3.org/1999/xhtml" src="https://...">` - `<h:meta http-equiv="refresh" content="0;url=https://...">` - `<h:form action="javascript:...">` - a root `<svg xmlns="http://www.w3.org/1999/xhtml">` (a different document type, with a normal `<img src>` inside) - `fill="\75 rl(https://...)"` Spec §3.6 promises "no external refs". The data: URI planned in §3.8 hides this today, but the stored logo is permanent and any future direct serving would expose it. Fix: - Require every element (the root included) to be in the SVG namespace. - Refuse attributes in any namespace other than none, xlink, xml and xmlns. - Refuse `src`. - Refuse a backslash in any attribute value. - Add these cases to `TestOpLegalLogoCheck`. 2. **A signed-in non-operator can tell these routes exist** (oplegal.go:295-310). The body is parsed and CSRF checked before `operatorOnly`. A signed-in non-operator gets a 400 page for a body over 1 MiB or a malformed multipart body, and a 403 "Cross-site request blocked." page for a missing or wrong token. An unknown route gives a plain 404, so `/fleet/legal/*` can be told apart. This follows the brief's literal order, but the house precedent for operator writes differs: `alertOperatorForm` (alertpages.go:474-486) runs `operatorOnly` before the CSRF check. The comment on `operatorOnly` (server.go:3995-4001) says the plain 404 exists so that /fleet routes cannot be probed. Running owner before CSRF parks nothing, so the step-up guarantee still holds. Recommend the controller rule to match the alert doors, and extend `TestOpLegalNonOperator404` to cover a bad token and an oversize body. #### Minor (Nice to Have) 1. A dpa's `url` (the page address) is never fetched, so it is never required to be https (oplegal.go:378, 432-435). An `http://` or relative value is stored and later linked from the customer pane; html/template blocks only `javascript:`. Requiring a `https://` prefix would close this. 2. `TestOpLegalCSRF` (oplegal_test.go:574-584) records a fresh step-up first, so it does not prove that a bad-token POST without a step-up stays unparked. The code order makes that true; an assertion would pin it. 3. Nothing caps the size of a stashed form (stepup.go:190). This is fine at 1 MiB per operator write, but it is the first door that parks a few hundred KB. Worth a line in the stash comment. ### Assessment **Task quality:** Needs fixes **Reasoning:** The publish and letterhead behaviour, the copy, the step-up replay and the fetch handling all match the brief and rulings. Two small fixes remain: the SVG check passes external references through other namespaces (against §3.6's promise), and the pre-`operatorOnly` parse and CSRF answers let a signed-in non-operator see these routes exist, which the existing operator doors avoid.</result> <usage><subagent_tokens>112555</subagent_tokens><tool_uses>22</tool_uses><duration_ms>288808</duration_ms></usage> </task-notification>
Attributed to this commit: 17.7 g CO₂e (2,231,861 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on dpa-and-retention, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/internal/console/oplegal.go b/internal/console/oplegal.go| index 3fa32fe8e..0999c36ba 100644 |
| --- a/internal/console/oplegal.go |
| +++ b/internal/console/oplegal.go |
| @@ -279,17 +279,17 @@ func (s *Server) handleOpLegal(w http.ResponseWriter, r *http.Request) { |
| s.renderLegal(w, r, addr, raw, http.StatusOK, r.URL.Query().Get("kind"), "", nil, nil) |
| } |
| -// legalFormGate is a /fleet/legal write's gates before the step-up, in the |
| -// house order: a POST with a session, its form read, CSRF, operatorOnly, |
| -// then the write limit. On false it has answered. The caller calls |
| -// requireFreshAuth last. |
| +// legalFormGate is a /fleet/legal write's gates before the step-up, as |
| +// alertOperatorForm orders them: a POST, operatorOnly (the plain 404 for |
| +// anyone else, before any of the body is read), the form read under its |
| +// cap, CSRF, then the write limit. On false it has answered. The caller |
| +// calls requireFreshAuth last. |
| func (s *Server) legalFormGate(w http.ResponseWriter, r *http.Request) (addr, raw string, ok bool) { |
| if r.Method != http.MethodPost { |
| http.NotFound(w, r) |
| return "", "", false |
| } |
| - if _, raw, ok = s.session(r); !ok { |
| - http.NotFound(w, r) |
| + if addr, raw, ok = s.operatorOnly(w, r); !ok { |
| return "", "", false |
| } |
| r.Body = http.MaxBytesReader(w, r.Body, legalFormMax) |
| @@ -307,9 +307,6 @@ func (s *Server) legalFormGate(w http.ResponseWriter, r *http.Request) (addr, ra |
| s.renderMessage(w, r, http.StatusForbidden, "Refused", "Cross-site request blocked.") |
| return "", "", false |
| } |
| - if addr, raw, ok = s.operatorOnly(w, r); !ok { |
| - return "", "", false |
| - } |
| if !s.allowWrite(Principal{Address: addr}, time.Now()) { |
| s.renderMessage(w, r, http.StatusTooManyRequests, "Refused", "too many requests. Wait a minute and try again") |
| return "", "", false |
| @@ -381,6 +378,10 @@ func (s *Server) handleOpLegalPublish(w http.ResponseWriter, r *http.Request) { |
| if kind != "dpa" { |
| bodyURL, okB = "", true |
| } |
| + // A dpa's page is never fetched, but the customer's pane links to it. |
| + if kind == "dpa" && !strings.HasPrefix(pageURL, "https://") { |
| + okU = false |
| + } |
| if !okV || !okU || !okS || !okB || version == "" || pageURL == "" || summary == "" || (kind == "dpa" && bodyURL == "") { |
| fail(http.StatusBadRequest, legalErrForm) |
| return |
| @@ -611,10 +612,23 @@ var svgRefused = map[string]bool{ |
| "handler": true, "listener": true, |
| } |
| -// svgLogoOK is true for well-formed UTF-8 XML whose root is svg, with no |
| -// refused element, no on* or style attribute, no xml:base, every href |
| -// (xlink:href included) a fragment reference ("#..."), and every url(...) |
| -// in an attribute a fragment reference too. A processing instruction other |
| +// The namespaces a logo may use: every element is SVG's, and an attribute |
| +// is in no namespace or in xlink's, xml's or a namespace declaration. |
| +const ( |
| + svgNS = "http://www.w3.org/2000/svg" |
| + xlinkNS = "http://www.w3.org/1999/xlink" |
| + xmlNS = "http://www.w3.org/XML/1998/namespace" |
| +) |
| + |
| +var svgAttrNS = map[string]bool{"": true, xlinkNS: true, xmlNS: true, "xmlns": true} |
| + |
| +// svgLogoOK is true for well-formed UTF-8 XML whose root is svg and whose |
| +// every element is in the SVG namespace (an XHTML img or meta inside would |
| +// load a URL), with no refused element, no attribute in another namespace, |
| +// no on*, style or src attribute, no xml:base, no backslash in any value (a |
| +// CSS escape could spell url), every href (xlink:href included) a fragment |
| +// reference ("#..."), and every url(...) in an attribute a fragment |
| +// reference too. A processing instruction other |
| // than the XML declaration (xml-stylesheet loads CSS) and a DOCTYPE with an |
| // internal subset (which can add attributes or entities this check would |
| // not see) are refused. Unknown entities fail the strict parse. |
| @@ -635,6 +649,9 @@ func svgLogoOK(b []byte) bool { |
| } |
| switch t := tok.(type) { |
| case xml.StartElement: |
| + if t.Name.Space != svgNS { |
| + return false |
| + } |
| name := strings.ToLower(t.Name.Local) |
| if root == "" { |
| root = name |
| @@ -648,7 +665,9 @@ func svgLogoOK(b []byte) bool { |
| for _, a := range t.Attr { |
| key := strings.ToLower(a.Name.Local) |
| switch { |
| - case strings.HasPrefix(key, "on"), key == "style", key == "base": |
| + case !svgAttrNS[a.Name.Space], strings.ContainsRune(a.Value, '\\'): |
| + return false |
| + case strings.HasPrefix(key, "on"), key == "style", key == "base", key == "src": |
| return false |
| case key == "href" && !strings.HasPrefix(a.Value, "#"): |
| return false |
diff --git a/internal/console/oplegal_test.go b/internal/console/oplegal_test.go| index b71157f9e..1a836fcbe 100644 |
| --- a/internal/console/oplegal_test.go |
| +++ b/internal/console/oplegal_test.go |
| @@ -170,6 +170,23 @@ func TestOpLegalNonOperator404(t *testing.T) { |
| t.Errorf("GET %s = %d %q", p, status, body) |
| } |
| } |
| + // Nothing about the body is looked at before the operator gate: a bad |
| + // token, no token, an oversize body and a broken multipart body all get |
| + // the same 404. |
| + for _, p := range []string{"/fleet/legal/publish", "/fleet/legal/letterhead"} { |
| + for name, req := range map[string]struct{ ct, body string }{ |
| + "bad token": {"application/x-www-form-urlencoded", "csrf=wrong&kind=dpa"}, |
| + "no token": {"application/x-www-form-urlencoded", "kind=dpa"}, |
| + "oversize": {"application/x-www-form-urlencoded", "csrf=" + url.QueryEscape(csrf) + "&kind=dpa&pad=" + strings.Repeat("x", 2<<20)}, |
| + "multipart": {"multipart/form-data; boundary=zz", "--zz\r\nbroken"}, |
| + "no boundary": {"multipart/form-data", "csrf=" + url.QueryEscape(csrf)}, |
| + } { |
| + status, body := oplRawPost(t, c, fx.ts.URL+p, req.ct, req.body) |
| + if status != http.StatusNotFound || body != "404 page not found\n" { |
| + t.Errorf("POST %s (%s) = %d %q", p, name, status, body) |
| + } |
| + } |
| + } |
| // Signed out, too. |
| anon := newBrowser(t) |
| if status, _, _ := get(t, anon, fx.ts.URL+"/fleet/legal"); status != http.StatusNotFound { |
| @@ -239,6 +256,23 @@ func TestOpLegalPublishDPA(t *testing.T) { |
| } |
| } |
| +func TestOpLegalDPAPageMustBeHTTPS(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + c := signInOperator(t, fx) |
| + oplFresh(t, fx, c) |
| + srv, hits := oplSite(t, fx, map[string]string{"/dpa/1/agreement.html": oplFragment}) |
| + for _, page := range []string{"http://example.com/dpa/1/", "javascript:alert(1)", "/dpa/1/"} { |
| + status, _, body := oplPublish(t, fx, c, "kind", "dpa", "version", "1", "url", page, |
| + "body_url", srv.URL+"/dpa/1/agreement.html", "summary", "First.") |
| + if status != http.StatusBadRequest || !strings.Contains(body, legalErrForm) { |
| + t.Errorf("page %q = %d", page, status) |
| + } |
| + } |
| + if n := len(oplDocs(t, fx, "dpa")); n != 0 || hits.Load() != 0 { |
| + t.Fatalf("%d dpa rows, %d fetches", n, hits.Load()) |
| + } |
| +} |
| + |
| func TestOpLegalPublishRefusesNonCanonical(t *testing.T) { |
| fx := newConsoleFixture(t) |
| c := signInOperator(t, fx) |
| @@ -509,6 +543,18 @@ func TestOpLegalLogoCheck(t *testing.T) { |
| `<svg ` + ns + ` xml:base="https://example.com/"><use href="#p"/></svg>`, |
| "", |
| "not an image", |
| + // Elements outside the SVG namespace, attributes in a foreign one, |
| + // src, and a CSS escape that spells url. |
| + `<svg ` + ns + ` xmlns:h="http://www.w3.org/1999/xhtml"><h:img src="https://example.com/x.png"/></svg>`, |
| + `<svg ` + ns + ` xmlns:h="http://www.w3.org/1999/xhtml"><h:meta http-equiv="refresh" content="0;url=https://example.com/"/></svg>`, |
| + `<svg ` + ns + ` xmlns:h="http://www.w3.org/1999/xhtml"><h:form action="javascript:alert(1)"/></svg>`, |
| + `<svg xmlns="http://www.w3.org/1999/xhtml"><img src="https://example.com/x.png"/></svg>`, |
| + `<svg ` + ns + `><rect fill="\75 rl(https://example.com/)"/></svg>`, |
| + `<svg ` + ns + `><g xmlns="http://www.w3.org/1999/xhtml"><img/></g></svg>`, |
| + `<svg><rect/></svg>`, |
| + `<svg ` + ns + ` xmlns:x="urn:x"><rect x:fill="red"/></svg>`, |
| + `<svg ` + ns + `><rect u:fill="red"/></svg>`, |
| + `<svg ` + ns + `><image src="https://example.com/x.png"/></svg>`, |
| } |
| for _, s := range bad { |
| if got := letterheadLogoType([]byte(s)); got != "" { |
| @@ -574,6 +620,27 @@ func TestOpLegalRequiresFreshAuth(t *testing.T) { |
| func TestOpLegalCSRF(t *testing.T) { |
| fx := newConsoleFixture(t) |
| c := signInOperator(t, fx) |
| + srv, hits := oplSite(t, fx, map[string]string{"/dpa/1/agreement.html": oplFragment}) |
| + // Without a step-up, a bad token is refused before anything is parked. |
| + for _, p := range []string{"/fleet/legal/publish", "/fleet/legal/letterhead"} { |
| + status, _, _ := postForm(t, c, fx.ts.URL+p, url.Values{"csrf": {"wrong"}, "kind": {"dpa"}, "version": {"1"}, |
| + "url": {srv.URL + "/dpa/1/"}, "body_url": {srv.URL + "/dpa/1/agreement.html"}, "summary": {"x"}, |
| + "entity": {"Shop Limited"}, "office": {"1 Main Street"}, "number": {"1"}, "signatory": {"S"}, "privacy": {"privacy@example.com"}}) |
| + if status != http.StatusForbidden { |
| + t.Errorf("%s with a bad token and no step-up = %d, want 403", p, status) |
| + } |
| + } |
| + var parked int |
| + if err := fx.st.db.QueryRow(`SELECT COUNT(*) FROM pending_actions`).Scan(&parked); err != nil || parked != 0 { |
| + t.Fatalf("%d pending actions after refused posts (%v), want none", parked, err) |
| + } |
| + if n := len(oplDocs(t, fx, "dpa")); n != 0 || hits.Load() != 0 { |
| + t.Fatalf("%d dpa rows, %d fetches", n, hits.Load()) |
| + } |
| + if lh, _ := fx.st.CurrentLetterhead(); lh != nil { |
| + t.Fatal("a letterhead was stored") |
| + } |
| + |
| oplFresh(t, fx, c) |
| for _, p := range []string{"/fleet/legal/publish", "/fleet/legal/letterhead"} { |
| status, _, _ := postForm(t, c, fx.ts.URL+p, url.Values{"csrf": {"wrong"}, "kind": {"dpa"}}) |
| @@ -689,3 +756,15 @@ func oplDigest(b []byte) string { |
| sum := sha256.Sum256(b) |
| return hex.EncodeToString(sum[:]) |
| } |
| + |
| +// oplRawPost posts body with content type ct as c. |
| +func oplRawPost(t *testing.T, c *http.Client, u, ct, body string) (int, string) { |
| + t.Helper() |
| + res, err := c.Post(u, ct, strings.NewReader(body)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer res.Body.Close() |
| + b, _ := io.ReadAll(res.Body) |
| + return res.StatusCode, string(b) |
| +} |