source: TI12-security/trunk/MyProxyWebService/myproxy/server/test/myproxy_ws.py @ 6957

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

Incomplete - task 5: MyProxy? Logon HTTPS Interface

  • fixed paths to be absolute for PasteDeploy? loadapp ini file in unit tests.
  • 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.abspath(path.dirname(__file__))
18INI_FILENAME = 'myproxywsgi.ini'
19INI_FILEPATH = path.join(THIS_DIR, INI_FILENAME) 
20SSLCERT_FILEPATH = path.join(THIS_DIR, 'localhost.crt')
21SSLKEY_FILEPATH = path.join(THIS_DIR, 'localhost.key')
22PORTNUM = 7443
23WITH_SSL = True # Set to False to run over HTTP
24
25if __name__ == "__main__":
26    # Provide a port number as command line argument or accept the default
27    # PORTNUM
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   
37        ssl_context.use_privatekey_file(SSLKEY_FILEPATH)
38        ssl_context.use_certificate_file(SSLCERT_FILEPATH)
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.