Skip to content

Commit

Permalink
Test error is triggerd when xform title matches a url
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Ekisa <[email protected]>
  • Loading branch information
ivermac committed Jan 29, 2021
1 parent 54e8490 commit e7c43c4
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions onadata/apps/api/tests/viewsets/test_xform_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2710,15 +2710,32 @@ def test_update_xform_using_put_with_invalid_input(self):
'public_data': False,
'project': 'http://testserver/api/v1/projects/{0}'.format(
self.xform.project.pk),
'title': 'Transport Form',
'title': 'http://api.kfc.burger-king.nandos.io',
'version': unsanitized_html_str
}

# trigger error is form version is invalid
with self.assertRaises(XLSFormError):
with self.assertRaises(XLSFormError) as err:
request = self.factory.put('/', data=put_data, **self.extra)
response = view(request, pk=form_id)

self.assertEqual(
"Invalid title value; shouldn't matches a url",
str(err.exception)
)

put_data['title'] = 'Transport Form'

# trigger error is form version is invalid
with self.assertRaises(XLSFormError) as err:
request = self.factory.put('/', data=put_data, **self.extra)
response = view(request, pk=form_id)

self.assertEqual(
"Version shouldn't have any invalid characters ('>' '&' '<')",
str(err.exception)
)

put_data['version'] = self.xform.version

request = self.factory.put('/', data=put_data, **self.extra)
Expand Down

0 comments on commit e7c43c4

Please sign in to comment.