MCPcopy Create free account
hub / github.com/supabase/auth / TestTokenRefreshWithExpiredSession

Method TestTokenRefreshWithExpiredSession

internal/api/token_test.go:531–552  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

529}
530
531func (ts *TokenTestSuite) TestTokenRefreshWithExpiredSession() {
532 var err error
533
534 now := time.Now().UTC().Add(-1 * time.Second)
535
536 ts.RefreshToken, err = models.GrantAuthenticatedUser(ts.API.db, ts.User, models.GrantParams{
537 SessionNotAfter: &now,
538 })
539 require.NoError(ts.T(), err, "Error creating refresh token")
540
541 var buffer bytes.Buffer
542 require.NoError(ts.T(), json.NewEncoder(&buffer).Encode(map[string]interface{}{
543 "refresh_token": ts.RefreshToken.Token,
544 }))
545
546 req := httptest.NewRequest(http.MethodPost, "http://localhost/token?grant_type=refresh_token", &buffer)
547 req.Header.Set("Content-Type", "application/json")
548
549 w := httptest.NewRecorder()
550 ts.API.handler.ServeHTTP(w, req)
551 assert.Equal(ts.T(), http.StatusBadRequest, w.Code)
552}
553
554func (ts *TokenTestSuite) TestTokenRefreshWithUnexpiredSession() {
555 var err error

Callers

nothing calls this directly

Calls 7

GrantAuthenticatedUserFunction · 0.92
NowMethod · 0.80
EncodeMethod · 0.80
SetMethod · 0.80
EqualMethod · 0.80
AddMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected