[OAuth2Provider] Add webAPI end point for user to remove OAuth2 token from My Account page

Review Request #7964 — Created Feb. 15, 2016 and discarded

Information

Review Board
master

Reviewers

A new webAPI end point is added for user to GET and DELETE a OAuth2 token given
OAuth2 token ID. The webAPI is meant to be called from My Account for user to
remove a OAuth2 token.

Command run: python ./tests/runtests.py reviewboard.webapi.tests.test_oauth2_token

Test GET for list of OAuth2 token
Test GET and DELETE for OAuth2 token

This a copy from test_api_token

Description From Last Updated

'json' imported but unused

reviewbotreviewbot

'ValidationError' imported but unused

reviewbotreviewbot

'ObjectDoesNotExist' imported but unused

reviewbotreviewbot

'_' imported but unused

reviewbotreviewbot

'webapi_response_errors' imported but unused

reviewbotreviewbot

'webapi_request_fields' imported but unused

reviewbotreviewbot

'webapi_login_required' imported but unused

reviewbotreviewbot

'NOT_LOGGED_IN' imported but unused

reviewbotreviewbot

'DOES_NOT_EXIST' imported but unused

reviewbotreviewbot

'PERMISSION_DENIED' imported but unused

reviewbotreviewbot

'INVALID_FORM_DATA' imported but unused

reviewbotreviewbot

'resources' imported but unused

reviewbotreviewbot

'Application' imported but unused

reviewbotreviewbot

'oauth2_token_item_mimetype' imported but unused

reviewbotreviewbot

Col: 1 E302 expected 2 blank lines, found 1

reviewbotreviewbot

oauth2_provider is an outside module, so should belong in the same import group, in alphabetical order.

chipx86chipx86

Same import group.

chipx86chipx86

This seems to be missing a _get_queryset. It'd need one in order to limit results to the user, and to …

chipx86chipx86

Blank line between these.

chipx86chipx86

This is an outside module, so it should be part of the next import group.

chipx86chipx86

Make sure things are in alphabetical order.

chipx86chipx86

No need for parens.

chipx86chipx86

Indented too far.

chipx86chipx86

We don't put one argument per line. Ends up being pretty long this way. Same below.

chipx86chipx86

Same line, no trailing comma, since this is a function call.

chipx86chipx86

Blank line between these.

chipx86chipx86

Same line, no comma.

chipx86chipx86

Blank line between these. Same below.

chipx86chipx86

Col: 18 E711 comparison to None should be 'if cond is None:'

reviewbotreviewbot

Col: 20 E711 comparison to None should be 'if cond is None:'

reviewbotreviewbot

Col: 24 E711 comparison to None should be 'if cond is None:'

reviewbotreviewbot

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

reviewbotreviewbot

Col: 18 E711 comparison to None should be 'if cond is None:'

reviewbotreviewbot

Col: 20 E711 comparison to None should be 'if cond is None:'

reviewbotreviewbot

Col: 24 E711 comparison to None should be 'if cond is None:'

reviewbotreviewbot

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

reviewbotreviewbot
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/resources/user.py
        reviewboard/webapi/resources/__init__.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/resources/user.py
        reviewboard/webapi/resources/__init__.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
  2. Show all issues
     'json' imported but unused
    
  3. Show all issues
     'ValidationError' imported but unused
    
  4. Show all issues
     'ObjectDoesNotExist' imported but unused
    
  5. Show all issues
     '_' imported but unused
    
  6. Show all issues
     'webapi_response_errors' imported but unused
    
  7. Show all issues
     'webapi_request_fields' imported but unused
    
  8. Show all issues
     'webapi_login_required' imported but unused
    
  9. Show all issues
     'NOT_LOGGED_IN' imported but unused
    
  10. Show all issues
     'DOES_NOT_EXIST' imported but unused
    
  11. Show all issues
     'PERMISSION_DENIED' imported but unused
    
  12. Show all issues
     'INVALID_FORM_DATA' imported but unused
    
  13. Show all issues
     'resources' imported but unused
    
  14. 
      
LE
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/__init__.py
        reviewboard/webapi/tests/test_oauth2_token.py
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/tests/urls.py
        reviewboard/webapi/tests/mimetypes.py
        reviewboard/webapi/resources/user.py
    
    Ignored Files:
        reviewboard/static/rb/js/accountPrefsPage/views/oauth2TokensView.js
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
    
    Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/__init__.py
        reviewboard/webapi/tests/test_oauth2_token.py
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/tests/urls.py
        reviewboard/webapi/tests/mimetypes.py
        reviewboard/webapi/resources/user.py
    
    Ignored Files:
        reviewboard/static/rb/js/accountPrefsPage/views/oauth2TokensView.js
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
  2. Show all issues
     'Application' imported but unused
    
  3. Show all issues
     'oauth2_token_item_mimetype' imported but unused
    
  4. reviewboard/webapi/tests/urls.py (Diff revision 2)
     
     
    Show all issues
    Col: 1
     E302 expected 2 blank lines, found 1
    
  5. 
      
