Add unit tests for Djblets web API backend auth.

Review Request #8440 — Created Sept. 25, 2016 and submitted

stensby
Djblets
master
6542556...
djblets, students

Added unit tests for WebAPITokenAuthBackend and WebAPIBasicAuthBackend.

This patch is based on previous work by Minh Le Hoang at
https://reviews.reviewboard.org/r/7997/.

All tests pass.

Description From Last Updated

Your description is missing a period.

brenniebrennie

Please re-write your summary in the imperitive mood.

brenniebrennie

Please include in your summary: This patch is based on work by Minh Le Hong at (the URL)

brenniebrennie

local variable 'user' is assigned to but never used

reviewbotreviewbot

Col: 41 E126 continuation line over-indented for hanging indent

reviewbotreviewbot

local variable 'get_credentials_mock' is assigned to but never used

reviewbotreviewbot

local variable 'get_credentials_mock' is assigned to but never used

reviewbotreviewbot

Col: 53 E126 continuation line over-indented for hanging indent

reviewbotreviewbot

Col: 9 E265 block comment should start with '# '

reviewbotreviewbot

Col: 41 E126 continuation line over-indented for hanging indent

reviewbotreviewbot

Col: 41 E126 continuation line over-indented for hanging indent

reviewbotreviewbot

Col: 41 E126 continuation line over-indented for hanging indent

reviewbotreviewbot

You don't need the entire module path in here, you can just do: """Unit tests for the WebAPITokenBackend.""" For future ...

brenniebrennie

See previous comment about docstring formatting.

brenniebrennie

""" will fit on previous line.

brenniebrennie

See previous comment about docstring formatting

brenniebrennie

This attribution should be in the commit message, I believe. May want to ask Christian. Best to include the URL ...

brenniebrennie

Needs module-level docstring.

brenniebrennie

See comment re: formatting docstrings.

brenniebrennie

Col: 53 E126 continuation line over-indented for hanging indent

reviewbotreviewbot

See comment re: formatting docstrings.

brenniebrennie

See comment re: formatting docstrings.

brenniebrennie

See comment re: formatting docstrings.

brenniebrennie

See comment re: formatting docstrings.

brenniebrennie

Col: 41 E126 continuation line over-indented for hanging indent

reviewbotreviewbot

See comment re: formatting docstrings.

brenniebrennie

Col: 41 E126 continuation line over-indented for hanging indent

reviewbotreviewbot

See comment re: formatting docstrings.

brenniebrennie

Col: 41 E126 continuation line over-indented for hanging indent

reviewbotreviewbot

See comment re: formatting docstrings.

brenniebrennie

Col: 41 E126 continuation line over-indented for hanging indent

reviewbotreviewbot

See comment re: formatting docstrings.

brenniebrennie

Col: 13 E128 continuation line under-indented for visual indent

reviewbotreviewbot

See comment re: formatting docstrings.

brenniebrennie

Col: 13 E128 continuation line under-indented for visual indent

reviewbotreviewbot

Blank line between these.

brenniebrennie

Docstring (just needs to indicate that its a dummy model for tests.)

brenniebrennie

Likewise.

brenniebrennie

Blank line between these.

brenniebrennie

Single quotes.

brenniebrennie

Single quotes.

brenniebrennie

Single quotes.

brenniebrennie

Single quotes.

brenniebrennie

Single quotes.

brenniebrennie

Single quotes.

brenniebrennie

Blank line between these.

brenniebrennie

Unused method.

brenniebrennie

Since this is a private method for tests, lets call it _validate_credentials. Also, needs a docstring.

brenniebrennie

You can reflow this to fill more of the first line.

brenniebrennie

Single quotes.

brenniebrennie

This should be comparing against a constant.

brenniebrennie

No leading space. Missing a period.

brenniebrennie

Missing a period.

brenniebrennie

Missing super(...).tearDown()

brenniebrennie

You should just use the constant here.

brenniebrennie

Single quotes.

brenniebrennie

You want to use bytes(random()). We avoid str because in Python 2 str is a binary type and not a ...

brenniebrennie

bytes(random())

brenniebrennie

missing super(...).setUp()

brenniebrennie

Single quotes.

brenniebrennie

missing super(...).tearDown()

brenniebrennie

No leading or trailing spaces. Missing a period. Missing args, returns.

brenniebrennie

Use either: clean_credentials = \ self.basic_auth_backend.clean_credentials_for_display( credentials) or: clean_credentials = ( self.basic_auth_backend .clean_credentials_for_display( credentials ) )

brenniebrennie

You should inherit from SpyAgency e.g. class WebAPITokenAuthBackendTests(SpyAgency, TestModelsLoaderMixin, TestCase): # ... That way, you dont need self.agency, nor do ...

brenniebrennie

"succeeds"

brenniebrennie

Add a trailing , or move the ) onto this line.

brenniebrennie

Same here.

brenniebrennie

Since you're inheriting from SpyAgency, you don't need to unspy in tearDown -- it will happen automatically.

brenniebrennie

Can you rename this to TestWebAPITokenModel

brenniebrennie

TestTokenAuthBackend.

brenniebrennie

You will want to use assertIsNone(result). When comparing against None, you always want to use is or is not.

brenniebrennie

assertIsNone

brenniebrennie

You aren't using middleware or requestfactory in the testcases so why not: self.request = RequestFactory().get('/') SessionMiddleware().process_request(self.request)

brenniebrennie

Does the User need to exist in the database? If not we can just make User() object.

brenniebrennie

"web API" missing period.

brenniebrennie

Can you move this into test_get_credentials_missing_credentials? It is only used in that test.

brenniebrennie

Unnecessary.

brenniebrennie

Put the trailing space on the previous line, even if it means splitting the string earlier.

brenniebrennie

You can move this to a single line statement -- you won't need the comma in that case.

brenniebrennie

Is there any particular reason we are doing rand() here instead of just using a non-matching token

brenniebrennie

Is there any particular reason we are doing rand() here instead of just using a non-matching token

brenniebrennie

Missing period. web API

brenniebrennie

import foo statements go above from foo import bar statements.

brenniebrennie

Can you move this into test_get_credentials_malformed_credentials? It is only used in that test.

brenniebrennie

Unnecessary method. If this class doesn't implement tearDown, the superclass method will be invoked instead.

brenniebrennie

This sentence contains a comma splice. How about: """Fake version of validate credentials that always succeeds. This is used in ...

