source: TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/openid/provider/authninterface/test_authninterface.py @ 7077

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg-security/TI12-security/trunk/NDGSecurity/python/ndg_security_test/ndg/security/test/unit/openid/provider/authninterface/test_authninterface.py@7077
Revision 7077, 2.1 KB checked in by pjkersha, 11 years ago (diff)
  • Property svn:keywords set to Id
Line 
1"""OpenID Provider Authentication Interface unit tests
2
3NERC DataGrid Project
4"""
5__author__ = "P J Kershaw"
6__date__ = "12/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
12import unittest
13     
14from ndg.security.test.unit import BaseTestCase
15from ndg.security.server.wsgi.openid.provider.authninterface import (
16                                                    AuthNInterfaceConfigError)
17from ndg.security.server.wsgi.openid.provider.authninterface.sqlalchemy_authn \
18    import SQLAlchemyAuthnInterface
19
20
21class SQLAlchemyAuthnInterfaceTestCase(BaseTestCase):
22    LOGON_SQLQUERY = ("select count(*) from users where username = "
23                      "'${username}' and md5password = '${password}'")
24   
25    USERNAME2USERIDENTIFIER_SQLQUERY = ("select openid_identifier from users "
26                                        "where username = '${username}'")
27   
28    def __init__(self, *arg, **kw):
29        super(SQLAlchemyAuthnInterfaceTestCase, self).__init__(*arg, **kw)
30        self.__interface = None
31       
32        self.initDb()
33         
34    def setUp(self):
35        self.__interface = SQLAlchemyAuthnInterface(
36            connectionString=SQLAlchemyAuthnInterfaceTestCase.DB_CONNECTION_STR,
37            logonSqlQuery=SQLAlchemyAuthnInterfaceTestCase.LOGON_SQLQUERY,
38            username2UserIdentifierSqlQuery=\
39            SQLAlchemyAuthnInterfaceTestCase.USERNAME2USERIDENTIFIER_SQLQUERY,
40            isMD5EncodedPwd=True
41        )
42                 
43    def test01Logon(self):
44        self.__interface.logon({}, 
45                               None, 
46                               SQLAlchemyAuthnInterfaceTestCase.USERNAME, 
47                               SQLAlchemyAuthnInterfaceTestCase.PASSWORD)
48
49    def test02Username2UserIdentifier(self):
50        self.__interface.username2UserIdentifiers({}, 
51                               SQLAlchemyAuthnInterfaceTestCase.USERNAME)
52       
53                                                       
54if __name__ == "__main__":
55    unittest.main()
Note: See TracBrowser for help on using the repository browser.