Commit 60d8fb7d authored by Jérome Perrin's avatar Jérome Perrin

tests: use urlparse to check URL redirect

this does not depend on the details of the URL
parent 450daca3
......@@ -19,6 +19,8 @@
#
##############################################################################
import six
import six.moves.urllib.parse
from erp5.component.test.testSlapOSCloudSecurityGroup import TestSlapOSSecurityMixin
from erp5.component.test.SlapOSTestCaseMixin import changeSkin
import re
......@@ -65,7 +67,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
email = '%s@example.com' % reference
request = self.web_site.hateoas.connection.WebSection_newCredentialRequest(
redirect_url = self.web_site.hateoas.connection.WebSection_newCredentialRequest(
reference=reference,
default_email_text=email,
first_name="Joe",
......@@ -77,9 +79,12 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
default_address_street_address="Av Pelinca",
default_address_zip_code="28480",
)
self.assertIn('Thank you for your registration. You will receive an email to activate your account.', request)
parsed_url = six.moves.urllib.parse.urlparse(redirect_url)
self.assertEqual(parsed_url.path.split('/')[-1], 'login_form')
self.assertEqual(
sorted(six.iteritems(dict(six.moves.urllib.parse.parse_qsl(parsed_url.query)))), [
('portal_status_message', 'Thank you for your registration. You will receive an email to activate your account.'),
])
self.tic()
to_click_message = findMessage(email, 'You have requested one user')
......
......@@ -18,6 +18,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
import six
import six.moves.urllib.parse
from erp5.component.test.SlapOSTestCaseMixin import \
SlapOSTestCaseMixinWithAbort, simulate
from zExceptions import Unauthorized
......@@ -310,13 +314,19 @@ class Test0SubscriptionRequestModule_requestSubscriptionProxy(TestSubscriptionSk
self.tic()
module = self.portal.web_site_module.hostingjs.subscription_request_module
response = module.SubscriptionRequestModule_requestSubscriptionProxy(
redirect_url = module.SubscriptionRequestModule_requestSubscriptionProxy(
email=email, subscription_reference=subscription_reference,
confirmation_required=True, user_input_dict=user_input_dict)
self.assertTrue(
response.endswith(
"order_confirmation?field_your_reservation_name=Member Template&field_your_reservation_email=%s&field_your_reservation_number_of_machines=1&field_your_reservation_network=test_subscription_reference" % email), response)
parsed_url = six.moves.urllib.parse.urlparse(redirect_url)
self.assertEqual(parsed_url.path.split('/')[-1], 'order_confirmation')
self.assertEqual(
sorted(six.iteritems(dict(six.moves.urllib.parse.parse_qsl(parsed_url.query)))), [
('field_your_reservation_email', email),
('field_your_reservation_name', 'Member Template'),
('field_your_reservation_network', 'test_subscription_reference'),
('field_your_reservation_number_of_machines', '1'),
])
# Missing tests XXXX
class TestSubscriptionRequest_applyCondition(TestSubscriptionSkinsMixin):
......
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