1 | #!/usr/bin/env python |
---|
2 | """Test script to run MyProxy web service interface in the Paster web |
---|
3 | application 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: $" |
---|
11 | import sys |
---|
12 | from os import path |
---|
13 | from OpenSSL import SSL |
---|
14 | |
---|
15 | from myproxy.server.test import PasteDeployAppServer |
---|
16 | |
---|
17 | THIS_DIR = path.abspath(path.dirname(__file__)) |
---|
18 | INI_FILENAME = 'myproxywsgi.ini' |
---|
19 | INI_FILEPATH = path.join(THIS_DIR, INI_FILENAME) |
---|
20 | SSLCERT_FILEPATH = path.join(THIS_DIR, 'localhost.crt') |
---|
21 | SSLKEY_FILEPATH = path.join(THIS_DIR, 'localhost.key') |
---|
22 | PORTNUM = 7443 |
---|
23 | WITH_SSL = True # Set to False to run over HTTP |
---|
24 | |
---|
25 | if __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) |
---|