diff --git a/spec/controllers/experts/avis_controller_spec.rb b/spec/controllers/experts/avis_controller_spec.rb index 20873a21e..a50cf9186 100644 --- a/spec/controllers/experts/avis_controller_spec.rb +++ b/spec/controllers/experts/avis_controller_spec.rb @@ -559,7 +559,7 @@ describe Experts::AvisController, type: :controller do procedure_id:, email: avis.expert.email, user: { - password: 'my-s3cure-p4ssword' + password: SECURE_PASSWORD } } end @@ -575,7 +575,7 @@ describe Experts::AvisController, type: :controller do it 'saves the expert new password' do subject - expect(expert.user.reload.valid_password?('my-s3cure-p4ssword')).to be true + expect(expert.user.reload.valid_password?(SECURE_PASSWORD)).to be true end it { is_expected.to redirect_to expert_all_avis_path } @@ -586,7 +586,7 @@ describe Experts::AvisController, type: :controller do it 'doesn’t change the expert password' do subject - expect(expert.user.reload.valid_password?('my-s3cure-p4ssword')).to be false + expect(expert.user.reload.valid_password?(SECURE_PASSWORD)).to be false end it { is_expected.to redirect_to new_user_session_url } diff --git a/spec/controllers/france_connect/particulier_controller_spec.rb b/spec/controllers/france_connect/particulier_controller_spec.rb index 76bbae30d..6d0379008 100644 --- a/spec/controllers/france_connect/particulier_controller_spec.rb +++ b/spec/controllers/france_connect/particulier_controller_spec.rb @@ -197,7 +197,7 @@ describe FranceConnect::ParticulierController, type: :controller do let(:fci) { FranceConnectInformation.create!(user_info) } let(:merge_token) { fci.create_merge_token! } let(:email) { 'EXISTING_account@a.com ' } - let(:password) { 'my-s3cure-p4ssword' } + let(:password) { SECURE_PASSWORD } let(:format) { :turbo_stream } subject { post :merge_with_existing_account, params: { merge_token: merge_token, email: email, password: password }, format: format } diff --git a/spec/controllers/manager/administrateurs_controller_spec.rb b/spec/controllers/manager/administrateurs_controller_spec.rb index 58f0f4877..845813cf5 100644 --- a/spec/controllers/manager/administrateurs_controller_spec.rb +++ b/spec/controllers/manager/administrateurs_controller_spec.rb @@ -36,7 +36,7 @@ describe Manager::AdministrateursController, type: :controller do describe 'POST #create' do let(:email) { 'plop@plop.com' } - let(:password) { 'my-s3cure-p4ssword' } + let(:password) { SECURE_PASSWORD } subject { post :create, params: { administrateur: { email: email } } } diff --git a/spec/controllers/users/registrations_controller_spec.rb b/spec/controllers/users/registrations_controller_spec.rb index 2152cef3b..98c927a84 100644 --- a/spec/controllers/users/registrations_controller_spec.rb +++ b/spec/controllers/users/registrations_controller_spec.rb @@ -1,6 +1,6 @@ describe Users::RegistrationsController, type: :controller do let(:email) { 'test@octo.com' } - let(:password) { 'my-s3cure-p4ssword' } + let(:password) { SECURE_PASSWORD } let(:user) { { email: email, password: password } } diff --git a/spec/controllers/users/sessions_controller_spec.rb b/spec/controllers/users/sessions_controller_spec.rb index 9ccf0ced1..717fbe71b 100644 --- a/spec/controllers/users/sessions_controller_spec.rb +++ b/spec/controllers/users/sessions_controller_spec.rb @@ -1,6 +1,6 @@ describe Users::SessionsController, type: :controller do let(:email) { 'unique@plop.com' } - let(:password) { 'my-s3cure-p4ssword' } + let(:password) { SECURE_PASSWORD } let(:loged_in_with_france_connect) { User.loged_in_with_france_connects.fetch(:particulier) } let!(:user) { create(:user, email: email, password: password, loged_in_with_france_connect: loged_in_with_france_connect) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 55e9ae977..7c327f5b4 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -6,7 +6,7 @@ describe User, type: :model do let(:user) do create(:user, email: email, - password: 'my-s3cure-p4ssword', + password: SECURE_PASSWORD, confirmation_token: '123', confirmed_at: nil) end @@ -125,11 +125,11 @@ describe User, type: :model do end context 'with an existing user' do - before { create(:user, email: email, password: 'my-s3cure-p4ssword') } + before { create(:user, email: email, password: SECURE_PASSWORD) } it 'keeps the previous password' do user = subject - expect(user.valid_password?('my-s3cure-p4ssword')).to be true + expect(user.valid_password?(SECURE_PASSWORD)).to be true expect(user.instructeur).to be_present end @@ -189,11 +189,11 @@ describe User, type: :model do end context 'with an existing user' do - before { create(:user, email: email, password: 'my-s3cure-p4ssword') } + before { create(:user, email: email, password: SECURE_PASSWORD) } it 'keeps the previous password' do user = subject - expect(user.valid_password?('my-s3cure-p4ssword')).to be true + expect(user.valid_password?(SECURE_PASSWORD)).to be true expect(user.expert).to be_present end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9a04c8697..772be45ab 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,6 +18,8 @@ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration require 'rspec/retry' +SECURE_PASSWORD = 'my-s3cure-p4ssword' + RSpec.configure do |config| config.filter_run_excluding disable: true config.color = true diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb index b3cd3f13d..649493dbd 100644 --- a/spec/support/system_helpers.rb +++ b/spec/support/system_helpers.rb @@ -34,7 +34,7 @@ module SystemHelpers end end - def sign_up_with(email, password = 'my-s3cure-p4ssword') + def sign_up_with(email, password = SECURE_PASSWORD) fill_in :user_email, with: email fill_in :user_password, with: password diff --git a/spec/system/france_connect/france_connect_particulier_spec.rb b/spec/system/france_connect/france_connect_particulier_spec.rb index 7ddf43494..1c477b94a 100644 --- a/spec/system/france_connect/france_connect_particulier_spec.rb +++ b/spec/system/france_connect/france_connect_particulier_spec.rb @@ -47,7 +47,7 @@ describe 'France Connect Particulier Connexion' do end context 'and an user exists with the same email' do - let!(:user) { create(:user, email: email, password: 'my-s3cure-p4ssword') } + let!(:user) { create(:user, email: email, password: SECURE_PASSWORD) } before do page.find('.fr-connect').click @@ -59,7 +59,7 @@ describe 'France Connect Particulier Connexion' do scenario 'it merges its account' do page.find('#it-is-mine').click - fill_in 'password', with: 'my-s3cure-p4ssword' + fill_in 'password', with: SECURE_PASSWORD click_on 'Fusionner les comptes' expect(page).to have_content('Dossiers') @@ -74,7 +74,7 @@ describe 'France Connect Particulier Connexion' do end context 'and the user wants an email that belongs to another account', js: true, retry: 3 do - let!(:another_user) { create(:user, email: 'an_existing_email@a.com', password: 'my-s3cure-p4ssword') } + let!(:another_user) { create(:user, email: 'an_existing_email@a.com', password: SECURE_PASSWORD) } scenario 'it uses another email that belongs to another account' do page.find('#it-is-not-mine').click @@ -84,7 +84,7 @@ describe 'France Connect Particulier Connexion' do expect(page).to have_css('#password-for-another-account', visible: true) within '#new-account-password-confirmation' do - fill_in 'password', with: 'my-s3cure-p4ssword' + fill_in 'password', with: SECURE_PASSWORD click_on 'Fusionner les comptes' end diff --git a/spec/system/instructeurs/expert_spec.rb b/spec/system/instructeurs/expert_spec.rb index 2bfa1e1bb..a2072fd2b 100644 --- a/spec/system/instructeurs/expert_spec.rb +++ b/spec/system/instructeurs/expert_spec.rb @@ -2,7 +2,7 @@ describe 'Inviting an expert:', js: true, retry: 3 do include ActiveJob::TestHelper include ActionView::Helpers - let(:instructeur) { create(:instructeur, password: 'my-s3cure-p4ssword') } + let(:instructeur) { create(:instructeur, password: SECURE_PASSWORD) } let(:expert) { create(:expert, password: expert_password) } let(:expert2) { create(:expert, password: expert_password) } let(:expert_password) { 'mot de passe d’expert' } diff --git a/spec/system/instructeurs/instructeur_creation_spec.rb b/spec/system/instructeurs/instructeur_creation_spec.rb index 0913182bc..0ed5e7f9a 100644 --- a/spec/system/instructeurs/instructeur_creation_spec.rb +++ b/spec/system/instructeurs/instructeur_creation_spec.rb @@ -20,7 +20,7 @@ describe 'As an instructeur', js: true, retry: 3 do token_params = confirmation_email.body.match(/token=[^"]+/) visit "users/activate?#{token_params}" - fill_in :user_password, with: 'my-s3cure-p4ssword' + fill_in :user_password, with: SECURE_PASSWORD click_button 'Définir le mot de passe' diff --git a/spec/system/instructeurs/instruction_spec.rb b/spec/system/instructeurs/instruction_spec.rb index 0c33901bd..58ca53157 100644 --- a/spec/system/instructeurs/instruction_spec.rb +++ b/spec/system/instructeurs/instruction_spec.rb @@ -1,7 +1,7 @@ describe 'Instructing a dossier:', js: true, retry: 3 do include ActiveJob::TestHelper - let(:password) { 'my-s3cure-p4ssword' } + let(:password) { SECURE_PASSWORD } let!(:instructeur) { create(:instructeur, password: password) } let!(:procedure) { create(:procedure, :with_type_de_champ, :published, instructeurs: [instructeur]) } diff --git a/spec/system/sessions/sign_in_spec.rb b/spec/system/sessions/sign_in_spec.rb index c2a03630e..a58df1ce4 100644 --- a/spec/system/sessions/sign_in_spec.rb +++ b/spec/system/sessions/sign_in_spec.rb @@ -1,6 +1,6 @@ describe 'Signin in:' do let!(:user) { create(:user, password: password) } - let(:password) { 'my-s3cure-p4ssword' } + let(:password) { SECURE_PASSWORD } scenario 'an existing user can sign-in' do visit root_path diff --git a/spec/system/users/brouillon_spec.rb b/spec/system/users/brouillon_spec.rb index cf12ecb7d..d4ef793f1 100644 --- a/spec/system/users/brouillon_spec.rb +++ b/spec/system/users/brouillon_spec.rb @@ -1,5 +1,5 @@ describe 'The user' do - let(:password) { 'my-s3cure-p4ssword' } + let(:password) { SECURE_PASSWORD } let!(:user) { create(:user, password: password) } let!(:procedure) { create(:procedure, :published, :for_individual, :with_all_champs_mandatory) } diff --git a/spec/system/users/dossier_prefill_get_spec.rb b/spec/system/users/dossier_prefill_get_spec.rb index 51842c273..23476ad14 100644 --- a/spec/system/users/dossier_prefill_get_spec.rb +++ b/spec/system/users/dossier_prefill_get_spec.rb @@ -1,5 +1,5 @@ describe 'Prefilling a dossier (with a GET request):', js: true, retry: 3 do - let(:password) { 'my-s3cure-p4ssword' } + let(:password) { SECURE_PASSWORD } let(:procedure) { create(:procedure, :published, opendata: true) } let(:dossier) { procedure.dossiers.last } diff --git a/spec/system/users/dossier_prefill_post_spec.rb b/spec/system/users/dossier_prefill_post_spec.rb index 75d724b3c..761cbbfd2 100644 --- a/spec/system/users/dossier_prefill_post_spec.rb +++ b/spec/system/users/dossier_prefill_post_spec.rb @@ -1,5 +1,5 @@ describe 'Prefilling a dossier (with a POST request):', js: true, retry: 3 do - let(:password) { 'my-s3cure-p4ssword' } + let(:password) { SECURE_PASSWORD } let(:procedure) { create(:procedure, :published) } let(:dossier) { procedure.dossiers.last } diff --git a/spec/system/users/dropdown_spec.rb b/spec/system/users/dropdown_spec.rb index ae4efd9d2..2d8043132 100644 --- a/spec/system/users/dropdown_spec.rb +++ b/spec/system/users/dropdown_spec.rb @@ -1,5 +1,5 @@ describe 'dropdown list with other option activated', js: true, retry: 3 do - let(:password) { 'my-s3cure-p4ssword' } + let(:password) { SECURE_PASSWORD } let!(:user) { create(:user, password: password) } let(:procedure) { create(:procedure, :published, :for_individual, types_de_champ_public: [{ type: :drop_down_list, libelle: 'simple dropdown other', options: options + [:other] }]) } diff --git a/spec/system/users/linked_dropdown_spec.rb b/spec/system/users/linked_dropdown_spec.rb index 337442850..d573aca21 100644 --- a/spec/system/users/linked_dropdown_spec.rb +++ b/spec/system/users/linked_dropdown_spec.rb @@ -1,5 +1,5 @@ describe 'linked dropdown lists' do - let(:password) { 'my-s3cure-p4ssword' } + let(:password) { SECURE_PASSWORD } let!(:user) { create(:user, password: password) } let(:options) do diff --git a/spec/system/users/sign_up_spec.rb b/spec/system/users/sign_up_spec.rb index dd6fda18f..6693210d4 100644 --- a/spec/system/users/sign_up_spec.rb +++ b/spec/system/users/sign_up_spec.rb @@ -1,6 +1,6 @@ describe 'Signing up:' do let(:user_email) { generate :user_email } - let(:user_password) { 'my-s3cure-p4ssword' } + let(:user_password) { SECURE_PASSWORD } let(:procedure) { create :simple_procedure, :with_service } scenario 'a new user can sign-up from scratch' do