source: TI12-security/trunk/ndg_xacml/ndg/xacml/test/context/test_context.py @ 7665

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/ndg_xacml/ndg/xacml/test/context/test_context.py@7665
Revision 7665, 1.9 KB checked in by pjkersha, 10 years ago (diff)

Working tests refactored into policy and context sub-packages.

  • Property svn:keywords set to Id
Line 
1#!/usr/bin/env python
2"""NDG XACML Context unit test package
3
4NERC DataGrid
5"""
6__author__ = "P J Kershaw"
7__date__ = "26/03/10"
8__copyright__ = "(C) 2010 Science and Technology Facilities Council"
9__contact__ = "Philip.Kershaw@stfc.ac.uk"
10__license__ = "BSD - see LICENSE file in top-level directory"
11__contact__ = "Philip.Kershaw@stfc.ac.uk"
12__revision__ = "$Id$"
13import unittest
14import logging
15logging.basicConfig(level=logging.DEBUG)
16
17from ndg.xacml.core.context.pdpinterface import PDPInterface
18from ndg.xacml.core.context.pdp import PDP
19from ndg.xacml.core.context.handler import CtxHandlerInterface
20from ndg.xacml.core.context.response import Response
21from ndg.xacml.core.context.result import Result, Decision
22from ndg.xacml.test.context import XacmlContextBaseTestCase, TestContextHandler 
23
24
25class XacmlContextTestCase(XacmlContextBaseTestCase):
26    """Test PDP, PAP, PIP and Context handler"""
27   
28    def test01CreateRequest(self):
29        requestCtx = self._createRequestCtx("http://localhost")
30        self.assert_(requestCtx)
31       
32    def test02CreateResponse(self):
33        response = Response()
34        result = Result()
35        response.results.append(result)
36        result.decision = Decision()
37        result.decision.value = Decision.NOT_APPLICABLE
38       
39    def test03AbstractCtxHandler(self):
40        self.assertRaises(TypeError, CtxHandlerInterface, 
41                          "Context handler is an abstract base class")
42       
43    def test04CreateCtxHandler(self):
44        ctxHandler = TestContextHandler()
45       
46    def test05PDPInterface(self):
47        self.assertRaises(TypeError, PDPInterface)
48       
49    def test06CreatePDP(self):
50        pdp = PDP()
51        self.assert_(pdp)
52       
53    def test07CreatePDPfromPolicy(self):
54        pdp = self._createPDPfromNdgTest1Policy()
55        self.assert_(pdp)
56       
57                               
58if __name__ == "__main__":
59    unittest.main()
Note: See TracBrowser for help on using the repository browser.