Skip to content
Snippets Groups Projects
Commit 579f3318 authored by Leah Klearman's avatar Leah Klearman
Browse files

BrowserID.persona_test_user() with unit tests

this has not been plumbed into any actual tests yet
parent ef749e89
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,9 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import urllib2
import json
import selenium
......@@ -23,3 +26,46 @@ class BrowserID(object):
from pages.sign_in import SignIn
sign_in = SignIn(self.selenium, timeout=self.timeout, expect='new')
sign_in.sign_in(email, password)
def persona_test_user(self, verified=True, env='prod'):
'''
Create a test user.
::Args::
- verified - boolean True/False should the user be verified
- env - string dev/stage/prod instance of persona.org used by
the system under test(default prod)
::Returns::
A dictionary that combines the values returned by the personatestuser API
and the values returned by browserid.mocks.MockUser.
{
'email': 'lopez401@personatestuser.org'
'primary_email': 'lopez401@personatestuser.org',
'pass': 'SOaUo9qJqYyBl1sN',
'password': 'SOaUo9qJqYyBl1sN',
'expires': '1346445745',
'verifier': 'https://verifier.dev.anosrep.org',
'browserid': 'https://login.dev.anosrep.org',
'token': 'U6bFrRZJrZggwkJ0gkpvC9tuNNaIXpvEZM11gzLnw9l4o4UK', # for verified=False only
'env': 'dev',
}
'''
command = ''
if verified:
command = 'email'
else:
command = 'unverified_email'
response = urllib2.urlopen(
'http://personatestuser.org/%s/%s' %
(command, env), timeout=self.timeout)
user = json.loads(response.read())
user['password'] = user['pass']
user['primary_email'] = user['email']
user.pop('events')
print user
return user
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import pytest
from browser_id import BrowserID
@pytest.mark.nondestructive
class TestBrowserID(object):
@pytest.mark.travis
@pytest.mark.skip_selenium
def test_persona_test_user_verified_prod(self, mozwebqa):
user = BrowserID(mozwebqa.selenium, mozwebqa.timeout).persona_test_user()
assert user['email']
assert user['password']
assert user['browserid'] == 'https://login.persona.org'
assert user['verifier'] == 'https://login.persona.org/verify'
assert not user.has_key('token')
@pytest.mark.travis
@pytest.mark.skip_selenium
def test_persona_test_user_verified_stage(self, mozwebqa):
user = BrowserID(mozwebqa.selenium, mozwebqa.timeout).persona_test_user(env='stage')
assert user['email']
assert user['password']
assert user['browserid'] == 'https://login.anosrep.org'
assert not user.has_key('token')
@pytest.mark.travis
@pytest.mark.skip_selenium
def test_persona_test_user_verified_dev(self, mozwebqa):
user = BrowserID(mozwebqa.selenium, mozwebqa.timeout).persona_test_user(env='dev')
assert user['email']
assert user['password']
assert user['browserid'] == 'https://login.dev.anosrep.org'
assert not user.has_key('token')
@pytest.mark.travis
@pytest.mark.skip_selenium
def test_persona_test_user_unverified_prod(self, mozwebqa):
user = BrowserID(mozwebqa.selenium, mozwebqa.timeout).persona_test_user(verified=False)
assert user['email']
assert user['password']
assert user['browserid'] == 'https://login.persona.org'
assert user['verifier'] == 'https://login.persona.org/verify'
assert user.has_key('token')
@pytest.mark.travis
@pytest.mark.skip_selenium
def test_persona_test_user_unverified_stage(self, mozwebqa):
user = BrowserID(mozwebqa.selenium, mozwebqa.timeout).persona_test_user(verified=False, env='stage')
assert user['email']
assert user['password']
assert user['browserid'] == 'https://login.anosrep.org'
assert user['verifier'] == 'https://login.anosrep.org/verify'
assert user.has_key('token')
@pytest.mark.travis
@pytest.mark.skip_selenium
def test_persona_test_user_unverified_dev(self, mozwebqa):
user = BrowserID(mozwebqa.selenium, mozwebqa.timeout).persona_test_user(verified=False, env='dev')
assert user['email']
assert user['password']
assert user['browserid'] == 'https://login.dev.anosrep.org'
assert user['verifier'] == 'https://verifier.dev.anosrep.org'
assert user.has_key('token')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment