1 | import logging |
---|
2 | logging.basicConfig(level=logging.DEBUG) |
---|
3 | import os |
---|
4 | from os.path import dirname, abspath, join |
---|
5 | |
---|
6 | from ndg.security.server.wsgi.apploader import AppLoaderMiddleware |
---|
7 | |
---|
8 | def application(environ, start_response): |
---|
9 | status = '200 OK' |
---|
10 | output = 'Access allowed to this URL' |
---|
11 | |
---|
12 | response_headers = [('Content-type', 'text/plain'), |
---|
13 | ('Content-Length', str(len(output)))] |
---|
14 | start_response(status, response_headers) |
---|
15 | |
---|
16 | return [output] |
---|
17 | |
---|
18 | def app_factory(app_conf, **local_conf): |
---|
19 | return application |
---|
20 | |
---|
21 | from ndg.security.test.unit import BaseTestCase |
---|
22 | |
---|
23 | # Initialize environment for unit tests |
---|
24 | if BaseTestCase.configDirEnvVarName not in os.environ: |
---|
25 | os.environ[BaseTestCase.configDirEnvVarName] = \ |
---|
26 | join(dirname(abspath(dirname(__file__))), 'config') |
---|
27 | |
---|
28 | # Initialize environment for unit tests |
---|
29 | if 'NDGSEC_SSLCLNTAUTHN_UNITTEST_DIR' not in os.environ: |
---|
30 | os.environ['NDGSEC_SSLCLNTAUTHN_UNITTEST_DIR'] = \ |
---|
31 | os.path.abspath(os.path.dirname(__file__)) |
---|
32 | |
---|
33 | if __name__ == '__main__': |
---|
34 | import sys |
---|
35 | from paste.httpserver import serve |
---|
36 | |
---|
37 | if len(sys.argv) > 1: |
---|
38 | port = int(sys.argv[1]) |
---|
39 | else: |
---|
40 | port = 7000 |
---|
41 | |
---|
42 | cfgFilePath = os.path.join(os.path.dirname(os.path.abspath(__file__)), |
---|
43 | 'test.ini') |
---|
44 | |
---|
45 | sslPEM = os.environ['NDGSEC_SSLCLNTAUTHN_UNITTEST_DIR']+'/localhost.pem' |
---|
46 | app = AppLoaderMiddleware(configFilePath=cfgFilePath) |
---|
47 | serve(app, host='0.0.0.0', port=port, ssl_pem=sslPEM) |
---|