Merge branch 'master' into glitch-soc/merge-upstream

Conflicts:
- app/controllers/auth/sessions_controller.rb
  Minor conflict due to glitch-soc's theming code
This commit is contained in:
Thibaut Girka
2019-09-18 17:25:56 +02:00
180 changed files with 1537 additions and 432 deletions

View File

@ -5,11 +5,11 @@ require 'rails_helper'
RSpec.describe Auth::SessionsController, type: :controller do
render_views
describe 'GET #new' do
before do
request.env['devise.mapping'] = Devise.mappings[:user]
end
before do
request.env['devise.mapping'] = Devise.mappings[:user]
end
describe 'GET #new' do
it 'returns http success' do
get :new
expect(response).to have_http_status(200)
@ -19,10 +19,6 @@ RSpec.describe Auth::SessionsController, type: :controller do
describe 'DELETE #destroy' do
let(:user) { Fabricate(:user) }
before do
request.env['devise.mapping'] = Devise.mappings[:user]
end
context 'with a regular user' do
it 'redirects to home after sign out' do
sign_in(user, scope: :user)
@ -51,10 +47,6 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
describe 'POST #create' do
before do
request.env['devise.mapping'] = Devise.mappings[:user]
end
context 'using PAM authentication', if: ENV['PAM_ENABLED'] == 'true' do
context 'using a valid password' do
before do
@ -191,11 +183,11 @@ RSpec.describe Auth::SessionsController, type: :controller do
end
context 'using two-factor authentication' do
let(:user) do
Fabricate(:user, email: 'x@y.com', password: 'abcdefgh',
otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
let!(:user) do
Fabricate(:user, email: 'x@y.com', password: 'abcdefgh', otp_required_for_login: true, otp_secret: User.generate_otp_secret(32))
end
let(:recovery_codes) do
let!(:recovery_codes) do
codes = user.generate_otp_backup_codes!
user.save
return codes

View File

@ -68,7 +68,7 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do
true
end
post :create, params: { form_two_factor_confirmation: { code: '123456' } }
post :create, params: { form_two_factor_confirmation: { otp_attempt: '123456' } }
expect(assigns(:recovery_codes)).to eq otp_backup_codes
expect(flash[:notice]).to eq 'Two-factor authentication successfully enabled'
@ -85,7 +85,7 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do
false
end
post :create, params: { form_two_factor_confirmation: { code: '123456' } }
post :create, params: { form_two_factor_confirmation: { otp_attempt: '123456' } }
end
it 'renders the new view' do
@ -99,7 +99,7 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do
context 'when not signed in' do
it 'redirects if not signed in' do
post :create, params: { form_two_factor_confirmation: { code: '123456' } }
post :create, params: { form_two_factor_confirmation: { otp_attempt: '123456' } }
expect(response).to redirect_to('/auth/sign_in')
end
end

View File

@ -91,7 +91,7 @@ describe Settings::TwoFactorAuthenticationsController do
true
end
post :destroy, params: { form_two_factor_confirmation: { code: '123456' } }
post :destroy, params: { form_two_factor_confirmation: { otp_attempt: '123456' } }
expect(response).to redirect_to(settings_two_factor_authentication_path)
user.reload
@ -105,7 +105,7 @@ describe Settings::TwoFactorAuthenticationsController do
false
end
post :destroy, params: { form_two_factor_confirmation: { code: '057772' } }
post :destroy, params: { form_two_factor_confirmation: { otp_attempt: '057772' } }
user.reload
expect(user.otp_required_for_login).to eq(true)