Add a resource for retrieving info on the client's session.

Review Request #1632 — Created June 2, 2010 and submitted

Information

Review Board
master

Reviewers

Add a resource for retrieving info on the client's session.

This introduces a new /api/session/ resource, which returns some very
basic information on the client's session.

If the client is logged in, the 'authenticated' key will be set to True, and a
link to the logged in user will be returned.

If the client is not logged in, the 'authenticated' key will be set to False.

In the future, we may want to provide more information in this (such as API
rate limiting), but this is useful for now.
Added test cases. They passed. Also verified that the information is correct when logged in and out.

Since we handle expanded resources ourselves here, I also tested to make sure that ?expand=user works for this resource.
mike_conley
  1. Looks alright to me - though I have one failing test.  See below.
  2. reviewboard/webapi/tests.py (Diff revision 1)
     
     
    This test is failing for me:
    
    http://www.pastie.org/990789
    1. On your setup, is anonymous access enabled? If that's the difference, I'll have to poke at it to force that on for unit tests.
    2. Yes, anonymous access is enabled.
      
      Strangely, with my REST client, things work as expected - when logged out, I get the following back from a GET on /api/session/:
      
      {"stat": "ok", "session": {"authenticated": false}}
      
      I did a bit of debugging with the test, and this is the response it is getting:
      
      {"stat": "fail", "err": {"msg": "You are not logged in", "code": 103}}
      
      103 corresponds with the NOT_LOGGED_IN error from djblets/webapi/errors.py
      
      Not sure why there's a difference.  :/
    3. I'm not seeing any good reason for this... Hard to say right now. They're passing here. I'll commit and see if it passes the nightlies as well. If it does, then maybe there's something funky with its interaction with your setup.
  3. 
      
david
  1. 
      
  2.