Commit 3e1942a3 authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Kazuhiko Shiozaki

erp5_oauth_google_login: Extend test for consider configured or not connectors

   On login pages
parent 55988caf
...@@ -60,13 +60,16 @@ class GoogleLoginTestCase(ERP5TypeTestCase): ...@@ -60,13 +60,16 @@ class GoogleLoginTestCase(ERP5TypeTestCase):
).validate() ).validate()
self.default_user_person.newContent(portal_type='Assignment').open() self.default_user_person.newContent(portal_type='Assignment').open()
if getattr(self.portal.portal_oauth, self.dummy_connector_id, None) is None: connector = getattr(self.portal.portal_oauth, self.dummy_connector_id, None)
if connector is None:
connector = self.portal.portal_oauth.newContent( connector = self.portal.portal_oauth.newContent(
id=self.dummy_connector_id, id=self.dummy_connector_id,
portal_type="Google Connector", portal_type="Google Connector",
reference="default", reference="default",
client_id=self.client_id, client_id=self.client_id,
secret_key=self.secret_key) secret_key=self.secret_key)
if connector.getValidationState() != "validated":
connector.validate() connector.validate()
self.tic() self.tic()
...@@ -416,6 +419,22 @@ class TestERP5JSGoogleLogin(GoogleLoginTestCase): ...@@ -416,6 +419,22 @@ class TestERP5JSGoogleLogin(GoogleLoginTestCase):
self.assertEqual(resp.getStatus(), six.moves.http_client.FOUND) self.assertEqual(resp.getStatus(), six.moves.http_client.FOUND)
self.assertIn('google.com', resp.getHeader('Location')) self.assertIn('google.com', resp.getHeader('Location'))
def test_login_form_not_configured(self):
connector = getattr(self.portal.portal_oauth, self.dummy_connector_id, None)
if connector is not None:
if connector.getValidationState() == "validated":
connector.invalidate()
self.tic()
resp = self.publish(self._getWebSite().getPath() + '/login_form')
tree = lxml.etree.fromstring(resp.getBody(), parser=lxml.etree.HTMLParser())
self.assertEqual([], [
img.getparent().attrib['href']
for img in tree.findall('.//a/img')
if img.attrib['alt'] == 'Sign in with Google'
])
def test_logout(self): def test_logout(self):
resp = self.publish(self._getWebSite().getPath() + '/WebSite_logout') resp = self.publish(self._getWebSite().getPath() + '/WebSite_logout')
self.assertEqual(resp.getCookie("__ac_google_hash")['value'], 'deleted') self.assertEqual(resp.getCookie("__ac_google_hash")['value'], 'deleted')
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