MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestMagicLinkExpiredToken

Function TestMagicLinkExpiredToken

internal/agent/hitl_magic_api_test.go:397–416  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

395}
396
397func 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

Callers

nothing calls this directly

Calls 7

setupMagicLinkAPIFunction · 0.85
prepareHITLAgentFunction · 0.85
issuePendingFunction · 0.85
postFormFunction · 0.85
GetMethod · 0.65
SignMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected