test_t6.py :  » Business-Application » PDB2PQR » pdb2pqr-1.6 » contrib » ZSI-2.1-a1 » test » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Business Application » PDB2PQR 
PDB2PQR » pdb2pqr 1.6 » contrib » ZSI 2.1 a1 » test » test_t6.py
#!/usr/bin/env python
import unittest, sys, multifile, mimetools, base64
from ZSI import *
from ZSI import resolvers
try:
    import cStringIO as StringIO
except ImportError:
    import StringIO

class t6TestCase(unittest.TestCase):
    "Test case wrapper for old ZSI t6 test case"

    def checkt6(self):
        try:
            istr = StringIO.StringIO(intext)
            m = mimetools.Message(istr)
            cid = resolvers.MIMEResolver(m['content-type'], istr)
            xml = cid.GetSOAPPart()
            ps = ParsedSoap(xml, resolver=cid.Resolve)
        except ParseException, e:
            print >>OUT, FaultFromZSIException(e).AsSOAP()
            self.fail()
        except Exception, e:
            # Faulted while processing; assume it's in the header.
            print >>OUT, FaultFromException(e, 1, sys.exc_info()[2]).AsSOAP() 
            self.fail()

        try:
            dict = ps.Parse(typecode)
        except Exception, e:
            # Faulted while processing; now it's the body
            print >>OUT, FaultFromException(e, 0, sys.exc_info()[2]).AsSOAP()
            self.fail()

        self.failUnlessEqual(dict['stringtest'], strExtTest, 
                            "Failed to extract stringtest correctly")
        print base64.encodestring(cid['partii@zolera.com'].read()) 
        v = dict['b64']
        print type(v), 'is type(v)' 
        self.failUnlessEqual(cid['partii@zolera.com'].getvalue(), v,
                                    "mismatch")
        print base64.encodestring(v)             
        from ZSI.wstools.c14n import Canonicalize
        z = dict['xmltest'] 
        print type(z), z 
        print Canonicalize(z)

def makeTestSuite():
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(t6TestCase, "check"))
    return suite

def main():
    unittest.main(defaultTest="makeTestSuite")

OUT = sys.stdout
typecode = TC.Struct(None, [
                TC.String('b64'),
                TC.String('stringtest'),
                TC.XML('xmltest'),
            ])
                                                            
intext='''Return-Path: <rsalz@zolera.com>
Received: from zolera.comos390.zolera.com import 
        by zolera.com (8.11.0/8.11.0) with ESMTP id f57I2sf00832
        for <rsalz@zolera.com>; Thu, 7 Jun 2001 14:02:54 -0400
Sender: rsalz@zolera.com
Message-ID: <3B1FC1D1.FF6B21B4@zolera.com>
Date: Thu, 07 Jun 2001 14:02:57 -0400
From: Rich Salz <rsalz@zolera.com>
X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0 i686)
X-Accept-Language: en
MIME-Version: 1.0
To: rsalz@zolera.com
Subject: mime with attachments
Content-Type: multipart/mixed;
 boundary="------------68E4BAC5B266315E42428C64"
Status: R

This is a multi-part message in MIME format.
--------------68E4BAC5B266315E42428C64
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

<SOAP-ENV:Envelope
 xmlns="http://www.example.com/schemas/TEST"
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:ZSI="http://www.zolera.com/schemas/ZSI/">
<SOAP-ENV:Body>
<hreftest>
    <stringtest href="cid:part1@zolera.com"/>
    <b64 href="cid:partii@zolera.com"/>
    <xmltest href="cid:12@zolera.com"/>
</hreftest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
--------------68E4BAC5B266315E42428C64
Content-Type: text/plain; charset=us-ascii;
 name="abs.txt"
Content-Transfer-Encoding: 7bit
Content-ID: <part1@zolera.com>
Content-Disposition: inline;
 filename="abs.txt"


Digitial Signatures in a Web Services World

An influential Forrestor report created the term inverted security: it's
not about who you keep out, it's about who you let in.  Customer portals,
without a costly PKI deployment or application integration issues.

--------------68E4BAC5B266315E42428C64
Content-Type: application/pdf;
 name="gmpharma.pdf"
Content-Transfer-Encoding: base64
Content-ID: <partii@zolera.com>
Content-Disposition: inline;
 filename="gmpharma.pdf"

JVBERi0xLjINJeLjz9MNCjQzIDAgb2JqDTw8IA0vTGluZWFyaXplZCAxIA0vTyA0NSANL0gg
WyAxMTQ0IDM5NiBdIA0vTCA2NjkwMiANL0UgMTAyODIgDS9OIDkgDS9UIDY1OTI0IA0+PiAN
RB3nwVOQH9JpmFv6Ri2Zq7mlddSS2B5WcZwvAP+gy9QtuYlfqj1rsi9WqJOszzHXmXZ8fXxK
XBBztIpgbkRrd+SGtY4QXo0fX0VN86uKXwtrkd7h1qiq2FUtXl6uNfnCoyX1Dve1O3RPRyhG
sKn6fLMb+uSSIHPQkClRBwu5gechz/1PBUBSB34jXbPdMTIb+/wRP+pauSAhLBzFELDOgk5b
PaIPAnIudFovQTc7Df2Ws9Atz4Bua+oINphIOojogG5LP3Tb3oNu8bsmuK+wFXEdbfgFIx+G
gKULYx5A2WnaDXB5JeoRQg90S0HcX2dCPmRCqDXB/aX34KujsPwJ/UpRdxXPeAftDkQS6hag
bh/yTOiUyqBz9CzxnyMYQGDO0jrUZ47kkWfmYvVg
--------------68E4BAC5B266315E42428C64
Content-ID: <12@zolera.com>

<foo xmlns="example.com" xmlns:Z="zolera">
    this is a foo
    <b xmlns:Z="zolera">redundnant ns decl</b>
    <b Z:x="this was first" Z:a="2nd-orig">b test</b>
</foo>

--------------68E4BAC5B266315E42428C64--
'''

strExtTest = '''
Digitial Signatures in a Web Services World

An influential Forrestor report created the term inverted security: it's
not about who you keep out, it's about who you let in.  Customer portals,
without a costly PKI deployment or application integration issues.

'''

if __name__ == "__main__" : main()


www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.