(t *testing.T)
| 395 | } |
| 396 | |
| 397 | func TestMagicLinkExpiredToken(t *testing.T) { |
| 398 | server, store, signer, smtpDone := setupMagicLinkAPI(t) |
| 399 | defer smtpDone() |
| 400 | a, _ := prepareHITLAgent(t, store, "magic-expired") |
| 401 | msg := issuePending(t, store, a.ID) |
| 402 | |
| 403 | tok, _ := signer.Sign(msg.ID, approvaltoken.ActionApprove, time.Now().Add(-1*time.Second)) |
| 404 | |
| 405 | // GET and POST both reject expired tokens with 410. |
| 406 | getResp, _ := http.Get(server.URL + "/v1/approve?t=" + url.QueryEscape(tok)) |
| 407 | getResp.Body.Close() |
| 408 | if getResp.StatusCode != http.StatusGone { |
| 409 | t.Errorf("GET expired: status = %d, want 410", getResp.StatusCode) |
| 410 | } |
| 411 | postResp := postForm(t, server.URL+"/v1/approve", map[string]string{"t": tok}) |
| 412 | postResp.Body.Close() |
| 413 | if postResp.StatusCode != http.StatusGone { |
| 414 | t.Errorf("POST expired: status = %d, want 410", postResp.StatusCode) |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | // TestMagicApproveTokenRejectedAtRejectEndpoint confirms a token issued |
| 419 | // for approve cannot be redeemed at /reject. Tested on both GET and |
nothing calls this directly
no test coverage detected