source: TI12-security/trunk/MyProxyServerUtils/myproxy/server/test/myproxy_ws.py @ 6893

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/MyProxyServerUtils/myproxy/server/test/myproxy_ws.py@6893
Revision 6893, 1.5 KB checked in by pjkersha, 10 years ago (diff)

Progress testing with new myproxy-ws-logon.sh web service client shell script and test app running in paster over SSL.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2"""Test script to run MyProxy web service interface in the Paster web
3application server.
4"""
5__author__ = "P J Kershaw"
6__date__ = "26/05/10"
7__copyright__ = "(C) 2010 Science and Technology Facilities Council"
8__license__ = "BSD - see LICENSE file in top-level directory"
9__contact__ = "Philip.Kershaw@stfc.ac.uk"
10__revision__ = "$Id: $"
11import sys
12from os import path
13from OpenSSL import SSL
14
15from myproxy.server.test import PasteDeployAppServer
16
17THIS_DIR = path.dirname(__file__)
18INI_FILENAME = 'myproxywsgi.ini'
19INI_FILEPATH = path.join(THIS_DIR, INI_FILENAME) 
20SSLCERT_FILEPATH = 'localhost.crt'
21SSLKEY_FILEPATH = 'localhost.key'
22PORTNUM = 7443
23WITH_SSL = True
24
25if __name__ == "__main__":
26    if len(sys.argv) > 1:
27        port = sys.argv[1]
28    else:
29        port = PORTNUM
30       
31    certFilePath = path.join(THIS_DIR, SSLCERT_FILEPATH)
32    priKeyFilePath = path.join(THIS_DIR, SSLKEY_FILEPATH)
33   
34    if WITH_SSL:
35        ssl_context = SSL.Context(SSL.SSLv23_METHOD)
36        ssl_context.set_options(SSL.OP_NO_SSLv2)
37   
38        ssl_context.use_privatekey_file(priKeyFilePath)
39        ssl_context.use_certificate_file(certFilePath)
40    else:
41        ssl_context = None
42       
43    server = PasteDeployAppServer(ssl_context=ssl_context, 
44                                  cfgFilePath=INI_FILEPATH, 
45                                  port=port, 
46                                  withLoggingConfig=False) 
47    try:   
48        server.start()   
49    except KeyboardInterrupt:
50        sys.exit(0) 
Note: See TracBrowser for help on using the repository browser.