Greatly improve validation for cache backend configuration.

Review Request #8624 — Created Jan. 16, 2017 and submitted

Information

Review Board
release-2.0.x
9838eef...

Reviewers

The General Settings page has always trusted the user to provide sane
caching server information, but if things went wrong, this could lead to
failures when loading the caching backend. It didn't help that we didn't
visually indicate that the fields were required at times (even if we did
in fact check it).

The logic for cache server validation has been completely replaced. We
now properly show the "required" states for the fields, and display the
correct error messages for them at all times. If the fields individually
are valid, then we validate the entirety of the caching configuration,
making an attempt to load the backend and set/get/delete a value. If
there are any errors, or the value does not come back, then we raise a
validation error.

This should help keep people from running into broken states when
touching their caching configuration.

Tested the Local Memory, File, and Memcached backends with and without
valid configurations (technically Local Memory only has valid).

For File, I tested with a valid path, with an invalid path (non-existent
and read-only), blank field, and fields with spaces (blank and otherwise).

For Memcached, I tested with a valid host, with an invalid host (invalid
format and valid but without a running daemon), blank field, and fields
with spaces (blank and otherwise).

Checked the error messages for required fields (with and without spaces).

Checked the "required" states for the caching fields.

reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/admin/forms.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/admin/forms.py
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.0.x (af74865)
Loading...