1 | #!/usr/bin/env python |
---|
2 | """NDG Security Session Manager test harness for client unit tests |
---|
3 | |
---|
4 | NERC Data Grid Project |
---|
5 | |
---|
6 | This software may be distributed under the terms of the Q Public License, |
---|
7 | version 1.0 or later. |
---|
8 | """ |
---|
9 | __author__ = "P J Kershaw" |
---|
10 | __date__ = "29/09/08" |
---|
11 | __copyright__ = "(C) 2008 STFC" |
---|
12 | __contact__ = "Philip.Kershaw@stfc.ac.uk" |
---|
13 | __revision__ = "$Id$" |
---|
14 | import os |
---|
15 | |
---|
16 | def infoApp(environ, start_response): |
---|
17 | start_response('200 OK', [('Content-type', 'text/plain')]) |
---|
18 | return "NDG Security Session Manager for Client Unit Tests" |
---|
19 | |
---|
20 | def app_factory(global_config, **local_conf): |
---|
21 | return infoApp |
---|
22 | |
---|
23 | |
---|
24 | # Initialize environment for unit tests |
---|
25 | if 'NDGSEC_SMCLNT_UNITTEST_DIR' not in os.environ: |
---|
26 | os.environ['NDGSEC_SMCLNT_UNITTEST_DIR'] = \ |
---|
27 | os.path.dirname(os.path.abspath(os.path.dirname(__file__))) |
---|
28 | |
---|
29 | if 'NDGSEC_AA_PROPFILEPATH' not in os.environ: |
---|
30 | os.environ['NDGSEC_AA_PROPFILEPATH'] = \ |
---|
31 | os.path.join(os.environ['NDGSEC_SMCLNT_UNITTEST_DIR'], |
---|
32 | "sessionMgr.cfg") |
---|
33 | |
---|
34 | # To start the Site A Session Manager run |
---|
35 | # $ paster serve site-a.ini or run this file as a script |
---|
36 | # $ ./siteAServerApp.py [port #] |
---|
37 | if __name__ == '__main__': |
---|
38 | import sys |
---|
39 | import logging |
---|
40 | logging.basicConfig(level=logging.DEBUG) |
---|
41 | |
---|
42 | if len(sys.argv) > 1: |
---|
43 | port = int(sys.argv[1]) |
---|
44 | else: |
---|
45 | port = 5500 |
---|
46 | |
---|
47 | cfgFilePath = os.path.join(os.path.dirname(os.path.abspath(__file__)), |
---|
48 | 'session-manager.ini') |
---|
49 | |
---|
50 | from paste.httpserver import serve |
---|
51 | from paste.deploy import loadapp |
---|
52 | |
---|
53 | app = loadapp('config:%s' % cfgFilePath) |
---|
54 | serve(app, host='0.0.0.0', port=port) |
---|