Mercurial > p > roundup > code
comparison test/test_cgi.py @ 1684:b87c40d1b8fb
fix hackish message escaping [SF#757128]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 24 Jun 2003 03:30:40 +0000 |
| parents | 8a908bbad1ef |
| children | 5a04969176dc |
comparison
equal
deleted
inserted
replaced
| 1682:25350acdcb82 | 1684:b87c40d1b8fb |
|---|---|
| 6 # | 6 # |
| 7 # This module is distributed in the hope that it will be useful, | 7 # This module is distributed in the hope that it will be useful, |
| 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 10 # | 10 # |
| 11 # $Id: test_cgi.py,v 1.16 2003-05-09 01:47:50 richard Exp $ | 11 # $Id: test_cgi.py,v 1.17 2003-06-24 03:30:40 richard Exp $ |
| 12 | 12 |
| 13 import unittest, os, shutil, errno, sys, difflib, cgi, re | 13 import unittest, os, shutil, errno, sys, difflib, cgi, re |
| 14 | 14 |
| 15 from roundup.cgi import client | 15 from roundup.cgi import client |
| 16 from roundup import init, instance, password, hyperdb, date | 16 from roundup import init, instance, password, hyperdb, date |
| 34 return form | 34 return form |
| 35 | 35 |
| 36 class config: | 36 class config: |
| 37 TRACKER_NAME = 'testing testing' | 37 TRACKER_NAME = 'testing testing' |
| 38 TRACKER_WEB = 'http://testing.testing/' | 38 TRACKER_WEB = 'http://testing.testing/' |
| 39 | |
| 40 cm = client.clean_message | |
| 41 class MessageTestCase(unittest.TestCase): | |
| 42 def testCleanMessageOK(self): | |
| 43 self.assertEqual(cm('<br>x<br />'), '<br>x<br />') | |
| 44 self.assertEqual(cm('<i>x</i>'), '<i>x</i>') | |
| 45 self.assertEqual(cm('<b>x</b>'), '<b>x</b>') | |
| 46 self.assertEqual(cm('<a href="y">x</a>'), | |
| 47 '<a href="y">x</a>') | |
| 48 self.assertEqual(cm('<BR>x<BR />'), '<BR>x<BR />') | |
| 49 self.assertEqual(cm('<I>x</I>'), '<I>x</I>') | |
| 50 self.assertEqual(cm('<B>x</B>'), '<B>x</B>') | |
| 51 self.assertEqual(cm('<A HREF="y">x</A>'), | |
| 52 '<A HREF="y">x</A>') | |
| 53 | |
| 54 def testCleanMessageBAD(self): | |
| 55 self.assertEqual(cm('<script>x</script>'), | |
| 56 '<script>x</script>') | |
| 57 self.assertEqual(cm('<iframe>x</iframe>'), | |
| 58 '<iframe>x</iframe>') | |
| 39 | 59 |
| 40 class FormTestCase(unittest.TestCase): | 60 class FormTestCase(unittest.TestCase): |
| 41 def setUp(self): | 61 def setUp(self): |
| 42 self.dirname = '_test_cgi_form' | 62 self.dirname = '_test_cgi_form' |
| 43 try: | 63 try: |
| 500 ({('issue', None): {}, ('file', '-1'): {'content': 'foo', | 520 ({('issue', None): {}, ('file', '-1'): {'content': 'foo', |
| 501 'name': 'foo.txt', 'type': 'text/plain'}}, | 521 'name': 'foo.txt', 'type': 'text/plain'}}, |
| 502 [('issue', None, 'files', [('file', '-1')])])) | 522 [('issue', None, 'files', [('file', '-1')])])) |
| 503 | 523 |
| 504 def suite(): | 524 def suite(): |
| 505 l = [unittest.makeSuite(FormTestCase), | 525 l = [ |
| 526 unittest.makeSuite(FormTestCase), | |
| 527 unittest.makeSuite(MessageTestCase), | |
| 506 ] | 528 ] |
| 507 return unittest.TestSuite(l) | 529 return unittest.TestSuite(l) |
| 508 | 530 |
| 509 def run(): | 531 def run(): |
| 510 runner = unittest.TextTestRunner() | 532 runner = unittest.TextTestRunner() |