brenniebrennie

None. Only one space between sentences.

brenniebrennie

"request" Missing period.

brenniebrennie

"non-basic"

brenniebrennie

"with"

brenniebrennie

"with"

brenniebrennie

Missing trailing comma.

brenniebrennie

Missing trailing comma.

brenniebrennie

Missing trailing comma.

brenniebrennie

Missing trailing comma.

brenniebrennie

Missing trailing comma.

brenniebrennie

Missing trailing comma.

brenniebrennie

print() is not used.

brenniebrennie

Alphabetize.

brenniebrennie

Alphabetize imports.

brenniebrennie

Blank line between these.

brenniebrennie

Can you rearrange this so that things are defined just before they're tested? result = self.api_token_auth_backend.get_credentials(self.request) self.assertIsNone(result) warning_message = logging.warning.spy.last_call.args[0] ...

daviddavid

Please use single quotes around HTTP_AUTHORIZATION

daviddavid

username and password are only used the once, so we could bring them inline instead of creating variables: self.user = ...

daviddavid

Same comments about username/password.

daviddavid

print() is not used.

brenniebrennie

Alphabetize these.

brenniebrennie

Blank line between these.

brenniebrennie

can also include that function returns None in function doc string. I believe like Returns: None

LA larmiej

username and password are only used once, so we can simplify: encoded_credentials = 'testuser:testpassword'.encode('base64')

daviddavid

Same here.

daviddavid

Same here.

daviddavid

It's a little silly to define a credentials dict just to unpack it for kwargs. Let's change this to be: ...

daviddavid

Same here re: credentials.

daviddavid

Same here re: credentials

daviddavid

Same here re: credentials

daviddavid

Same here re: credentials

daviddavid

Same here re: credentials

daviddavid

No blank line here (django and kgb are both third-party libraries from the point of view of the djblets package).

daviddavid

Why is this 'invalidtoken123? This is a valid token, no? Kinda makes the test confusing when the invalidtoken is valid.

mike_conleymike_conley

