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

Method TestAdminUserGetFactors

internal/api/admin_test.go:808–828  ·  view source on GitHub ↗

TestAdminUserGetFactor tests API /admin/user/ /factors/

()

Source from the content-addressed store, hash-verified

806
807// TestAdminUserGetFactor tests API /admin/user/<user_id>/factors/
808func (ts *AdminTestSuite) TestAdminUserGetFactors() {
809 u, err := models.NewUser("123456789", "test-delete@example.com", "test", ts.Config.JWT.Aud, nil)
810 require.NoError(ts.T(), err, "Error making new user")
811 require.NoError(ts.T(), ts.API.db.Create(u), "Error creating user")
812
813 f := models.NewTOTPFactor(u, "testSimpleName")
814 require.NoError(ts.T(), f.SetSecret("secretkey", ts.Config.Security.DBEncryption.Encrypt, ts.Config.Security.DBEncryption.EncryptionKeyID, ts.Config.Security.DBEncryption.EncryptionKey))
815 require.NoError(ts.T(), ts.API.db.Create(f), "Error saving new test factor")
816
817 // Setup request
818 w := httptest.NewRecorder()
819 req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/admin/users/%s/factors/", u.ID), nil)
820
821 req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", ts.token))
822
823 ts.API.handler.ServeHTTP(w, req)
824 require.Equal(ts.T(), http.StatusOK, w.Code)
825 getFactorsResp := []*models.Factor{}
826 require.NoError(ts.T(), json.NewDecoder(w.Body).Decode(&getFactorsResp))
827 require.Equal(ts.T(), getFactorsResp[0].Secret, "")
828}
829
830func (ts *AdminTestSuite) TestAdminUserUpdateFactor() {
831 u, err := models.NewUser("123456789", "test-delete@example.com", "test", ts.Config.JWT.Aud, nil)

Callers

nothing calls this directly

Calls 7

NewUserFunction · 0.92
NewTOTPFactorFunction · 0.92
SetSecretMethod · 0.80
SetMethod · 0.80
EqualMethod · 0.80
ServeHTTPMethod · 0.45
DecodeMethod · 0.45

Tested by

no test coverage detected