configurationengine/source/cone/storage/tests/unittest_authenticate.py
changeset 3 e7e0ae78773e
equal deleted inserted replaced
2:87cfa131b535 3:e7e0ae78773e
       
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 #
       
    16 
       
    17 import unittest
       
    18 import os
       
    19 
       
    20 from cone.storage import authenticate
       
    21 
       
    22 ROOT_PATH   = os.path.dirname(os.path.abspath(__file__))
       
    23 
       
    24 class TestCarbonAuthHandler(unittest.TestCase):
       
    25     def setUp(self):
       
    26         self.test_user   = "admin"
       
    27         self.test_passwd = "minda"
       
    28         
       
    29     def callback_username(self):
       
    30         return self.test_user
       
    31 
       
    32     def callback_password(self):
       
    33         return self.test_passwd
       
    34         
       
    35     def test_username_password_func(self):
       
    36         carbon_handler = authenticate.CarbonAuthHandler()
       
    37         carbon_handler.add_username_func(self.callback_username)
       
    38         carbon_handler.add_password_func(self.callback_password)
       
    39         username = carbon_handler.get_username()
       
    40         password = carbon_handler.get_password()
       
    41         self.assertEqual(self.test_user,username)
       
    42         self.assertEqual(self.test_passwd,password)        
       
    43    
       
    44 if __name__ == '__main__':
       
    45     unittest.main()
       
    46