(t *testing.T)
| 303 | } |
| 304 | |
| 305 | func TestMagicRejectPOSTWithReason(t *testing.T) { |
| 306 | server, store, signer, smtpDone := setupMagicLinkAPI(t) |
| 307 | a, userID := prepareHITLAgent(t, store, "post-reject") |
| 308 | msg := issuePending(t, store, a.ID) |
| 309 | |
| 310 | tok, _ := signer.Sign(msg.ID, approvaltoken.ActionReject, time.Now().Add(1*time.Hour)) |
| 311 | resp := postForm(t, server.URL+"/v1/reject", map[string]string{ |
| 312 | "t": tok, |
| 313 | "reason": "not the right tone", |
| 314 | }) |
| 315 | defer resp.Body.Close() |
| 316 | if resp.StatusCode != http.StatusOK { |
| 317 | t.Fatalf("POST reject: status = %d", resp.StatusCode) |
| 318 | } |
| 319 | |
| 320 | if msgs := smtpDone(); len(msgs) != 0 { |
| 321 | t.Errorf("reject should not call SMTP, got %d", len(msgs)) |
| 322 | } |
| 323 | |
| 324 | got, _ := store.GetOutboundMessageForUser(context.Background(), msg.ID, userID) |
| 325 | if got.Status != identity.MessageStatusReviewRejected { |
| 326 | t.Errorf("status = %q, want rejected", got.Status) |
| 327 | } |
| 328 | if got.RejectionReason != "not the right tone" { |
| 329 | t.Errorf("rejection_reason = %q, want 'not the right tone'", got.RejectionReason) |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | func TestMagicRejectPOSTWithoutReasonUsesDefault(t *testing.T) { |
| 334 | server, store, signer, _ := setupMagicLinkAPI(t) |
nothing calls this directly
no test coverage detected