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