-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: move is owned by check to load factor (#1703)
## What kind of change does this PR introduce? In `loadFactor` ensure that all factors which are loaded are owned by the user
- Loading branch information
Showing
4 changed files
with
41 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -569,6 +569,30 @@ func (ts *MFATestSuite) TestMFAFollowedByPasswordSignIn() { | |
require.True(ts.T(), session.IsAAL2()) | ||
} | ||
|
||
func (ts *MFATestSuite) TestChallengeFactorNotOwnedByUser() { | ||
var buffer bytes.Buffer | ||
email := "[email protected]" | ||
password := "testpassword" | ||
signUpResp := signUp(ts, email, password) | ||
|
||
friendlyName := "testfactor" | ||
phoneNumber := "+1234567" | ||
|
||
otherUsersPhoneFactor := models.NewPhoneFactor(ts.TestUser, phoneNumber, friendlyName) | ||
require.NoError(ts.T(), ts.API.db.Create(otherUsersPhoneFactor), "Error creating factor") | ||
|
||
w := ServeAuthenticatedRequest(ts, http.MethodPost, fmt.Sprintf("http://localhost/factors/%s/challenge", otherUsersPhoneFactor.ID), signUpResp.Token, buffer) | ||
|
||
expectedError := notFoundError(ErrorCodeMFAFactorNotFound, "Factor not found") | ||
|
||
var data HTTPError | ||
require.NoError(ts.T(), json.NewDecoder(w.Body).Decode(&data)) | ||
|
||
require.Equal(ts.T(), expectedError.ErrorCode, data.ErrorCode) | ||
require.Equal(ts.T(), http.StatusNotFound, w.Code) | ||
|
||
} | ||
|
||
func signUp(ts *MFATestSuite, email, password string) (signUpResp AccessTokenResponse) { | ||
ts.API.config.Mailer.Autoconfirm = true | ||
var buffer bytes.Buffer | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters