def _get_userid_from_assertion(self, assertion): """Extract the userid from a BrowserID assertion.""" try: data = json.loads(urlb64decode(assertion)) except (ValueError, TypeError): return assertion else: payload = data["certificates"][0].split(".")[1] payload = json.loads(urlb64decode(payload)) return payload["principal"]["email"]
def test_decode(self): decode = json.loads(urlb64decode(assertion)) keys = decode.keys() keys.sort() self.assertEqual(keys, ['assertion', 'certificates'])