Skip to content
This repository has been archived by the owner on Mar 20, 2019. It is now read-only.

Commit

Permalink
Fixed failing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Mar 11, 2015
1 parent 9c0c293 commit 87eff1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 6 additions & 3 deletions test/test_client_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ def test_login_logout():


def test_header_authentication():
app.post(
json_session_id = app.post(
'/login',
{'username': 'user1', 'password': 'pass1'}
)
).json.get('session')

session_id = app.cookies[SESSION_COOKIE]
#Clear the cookie
# Clear the cookie
app.reset()
app.get('/status', status=400)

# Make sure cookie matches json body
assert session_id == json_session_id

headers = {SESSION_HEADER: session_id}

username = app.get('/status', headers=headers).json['username']
Expand Down
9 changes: 8 additions & 1 deletion yubiauth/client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,14 @@ def new_func(self, request, *args, **kwargs):


def get_session_cookie(request):
cookie = request.environ['beaker.session']._headers['cookie_out']
log.info('beaker.session: %r', request.environ['beaker.session']._headers)
headers = request.environ['beaker.session']._headers
if SESSION_COOKIE in (headers.get('cookie_set') or ''):
cookie = headers['cookie_set']
elif SESSION_COOKIE in (headers.get('cookie') or ''):
cookie = headers['cookie']
else:
return None
return cookie.split('=', 1)[1].split(';', 1)[0]


Expand Down

0 comments on commit 87eff1f

Please sign in to comment.