Merge pull request #8740 from govpf/feature/unique_test_password

add a constant for the most used test password
This commit is contained in:
LeSim 2023-08-31 11:50:50 +00:00 committed by GitHub
commit a84efbf70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 29 additions and 27 deletions

View file

@ -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 'doesnt 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 }

View file

@ -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 }

View file

@ -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 } } }

View file

@ -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 } }

View file

@ -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) }

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 dexpert' }

View file

@ -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'

View file

@ -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]) }

View file

@ -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

View file

@ -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) }

View file

@ -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 }

View file

@ -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 }

View file

@ -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] }]) }

View file

@ -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

View file

@ -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