Commit a00be4c3 by Eric Fischer

Fix broken auto_auth page

parent 6db440fc
"""
Auto-auth page (used to automatically log in during testing).
"""
import json
import os
import re
import urllib
......@@ -54,6 +54,8 @@ class AutoAuthPage(PageObject):
if roles is not None:
self._params['roles'] = roles
self.data = {}
@property
def url(self):
"""
......@@ -68,24 +70,17 @@ class AutoAuthPage(PageObject):
return url
def is_browser_on_page(self):
message = self.q(css='BODY').text[0]
match = re.search(r'Logged in user ([^$]+) with password ([^$]+) and user_id ([^$]+)$', message)
return True if match else False
self.data = json.loads(self.q(css='BODY').text[0])
return self.data['created_status'] == "Logged in"
def get_user_id(self):
"""
Finds and returns the user_id
"""
message = self.q(css='BODY').text[0].strip()
match = re.search(r' user_id ([^$]+)$', message)
return match.groups()[0] if match else None
return self.data['user_id']
def get_username_and_email(self):
"""
Finds and returns the username and email address of the current user.
"""
message = self.q(css='BODY').text[0].strip()
match = re.search(r'Logged in user (\S+) \((.*)\).*', message)
if not match:
return None
return match.group(1), match.group(2)
return self.data['username'], self.data['email']
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment