def test_one(self):
        from session_storage_memcached import SessionStorageMemcached
        from login_biz import Login_Biz
        lb = Login_Biz(Mockup_Account_Biz(), SessionStorageMemcached('127.0.0.1:11211', 'test_session_storage_memcached'))

        lb.login('test_user_1', PASSWORD)

        self.assert_( lb.is_logged_in('test_user_1') )
Exemplo n.º 2
0
    def testlogin_invalid_password(self):
        from login_biz import Login_Biz
        from errors import BadLoginOrPassword
        lb = Login_Biz(Mockup_Account_Biz(), Mockup_Session_Storage())

        e = None
        try:
            lb.login('test_user_1', PASSWORD.lower())
        except Exception, catched:
            e = catched
Exemplo n.º 3
0
    def testlogin_invalid_login(self):
        from login_biz import Login_Biz
        from errors import AccountNotFound
        lb = Login_Biz(Mockup_Account_Biz(), Mockup_Session_Storage())

        e = None
        try:
            lb.login('test_user_10000', PASSWORD)
        except Exception, catched:
            e = catched
    def test_set_by_login(self):
        from session_storage_memcached import SessionStorageMemcached
        from login_biz import Login_Biz

        storage = SessionStorageMemcached('127.0.0.1:11211', 'test_session_storage_memcached')

        lb = Login_Biz(Mockup_Account_Biz(), storage)

        lb.login('test_user_1', PASSWORD)

        storage.set_by_login('test_user_1', { 'STR': 'SSS', 'NUM':22 } )

        d = storage.get_by_login('test_user_1')

        self.assert_( d['STR'] == 'SSS' )
        self.assert_( d['NUM'] == 22 )
Exemplo n.º 5
0
    def test_db(self):
        from connection_factory import connect
        from account_generator import Account_Postgres_MD5_Salt_Generator
        path = os.path.join(get_abs_module_path(self.__class__), 'account')
        self.cleanup_dir(path)
        gen = Account_Postgres_MD5_Salt_Generator(path,'Account','connection_factory')
        gen.generate_files()
        with connect() as conn:
            with transaction(conn):
                cur = conn.cursor()
                try:
                    cur.execute('''DROP TABLE account CASCADE''')
                except:
                    pass

            with transaction(conn):
                cur = conn.cursor()
                try:
                    cur.execute('''DROP SEQUENCE account_pk_seq''')
                except:
                    pass

            with transaction(conn):
                cur = conn.cursor()
                sql = open( os.path.join(get_abs_module_path(self.__class__), 'account/account.sql'), 'r'  ).read()
                cur.execute(sql)

            m = __import__('account.account_biz', fromlist=['account_biz'])
            acc = m.AccountBiz()
            (passw, phash, salt) = acc.gen_password()
            idn = acc.create('test_user1', phash, salt)

            from session_storage_memcached import SessionStorageMemcached
            from login_biz import Login_Biz

            storage = SessionStorageMemcached('127.0.0.1:11211', 'test_session_storage_memcached')

            lb = Login_Biz(acc, storage)

            lb.login('test_user1', passw)
Exemplo n.º 6
0
 def testis_not_logged_in(self):
     from login_biz import Login_Biz
     lb = Login_Biz(Mockup_Account_Biz(), Mockup_Session_Storage())
     self.assert_( not lb.is_logged_in('test_user_2') )
Exemplo n.º 7
0
 def testis_logged_in(self):
     from login_biz import Login_Biz
     lb = Login_Biz(Mockup_Account_Biz(), Mockup_Session_Storage())
     lb.login('test_user_1', PASSWORD)
     self.assert_( lb.is_logged_in('test_user_1') )
Exemplo n.º 8
0
 def testlogin_valid(self):
     from login_biz import Login_Biz
     lb = Login_Biz(Mockup_Account_Biz(), Mockup_Session_Storage())
     lb.login('test_user_1', PASSWORD)
     pass