00001
00002 import unittest, sys, tests_good, tests_bad, time
00003 from ZSI import *
00004 try:
00005 import cStringIO as StringIO
00006 except ImportError:
00007 import StringIO
00008
00009
00010 """Bug [ 1520092 ] URI Bug: urllib.quote escaping reserved chars
00011
00012 From rfc2396:
00013
00014 "If the data for a URI component would conflict with the reserved
00015 purpose, then the conflicting data must be escaped before forming the
00016 URI."
00017
00018 reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
00019 "$" | ","
00020
00021
00022
00023 This implies that if ":" is used for a reserved purpose,
00024
00025 if scheme is defined then
00026 append scheme to result
00027 append ":" to result
00028
00029 , then it should not be escaped.
00030 """
00031
00032
00033 class TestCase(unittest.TestCase):
00034 def check_uri_quoting(self):
00035 """ all reserved characters used for reserved purpose.
00036 """
00037 sw1 = SoapWriter(envelope=False)
00038 tc1= TC.URI('sourceforge')
00039 orig = 'https://sourceforge.net/tracker/index.php?func=detail&aid=1520092&group_id=26590&atid=387667'
00040 sw1.serialize(orig, typecode=tc1, typed=False)
00041 s1 = str(sw1)
00042
00043 sw2 = SoapWriter(envelope=False)
00044 tc2= TC.String('sourceforge')
00045 sw2.serialize(orig, typecode=tc2, typed=False)
00046 s2 = str(sw2)
00047
00048 print s1
00049 print s2
00050 self.failUnless(s1 == s2,
00051 'reserved characters used for reserved purpose should not be escaped.')
00052
00053 ps = ParsedSoap(s2, envelope=False)
00054 pyobj = ps.Parse(tc2)
00055
00056 self.failUnless(pyobj == orig, 'parsed object should be equivalent to original')
00057
00058
00059
00060
00061
00062
00063 _SEP = '_'
00064 for t in [i[0].split(_SEP) for i in filter(lambda i: callable(i[1]), TestCase.__dict__.items())]:
00065 test = ''
00066 for f in t:
00067 test += f
00068 if globals().has_key(test): test += _SEP; continue
00069 def _closure():
00070 name = test
00071 def _makeTestSuite():
00072 suite = unittest.TestSuite()
00073 suite.addTest(unittest.makeSuite(TestCase, name))
00074 return suite
00075 return _makeTestSuite
00076
00077 globals()[test] = _closure()
00078 test += _SEP
00079
00080
00081 makeTestSuite = check
00082 def main():
00083 unittest.main(defaultTest="makeTestSuite")
00084 if __name__ == "__main__" : main()
00085
00086