source: TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/attributeauthority/test_attributeauthority.py @ 7077

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg-security/TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/wsgi/attributeauthority/test_attributeauthority.py@7077
Revision 7077, 1.7 KB checked in by pjkersha, 11 years ago (diff)
  • Property svn:keywords set to Id
Line 
1"""WSGI Middleware to set an Attribute Authority instance in tyhe WSGI environ
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "19/08/09"
7__copyright__ = "(C) 2009 Science and Technology Facilities Council"
8__contact__ = "Philip.Kershaw@stfc.ac.uk"
9__license__ = "BSD - see LICENSE file in top-level directory"
10__revision__ = "$Id$"
11import logging
12log = logging.getLogger(__name__)
13import os
14import unittest
15
16import paste.fixture
17from paste.deploy import loadapp
18
19from ndg.security.server.wsgi.attributeauthority import \
20    AttributeAuthorityMiddleware
21
22class TestAttributeAuthorityApp(object):
23    '''Test harness for Attribute Authority'''
24    response = "Attribute Authority environ key: environ['%s']=%r"
25       
26    def __init__(self, app_conf, **local_conf):
27        pass
28   
29    def __call__(self, environ, start_response):
30        assert('myAttributeAuthority' in environ)
31       
32        response = TestAttributeAuthorityApp.response %('myAttributeAuthority',
33                                            environ['myAttributeAuthority'])
34        strReponseLen = str(len(response))
35        start_response("200 OK",
36                       [('Content-length', strReponseLen),
37                        ('Content-type', 'text/plain')])
38        return [response]
39
40
41class AttributeAuthorityMiddlewareTestCase(unittest.TestCase):
42
43    def test01CheckForEnvironKey(self):
44        here_dir = os.path.dirname(os.path.abspath(__file__))
45        app = loadapp('config:test.ini', relative_to=here_dir)
46        self.app = paste.fixture.TestApp(app)
47       
48        response = self.app.get('/')
49        self.assert_(response) 
50        print(response)     
51       
52if __name__ == "__main__":
53    unittest.main()
Note: See TracBrowser for help on using the repository browser.