Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global enabled option so we can toggle it on and off for different tests #30

Open
TylerRick opened this issue Apr 25, 2020 · 0 comments · May be fixed by #31
Open

Add global enabled option so we can toggle it on and off for different tests #30

TylerRick opened this issue Apr 25, 2020 · 0 comments · May be fixed by #31

Comments

@TylerRick
Copy link
Contributor

It would be useful to be able to configure the pwned_password checking feature to be disabled by default — this is what we would want in most tests, so that tests and user factory calls run faster — but to be able to enable them for certain feature tests that specifically need to test the flow/behavior for what should happen when a user does try to use, or already have, a pwned password.

I was thinking of adding a setting called pwned_password_check_enabled (to match pwned_password_check_on_sign_in), like:

Devise.pwned_password_check_enabled = false  # default true

This would be similar to PaperTrail.enabled, for example, and toggle the behavior on and off globally.

Then we'd just make the validation depend on that config, like:

  validate :not_pwned_password, if: :check_pwned_password?

check_pwned_password? could just delegate to Devise.pwned_password_check_enabled:

def check_pwned_password?
  Devise.pwned_password_check_enabled &&
    (Devise.activerecord51? ? :will_save_change_to_encrypted_password? : :encrypted_password_changed?)
end

Of course the docs would have to be updated, too. See PaperTrail's section on testing.

Does this sound good?

See also: #18, #27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant