source: TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/paster_templates/test_paster_templates.py @ 7794

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/paster_templates/test_paster_templates.py@7794
Revision 7794, 5.0 KB checked in by pjkersha, 9 years ago (diff)

Incomplete - task 16: NDG Security 2.x.x - incl. updated Paster templates

  • Revising openidprovider integration test. - Provider now runs with all static content loaded correctly using a cascade in the ini file.
Line 
1#!/usr/bin/env python
2"""Unit tests for NDG Security paster templates
3
4NERC DataGrid Project
5"""
6__author__ = "P J Kershaw"
7__date__ = "18/11/10"
8__copyright__ = "(C) 2010 Science and Technology Facilities Council"
9__license__ = "BSD - see LICENSE file in top-level directory"
10__contact__ = "Philip.Kershaw@stfc.ac.uk"
11__revision__ = '$Id$'
12import unittest
13from os import path, listdir
14import shutil
15from paste.script.create_distro import CreateDistroCommand
16       
17   
18class ServicesTemplateTestCase(unittest.TestCase):
19    """Test create configuration for an application which bundles all the NDG
20    Security Services
21    """
22    HERE_DIR = path.dirname(path.abspath(__file__))
23    SERVICE_TMPL_NAME = 'ndgsecurity_services'
24    SERVICE_CONF_DIR = 'services'
25    SERVICE_CONF_DIRPATH = path.join(HERE_DIR, SERVICE_CONF_DIR)
26    SERVICE_CONF_DIR_FILES = (
27        'pki', 'pip-mapping.txt', 'service.ini', 'policy.xml', 'user.db'
28    )
29   
30    def test01Run(self):
31        cmd = CreateDistroCommand(None)
32        cmd.default_interactive = False
33        cmd.run([self.__class__.SERVICE_CONF_DIR, 
34                 '-t', 
35                 self.__class__.SERVICE_TMPL_NAME])
36       
37        createdFiles = listdir(self.__class__.SERVICE_CONF_DIRPATH)
38       
39        for _file in self.__class__.SERVICE_CONF_DIR_FILES:
40            self.assert_(_file in createdFiles, "Missing file %r" % _file)
41
42    def tearDown(self):
43        shutil.rmtree(self.__class__.SERVICE_CONF_DIRPATH, True)
44           
45
46class AttributeServiceTemplateTestCase(unittest.TestCase):
47    """Test creation of ini file and basic configuration settings for NDG
48    Security Attribute Service
49    """
50    HERE_DIR = path.dirname(path.abspath(__file__))
51    ATTRIBUTE_SERVICE_TMPL_NAME = 'ndgsecurity_attribute_service'
52    ATTRIBUTE_SERVICE_CONF_DIR = 'attribute-service'
53    ATTRIBUTE_SERVICE_CONF_DIRPATH = path.join(HERE_DIR, 
54                                                ATTRIBUTE_SERVICE_CONF_DIR)
55    ATTRIBUTE_SERVICE_CONF_DIR_FILES = (
56        'pki', 'attribute-service.ini', 'user.db'
57    )
58   
59    def test01Run(self):
60        cmd = CreateDistroCommand(None)
61        cmd.default_interactive = False
62        cmd.run([self.__class__.ATTRIBUTE_SERVICE_CONF_DIR, 
63                 '-t', 
64                 self.__class__.ATTRIBUTE_SERVICE_TMPL_NAME])
65       
66        createdFiles = listdir(
67                            self.__class__.ATTRIBUTE_SERVICE_CONF_DIRPATH)
68       
69        for _file in self.__class__.ATTRIBUTE_SERVICE_CONF_DIR_FILES:
70            self.assert_(_file in createdFiles, "Missing file %r" % _file)
71
72    def tearDown(self):
73        shutil.rmtree(self.__class__.ATTRIBUTE_SERVICE_CONF_DIRPATH, True) 
74                   
75
76class AuthorisationServiceTemplateTestCase(unittest.TestCase):
77    """Test creation of ini file and basic configuration settings for NDG
78    Security Authorisation Service
79    """
80    HERE_DIR = path.dirname(path.abspath(__file__))
81    AUTHORISATION_SERVICE_TMPL_NAME = 'ndgsecurity_authorisation_service'
82    AUTHORISATION_SERVICE_CONF_DIR = 'authorisation-service'
83    AUTHORISATION_SERVICE_CONF_DIRPATH = path.join(HERE_DIR, 
84                                                AUTHORISATION_SERVICE_CONF_DIR)
85    AUTHORISATION_SERVICE_CONF_DIR_FILES = (
86        'pki', 'pip-mapping.txt', 'authorisation-service.ini', 'policy.xml'
87    )
88   
89    def test01Run(self):
90        cmd = CreateDistroCommand(None)
91        cmd.default_interactive = False
92        cmd.run([self.__class__.AUTHORISATION_SERVICE_CONF_DIR, 
93                 '-t', 
94                 self.__class__.AUTHORISATION_SERVICE_TMPL_NAME])
95       
96        createdFiles = listdir(
97                            self.__class__.AUTHORISATION_SERVICE_CONF_DIRPATH)
98       
99        for _file in self.__class__.AUTHORISATION_SERVICE_CONF_DIR_FILES:
100            self.assert_(_file in createdFiles, "Missing file %r" % _file)
101
102    def tearDown(self):
103        shutil.rmtree(self.__class__.AUTHORISATION_SERVICE_CONF_DIRPATH, True)         
104
105
106class OpenIdProviderTemplateTestCase(unittest.TestCase):
107    """Test creation of ini file and basic configuration settings for NDG
108    Security OpenID Provider Service
109    """
110    HERE_DIR = path.dirname(path.abspath(__file__))
111    OP_SERVICE_TMPL_NAME = 'ndgsecurity_openidprovider_service'
112    OP_SERVICE_CONF_DIR = 'openid-provider'
113    OP_SERVICE_CONF_DIRPATH = path.join(HERE_DIR, OP_SERVICE_CONF_DIR)
114    OP_SERVICE_CONF_DIR_FILES = (
115        'pki', 'openidprovider-service.ini', 
116    )
117   
118    def _test01Run(self):
119        cmd = CreateDistroCommand(None)
120        cmd.default_interactive = False
121        cmd.run([self.__class__.OP_SERVICE_CONF_DIR, 
122                 '-t', 
123                 self.__class__.OP_SERVICE_TMPL_NAME])
124       
125        createdFiles = listdir(
126                            self.__class__.OP_SERVICE_CONF_DIRPATH)
127       
128        for _file in self.__class__.OP_SERVICE_CONF_DIR_FILES:
129            self.assert_(_file in createdFiles, "Missing file %r" % _file)
130
131    def _tearDown(self):
132        shutil.rmtree(self.__class__.OP_SERVICE_CONF_DIRPATH, True)
133       
134
135if __name__ == "__main__":
136    unittest.main()
Note: See TracBrowser for help on using the repository browser.