source: TI12-security/trunk/python/ndg.security.test/ndg/security/test/attAuthority/wsgi/siteBServerApp.py @ 4238

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.test/ndg/security/test/attAuthority/wsgi/siteBServerApp.py@4238
Revision 4238, 1.6 KB checked in by pjkersha, 11 years ago (diff)

Working unit tests for WSGI based Attribute Authority. TODO:

  • test with Attribute Authority properties picked up from ini file instead of XML properties file (code supports both methods)
  • refactor unit test config to use standard WS-Security config section
  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2"""NDG Security Attribute Authority test harness for unit test site 'A'
3
4NERC Data Grid Project
5
6This software may be distributed under the terms of the Q Public License,
7version 1.0 or later.
8"""
9__author__ = "P J Kershaw"
10__date__ = "24/09/08"
11__copyright__ = "(C) 2008 STFC & NERC"
12__contact__ = "P.J.Kershaw@rl.ac.uk"
13__revision__ = "$Id$"
14import os
15
16def infoApp(environ, start_response):
17    start_response('200 OK', [('Content-type', 'text/plain')])
18    return "NDG Security Attribute Authority Unit Tests: Site A Server"
19
20def app_factory(global_config, **local_conf):
21    return infoApp
22
23
24# Initialize environment for unit tests
25if 'NDGSEC_AACLNT_UNITTEST_DIR' not in os.environ:
26    os.environ['NDGSEC_AACLNT_UNITTEST_DIR'] = \
27                    os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
28   
29if 'NDGSEC_AA_PROPFILEPATH' not in os.environ:
30    os.environ['NDGSEC_AA_PROPFILEPATH'] = \
31                        os.path.join(os.environ['NDGSEC_AACLNT_UNITTEST_DIR'],
32                                     "siteBAttAuthorityProperties.xml")
33
34# To start the Site A Attribute Authority run
35# $ paster serve site-a.ini or run this file as a script
36# $ ./siteAServerApp.py [port #]
37if __name__ == '__main__':
38    import sys
39    if len(sys.argv) > 1:
40        port = int(sys.argv[1])
41    else:
42        port = 5100
43       
44    cfgFilePath = os.path.join(os.path.dirname(os.path.abspath(__file__)),
45                               'site-b.ini')
46       
47    from paste.httpserver import serve
48    from paste.deploy import loadapp
49
50    app = loadapp('config:%s' % cfgFilePath)
51    serve(app, host='0.0.0.0', port=port)
Note: See TracBrowser for help on using the repository browser.