source: TI12-security/trunk/python/ndg_security_test/ndg/security/test/unit/authz/msi/test_msi.py @ 6022

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg_security_test/ndg/security/test/unit/authz/msi/test_msi.py@6022
Revision 6022, 1.7 KB checked in by pjkersha, 10 years ago (diff)

Fixed MSI Policy file to enable 1 to 1 mapping Attribute name -> Attribute Authority URI

Line 
1"""MSI (Medium Sized Initiative aka NDG3) authorisation unit test module
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "18/11/09"
7__copyright__ = "(C) 2009 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$'
11from os import path
12from ndg.security.test.unit import BaseTestCase
13from ndg.security.common.authz.msi import Policy
14
15
16class PolicyTestCase(BaseTestCase):
17    THIS_DIR = path.dirname(__file__)
18    POLICY_1_0_FILENAME = 'policy-1.0.xml'
19    POLICY_1_0_FILEPATH = path.join(THIS_DIR, POLICY_1_0_FILENAME)
20    POLICY_1_1_FILENAME = 'policy-1.1.xml'
21    POLICY_1_1_FILEPATH = path.join(THIS_DIR, POLICY_1_1_FILENAME)
22    ATTRIBUTE_AUTHORITY_URI = 'http://localhost:7443/AttributeAuthority'
23   
24    def test01ParseVersion1_0PolicyFile(self):
25        policy = Policy.Parse(PolicyTestCase.POLICY_1_0_FILEPATH)
26       
27        assert(policy)
28        assert(len(policy.targets) > 0)
29       
30        for target in policy.targets:
31            assert(len(target.attributes) > 0)
32           
33            for attribute in target.attributes:
34                assert(attribute.name)
35                assert(attribute.attributeAuthorityURI == \
36                       PolicyTestCase.ATTRIBUTE_AUTHORITY_URI)
37       
38    def test01ParseVersion1_1PolicyFile(self):
39        policy = Policy.Parse(PolicyTestCase.POLICY_1_1_FILEPATH)
40       
41        assert(policy)
42        assert(len(policy.targets) > 0)
43       
44        for target in policy.targets:
45            assert(len(target.attributes) > 0)
46           
47            for attribute in target.attributes:
48                assert(attribute.name)
49                assert(attribute.attributeAuthorityURI)
Note: See TracBrowser for help on using the repository browser.