Commit 7f25c0eb authored by Jérome Perrin's avatar Jérome Perrin Committed by Rafael Monnerat

tests: use urlparse to check URL redirect

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