Skip to content

Commit

Permalink
Fixed tests to work with merged plone.login
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Jun 15, 2018
1 parent 51a28e9 commit b67a3f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ New features:

Bug fixes:

- Fixed tests to work with merged plone.login
[jensens]

- Avoid CSRF warnings due to generating image scales
stored in a plone.scale.storage.ScalesDict.
[davisagli]
Expand Down
19 changes: 12 additions & 7 deletions plone/protect/tests/testAuto.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_does_not_add_csrf_protection_to_different_domain(self):
try:
form.getControl(name="_authenticator")
self.assertEqual('should not add authenticator', '')
except:
except Exception:
pass

def test_does_not_add_csrf_protection_to_different_domain_scheme_relative(
Expand All @@ -57,7 +57,7 @@ def test_does_not_add_csrf_protection_to_different_domain_scheme_relative(
try:
form.getControl(name="_authenticator")
self.assertEqual('should not add authenticator', '')
except:
except Exception:
pass

def test_authentication_works_automatically(self):
Expand Down Expand Up @@ -97,8 +97,9 @@ def setUp(self):
self.browser.open(self.portal.absolute_url() + '/login_form')
self.browser.getControl(name='__ac_name').value = TEST_USER_NAME
self.browser.getControl(
name='__ac_password').value = TEST_USER_PASSWORD
self.browser.getControl(name='submit').click()
name='__ac_password'
).value = TEST_USER_PASSWORD
self.browser.getControl('Log in').click()

def open(self, path):
self.browser.open(self.portal.absolute_url() + '/' + path)
Expand Down Expand Up @@ -131,7 +132,9 @@ def setUp(self):
self.browser = Browser(self.layer['app'])
self.request = self.layer['request']
self.browser.addHeader(
'Authorization', 'Basic %s:%s' % (SITE_OWNER_NAME, SITE_OWNER_PASSWORD,))
'Authorization',
'Basic %s:%s' % (SITE_OWNER_NAME, SITE_OWNER_PASSWORD,)
)

def open(self, path):
self.browser.open(self.portal.aq_parent.absolute_url() + '/' + path)
Expand All @@ -158,7 +161,7 @@ def test_keyrings_get_rotated_on_login(self):
self.browser.getControl(name='__ac_name').value = TEST_USER_NAME
self.browser.getControl(
name='__ac_password').value = TEST_USER_PASSWORD
self.browser.getControl(name='submit').click()
self.browser.getControl('Log in').click()

self.assertNotEqual(keys, ring.data)
self.assertNotEqual(ring.last_rotation, 0)
Expand All @@ -183,6 +186,7 @@ def test_safe_write_empty_returns_true(self):
transform._registered_objects = lambda: [self.portal]
self.assertTrue(transform._check())


class TestAutoTransform(unittest.TestCase):
layer = PROTECT_FUNCTIONAL_TESTING

Expand All @@ -202,6 +206,7 @@ def test_empty_no_error(self):
def test_html(self):
transform = ProtectTransform(self.portal, self.request)
result = transform.transform([(
'<html>\n<body><form action="http://nohost/myaction" method="POST">'
'<html>\n<body>'
'<form action="http://nohost/myaction" method="POST">'
'</form></body>\n</html>')], 'utf-8')
self.failUnless('_authenticator' in result.serialize())

0 comments on commit b67a3f0

Please sign in to comment.