示例#1
0
def main():
    testmodules = [os.path.splitext(x)[0] for x in os.listdir(HERE) if x.endswith(".py") and x.startswith("test_")]
    configure_logging()
    remove_test_files()
    suite = unittest.TestSuite()
    for t in testmodules:
        suite.addTest(unittest.defaultTestLoader.loadTestsFromName(t))
    result = unittest.TextTestRunner(verbosity=VERBOSITY).run(suite)
    return result.wasSuccessful()
示例#2
0
def main():
    testmodules = [os.path.splitext(x)[0] for x in os.listdir(HERE)
                   if x.endswith('.py') and x.startswith('test_')]
    configure_logging()
    remove_test_files()
    suite = unittest.TestSuite()
    for t in testmodules:
        # ...so that "make test" will print the full test paths
        t = "pyftpdlib.test.%s" % t
        suite.addTest(unittest.defaultTestLoader.loadTestsFromName(t))
    result = unittest.TextTestRunner(verbosity=VERBOSITY).run(suite)
    return result.wasSuccessful()
示例#3
0
def main(name=None):
    configure_logging()
    remove_test_files()
    runner = ColouredRunner(verbosity=VERBOSITY)
    try:
        result = runner.run(get_suite(name))
    except (KeyboardInterrupt, SystemExit) as err:
        print("received %s" % err.__class__.__name__, file=sys.stderr)
        runner.result.printErrors()
        sys.exit(1)
    else:
        success = result.wasSuccessful()
        sys.exit(0 if success else 1)
示例#4
0
            # (except OP_NO_SSLv2 whch is enabled by default unless
            # ssl_proto is set to SSL.SSLv23_METHOD).
            TLS_FTPHandler.ssl_context = None
            TLS_FTPHandler.ssl_options = None
            ctx = TLS_FTPHandler.get_ssl_context()
            with contextlib.closing(socket.socket()) as s:
                s = SSL.Connection(ctx, s)
                opts = lib.SSL_CTX_get_options(ctx._context)
                self.assertTrue(opts & SSL.OP_NO_SSLv2)
                # self.assertFalse(opts & SSL.OP_NO_SSLv3)
                self.assertFalse(opts & SSL.OP_NO_COMPRESSION)
        finally:
            TLS_FTPHandler.ssl_context = None

    if hasattr(ssl, "PROTOCOL_SSLv2"):

        def test_sslv2(self):
            self.client.ssl_version = ssl.PROTOCOL_SSLv2
            self.client.close()
            with self.server.lock:
                self.client.connect(self.server.host, self.server.port)
            self.assertRaises(socket.error, self.client.login)
            self.client.ssl_version = ssl.PROTOCOL_SSLv2


configure_logging()
remove_test_files()

if __name__ == '__main__':
    unittest.main(verbosity=VERBOSITY)
示例#5
0
            self.client.quit()

    def test_ssl_version(self):
        protos = [ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1]
        if hasattr(ssl, "PROTOCOL_SSLv2"):
            protos.append(ssl.PROTOCOL_SSLv2)
            for proto in protos:
                self.try_protocol_combo(ssl.PROTOCOL_SSLv2, proto)
        for proto in protos:
            self.try_protocol_combo(ssl.PROTOCOL_SSLv3, proto)
        for proto in protos:
            self.try_protocol_combo(ssl.PROTOCOL_SSLv23, proto)
        for proto in protos:
            self.try_protocol_combo(ssl.PROTOCOL_TLSv1, proto)

    if hasattr(ssl, "PROTOCOL_SSLv2"):
        def test_sslv2(self):
            self.client.ssl_version = ssl.PROTOCOL_SSLv2
            self.client.close()
            self.client.connect(self.server.host, self.server.port)
            self.assertRaises(socket.error, self.client.login)
            self.client.ssl_version = ssl.PROTOCOL_SSLv2


configure_logging()
remove_test_files()


if __name__ == '__main__':
    unittest.main(verbosity=VERBOSITY)