Same as above.

mike_conleymike_conley

No blank line here.

daviddavid

So I believe you may be testing this wrongly after reading further into it. Firstly you are setting the user ...

brenniebrennie

I don't think "always succeeds" is true. Because this is returning None, it means we're falling back to the base ...

mike_conleymike_conley
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
    
    
  2.  local variable 'user' is assigned to but never used
    
  3. Col: 41
     E126 continuation line over-indented for hanging indent
    
  4.  local variable 'get_credentials_mock' is assigned to but never used
    
  5.  local variable 'get_credentials_mock' is assigned to but never used
    
  6. 
      
ST
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
    
    
  2. Col: 53
     E126 continuation line over-indented for hanging indent
    
  3. Col: 9
     E265 block comment should start with '# '
    
  4. Col: 41
     E126 continuation line over-indented for hanging indent
    
  5. Col: 41
     E126 continuation line over-indented for hanging indent
    
  6. Col: 41
     E126 continuation line over-indented for hanging indent
    
  7. 
      
ST
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
  2. Col: 53
     E126 continuation line over-indented for hanging indent
    
  3. Col: 41
     E126 continuation line over-indented for hanging indent
    
  4. Col: 41
     E126 continuation line over-indented for hanging indent
    
  5. Col: 41
     E126 continuation line over-indented for hanging indent
    
  6. Col: 41
     E126 continuation line over-indented for hanging indent
    
  7. Col: 13
     E128 continuation line under-indented for visual indent
    
  8. Col: 13
     E128 continuation line under-indented for visual indent
    
  9. 
      
ST
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
  2. 
      
