forked from TheEssem/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
expect
params wrapper for more "auth" and "2FA" "controllers" (m…
- Loading branch information
1 parent
e44b784
commit a1d9c3f
Showing
8 changed files
with
77 additions
and
10 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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Auth Sessions' do | ||
describe 'POST /auth/sign_in' do | ||
# The rack-attack check has issues with the non-nested invalid param used here | ||
before { Rack::Attack.enabled = false } | ||
after { Rack::Attack.enabled = true } | ||
|
||
it 'gracefully handles invalid nested params' do | ||
post user_session_path(user: 'invalid') | ||
|
||
expect(response) | ||
.to have_http_status(400) | ||
end | ||
end | ||
end |
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
19 changes: 19 additions & 0 deletions
19
spec/requests/settings/two_factor_authentication/confirmations_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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Settings 2FA Confirmations' do | ||
describe 'POST /settings/two_factor_authentication/confirmations' do | ||
before do | ||
sign_in Fabricate(:user, encrypted_password: '') # Empty encrypted password avoids challengable flow | ||
post settings_otp_authentication_path # Sets `session[:new_otp_secret]` which is needed for next step | ||
end | ||
|
||
it 'gracefully handles invalid nested params' do | ||
post settings_two_factor_authentication_confirmation_path(form_two_factor_confirmation: 'invalid') | ||
|
||
expect(response) | ||
.to have_http_status(400) | ||
end | ||
end | ||
end |
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,16 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'Settings Verifications' do | ||
describe 'PUT /settings/verification' do | ||
before { sign_in Fabricate(:user) } | ||
|
||
it 'gracefully handles invalid nested params' do | ||
put settings_verification_path(account: 'invalid') | ||
|
||
expect(response) | ||
.to have_http_status(400) | ||
end | ||
end | ||
end |