Add error handling for when LDAP "Full Name Attribute" has no white space.

Review Request #9211 — Created Sept. 23, 2017 and submitted

Information

Review Board
release-2.5.x
3096001...

Reviewers

When setting up LDAP authentication, an uncaught exception may be thrown
when splitting the full name into first name and last name. This happens
when the full name contains no space.

If this exception occurs it will now assign the full name to the first
name, and make the last name an empty string.
Because there was a comment just above my changes explaining how full
name is split between first and last name, I added to it to explain what
happens to first and last name in this situation.

I was not able to properly reproduce and test this manually because I
could not get a LDAP server up and running.

I have written a unit test that provides the modified function,
get_or_create_user(), with a user that has a full name containing no
spaces and verifies that the first and last name are assigned as
expected.
This test passes with this fix, and fails on 2.5.x without the fix.

Description From Last Updated

The description looks great, though it needs to wrap to 70-75 characters. I do want to see some testing in …

chipx86chipx86

Blank line between these (any time you have a block-creating statement like try, if/else, etc. and another statement).

chipx86chipx86

W293 blank line contains whitespace

reviewbotreviewbot

Can we add a blank line (with just a #) between these to separate the paragraphs?

daviddavid

Should end in a period.

daviddavid
chipx86
  1. 
      
  2. Show all issues

    The description looks great, though it needs to wrap to 70-75 characters.

    I do want to see some testing in here, though. I understand the issue with setting up an LDAP server (no fun), but we do have infrastructure for simulating LDAP connections in our unit tests, so you should at least have a unit test for this (one that fails prior to your fix and succeeds after).

  3. reviewboard/accounts/backends.py (Diff revision 1)
     
     
     
    Show all issues

    Blank line between these (any time you have a block-creating statement like try, if/else, etc. and another statement).

  4. 
      
RC
Review request changed
Summary:
Add error handling for exception thrown when LDAP "Full Name Attribute" has no white space.
Add error handling for when LDAP "Full Name Attribute" has no white space.
Description:
~  

When setting up LDAP authentication, an uncaught exception may be thrown when splitting the full name into first name and last name. This happens when the full name contains no space.

  ~

When setting up LDAP authentication, an uncaught exception may be thrown when

  + splitting the full name into first name and last name. This happens when the
  + full name contains no space.

   
~  

If this exception occurs it will now assign the full name to the first name, and make the last name an empty string.

  ~

If this exception occurs it will now assign the full name to the first name,

  + and make the last name an empty string.
  + Because there was a comment just above my changes explaining how full name
  + is split between first and last name, I added to it to explain what happens
  + to first and last name in this situation.

Testing Done:
~  

Unfortunately this has not been tested. I was told to skip setting up a LDAP server, which is needed to properly reproduce the bug and test this fix, because my efforts to get one working properly were unsuccessful.

~   The only "testing" that was done was to create a new file with the same situation of using str.split(' ',1) on a string containing no space, finding out the exact error, and catching it.

  ~

I was not able to properly reproduce and test this manually because I could

  ~ not get a LDAP server up and running.

  +
  +

I plan on writing a unit test for this fix, but I'm still working on

  + figuring out how to do so.

Commit:
abc2eeb4f35f3bdc8dd6c710b5dc912688db8886
d114a8d0c35de59be3767e4d25c50c69723e5057

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

RC
RC
RC
david
  1. 
      
  2. reviewboard/accounts/backends.py (Diff revision 4)
     
     
     
    Show all issues

    Can we add a blank line (with just a #) between these to separate the paragraphs?

  3. reviewboard/accounts/backends.py (Diff revision 4)
     
     
    Show all issues

    Should end in a period.

  4. 
      
RC
brennie
  1. Ship It!
  2. 
      
david
  1. Ship It!
  2. 
      
RC
Review request changed
Status:
Completed
Change Summary:
Pushed to release-2.5.x (d7e9803)