(t *testing.T)
| 182 | } |
| 183 | |
| 184 | func TestOutboundRequiresAuth(t *testing.T) { |
| 185 | pool := testutil.TestDB(t) |
| 186 | ts := testutil.TestServer(t, pool) |
| 187 | |
| 188 | // Send relocated (Slice 2): POST /v1/agents/{email}/messages. With no |
| 189 | // bearer the typed handler authenticates first and 401s before it ever |
| 190 | // resolves the path agent. |
| 191 | sendPayload := `{"to":["someone@test.com"],"subject":"Hi","body":"Hello"}` |
| 192 | req, _ := http.NewRequest("POST", ts.HTTPServer.URL+"/v1/agents/"+url.PathEscape("agent@noauth.example.com")+"/messages", bytes.NewBufferString(sendPayload)) |
| 193 | req.Header.Set("Content-Type", "application/json") |
| 194 | resp, _ := http.DefaultClient.Do(req) |
| 195 | defer resp.Body.Close() |
| 196 | |
| 197 | if resp.StatusCode != 401 { |
| 198 | t.Errorf("status = %d, want 401", resp.StatusCode) |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | func TestReplayProtection(t *testing.T) { |
| 203 | pool := testutil.TestDB(t) |
nothing calls this directly
no test coverage detected