############################################################################## # # Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Test for auth_header $Id: testAuthHeaderTest.py 30245 2005-05-05 09:50:09Z shh $ """ import os, sys if __name__ == '__main__': execfile(os.path.join(sys.path[0], 'framework.py')) from unittest import TestSuite, makeSuite from Testing.ZopeTestCase import TestCase from Testing.ZopeTestCase import zopedoctest auth_header = zopedoctest.functional.auth_header class AuthHeaderTestCase(TestCase): def test_auth_encoded(self): header = 'Basic Z2xvYmFsbWdyOmdsb2JhbG1ncnB3' self.assertEquals(auth_header(header), header) def test_auth_non_encoded(self): header = 'Basic globalmgr:globalmgrpw' expected = 'Basic Z2xvYmFsbWdyOmdsb2JhbG1ncnB3' self.assertEquals(auth_header(header), expected) def test_auth_non_encoded_empty(self): header = 'Basic globalmgr:' expected = 'Basic Z2xvYmFsbWdyOg==' self.assertEquals(auth_header(header), expected) header = 'Basic :pass' expected = 'Basic OnBhc3M=' self.assertEquals(auth_header(header), expected) def test_auth_non_encoded_colon(self): header = 'Basic globalmgr:pass:pass' expected = 'Basic Z2xvYmFsbWdyOnBhc3M6cGFzcw==' self.assertEquals(auth_header(header), expected) def test_suite(): return TestSuite(( makeSuite(AuthHeaderTestCase), )) if __name__ == '__main__': framework()