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

Method TestAdminUserDeleteFactor

internal/api/admin_test.go:783–805  ·  view source on GitHub ↗

TestAdminUserDeleteFactor tests API /admin/users/ /factors/ /

()

Source from the content-addressed store, hash-verified

781
782// TestAdminUserDeleteFactor tests API /admin/users/<user_id>/factors/<factor_id>/
783func (ts *AdminTestSuite) TestAdminUserDeleteFactor() {
784 u, err := models.NewUser("123456789", "test-delete@example.com", "test", ts.Config.JWT.Aud, nil)
785 require.NoError(ts.T(), err, "Error making new user")
786 require.NoError(ts.T(), ts.API.db.Create(u), "Error creating user")
787
788 f := models.NewTOTPFactor(u, "testSimpleName")
789 require.NoError(ts.T(), f.UpdateStatus(ts.API.db, models.FactorStateVerified))
790 require.NoError(ts.T(), f.SetSecret("secretkey", ts.Config.Security.DBEncryption.Encrypt, ts.Config.Security.DBEncryption.EncryptionKeyID, ts.Config.Security.DBEncryption.EncryptionKey))
791 require.NoError(ts.T(), ts.API.db.Create(f), "Error saving new test factor")
792
793 // Setup request
794 w := httptest.NewRecorder()
795 req := httptest.NewRequest(http.MethodDelete, fmt.Sprintf("/admin/users/%s/factors/%s/", u.ID, f.ID), nil)
796
797 req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", ts.token))
798
799 ts.API.handler.ServeHTTP(w, req)
800 require.Equal(ts.T(), http.StatusOK, w.Code)
801
802 _, err = models.FindFactorByFactorID(ts.API.db, f.ID)
803 require.EqualError(ts.T(), err, models.FactorNotFoundError{}.Error())
804
805}
806
807// TestAdminUserGetFactor tests API /admin/user/<user_id>/factors/
808func (ts *AdminTestSuite) TestAdminUserGetFactors() {

Callers

nothing calls this directly

Calls 9

NewUserFunction · 0.92
NewTOTPFactorFunction · 0.92
FindFactorByFactorIDFunction · 0.92
UpdateStatusMethod · 0.80
SetSecretMethod · 0.80
SetMethod · 0.80
EqualMethod · 0.80
ServeHTTPMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected