2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-08-31 18:14:32 +02:00
|
|
|
describe PasswordComplexityController, type: :controller do
|
|
|
|
describe '#show' do
|
|
|
|
let(:params) do
|
2024-09-16 14:58:37 +02:00
|
|
|
{ user: { password: 'motDePasseTropFacile' } }
|
2021-08-31 18:14:32 +02:00
|
|
|
end
|
|
|
|
|
2022-05-04 12:41:39 +02:00
|
|
|
subject { get :show, format: :turbo_stream, params: params }
|
2021-08-31 18:14:32 +02:00
|
|
|
|
|
|
|
it 'computes a password score' do
|
|
|
|
subject
|
|
|
|
expect(assigns(:score)).to eq(3)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a different resource name' do
|
|
|
|
let(:params) do
|
2024-09-16 14:58:37 +02:00
|
|
|
{ super_admin: { password: 'motDePasseTropFacile' } }
|
2021-08-31 18:14:32 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'computes a password score' do
|
|
|
|
subject
|
|
|
|
expect(assigns(:score)).to eq(3)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when rendering the view' do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
it 'renders Javascript that updates the password complexity meter' do
|
|
|
|
subject
|
2023-02-09 19:06:44 +01:00
|
|
|
expect(response.body).to include('Mot de passe vulnérable')
|
2021-08-31 18:14:32 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|