auth = self.authorizer_class() try: auth.impersonate_user('nobody', '') self.assertRaisesWithMsg(AuthorizerError, "super user privileges are required", UnixAuthorizer) finally: auth.terminate_impersonation('nobody') # ===================================================================== # --- Windows authorizer # ===================================================================== @unittest.skipUnless(WINDOWS, "Windows only") class TestWindowsAuthorizer(_SharedAuthorizerTests, unittest.TestCase): """Windows authorizer specific tests.""" authorizer_class = WindowsAuthorizer def test_wrong_anonymous_credentials(self): user = self.get_current_user() self.assertRaises(Win32ExtError, self.authorizer_class, anonymous_user=user, anonymous_password='******') if __name__ == '__main__': unittest.main(verbosity=VERBOSITY)
# (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)