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

Commit

Permalink
BrowserID.persona_test_user() with unit tests
Browse files Browse the repository at this point in the history
this has not been plumbed into any actual tests yet
  • Loading branch information
klrmn committed Aug 31, 2012
1 parent ef749e8 commit 579f331
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 0 deletions.
46 changes: 46 additions & 0 deletions automation-tests/browserid/browser_id.py
Expand Up @@ -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


Expand All @@ -23,3 +26,46 @@ def sign_in(self, email, password):
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
77 changes: 77 additions & 0 deletions automation-tests/browserid/check_browser_id.py
@@ -0,0 +1,77 @@
#!/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 comments on commit 579f331

Please sign in to comment.