source: TI12-security/trunk/python/ndg.security.test/ndg/security/test/authz/pdp/browse/testBrowse.py @ 4035

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.test/ndg/security/test/authz/pdp/browse/testBrowse.py@4035
Revision 4035, 2.7 KB checked in by pjkersha, 12 years ago (diff)

Fixes following update to NOCS deployment.

  • m2CryptoSSLUtility.HTTPSConnection now overrides putrequest in order to ensure that the URL path is string type. unicode type gives an error
  • added a unit test for BrowsePDP - gatekeeper for MOLES/CSML access control.
Line 
1#!/usr/bin/env python
2"""Test harness for NDG Browse PDP and PEP - makes access control decisions
3for MOLES and CSML documents
4
5NERC Data Grid Project
6"""
7__author__ = "P J Kershaw"
8__date__ = "02/07/08"
9__copyright__ = "(C) 2008 STFC & NERC"
10__license__ = \
11"""This software may be distributed under the terms of the Q Public
12License, version 1.0 or later."""
13__contact__ = "P.J.Kershaw@rl.ac.uk"
14__revision__ = '$Id$'
15
16import unittest
17import os, sys, getpass, re
18from ConfigParser import SafeConfigParser
19import traceback
20import logging
21logging.basicConfig()
22from ndg.security.common.authz.pdp.browse import BrowsePDP, \
23    AttributeCertificateRequestError
24
25from os.path import expandvars as xpdVars
26from os.path import join as jnPath
27mkPath = lambda file: jnPath(os.environ['NDGSEC_PDP_UNITTEST_DIR'], file)
28
29
30class BrowsePDPTestCase(unittest.TestCase):
31    """Unit test case for ndg.security.common.authz.pdp.BrowsePDP class."""
32     
33    def setUp(self):
34       
35        if 'NDGSEC_INT_DEBUG' in os.environ:
36            import pdb
37            pdb.set_trace()
38       
39        if 'NDGSEC_PDP_UNITTEST_DIR' not in os.environ:
40            os.environ['NDGSEC_PDP_UNITTEST_DIR'] = \
41                os.path.abspath(os.path.dirname(__file__))
42       
43
44        cfgFilePath = jnPath(os.environ['NDGSEC_PDP_UNITTEST_DIR'],
45                             "browse.cfg")
46        self.pdp = BrowsePDP(cfg=cfgFilePath)
47       
48                                 
49    def test1Config(self):
50        """test1Config - check client SOAP call is made correctly to
51        Session Manager - AttributeCertificateRequestError is expected
52        because calling a non-existent Session Manager service"""
53       
54        print "\n\t" + self.test1Config.__doc__
55        resrcHandle = dict(uri=xpdVars('file:///$NDGSEC_PDP_UNITTEST_DIR'),
56                           doc='MOLES doc')
57        userHandle = dict(h='https://localhost/sessionmanagerblah',
58                           sid='abcdef012345',
59                           u='testuser')
60
61        #self.pdp(resrcHandle, userHandle, None)
62        self.pdp.smURI = userHandle['h']
63        try:
64            self.pdp._pullUserSessionAttCert(self.pdp.aaURI, 'roleName')
65        except AttributeCertificateRequestError:
66            pass
67
68
69#_____________________________________________________________________________       
70class BrowsePDPTestSuite(unittest.TestSuite):
71   
72    def __init__(self):
73        print "BrowsePDPTestSuite ..."
74        testCaseMap = map(BrowsePDPTestCase,
75                          (
76                            "test1AccessPermitted",
77                          ))
78        unittest.TestSuite.__init__(self, testCaseMap)
79           
80                                                   
81if __name__ == "__main__":
82    unittest.main()       
Note: See TracBrowser for help on using the repository browser.