Enable email_login_token for all gestionnaires
This commit is contained in:
parent
2af37f85e2
commit
0969b1f85f
8 changed files with 36 additions and 58 deletions
|
@ -183,7 +183,7 @@ class ApplicationController < ActionController::Base
|
|||
def redirect_if_untrusted
|
||||
if instructeur_signed_in? &&
|
||||
sensitive_path &&
|
||||
Flipflop.enable_email_login_token? &&
|
||||
!Flipflop.bypass_email_login_token? &&
|
||||
!IPService.ip_trusted?(request.headers['X-Forwarded-For']) &&
|
||||
!trusted_device?
|
||||
|
||||
|
|
|
@ -14,12 +14,12 @@ Flipflop.configure do
|
|||
end
|
||||
|
||||
feature :web_hook
|
||||
feature :enable_email_login_token
|
||||
|
||||
feature :procedure_export_v2_enabled
|
||||
feature :operation_log_serialize_subject
|
||||
feature :download_as_zip_enabled,
|
||||
default: false
|
||||
feature :download_as_zip_enabled
|
||||
feature :bypass_email_login_token,
|
||||
default: Rails.env.test?
|
||||
|
||||
group :development do
|
||||
feature :mini_profiler_enabled,
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
namespace :'activate_trusted_device_for_a-f' do
|
||||
task run: :environment do
|
||||
letters_a_to_f = ('a'..'f').to_a
|
||||
Gestionnaire
|
||||
.where("substr(email, 1, 1) IN (?)", letters_a_to_f)
|
||||
.update_all(features: { "enable_email_login_token" => true })
|
||||
end
|
||||
end
|
|
@ -166,56 +166,44 @@ describe ApplicationController, type: :controller do
|
|||
context 'when the path is sensitive' do
|
||||
let(:sensitive_path) { true }
|
||||
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:bypass_email_login_token, false)
|
||||
end
|
||||
|
||||
context 'when the instructeur is signed_in' do
|
||||
let(:instructeur_signed_in) { true }
|
||||
|
||||
context 'when the feature is activated' do
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:enable_email_login_token, true)
|
||||
context 'when the ip is not trusted' do
|
||||
let(:ip_trusted) { false }
|
||||
|
||||
context 'when the device is trusted' do
|
||||
let(:trusted_device) { true }
|
||||
|
||||
before { subject }
|
||||
|
||||
it { expect(@controller).not_to have_received(:redirect_to) }
|
||||
end
|
||||
|
||||
context 'when the ip is not trusted' do
|
||||
let(:ip_trusted) { false }
|
||||
context 'when the device is not trusted' do
|
||||
let(:trusted_device) { false }
|
||||
|
||||
context 'when the device is trusted' do
|
||||
let(:trusted_device) { true }
|
||||
before { subject }
|
||||
|
||||
before { subject }
|
||||
|
||||
it { expect(@controller).not_to have_received(:redirect_to) }
|
||||
end
|
||||
it { expect(@controller).to have_received(:redirect_to) }
|
||||
it { expect(@controller).to have_received(:send_login_token_or_bufferize) }
|
||||
it { expect(@controller).to have_received(:store_location_for) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the feature is activated' do
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:enable_email_login_token, true)
|
||||
end
|
||||
context 'when the ip is trusted' do
|
||||
let(:ip_trusted) { true }
|
||||
|
||||
context 'when the ip is untrusted' do
|
||||
let(:ip_trusted) { false }
|
||||
context 'when the device is not trusted' do
|
||||
let(:trusted_device) { false }
|
||||
|
||||
context 'when the device is not trusted' do
|
||||
let(:trusted_device) { false }
|
||||
before { subject }
|
||||
|
||||
before { subject }
|
||||
|
||||
it { expect(@controller).to have_received(:redirect_to) }
|
||||
it { expect(@controller).to have_received(:send_login_token_or_bufferize) }
|
||||
it { expect(@controller).to have_received(:store_location_for) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the ip is trusted' do
|
||||
let(:ip_trusted) { true }
|
||||
|
||||
context 'when the device is not trusted' do
|
||||
let(:trusted_device) { false }
|
||||
|
||||
before { subject }
|
||||
|
||||
it { expect(@controller).not_to have_received(:redirect_to) }
|
||||
end
|
||||
it { expect(@controller).not_to have_received(:redirect_to) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,6 @@ describe Users::SessionsController, type: :controller do
|
|||
let(:send_password) { password }
|
||||
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:enable_email_login_token, true)
|
||||
allow(controller).to receive(:trusted_device?).and_return(trusted_device)
|
||||
allow(InstructeurMailer).to receive(:send_login_token).and_return(double(deliver_later: true))
|
||||
end
|
||||
|
@ -28,6 +27,9 @@ describe Users::SessionsController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when the device is not trusted' do
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:bypass_email_login_token, false)
|
||||
end
|
||||
let(:trusted_device) { false }
|
||||
|
||||
it 'redirects to the send_linked_path' do
|
||||
|
|
|
@ -9,10 +9,6 @@ feature 'The instructeur part' do
|
|||
let!(:procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
|
||||
let!(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure) }
|
||||
|
||||
before do
|
||||
Flipflop::FeatureSet.current.test!.switch!(:enable_email_login_token, true)
|
||||
end
|
||||
|
||||
context 'the instructeur is also a user' do
|
||||
scenario 'a instructeur can fill a dossier' do
|
||||
visit commencer_path(path: procedure.path)
|
||||
|
|
|
@ -12,10 +12,6 @@ describe Instructeur, type: :model do
|
|||
assign(procedure_2)
|
||||
end
|
||||
|
||||
describe 'default features' do
|
||||
it { expect(instructeur.features).to eq({ "enable_email_login_token" => true }) }
|
||||
end
|
||||
|
||||
describe '#visible_procedures' do
|
||||
let(:procedure_not_assigned) { create :procedure, administrateur: admin }
|
||||
let(:procedure_with_default_path) { create :procedure, administrateur: admin }
|
||||
|
|
|
@ -21,6 +21,10 @@ module FeatureHelpers
|
|||
fill_in :user_email, with: email
|
||||
fill_in :user_password, with: password
|
||||
|
||||
if sign_in_by_link
|
||||
Flipflop::FeatureSet.current.test!.switch!(:bypass_email_login_token, false)
|
||||
end
|
||||
|
||||
perform_enqueued_jobs do
|
||||
click_on 'Se connecter'
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue