Пример #1
0
    def test_login(self):
        """Tests if the SMTP bee can send emails to the SMTP capability"""

        sessions = {}
        users = {'test': BaitUser('test', 'test')}
        authenticator = Authenticator(users)
        Session.authenticator = authenticator

        cap = hive_smtp.smtp(sessions, {'enabled': 'True', 'port': 0, 'banner': 'Test'}, users, self.work_dir)
        srv = StreamServer(('0.0.0.0', 0), cap.handle_session)
        srv.start()

        bee_info = {
            'timing': 'regular',
            'username': '******',
            'password': '******',
            'port': srv.server_port,
            'server': '127.0.0.1',
            'local_hostname': 'testhost'
        }
        beesessions = {}

        BaitSession.client_id = 'f51171df-c8f6-4af4-86c0-f4e163cf69e8'
        current_bee = bee_smtp.smtp(beesessions, bee_info)
        current_bee.connect()
        current_bee.login(bee_info['username'], bee_info['password'])
        result = current_bee.client.sendmail('*****@*****.**', '*****@*****.**', 'Just testing the SMTP bee')
        self.assertEquals(result, {})
        srv.stop()
Пример #2
0
    def test_retrieve(self):
        """ Tests if a mail can be properly retrieved from the mail corpus """

        sessions = {}
        users = {'test': BaitUser('test', 'test')}
        authenticator = Authenticator(users)
        Session.authenticator = authenticator

        cap = hive_smtp.smtp(sessions, {'enabled': 'True', 'port': 0, 'banner': 'Test'}, users, self.work_dir)
        srv = StreamServer(('0.0.0.0', 0), cap.handle_session)
        srv.start()
        gevent.sleep()
        bee_info = {
            'timing': 'regular',
            'username': '******',
            'password': '******',
            'port': srv.server_port,
            'server': '127.0.0.1',
            'local_hostname': 'testhost'
        }
        beesessions = {}

        BaitSession.client_id = 'f51171df-c8f6-4af4-86c0-f4e163cf69e8'
        current_bee = bee_smtp.smtp(beesessions, bee_info)

        from_addr, to_addr, mail_body = current_bee.get_one_mail()
        self.assertGreater(len(from_addr), 0)
        self.assertGreater(len(to_addr), 0)
        self.assertGreater(len(mail_body), 0)