Skip to content

Commit

Permalink
Tests: set browser.handleErrors to False.
Browse files Browse the repository at this point in the history
That way we get a proper traceback, instead of a general internal server error.
  • Loading branch information
mauritsvanrees committed Jun 3, 2017
1 parent 06e68fd commit f2333cb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
3 changes: 2 additions & 1 deletion Products/PloneFormGen/tests/attachment.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ File attachments
>>> import cStringIO
>>> from plone.testing.z2 import Browser
>>> browser = Browser(app)
>>> browser.handleErrors = False

Login to the portal:

Expand Down Expand Up @@ -93,4 +94,4 @@ the file field is not listed in the mailer's showFields::

>>> app._p_jar.sync()
>>> 'file contents' not in portal.MailHost.msg.get_payload(decode=True)
True
True
30 changes: 15 additions & 15 deletions Products/PloneFormGen/tests/browser.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Integration tests
>>> request = layer['request']
>>> from plone.testing.z2 import Browser
>>> browser = Browser(app)
>>> browser.handleErrors = False

Login to the portal:

Expand Down Expand Up @@ -150,41 +151,40 @@ Attempts to use clearSavedFormInput without auth should be forbidden::
>>> browser.open(portal_url + '/testform/saver/clearSavedFormInput')
Traceback (most recent call last):
...
HTTPError: HTTP Error 403: Forbidden

Forbidden: Form authenticator is invalid.

Attempts to use gpg_services TTW should be fruitless::

>>> browser.open(portal_url + '/testform/@@gpg_services/encrypt?data=XXX&recipient_key_id=yyy')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

Attempts to read the success action TTW should be fruitless::

>>> browser.open(portal_url + '/testform/fgGetSuccessAction')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

That should also be true for fields::

>>> browser.open(portal_url + '/testform/comments/fgGetSuccessAction')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

Attempts to set mailer body TTW should fail
>>> browser.open(portal_url + '/testform/mailer/setBody_pt?value=stuff')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

Attempts to read mailer body TTW should fail
>>> browser.open(portal_url + '/testform/mailer/body_pt')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

We want to test security on the custom script adapter. Let's add one::

Expand All @@ -201,48 +201,48 @@ Attempts to set script body TTW should fail::
>>> browser.open(portal_url + '/testform/test-script-adapter/updateScript?body=raise%2010&role=none')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

Attempts to run the script TTW should fail::

>>> browser.open(portal_url + '/testform/test-script-adapter/onSuccess?fields=')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

>>> browser.open(portal_url + '/testform/test-script-adapter/scriptBody?fields=')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

>>> browser.open(portal_url + '/testform/test-script-adapter/executeCustomScript?fields=&form=&req=')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

Attempts to use onSuccess TTW should fail::

>>> browser.open(portal_url + '/testform/saver/onSuccess?fields=&request=')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

Attempts to read our special member attributes TTW should fail::

>>> browser.open(portal_url + '/testform/memberId')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

>>> browser.open(portal_url + '/testform/memberFullName')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

>>> browser.open(portal_url + '/testform/memberEmail')
Traceback (most recent call last):
...
HTTPError: HTTP Error 404: Not Found
NotFound:...

Archetypes does not quote an input widget's description. That's fine for Archetypes,
where descriptions are set in code, but it's not OK when form help may be
Expand Down
7 changes: 4 additions & 3 deletions Products/PloneFormGen/tests/serverside_field.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Server-side only field
----------------------

Get our test browser::

>>> app = layer['app']
>>> portal = layer['portal']
>>> from Products.PloneFormGen.tests.pfgtc import MailHostMock
Expand All @@ -11,10 +11,11 @@ Get our test browser::
>>> request = layer['request']
>>> from plone.testing.z2 import Browser
>>> browser = Browser(app)
>>> browser.handleErrors = False

Add a new form folder and mark the subject input variable as a server side variable.
(It needs a non-empty default value because it's set as required.) ::

>>> from plone.app.testing import setRoles
>>> from plone.app.testing import login
>>> from plone.app.testing import TEST_USER_NAME
Expand All @@ -40,7 +41,7 @@ Login to the portal:
>>> browser.getControl(name='submit').click()

And confirm that the server-side field is absent from the rendered form::

>>> browser.open(portal_url + '/testform')
>>> 'id="archetypes-fieldname-topic"' in browser.contents
False
Expand Down
7 changes: 4 additions & 3 deletions Products/PloneFormGen/tests/ssl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ First let's get our test browser and make sure that it won't re-raise Redirect e
>>> request = layer['request']
>>> from plone.testing.z2 import Browser
>>> browser = Browser(app)
>>> browser.handleErrors = False
>>> from ZPublisher import HTTPResponse
>>> HTTPResponse.status_codes['redirect'] = 200

Expand All @@ -35,9 +36,9 @@ Set up a form with the 'force SSL' setting on::
>>> browser.open(portal_url)
>>> browser.getLink('Form Folder').click()
>>> browser.getControl('Title').value = 'testform'

>>> browser.getControl(name='forceSSL:boolean').value = '1'

>>> browser.getControl('Save').click()
>>> browser.url
'.../testform/...'
Expand All @@ -62,4 +63,4 @@ well (so the user sees a security icon in their browser.) ::
>>> browser.open(portal_url + '/testform')
>>> browser.headers['Bobo-Exception-Type'] in ('Redirect', "<class 'zExceptions.Redirect'>")
True

0 comments on commit f2333cb

Please sign in to comment.