Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid token.xml template by adding closing slash to Pause tags #708

Merged
merged 2 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions tests/test_gateways.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest.mock import Mock, patch
from urllib.parse import urlencode
from xml.etree import ElementTree

from django.template.loader import render_to_string
from django.test import TestCase
Expand All @@ -17,7 +18,10 @@ def test_call_app(self):
self.maxDiff = None
url = reverse('two_factor_twilio:call_app', args=['123456'])
response = self.client.get(url)
self.assertEqual(response.content.decode('utf-8'), """<?xml version="1.0" encoding="UTF-8" ?>
content = response.content.decode('utf-8')
# raises an exception if invalid xml
ElementTree.fromstring(content)
self.assertEqual(content, """<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Gather timeout="15" numDigits="1" finishOnKey="">
<Say language="en">Hi, this is testserver calling. Press any key to continue.</Say>
Expand All @@ -27,36 +31,39 @@ def test_call_app(self):

url = reverse('two_factor_twilio:call_app', args=['123456'])
response = self.client.post(url)
self.assertEqual(response.content.decode('utf-8'), """<?xml version="1.0" encoding="UTF-8" ?>
content = response.content.decode('utf-8')
# raises an exception if invalid xml
ElementTree.fromstring(content)
self.assertEqual(content, """<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Say language="en">Your token is:</Say>
<Pause>
<Pause/>
<Say language="en">1</Say>
<Pause>
<Pause/>
<Say language="en">2</Say>
<Pause>
<Pause/>
<Say language="en">3</Say>
<Pause>
<Pause/>
<Say language="en">4</Say>
<Pause>
<Pause/>
<Say language="en">5</Say>
<Pause>
<Pause/>
<Say language="en">6</Say>
<Pause>
<Pause/>
<Say language="en">Repeat:</Say>
<Pause>
<Pause/>
<Say language="en">1</Say>
<Pause>
<Pause/>
<Say language="en">2</Say>
<Pause>
<Pause/>
<Say language="en">3</Say>
<Pause>
<Pause/>
<Say language="en">4</Say>
<Pause>
<Pause/>
<Say language="en">5</Say>
<Pause>
<Pause/>
<Say language="en">6</Say>
<Pause>
<Pause/>
<Say language="en">Good bye.</Say>
</Response>\n""")

Expand Down
8 changes: 4 additions & 4 deletions two_factor/templates/two_factor/twilio/token.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% load i18n %}<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Say language="{{ locale }}">{% trans "Your token is:" %}</Say>
<Pause>
<Pause/>
{% for digit in token %} <Say language="{{ locale }}">{{ digit }}</Say>
<Pause>
<Pause/>
{% endfor %} <Say language="{{ locale }}">{% trans "Repeat:" %}</Say>
<Pause>
<Pause/>
{% for digit in token %} <Say language="{{ locale }}">{{ digit }}</Say>
<Pause>
<Pause/>
{% endfor %} <Say language="{{ locale }}">{% trans "Good bye." %}</Say>
</Response>
Loading