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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/MyProxyServerUtils/myproxy/server/test/myproxy_ws.py@6895
Revision 6895, 1.5 KB checked in by pjkersha, 10 years ago (diff)
  • Working myproxy-ws-logon.sh MyProxy? logon web service client script.
  • Also integrated with unit test which launches the WSGI app by starting it running over HTTPS with paster in a separate thread and then queries it with the client script.
  • Property svn:executable set to *
RevLine 
[6893]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'
[6895]19INI_FILEPATH = path.join(THIS_DIR, INI_FILENAME) 
20SSLCERT_FILEPATH = path.join(THIS_DIR, 'localhost.crt')
21SSLKEY_FILEPATH = path.join(THIS_DIR, 'localhost.key')
[6893]22PORTNUM = 7443
[6895]23WITH_SSL = True # Set to False to run over HTTP
[6893]24
25if __name__ == "__main__":
[6895]26    # Provide a port number as command line argument or accept the default
27    # PORTNUM
[6893]28    if len(sys.argv) > 1:
29        port = sys.argv[1]
30    else:
31        port = PORTNUM
32       
33    if WITH_SSL:
34        ssl_context = SSL.Context(SSL.SSLv23_METHOD)
35        ssl_context.set_options(SSL.OP_NO_SSLv2)
36   
[6895]37        ssl_context.use_privatekey_file(SSLKEY_FILEPATH)
38        ssl_context.use_certificate_file(SSLCERT_FILEPATH)
[6893]39    else:
40        ssl_context = None
41       
42    server = PasteDeployAppServer(ssl_context=ssl_context, 
43                                  cfgFilePath=INI_FILEPATH, 
44                                  port=port, 
45                                  withLoggingConfig=False) 
46    try:   
47        server.start()   
48    except KeyboardInterrupt:
49        sys.exit(0) 
Note: See TracBrowser for help on using the repository browser.