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

Method TestChallengeFactorNotOwnedByUser

internal/api/mfa_test.go:745–767  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

743}
744
745func (ts *MFATestSuite) TestChallengeFactorNotOwnedByUser() {
746 var buffer bytes.Buffer
747 email := "nomfaenabled@test.com"
748 password := "testpassword"
749 signUpResp := signUp(ts, email, password)
750
751 friendlyName := "testfactor"
752 phoneNumber := "+1234567"
753
754 otherUsersPhoneFactor := models.NewPhoneFactor(ts.TestUser, phoneNumber, friendlyName)
755 require.NoError(ts.T(), ts.API.db.Create(otherUsersPhoneFactor), "Error creating factor")
756
757 w := ServeAuthenticatedRequest(ts, http.MethodPost, fmt.Sprintf("http://localhost/factors/%s/challenge", otherUsersPhoneFactor.ID), signUpResp.Token, buffer)
758
759 expectedError := apierrors.NewNotFoundError(apierrors.ErrorCodeMFAFactorNotFound, "Factor not found")
760
761 var data HTTPError
762 require.NoError(ts.T(), json.NewDecoder(w.Body).Decode(&data))
763
764 require.Equal(ts.T(), expectedError.ErrorCode, data.ErrorCode)
765 require.Equal(ts.T(), http.StatusNotFound, w.Code)
766
767}
768
769func signUp(ts *MFATestSuite, email, password string) (signUpResp AccessTokenResponse) {
770 ts.API.config.Mailer.Autoconfirm = true

Callers

nothing calls this directly

Calls 6

NewPhoneFactorFunction · 0.92
NewNotFoundErrorFunction · 0.92
signUpFunction · 0.85
EqualMethod · 0.80
DecodeMethod · 0.45

Tested by

no test coverage detected