Commit cbb00275 authored by Jérome Perrin's avatar Jérome Perrin

oauth_google_login: test integration with ERP5JS

parent 10a8aafd
......@@ -27,6 +27,9 @@
import uuid
import mock
import lxml
import urlparse
import httplib
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript
......@@ -89,8 +92,7 @@ def getUserEntry(access_token):
}
class TestGoogleLogin(ERP5TypeTestCase):
class GoogleLoginTestCase(ERP5TypeTestCase):
def afterSetUp(self):
"""
This is ran before anything, used to set the environment
......@@ -123,6 +125,8 @@ class TestGoogleLogin(ERP5TypeTestCase):
self.tic()
self.logout()
class TestGoogleLogin(GoogleLoginTestCase):
def test_redirect(self):
"""
Check URL generate to redirect to Google
......@@ -304,3 +308,26 @@ return credential_request
def test_logout(self):
resp = self.publish(self.portal.getId() + '/logout')
self.assertEqual(resp.getCookie("__ac_google_hash")['value'], 'deleted')
class TestERP5JSGoogleLogin(GoogleLoginTestCase):
def _getWebSite(self):
return self.portal.web_site_module.renderjs_runner
def test_login_form(self):
resp = self.publish(self._getWebSite().getPath() + '/login_form')
tree = lxml.etree.fromstring(resp.getBody(), parser=lxml.etree.HTMLParser())
google_login_link, = [
img.getparent().attrib['href']
for img in tree.findall('.//a/img')
if img.attrib['alt'] == 'Sign in with Google'
]
self.assertIn('/ERP5Site_redirectToGoogleLoginPage', google_login_link)
resp = self.publish(urlparse.urlparse(google_login_link).path)
# this request redirects to google
self.assertEqual(resp.getStatus(), httplib.FOUND)
self.assertIn('google.com', resp.getHeader('Location'))
def test_logout(self):
resp = self.publish(self._getWebSite().getPath() + '/WebSite_logout')
self.assertEqual(resp.getCookie("__ac_google_hash")['value'], 'deleted')
erp5_full_text_myisam_catalog
erp5_credential
\ No newline at end of file
erp5_credential
erp5_web_renderjs_ui
\ No newline at end of file
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