Fix Django 1.11 compatibility for auth validation methods.

Review Request #10837 — Created Jan. 19, 2020 and submitted

Information

Djblets
release-2.0.x

Reviewers

djblets.auth.util.validate_test_cookie() was using an old module
location for ErrorList(), used for form errors. We had a couple
imports at the top of the module that were designed to locate the
correct version of this for validate_old_password, but
validate_test_cookie wasn't using it.

A more correct approach, which this change implements, is to use the
provided form's error_class attribute instead, which defaults to
ErrorList but could be something more specific on some forms. This
simplifies our code, since we don't have to guess where the class is,
and ensures we work with more form implementations.

Unit tests were added for the validation methods to ensure they work in
all Django versions.

Unit tests pass on Django 1.7 and 1.11.

Summary ID
Fix Django 1.11 compatibility for auth validation methods.
`djblets.auth.util.validate_test_cookie()` was using an old module location for `ErrorList()`, used for form errors. We had a couple imports at the top of the module that were designed to locate the correct version of this for `validate_old_password`, but `validate_test_cookie` wasn't using it. A more correct approach, which this change implements, is to use the provided form's `error_class` attribute instead, which defaults to `ErrorList` but could be something more specific on some forms. This simplifies our code, since we don't have to guess where the class is, and ensures we work with more form implementations. Unit tests were added for the validation methods to ensure they work in all Django versions.
3665745f1b2ebe08a4875d4ae0be0880f445c0a6
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.0.x (40a7d18)
Loading...