brennie
  1. 
      
  2. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 3)
     
     
     
     

    You don't need the entire module path in here, you can just do:

    """Unit tests for the WebAPITokenBackend."""
    

    For future reference, docstrings should be of the form:

    """Single line sumnary
    
    Multi-line description.
    """
    

    (except for test_ method docstrings, of course).

    1. Sorry about that! I copied docstrings from Minh's RR.

  3. See previous comment about docstring formatting.

    1. For all of the test docstrings would you prefer the following format?

      """Testing Token Auth get_credentials with missing token."""
      
    2. Yes, with the exception that we don't include the trailing period because the test suite will add "..." in the output.

  4. """ will fit on previous line.

  5. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 3)
     
     
     
     

    See previous comment about docstring formatting

  6. This attribution should be in the commit message, I believe. May want to ask Christian. Best to include the URL instead of just the ID.

  7. Needs module-level docstring.

    1. What do you mean by module level docstring?

  8. See comment re: formatting docstrings.

  9. djblets/webapi/tests/test_basic_auth_backend.py (Diff revision 3)
     
     
     
     

    See comment re: formatting docstrings.

  10. See comment re: formatting docstrings.

  11. See comment re: formatting docstrings.

  12. See comment re: formatting docstrings.

  13. See comment re: formatting docstrings.

  14. See comment re: formatting docstrings.

  15. See comment re: formatting docstrings.

  16. See comment re: formatting docstrings.

  17. See comment re: formatting docstrings.

  18. 
      
ST
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
  2. 
      
ST
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
  2. 
      
brennie
  1. 
      
  2. Blank line between these.

  3. Docstring (just needs to indicate that its a dummy model for tests.)

  4. Blank line between these.

  5. Single quotes.

  6. Single quotes.

  7. Single quotes.

  8. Single quotes.

  9. Single quotes.

  10. Single quotes.

  11. Blank line between these.

  12. Unused method.

  13. Since this is a private method for tests, lets call it _validate_credentials.

    Also, needs a docstring.

  14. You can reflow this to fill more of the first line.

  15. djblets/webapi/tests/test_basic_auth_backend.py (Diff revision 6)
     
     
     
     
     

    Single quotes.

  16. djblets/webapi/tests/test_basic_auth_backend.py (Diff revision 6)
     
     
     
     

    This should be comparing against a constant.

    1. Do you mean I should use a single assert statement against the entire dictionary?

  17. 
      
ST
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
  2. 
      
brennie
  1. 
      
  2. Your description is missing a period.

  3. No leading space. Missing a period.

  4. Missing a period.

  5. Missing super(...).tearDown()

  6. You should just use the constant here.

  7. Single quotes.

  8. You want to use bytes(random()).

    We avoid str because in Python 2 str is a binary type and not a text type. It has been renamed to bytes in Python 3 and backported. The text type of Python 2 is unicode (which was renamed to str in Python 3). For actual string types, use six.text_type which converts to unicode in py2 and str in py3. For binary data (such as HTTP headers) use bytes. (There is also six.binary_type, but since we are Python 2.7 only we can use bytes instead.)

  9. bytes(random())

  10. missing super(...).setUp()

  11. Single quotes.

  12. missing super(...).tearDown()

  13. No leading or trailing spaces.
    Missing a period.
    Missing args, returns.

  14. Use either:

            clean_credentials = \
                self.basic_auth_backend.clean_credentials_for_display(
                    credentials)
    

    or:

            clean_credentials = (
                self.basic_auth_backend
                .clean_credentials_for_display(
                    credentials
                )
            )
    
  15. 
      
ST
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
  2. 
      
brennie
  1. 
      
  2. Please re-write your summary in the imperitive mood.

  3. You should inherit from SpyAgency e.g.

    class WebAPITokenAuthBackendTests(SpyAgency, TestModelsLoaderMixin, TestCase):
        # ...
    

    That way, you dont need self.agency, nor do you need your tearDown method -- SpyAgency.tearDown() (which will be called after each test) will unspy on all spies!

  4. Add a trailing , or move the ) onto this line.

  5. djblets/webapi/tests/test_basic_auth_backend.py (Diff revision 8)
     
     
     
     

    Since you're inheriting from SpyAgency, you don't need to unspy in tearDown -- it will happen automatically.

  6. 
      
ST
brennie
  1. 
      
  2. Can you rename this to TestWebAPITokenModel

  3. TestTokenAuthBackend.

  4. You will want to use assertIsNone(result). When comparing against None, you always want to use is or is not.

  5. assertIsNone

  6. djblets/webapi/tests/test_basic_auth_backend.py (Diff revision 9)
     
     
     
     
     
     

    You aren't using middleware or requestfactory in the testcases so why not:

    self.request = RequestFactory().get('/')
    SessionMiddleware().process_request(self.request)
    
  7. djblets/webapi/tests/test_basic_auth_backend.py (Diff revision 9)
     
     
     
     
     

    Does the User need to exist in the database? If not we can just make User() object.

    1. Two of the functions being tested end up doing a db query for that user to check credentials. Is it a problem that it creates a user? I was under the impression that a test database is created and then destroyed.

    2. No, its no problem. I was just curious.

  8. 
      
ST
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
  2. 
      
brennie
  1. 
      
  2. "web API"
    missing period.

  3. Can you move this into test_get_credentials_missing_credentials? It is only used in that test.

  4. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 10)
     
     
     

    Unnecessary.

  5. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 10)
     
     
     

    Put the trailing space on the previous line, even if it means splitting the string earlier.

  6. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 10)
     
     
     
     

    You can move this to a single line statement -- you won't need the comma in that case.

  7. Is there any particular reason we are doing rand() here instead of just using a non-matching token

  8. Is there any particular reason we are doing rand() here instead of just using a non-matching token

  9. Missing period.

    web API

  10. import foo statements go above from foo import bar statements.

  11. Can you move this into test_get_credentials_malformed_credentials? It is only used in that test.

  12. Unnecessary method. If this class doesn't implement tearDown, the superclass method will be invoked instead.

  13. This sentence contains a comma splice. How about:

    """Fake version of validate credentials that always succeeds.
    
    This is used in lieu of the actual method for testing purposes.
    
    ...
    """
    

    or similar.

  14. None.

    Only one space between sentences.

  15. "request"

    Missing period.

  16. Missing trailing comma.

  17. Missing trailing comma.

  18. Missing trailing comma.

  19. Missing trailing comma.

  20. Missing trailing comma.

  21. Missing trailing comma.

  22. 
      
ST
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
  2. 
      
ST
brennie
  1. 
      
  2. Please include in your summary:

    This patch is based on work by Minh Le Hong at (the URL)
    
  3. print() is not used.

  4. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 11)
     
     
     

    Alphabetize.

  5. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 11)
     
     
     

    Alphabetize imports.

  6. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 11)
     
     
     

    Blank line between these.

  7. print() is not used.

  8. Alphabetize these.

  9. Blank line between these.

  10. 
      
david
  1. 
      
  2. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 11)
     
     
     
     
     
     
     
     

    Can you rearrange this so that things are defined just before they're tested?

    result = self.api_token_auth_backend.get_credentials(self.request)
    self.assertIsNone(result)
    
    warning_message = logging.warning.spy.last_call.args[0]
    self.assertTrue(warning_message.startswith(
        ...)
    
  3. Please use single quotes around HTTP_AUTHORIZATION

  4. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 11)
     
     
     

    username and password are only used the once, so we could bring them inline instead of creating variables:

    self.user = User.objects.create_user(
        username='testuser', password='testuser_password')
    

    That said, I don't see anywhere that we actually care about the password being set, so we could leave that out entirely.

  5. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 11)
     
     
     

    Same comments about username/password.

  6. djblets/webapi/tests/test_basic_auth_backend.py (Diff revision 11)
     
     
     
     

    username and password are only used once, so we can simplify:

    encoded_credentials = 'testuser:testpassword'.encode('base64')
    
  7. djblets/webapi/tests/test_basic_auth_backend.py (Diff revision 11)
     
     
     
     

    Same here.

  8. djblets/webapi/tests/test_basic_auth_backend.py (Diff revision 11)
     
     
     
     

    Same here.

  9. It's a little silly to define a credentials dict just to unpack it for kwargs. Let's change this to be:

    result = self.basic_auth_backend.login_with_credentials(
        request, username=username, password=password)
    

    and kill the credentials definition.

  10. Same here re: credentials.

  11. Same here re: credentials

  12. Same here re: credentials

  13. Same here re: credentials

  14. Same here re: credentials

  15. 
      
ST
ST
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
  2. 
      
LA
  1. 
      
  2. can also include that function returns None in function doc string. I believe like
    Returns: None

    1. See: https://reviewboard.slack.com/archives/general/p1477019907002766

  3. 
      
mike_conley
  1. Thanks stensby - just a few questions. See below.

  2. Why is this 'invalidtoken123? This is a valid token, no? Kinda makes the test confusing when the invalidtoken is valid.

    1. What the token itself is doesn't really matter, it is named that to signify that it is not a token that has been handed to a user (so the token doesn't exist in our TestWebAPITokenModel). Any suggestions on what to rename it to so that is clear?

  3. Same as above.

  4. I don't think "always succeeds" is true. Because this is returning None, it means we're falling back to the base authentication mechanism. At least, that's what I understand from reading https://github.com/djblets/djblets/blob/c4fa360ad80e72bab4cca142e17a90ee9dbfb68a/djblets/webapi/auth/backends/base.py#L59

    1. The function is actually replacing a function that is used to 'short-circut' the authentication process if the current user is already logged in. See https://github.com/djblets/djblets/blob/c4fa360ad80e72bab4cca142e17a90ee9dbfb68a/djblets/webapi/auth/backends/base.py#L159

  5. 
      
david
  1. 
      
  2. djblets/webapi/tests/test_api_auth_backend.py (Diff revision 12)
     
     
     
     

    No blank line here (django and kgb are both third-party libraries from the point of view of the djblets package).

  3. djblets/webapi/tests/test_basic_auth_backend.py (Diff revision 12)
     
     
     
     

    No blank line here.

  4. 
      
ST
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
  2. 
      
brennie
  1. 
      
  2. djblets/webapi/tests/test_basic_auth_backend.py (Diff revision 12)
     
     
     
     
     
     
     

    So I believe you may be testing this wrongly after reading further into it.

    Firstly you are setting the user on the request AND short circuiting the validate_credentials method. We shouldn't have to do either of these things.

    Instead, you should create the user and store it as self.user and set self.request.user = AnonymousUser(). That way, the real validate_credentials will be called and return None.

  3. 
      
ST
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        djblets/webapi/tests/test_basic_auth_backend.py
        djblets/webapi/tests/test_api_auth_backend.py
    
    
  2. 
      
brennie
  1. Ship It!
  2. 
      
ST
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.9.x (9b44865)
Loading...