Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Adds tests and renames provider
  • Loading branch information
rmauge committed Mar 8, 2014
commit 5c1c25de7cfa75554a90d8d005449a7bb9653529
7 changes: 7 additions & 0 deletions tests/selenium/testapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ def main(global_conf, **settings):
settings['velruse.linkedin.consumer_key'],
settings['velruse.linkedin.consumer_secret'],
)

if 'linkedin_oauth2' in providers:
config.include('velruse.providers.linkedin_oauth2')
config.add_linkedin_oauth2_login(
settings['velruse.linkedin.consumer_key'],
settings['velruse.linkedin.consumer_secret'],
)

config.scan(__name__)
return config.make_wsgi_app()
1 change: 1 addition & 0 deletions tests/selenium/testapp/templates/login.mako
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ${form('google_hybrid', 'Login with Google OpenID+OAuth',
openid_identifier='google.com')}
${form('google_oauth2', 'Login with Google OAuth2')}
${form('linkedin', 'Login with Linkedin')}
${form('linkedin_oauth2', 'Login with Linkedin OAuth2')}
${form('live', 'Login with Windows Live')}
${form('openid', 'Login with OpenID',
openid_identifier='myopenid.com')}
Expand Down
33 changes: 33 additions & 0 deletions tests/selenium/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,3 +492,36 @@ def test_it(self):
creds = result['credentials']
self.assertTrue('oauthAccessToken' in creds)
self.assertTrue('oauthAccessTokenSecret' in creds)

class TestLinkedinOAuth2(ProviderTests, unittest.TestCase):

@classmethod
def setUpClass(cls):
cls.require_provider('linkedin_oauth2')
cls.login = config['linkedin_oauth2.login']
cls.password = config['linkedin_oauth2.password']
cls.login_url = find_login_url(config, 'linkedin_oauth2.login_url')

def test_it(self):
browser.get(self.login_url)
self.assertEqual(browser.title, 'Auth Page')
browser.find_element_by_id('linkedin_oauth2').submit()
self.assertEqual(browser.title, 'Authorize | LinkedIn')
form = browser.find_element_by_name('oauth2SAuthorizeForm')
login = form.find_element_by_id('session_key-oauth2SAuthorizeForm')
login.send_keys(self.login)
passwd = form.find_element_by_id('session_password-oauth2SAuthorizeForm')
passwd.send_keys(self.password)
form.find_element_by_name('authorize').submit()
result = WebDriverWait(browser, 2).until(
EC.presence_of_element_located((By.ID, 'result')))
self.assertEqual(browser.title, 'Result Page')
result = json.loads(result.text)
self.assertTrue('profile' in result)
self.assertTrue('credentials' in result)
profile = result['profile']
self.assertTrue('displayName' in profile)
self.assertTrue('accounts' in profile)
creds = result['credentials']
self.assertTrue('oauthAccessToken' in creds)
self.assertTrue('oauthExpiresIn' in creds)
2 changes: 1 addition & 1 deletion velruse/providers/linkedin_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def add_linkedin_login(config,
scope='',
login_path='/login/linkedin',
callback_path='/login/linkedin/callback',
name='linkedin'):
name='linkedin_oauth2'):
"""
Add a Linkedin login provider to the application supporting the new
OAuth2 protocol.
Expand Down