temporary remove password complexity check

This commit is contained in:
simon lehericey 2019-08-09 10:41:10 +02:00
parent 27c81c1992
commit 1b38d4071d
2 changed files with 23 additions and 23 deletions

View file

@ -16,7 +16,7 @@ class Administrateur < ApplicationRecord
scope :inactive, -> { where(active: false) } scope :inactive, -> { where(active: false) }
scope :with_publiees_ou_archivees, -> { joins(:procedures).where(procedures: { aasm_state: [:publiee, :archivee] }) } scope :with_publiees_ou_archivees, -> { joins(:procedures).where(procedures: { aasm_state: [:publiee, :archivee] }) }
validate :password_complexity, if: Proc.new { |a| Devise.password_length.include?(a.password.try(:size)) } # validate :password_complexity, if: Proc.new { |a| Devise.password_length.include?(a.password.try(:size)) }
def password_complexity def password_complexity
if password.present? && ZxcvbnService.new(password).score < PASSWORD_COMPLEXITY_FOR_ADMIN if password.present? && ZxcvbnService.new(password).score < PASSWORD_COMPLEXITY_FOR_ADMIN

View file

@ -71,33 +71,33 @@ describe Administrateur, type: :model do
it { expect(administrateur.feature_enabled?(:test_a)).to be_truthy } it { expect(administrateur.feature_enabled?(:test_a)).to be_truthy }
end end
describe '#password_complexity' do # describe '#password_complexity' do
let(:email) { 'mail@beta.gouv.fr' } # let(:email) { 'mail@beta.gouv.fr' }
let(:passwords) { ['pass', '12pass23', 'démarches ', 'démarches-simple', 'démarches-simplifiées-pwd'] } # let(:passwords) { ['pass', '12pass23', 'démarches ', 'démarches-simple', 'démarches-simplifiées-pwd'] }
let(:administrateur) { build(:administrateur, email: email, password: password) } # let(:administrateur) { build(:administrateur, email: email, password: password) }
let(:min_complexity) { PASSWORD_COMPLEXITY_FOR_ADMIN } # let(:min_complexity) { PASSWORD_COMPLEXITY_FOR_ADMIN }
subject do # subject do
administrateur.save # administrateur.save
administrateur.errors.full_messages # administrateur.errors.full_messages
end # end
context 'when password is too short' do # context 'when password is too short' do
let(:password) { 's' * (PASSWORD_MIN_LENGTH - 1) } # let(:password) { 's' * (PASSWORD_MIN_LENGTH - 1) }
it { expect(subject).to eq(["Le mot de passe est trop court"]) } # it { expect(subject).to eq(["Le mot de passe est trop court"]) }
end # end
context 'when password is too simple' do # context 'when password is too simple' do
let(:password) { passwords[min_complexity - 1] } # let(:password) { passwords[min_complexity - 1] }
it { expect(subject).to eq(["Le mot de passe n'est pas assez complexe"]) } # it { expect(subject).to eq(["Le mot de passe n'est pas assez complexe"]) }
end # end
context 'when password is acceptable' do # context 'when password is acceptable' do
let(:password) { passwords[min_complexity] } # let(:password) { passwords[min_complexity] }
it { expect(subject).to eq([]) } # it { expect(subject).to eq([]) }
end # end
end # end
end end