-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17219 from opf/bug/59408-signing-in-after-two-fac…
…tor-methods-have-been-deleted-lead-to-a-500-error [#59408] Signing in after two factor methods have been deleted lead to a 500 error
- Loading branch information
Showing
11 changed files
with
105 additions
and
31 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
4 changes: 3 additions & 1 deletion
4
modules/two_factor_authentication/spec/features/account_activation_spec.rb
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
2 changes: 1 addition & 1 deletion
2
modules/two_factor_authentication/spec/features/backup_codes/generate_backup_codes_spec.rb
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
4 changes: 3 additions & 1 deletion
4
modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb
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
54 changes: 54 additions & 0 deletions
54
modules/two_factor_authentication/spec/features/login/login_with_deleted_2fa_spec.rb
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require_relative "../../spec_helper" | ||
require_relative "../shared_two_factor_examples" | ||
|
||
RSpec.describe "Login after 2FA deleted 2FA was deleted (REGRESSION)", | ||
:js, | ||
:with_cuprite, | ||
with_settings: { | ||
plugin_openproject_two_factor_authentication: { | ||
"active_strategies" => %i[developer totp] | ||
} | ||
} do | ||
include SharedTwoFactorExamples | ||
let(:user_password) { "bob!" * 4 } | ||
let(:user) do | ||
create(:user, | ||
login: "bob", | ||
password: user_password, | ||
password_confirmation: user_password) | ||
end | ||
|
||
let!(:device1) { create(:two_factor_authentication_device_sms, user:, active: true, default: false) } | ||
let!(:device2) { create(:two_factor_authentication_device_totp, user:, active: true, default: true) } | ||
|
||
it "works correctly when not switching 2fa method" do | ||
first_login_step | ||
|
||
# ensure that no 2fa device is stored in the session | ||
session_data = Sessions::UserSession.last.data | ||
expect(session_data["two_factor_authentication_device_id"]).to be_nil | ||
|
||
# destroy all 2fa devices | ||
user.otp_devices.destroy_all | ||
|
||
# make sure we can sign in without 2fa | ||
first_login_step | ||
expect_logged_in | ||
end | ||
|
||
it "works correctly when the 2fa method was switched before deleting" do | ||
first_login_step | ||
switch_two_factor_device(device1) | ||
|
||
# ensure that the selected 2fa device is stored in the session | ||
session_data = Sessions::UserSession.last.data | ||
expect(session_data["two_factor_authentication_device_id"]).to eq(device1.id) | ||
|
||
# destroy all 2fa devices | ||
user.otp_devices.destroy_all | ||
|
||
# make sure we can sign in without 2fa | ||
first_login_step | ||
expect_logged_in | ||
end | ||
end |
3 changes: 2 additions & 1 deletion
3
modules/two_factor_authentication/spec/features/login/login_without_2fa_spec.rb
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
4 changes: 3 additions & 1 deletion
4
modules/two_factor_authentication/spec/features/login/switch_available_devices_spec.rb
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
53 changes: 31 additions & 22 deletions
53
...tion/spec/features/shared_2fa_examples.rb → ...ec/features/shared_two_factor_examples.rb
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