LE
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/__init__.py
        reviewboard/webapi/tests/test_oauth2_token.py
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/tests/urls.py
        reviewboard/webapi/tests/mimetypes.py
        reviewboard/webapi/resources/user.py
    
    Ignored Files:
        reviewboard/static/rb/js/accountPrefsPage/views/oauth2TokensView.js
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/__init__.py
        reviewboard/webapi/tests/test_oauth2_token.py
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/tests/urls.py
        reviewboard/webapi/tests/mimetypes.py
        reviewboard/webapi/resources/user.py
    
    Ignored Files:
        reviewboard/static/rb/js/accountPrefsPage/views/oauth2TokensView.js
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
  2. 
      
chipx86
  1. The first couple of files just remove stuff from prior changes. Instead, you should update the prior changes to remove the code there, so that each change is a cohesive unit.

  2. reviewboard/webapi/resources/__init__.py (Diff revision 3)
     
     
     
     
    Show all issues

    oauth2_provider is an outside module, so should belong in the same import group, in alphabetical order.

  3. reviewboard/webapi/resources/oauth2_token.py (Diff revision 3)
     
     
     
     
    Show all issues

    Same import group.

  4. Show all issues

    This seems to be missing a _get_queryset. It'd need one in order to limit results to the user, and to do permission checking, like other resources that are children of the user resource.

    1. Do we have a test for this? I dont it see anywhere.

  5. Show all issues

    Blank line between these.

  6. Show all issues

    This is an outside module, so it should be part of the next import group.

  7. reviewboard/webapi/tests/test_oauth2_token.py (Diff revision 3)
     
     
     
     
     
     
     
     
     
    Show all issues

    Make sure things are in alphabetical order.

  8. Show all issues

    No need for parens.

    1. parens as () not a typo for parents

  9. reviewboard/webapi/tests/test_oauth2_token.py (Diff revision 3)
     
     
     
     
    Show all issues

    Indented too far.

  10. reviewboard/webapi/tests/test_oauth2_token.py (Diff revision 3)
     
     
     
     
     
     
     
    Show all issues

    We don't put one argument per line. Ends up being pretty long this way.

    Same below.

    1. Discussed on Slack.
      token=random().__str__(), expires=timezone.now(), will be change to None and push to the body.
      Since we have the docstring we will try as many on a line as possible

  11. Show all issues

    Same line, no trailing comma, since this is a function call.

  12. Show all issues

    Blank line between these.

  13. Show all issues

    Same line, no comma.

  14. Show all issues

    Blank line between these.

    Same below.

  15. 
      
LE
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/__init__.py
        reviewboard/webapi/tests/test_oauth2_token.py
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/tests/urls.py
        reviewboard/webapi/tests/mimetypes.py
        reviewboard/webapi/resources/user.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
    
    Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/__init__.py
        reviewboard/webapi/tests/test_oauth2_token.py
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/tests/urls.py
        reviewboard/webapi/tests/mimetypes.py
        reviewboard/webapi/resources/user.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
  2. Show all issues
    Col: 18
     E711 comparison to None should be 'if cond is None:'
    
  3. Show all issues
    Col: 20
     E711 comparison to None should be 'if cond is None:'
    
  4. Show all issues
    Col: 24
     E711 comparison to None should be 'if cond is None:'
    
  5. Show all issues
    Col: 49
     E128 continuation line under-indented for visual indent
    
  6. 
      
LE
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/__init__.py
        reviewboard/webapi/tests/test_oauth2_token.py
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/tests/urls.py
        reviewboard/webapi/tests/mimetypes.py
        reviewboard/webapi/resources/user.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/__init__.py
        reviewboard/webapi/tests/test_oauth2_token.py
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/tests/urls.py
        reviewboard/webapi/tests/mimetypes.py
        reviewboard/webapi/resources/user.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
  2. Show all issues
    Col: 18
     E711 comparison to None should be 'if cond is None:'
    
  3. Show all issues
    Col: 20
     E711 comparison to None should be 'if cond is None:'
    
  4. Show all issues
    Col: 24
     E711 comparison to None should be 'if cond is None:'
    
  5. Show all issues
    Col: 49
     E128 continuation line under-indented for visual indent
    
  6. 
      
LE
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/webapi/resources/__init__.py
        reviewboard/webapi/tests/test_oauth2_token.py
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/tests/urls.py
        reviewboard/webapi/tests/mimetypes.py
        reviewboard/webapi/resources/user.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
    
    Tool: Pyflakes
    Processed Files:
        reviewboard/webapi/resources/__init__.py
        reviewboard/webapi/tests/test_oauth2_token.py
        reviewboard/webapi/resources/oauth2_token.py
        reviewboard/webapi/tests/urls.py
        reviewboard/webapi/tests/mimetypes.py
        reviewboard/webapi/resources/user.py
    
    Ignored Files:
        reviewboard/static/rb/js/resources/models/oauth2TokenModel.js
    
    
  2. 
      
brennie
Review request changed
Status:
Discarded