source: TI12-security/trunk/python/ndg.security.test/ndg/security/test/unit/attributeauthority/saml/test_samlinterface.py @ 5516

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.test/ndg/security/test/unit/attributeauthority/saml/test_samlinterface.py@5516
Revision 5516, 2.6 KB checked in by pjkersha, 11 years ago (diff)

Started work on SAML Attribute Interface SOAP Binding

  • added new ndg.security.common.soap module for ElementTree based SOAP handling. This will allow easy integration with ElementTree based SAML implementation.
Line 
1"""Attribute Authority SAML Interface unit test package
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "21/07/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$'
11import logging
12logging.basicConfig(level=logging.DEBUG)
13   
14from datetime import datetime
15import base64 
16import os
17from uuid import uuid4
18
19from ndg.security.test.unit import BaseTestCase
20
21from ndg.security.common.saml import Assertion, Attribute, AttributeValue, \
22    AttributeStatement, SAMLVersion, XSStringAttributeValue, \
23    XSGroupRoleAttributeValue
24from ndg.security.common.saml.xml import XMLConstants
25from ndg.security.common.saml.xml.etree import AssertionETreeObject, \
26    XSGroupRoleAttributeValueETreeObject
27
28class Request(object):
29    pass
30
31class Response(object):
32    pass
33
34class AttributeQuery(object):
35    pass
36
37class SamlSoapBindingMiddleware(object):
38    def __call__(self, environ, start_response):
39        pass
40
41       
42class SamlAttributeAuthorityInterfaceTestCase(unittest.TestCase):
43    """TODO: test SAML Attribute Authority interface"""
44    thisDir = os.path.dirname(os.path.abspath(__file__))
45
46    def __init__(self, *args, **kwargs):
47        wsgiApp = SamlSoapBindingMiddleware()
48        self.app = paste.fixture.TestApp(wsgiApp)
49         
50        unittest.TestCase.__init__(self, *args, **kwargs)
51       
52
53    def test01Catch401WithNotLoggedIn(self):
54        response = self.app.get('/test_401WithNotLoggedIn')
55        self.assert_(response.status == 302)
56       
57        try:
58            redirectResponse = response.follow()
59        except paste.fixture.AppError, e:
60            self.failIf('404 Not found' not in str(e), 
61                        "Expecting 404 Not found")
62
63    def test02Skip200WithLoggedIn(self):
64        response = self.app.get('/test_200WithLoggedIn',
65                                extra_environ={'REMOTE_USER': 'testuser'})
66
67    def test03Catch401WithLoggedIn(self):
68        response = self.app.get('/test_401WithLoggedIn', 
69                                extra_environ={'REMOTE_USER': 'testuser'},
70                                status=401)
71       
72    def test04Catch200WithNotLoggedIn(self):
73        response = self.app.get('/test_200WithNotLoggedIn')
74        self.assert_(response.status == 302)
75       
76        try:
77            redirectResponse = response.follow()
78        except paste.fixture.AppError, e:
79            self.failIf('404 Not found' not in str(e), 
80                        "Expecting 404 Not found")
81   
82   
83
84if __name__ == "__main__":
85    unittest.main()       
86
Note: See TracBrowser for help on using the repository browser.