()
| 743 | } |
| 744 | |
| 745 | func (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 | |
| 769 | func signUp(ts *MFATestSuite, email, password string) (signUpResp AccessTokenResponse) { |
| 770 | ts.API.config.Mailer.Autoconfirm = true |
nothing calls this directly
no test coverage detected