Ignore:
Timestamp:
18/03/10 16:09:25 (10 years ago)
Author:
pjkersha
Message:

Working rule1 example parsing, working on rule2 which contains a target resource.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/NDG_XACML/ndg/xacml/test/test_xacml.py

    r6750 r6751  
    1818class XACMLTestCase(unittest.TestCase): 
    1919    THIS_DIR = path.dirname(__file__) 
    20     XACML_FILENAME = "rule1.xml" 
    21     XACML_FILEPATH = path.join(THIS_DIR, XACML_FILENAME) 
    22      
     20    XACML_TEST1_FILENAME = "rule1.xml" 
     21    XACML_TEST1_FILEPATH = path.join(THIS_DIR, XACML_TEST1_FILENAME) 
     22    XACML_TEST2_FILENAME = "rule2.xml" 
     23    XACML_TEST2_FILEPATH = path.join(THIS_DIR, XACML_TEST2_FILENAME) 
     24    
    2325    def test01ETreeParseRule1Policy(self): 
    24         policy = PolicyReader.parse(XACMLTestCase.XACML_FILEPATH) 
     26        policy = PolicyReader.parse(XACMLTestCase.XACML_TEST1_FILEPATH) 
    2527        self.assert_(policy) 
    2628         
     
    4547            policy.rules[0].description) 
    4648         
    47         self.assert_(len(policy.rules[0].subjects) == 1) 
    48         self.assert_(len(policy.rules[0].actions) == 0) 
    49         self.assert_(len(policy.rules[0].resources) == 0) 
    50         self.assert_(len(policy.rules[0].environments) == 0) 
     49        self.assert_(len(policy.rules[0].target.subjects) == 1) 
     50        self.assert_(len(policy.rules[0].target.actions) == 0) 
     51        self.assert_(len(policy.rules[0].target.resources) == 0) 
     52        self.assert_(len(policy.rules[0].target.environments) == 0) 
    5153         
    52         self.assert_(len(policy.rules[0].subjects[0].subjectMatches) == 1) 
     54        self.assert_(len(policy.rules[0].target.subjects[0].subjectMatches) == 1) 
    5355         
    54         self.assert_(policy.rules[0].subjects[0].subjectMatches[0].id == \ 
    55                      "urn:oasis:names:tc:xacml:1.0:function:rfc822Name-match") 
     56        self.assert_(policy.rules[0].target.subjects[0].subjectMatches[0 
     57            ].matchId == \ 
     58            "urn:oasis:names:tc:xacml:1.0:function:rfc822Name-match") 
    5659         
    57         self.assert_(policy.rules[0].subjects[0].subjectMatches[0 
     60        self.assert_(policy.rules[0].target.subjects[0].subjectMatches[0 
    5861            ].attributeValue.dataType == \ 
    5962            "urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name") 
    6063         
    61         self.assert_(policy.rules[0].subjects[0].subjectMatches[0 
     64        self.assert_(policy.rules[0].target.subjects[0].subjectMatches[0 
    6265            ].attributeDesignator.dataType == \ 
    6366            "urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name") 
    6467         
    6568        # Attribute ID 
    66         self.assert_(policy.rules[0].subjects[0].subjectMatches[0 
     69        self.assert_(policy.rules[0].target.subjects[0].subjectMatches[0 
    6770            ].attributeDesignator.attributeId == \ 
    6871            "urn:oasis:names:tc:xacml:1.0:subject:subject-id") 
    69          
     72          
     73    def test02ETreeParseRule2Policy(self): 
     74        policy = PolicyReader.parse(XACMLTestCase.XACML_TEST2_FILEPATH) 
     75        self.assert_(policy) 
    7076 
    7177 
Note: See TracChangeset for help on using the changeset viewer.