00001
00002 import unittest, sys, multifile, mimetools, base64
00003 from ZSI import *
00004 from ZSI import resolvers
00005 try:
00006 import cStringIO as StringIO
00007 except ImportError:
00008 import StringIO
00009
00010 class t6TestCase(unittest.TestCase):
00011 "Test case wrapper for old ZSI t6 test case"
00012
00013 def checkt6(self):
00014 try:
00015 istr = StringIO.StringIO(intext)
00016 m = mimetools.Message(istr)
00017 cid = resolvers.MIMEResolver(m['content-type'], istr)
00018 xml = cid.GetSOAPPart()
00019 ps = ParsedSoap(xml, resolver=cid.Resolve)
00020 except ParseException, e:
00021 print >>OUT, FaultFromZSIException(e).AsSOAP()
00022 self.fail()
00023 except Exception, e:
00024
00025 print >>OUT, FaultFromException(e, 1, sys.exc_info()[2]).AsSOAP()
00026 self.fail()
00027
00028 try:
00029 dict = ps.Parse(typecode)
00030 except Exception, e:
00031
00032 print >>OUT, FaultFromException(e, 0, sys.exc_info()[2]).AsSOAP()
00033 self.fail()
00034
00035 self.failUnlessEqual(dict['stringtest'], strExtTest,
00036 "Failed to extract stringtest correctly")
00037 print base64.encodestring(cid['partii@zolera.com'].read())
00038 v = dict['b64']
00039 print type(v), 'is type(v)'
00040 self.failUnlessEqual(cid['partii@zolera.com'].getvalue(), v,
00041 "mismatch")
00042 print base64.encodestring(v)
00043 from ZSI.wstools.c14n import Canonicalize
00044 z = dict['xmltest']
00045 print type(z), z
00046 print Canonicalize(z)
00047
00048 def makeTestSuite():
00049 suite = unittest.TestSuite()
00050 suite.addTest(unittest.makeSuite(t6TestCase, "check"))
00051 return suite
00052
00053 def main():
00054 unittest.main(defaultTest="makeTestSuite")
00055
00056 OUT = sys.stdout
00057 typecode = TC.Struct(None, [
00058 TC.String('b64'),
00059 TC.String('stringtest'),
00060 TC.XML('xmltest'),
00061 ])
00062
00063 intext='''Return-Path: <rsalz@zolera.com>
00064 Received: from zolera.com (os390.zolera.com [10.0.1.9])
00065 by zolera.com (8.11.0/8.11.0) with ESMTP id f57I2sf00832
00066 for <rsalz@zolera.com>; Thu, 7 Jun 2001 14:02:54 -0400
00067 Sender: rsalz@zolera.com
00068 Message-ID: <3B1FC1D1.FF6B21B4@zolera.com>
00069 Date: Thu, 07 Jun 2001 14:02:57 -0400
00070 From: Rich Salz <rsalz@zolera.com>
00071 X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0 i686)
00072 X-Accept-Language: en
00073 MIME-Version: 1.0
00074 To: rsalz@zolera.com
00075 Subject: mime with attachments
00076 Content-Type: multipart/mixed;
00077 boundary="------------68E4BAC5B266315E42428C64"
00078 Status: R
00079
00080 This is a multi-part message in MIME format.
00081 --------------68E4BAC5B266315E42428C64
00082 Content-Type: text/plain; charset=us-ascii
00083 Content-Transfer-Encoding: 7bit
00084
00085 <SOAP-ENV:Envelope
00086 xmlns="http://www.example.com/schemas/TEST"
00087 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
00088 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
00089 xmlns:ZSI="http://www.zolera.com/schemas/ZSI/">
00090 <SOAP-ENV:Body>
00091 <hreftest>
00092 <stringtest href="cid:part1@zolera.com"/>
00093 <b64 href="cid:partii@zolera.com"/>
00094 <xmltest href="cid:12@zolera.com"/>
00095 </hreftest>
00096 </SOAP-ENV:Body>
00097 </SOAP-ENV:Envelope>
00098 --------------68E4BAC5B266315E42428C64
00099 Content-Type: text/plain; charset=us-ascii;
00100 name="abs.txt"
00101 Content-Transfer-Encoding: 7bit
00102 Content-ID: <part1@zolera.com>
00103 Content-Disposition: inline;
00104 filename="abs.txt"
00105
00106
00107 Digitial Signatures in a Web Services World
00108
00109 An influential Forrestor report created the term inverted security: it's
00110 not about who you keep out, it's about who you let in. Customer portals,
00111 without a costly PKI deployment or application integration issues.
00112
00113 --------------68E4BAC5B266315E42428C64
00114 Content-Type: application/pdf;
00115 name="gmpharma.pdf"
00116 Content-Transfer-Encoding: base64
00117 Content-ID: <partii@zolera.com>
00118 Content-Disposition: inline;
00119 filename="gmpharma.pdf"
00120
00121 JVBERi0xLjINJeLjz9MNCjQzIDAgb2JqDTw8IA0vTGluZWFyaXplZCAxIA0vTyA0NSANL0gg
00122 WyAxMTQ0IDM5NiBdIA0vTCA2NjkwMiANL0UgMTAyODIgDS9OIDkgDS9UIDY1OTI0IA0+PiAN
00123 RB3nwVOQH9JpmFv6Ri2Zq7mlddSS2B5WcZwvAP+gy9QtuYlfqj1rsi9WqJOszzHXmXZ8fXxK
00124 XBBztIpgbkRrd+SGtY4QXo0fX0VN86uKXwtrkd7h1qiq2FUtXl6uNfnCoyX1Dve1O3RPRyhG
00125 sKn6fLMb+uSSIHPQkClRBwu5gechz/1PBUBSB34jXbPdMTIb+/wRP+pauSAhLBzFELDOgk5b
00126 PaIPAnIudFovQTc7Df2Ws9Atz4Bua+oINphIOojogG5LP3Tb3oNu8bsmuK+wFXEdbfgFIx+G
00127 gKULYx5A2WnaDXB5JeoRQg90S0HcX2dCPmRCqDXB/aX34KujsPwJ/UpRdxXPeAftDkQS6hag
00128 bh/yTOiUyqBz9CzxnyMYQGDO0jrUZ47kkWfmYvVg
00129 --------------68E4BAC5B266315E42428C64
00130 Content-ID: <12@zolera.com>
00131
00132 <foo xmlns="example.com" xmlns:Z="zolera">
00133 this is a foo
00134 <b xmlns:Z="zolera">redundnant ns decl</b>
00135 <b Z:x="this was first" Z:a="2nd-orig">b test</b>
00136 </foo>
00137
00138 --------------68E4BAC5B266315E42428C64--
00139 '''
00140
00141 strExtTest = '''
00142 Digitial Signatures in a Web Services World
00143
00144 An influential Forrestor report created the term inverted security: it's
00145 not about who you keep out, it's about who you let in. Customer portals,
00146 without a costly PKI deployment or application integration issues.
00147
00148 '''
00149
00150 if __name__ == "__main__" : main()
00151
00152