aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/ssh/errorhandling/errorhandling.pro4
-rw-r--r--tests/manual/ssh/errorhandling/main.cpp206
-rw-r--r--tests/manual/ssh/remoteprocess/main.cpp49
-rw-r--r--tests/manual/ssh/remoteprocess/remoteprocess.pro5
-rw-r--r--tests/manual/ssh/remoteprocess/remoteprocesstest.cpp366
-rw-r--r--tests/manual/ssh/remoteprocess/remoteprocesstest.h76
-rw-r--r--tests/manual/ssh/sftp/argumentscollector.cpp171
-rw-r--r--tests/manual/ssh/sftp/argumentscollector.h52
-rw-r--r--tests/manual/ssh/sftp/main.cpp49
-rw-r--r--tests/manual/ssh/sftp/parameters.h34
-rw-r--r--tests/manual/ssh/sftp/sftp.pro6
-rw-r--r--tests/manual/ssh/sftp/sftptest.cpp631
-rw-r--r--tests/manual/ssh/sftp/sftptest.h102
-rw-r--r--tests/manual/ssh/shell/argumentscollector.cpp (renamed from tests/manual/ssh/remoteprocess/argumentscollector.cpp)0
-rw-r--r--tests/manual/ssh/shell/argumentscollector.h (renamed from tests/manual/ssh/remoteprocess/argumentscollector.h)0
-rw-r--r--tests/manual/ssh/shell/main.cpp2
-rw-r--r--tests/manual/ssh/shell/shell.pro4
-rw-r--r--tests/manual/ssh/ssh.pro2
-rw-r--r--tests/manual/ssh/tunnel/argumentscollector.cpp172
-rw-r--r--tests/manual/ssh/tunnel/argumentscollector.h51
-rw-r--r--tests/manual/ssh/tunnel/directtunnel.cpp164
-rw-r--r--tests/manual/ssh/tunnel/directtunnel.h74
-rw-r--r--tests/manual/ssh/tunnel/forwardtunnel.cpp146
-rw-r--r--tests/manual/ssh/tunnel/forwardtunnel.h70
-rw-r--r--tests/manual/ssh/tunnel/main.cpp59
-rw-r--r--tests/manual/ssh/tunnel/tunnel.pro12
26 files changed, 4 insertions, 2503 deletions
diff --git a/tests/manual/ssh/errorhandling/errorhandling.pro b/tests/manual/ssh/errorhandling/errorhandling.pro
deleted file mode 100644
index 1161d4642d..0000000000
--- a/tests/manual/ssh/errorhandling/errorhandling.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-include(../ssh.pri)
-
-TARGET=errorhandling
-SOURCES=main.cpp
diff --git a/tests/manual/ssh/errorhandling/main.cpp b/tests/manual/ssh/errorhandling/main.cpp
deleted file mode 100644
index 2140de5788..0000000000
--- a/tests/manual/ssh/errorhandling/main.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include <ssh/sftpchannel.h>
-#include <ssh/sshconnection.h>
-#include <ssh/sshremoteprocess.h>
-
-#include <QCoreApplication>
-#include <QList>
-#include <QObject>
-#include <QPair>
-#include <QTimer>
-
-#include <cstdlib>
-
-using namespace QSsh;
-
-class Test : public QObject {
- Q_OBJECT
-public:
- Test()
- {
- m_timeoutTimer.setSingleShot(true);
- m_connection = new SshConnection(SshConnectionParameters());
- if (m_connection->state() != SshConnection::Unconnected) {
- qDebug("Error: Newly created SSH connection has state %d.",
- m_connection->state());
- }
-
- if (m_connection->createRemoteProcess(""))
- qDebug("Error: Unconnected SSH connection creates remote process.");
- if (m_connection->createSftpChannel())
- qDebug("Error: Unconnected SSH connection creates SFTP channel.");
-
- SshConnectionParameters noHost;
- noHost.setHost("hgdfxgfhgxfhxgfchxgcf");
- noHost.setPort(12345);
- noHost.timeout = 10;
- noHost.authenticationType
- = SshConnectionParameters::AuthenticationTypeTryAllPasswordBasedMethods;
-
- SshConnectionParameters noUser;
- noUser.setHost("localhost");
- noUser.setPort(22);
- noUser.timeout = 30;
- noUser.authenticationType
- = SshConnectionParameters::AuthenticationTypeTryAllPasswordBasedMethods;
- noUser.setUserName("dumdidumpuffpuff");
- noUser.setPassword("whatever");
-
- SshConnectionParameters wrongPwd;
- wrongPwd.setHost("localhost");
- wrongPwd.setPort(22);
- wrongPwd.timeout = 30;
- wrongPwd.authenticationType
- = SshConnectionParameters::AuthenticationTypeTryAllPasswordBasedMethods;
- wrongPwd.setUserName("root");
- noUser.setPassword("thiscantpossiblybeapasswordcanit");
-
- SshConnectionParameters invalidKeyFile;
- invalidKeyFile.setHost("localhost");
- invalidKeyFile.setPort(22);
- invalidKeyFile.timeout = 30;
- invalidKeyFile.authenticationType = SshConnectionParameters::AuthenticationTypePublicKey;
- invalidKeyFile.setUserName("root");
- invalidKeyFile.privateKeyFile
- = QLatin1String("somefilenamethatwedontexpecttocontainavalidkey");
-
- // TODO: Create a valid key file and check for authentication error.
-
- m_testSet << TestItem("Behavior with non-existing host",
- noHost, ErrorList() << SshSocketError);
- m_testSet << TestItem("Behavior with non-existing user", noUser,
- ErrorList() << SshSocketError << SshTimeoutError
- << SshAuthenticationError);
- m_testSet << TestItem("Behavior with wrong password", wrongPwd,
- ErrorList() << SshSocketError << SshTimeoutError
- << SshAuthenticationError);
- m_testSet << TestItem("Behavior with invalid key file", invalidKeyFile,
- ErrorList() << SshSocketError << SshTimeoutError
- << SshKeyFileError);
-
- runNextTest();
- }
-
- ~Test()
- {
- delete m_connection;
- }
-
-private:
- void handleConnected()
- {
- qDebug("Error: Received unexpected connected() signal.");
- QCoreApplication::exit(EXIT_FAILURE);
- }
-
- void handleDisconnected()
- {
- qDebug("Error: Received unexpected disconnected() signal.");
- QCoreApplication::exit(EXIT_FAILURE);
- }
-
- void handleDataAvailable(const QString &msg)
- {
- qDebug("Error: Received unexpected dataAvailable() signal. "
- "Message was: '%s'.", qPrintable(msg));
- QCoreApplication::exit(EXIT_FAILURE);
- }
-
- void handleError(QSsh::SshError error)
- {
- if (m_testSet.isEmpty()) {
- qDebug("Error: Received error %d, but no test was running.", error);
- QCoreApplication::exit(EXIT_FAILURE);
- }
-
- const TestItem testItem = m_testSet.takeFirst();
- if (testItem.allowedErrors.contains(error)) {
- qDebug("Received error %d, as expected.", error);
- if (m_testSet.isEmpty()) {
- qDebug("All tests finished successfully.");
- QCoreApplication::quit();
- } else {
- runNextTest();
- }
- } else {
- qDebug("Received unexpected error %d.", error);
- QCoreApplication::exit(EXIT_FAILURE);
- }
- }
-
- void handleTimeout()
- {
- if (m_testSet.isEmpty()) {
- qDebug("Error: timeout, but no test was running.");
- QCoreApplication::exit(EXIT_FAILURE);
- }
- const TestItem testItem = m_testSet.takeFirst();
- qDebug("Error: The following test timed out: %s", testItem.description);
- }
-
- void runNextTest()
- {
- if (m_connection) {
- disconnect(m_connection, 0, this, 0);
- delete m_connection;
- }
- m_connection = new SshConnection(m_testSet.first().params);
- connect(m_connection, &SshConnection::connected, this, &Test::handleConnected);
- connect(m_connection, &SshConnection::disconnected, this, &Test::handleDisconnected);
- connect(m_connection, &SshConnection::dataAvailable, this, &Test::handleDataAvailable);
- connect(m_connection, &SshConnection::error, this, &Test::handleError);
- const TestItem &nextItem = m_testSet.first();
- m_timeoutTimer.stop();
- m_timeoutTimer.setInterval(qMax(10000, nextItem.params.timeout * 1000));
- qDebug("Testing: %s", nextItem.description);
- m_connection->connectToHost();
- }
-
- SshConnection *m_connection;
- typedef QList<SshError> ErrorList;
- struct TestItem {
- TestItem(const char *d, const SshConnectionParameters &p,
- const ErrorList &e) : description(d), params(p), allowedErrors(e) {}
-
- const char *description;
- SshConnectionParameters params;
- ErrorList allowedErrors;
- };
- QList<TestItem> m_testSet;
- QTimer m_timeoutTimer;
-};
-
-int main(int argc, char *argv[])
-{
- QCoreApplication a(argc, argv);
- Test t;
-
- return a.exec();
-}
-
-
-#include "main.moc"
diff --git a/tests/manual/ssh/remoteprocess/main.cpp b/tests/manual/ssh/remoteprocess/main.cpp
deleted file mode 100644
index 02d5d8ea3d..0000000000
--- a/tests/manual/ssh/remoteprocess/main.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "argumentscollector.h"
-#include "remoteprocesstest.h"
-
-#include <ssh/sshconnection.h>
-
-#include <QCoreApplication>
-#include <QObject>
-#include <QStringList>
-
-#include <cstdlib>
-#include <iostream>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
- bool parseSuccess;
- const QSsh::SshConnectionParameters &parameters
- = ArgumentsCollector(app.arguments()).collect(parseSuccess);
- if (!parseSuccess)
- return EXIT_FAILURE;
- RemoteProcessTest remoteProcessTest(parameters);
- remoteProcessTest.run();
- return app.exec();
-}
diff --git a/tests/manual/ssh/remoteprocess/remoteprocess.pro b/tests/manual/ssh/remoteprocess/remoteprocess.pro
deleted file mode 100644
index 11c31a0a36..0000000000
--- a/tests/manual/ssh/remoteprocess/remoteprocess.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-include(../ssh.pri)
-
-TARGET=remoteprocess
-SOURCES=main.cpp remoteprocesstest.cpp argumentscollector.cpp
-HEADERS=remoteprocesstest.h argumentscollector.h
diff --git a/tests/manual/ssh/remoteprocess/remoteprocesstest.cpp b/tests/manual/ssh/remoteprocess/remoteprocesstest.cpp
deleted file mode 100644
index 28540768b8..0000000000
--- a/tests/manual/ssh/remoteprocess/remoteprocesstest.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "remoteprocesstest.h"
-
-#include <ssh/sshpseudoterminal.h>
-
-#include <QCoreApplication>
-#include <QTextStream>
-#include <QTimer>
-
-#include <iostream>
-
-using namespace QSsh;
-
-const QByteArray StderrOutput("ChannelTest");
-
-RemoteProcessTest::RemoteProcessTest(const SshConnectionParameters &params)
- : m_sshParams(params),
- m_timeoutTimer(new QTimer(this)),
- m_sshConnection(0),
- m_remoteRunner(new SshRemoteProcessRunner(this)),
- m_state(Inactive)
-{
- m_timeoutTimer->setInterval(5000);
- connect(m_timeoutTimer, &QTimer::timeout, this, &RemoteProcessTest::handleTimeout);
-}
-
-RemoteProcessTest::~RemoteProcessTest()
-{
- delete m_sshConnection;
-}
-
-void RemoteProcessTest::run()
-{
- connect(m_remoteRunner, &SshRemoteProcessRunner::connectionError,
- this, &RemoteProcessTest::handleConnectionError);
- connect(m_remoteRunner, &SshRemoteProcessRunner::processStarted,
- this, &RemoteProcessTest::handleProcessStarted);
- connect(m_remoteRunner, &SshRemoteProcessRunner::readyReadStandardOutput,
- this, &RemoteProcessTest::handleProcessStdout);
- connect(m_remoteRunner, &SshRemoteProcessRunner::readyReadStandardError,
- this, &RemoteProcessTest::handleProcessStderr);
- connect(m_remoteRunner, &SshRemoteProcessRunner::processClosed,
- this, &RemoteProcessTest::handleProcessClosed);
-
- std::cout << "Testing successful remote process... " << std::flush;
- m_state = TestingSuccess;
- m_started = false;
- m_timeoutTimer->start();
- m_remoteRunner->run("ls -a /tmp", m_sshParams);
-}
-
-void RemoteProcessTest::handleConnectionError()
-{
- const QString error = m_state == TestingIoDevice || m_state == TestingProcessChannels
- ? m_sshConnection->errorString() : m_remoteRunner->lastConnectionErrorString();
-
- std::cerr << "Error: Connection failure (" << qPrintable(error) << ")." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
-}
-
-void RemoteProcessTest::handleProcessStarted()
-{
- if (m_started) {
- std::cerr << "Error: Received started() signal again." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- } else {
- m_started = true;
- if (m_state == TestingCrash) {
- SshRemoteProcessRunner * const killer = new SshRemoteProcessRunner(this);
- killer->run("pkill -9 sleep", m_sshParams);
- } else if (m_state == TestingIoDevice) {
- connect(m_catProcess.data(), &QIODevice::readyRead,
- this, &RemoteProcessTest::handleReadyRead);
- m_textStream = new QTextStream(m_catProcess.data());
- *m_textStream << testString();
- m_textStream->flush();
- }
- }
-}
-
-void RemoteProcessTest::handleProcessStdout()
-{
- if (!m_started) {
- std::cerr << "Error: Remote output from non-started process."
- << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- } else if (m_state != TestingSuccess && m_state != TestingTerminal) {
- std::cerr << "Error: Got remote standard output in state " << m_state
- << "." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- } else {
- m_remoteStdout += m_remoteRunner->readAllStandardOutput();
- }
-}
-
-void RemoteProcessTest::handleProcessStderr()
-{
- if (!m_started) {
- std::cerr << "Error: Remote error output from non-started process."
- << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- } else if (m_state == TestingSuccess) {
- std::cerr << "Error: Unexpected remote standard error output."
- << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- } else {
- m_remoteStderr += m_remoteRunner->readAllStandardError();
- }
-}
-
-void RemoteProcessTest::handleProcessClosed(int exitStatus)
-{
- switch (exitStatus) {
- case SshRemoteProcess::NormalExit:
- if (!m_started) {
- std::cerr << "Error: Process exited without starting." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- return;
- }
- switch (m_state) {
- case TestingSuccess: {
- const int exitCode = m_remoteRunner->processExitCode();
- if (exitCode != 0) {
- std::cerr << "Error: exit code is " << exitCode
- << ", expected zero." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- return;
- }
- if (m_remoteStdout.isEmpty()) {
- std::cerr << "Error: Command did not produce output."
- << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- return;
- }
-
- std::cout << "Ok.\nTesting unsuccessful remote process... " << std::flush;
- m_state = TestingFailure;
- m_started = false;
- m_timeoutTimer->start();
- m_remoteRunner->run("top -n 1", m_sshParams); // Does not succeed without terminal.
- break;
- }
- case TestingFailure: {
- const int exitCode = m_remoteRunner->processExitCode();
- if (exitCode == 0) {
- std::cerr << "Error: exit code is zero, expected non-zero."
- << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- return;
- }
- if (m_remoteStderr.isEmpty()) {
- std::cerr << "Error: Command did not produce error output." << std::flush;
- QCoreApplication::exit(EXIT_FAILURE);
- return;
- }
-
- std::cout << "Ok.\nTesting crashing remote process... " << std::flush;
- m_state = TestingCrash;
- m_started = false;
- m_timeoutTimer->start();
- m_remoteRunner->run("/bin/sleep 100", m_sshParams);
- break;
- }
- case TestingCrash:
- if (m_remoteRunner->processExitCode() == 0) {
- std::cerr << "Error: Successful exit from process that was "
- "supposed to crash." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- } else {
- // Some shells (e.g. mksh) don't report "killed", but just a non-zero exit code.
- handleSuccessfulCrashTest();
- }
- break;
- case TestingTerminal: {
- const int exitCode = m_remoteRunner->processExitCode();
- if (exitCode != 0) {
- std::cerr << "Error: exit code is " << exitCode
- << ", expected zero." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- return;
- }
- if (m_remoteStdout.isEmpty()) {
- std::cerr << "Error: Command did not produce output."
- << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- return;
- }
- std::cout << "Ok.\nTesting I/O device functionality... " << std::flush;
- m_state = TestingIoDevice;
- m_sshConnection = new SshConnection(m_sshParams);
- connect(m_sshConnection, &SshConnection::connected,
- this, &RemoteProcessTest::handleConnected);
- connect(m_sshConnection, &SshConnection::error,
- this, &RemoteProcessTest::handleConnectionError);
- m_sshConnection->connectToHost();
- m_timeoutTimer->start();
- break;
- }
- case TestingIoDevice:
- if (m_catProcess->exitCode() == 0) {
- std::cerr << "Error: Successful exit from process that was supposed to crash."
- << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- } else {
- handleSuccessfulIoTest();
- }
- break;
- case TestingProcessChannels:
- if (m_remoteStderr.isEmpty()) {
- std::cerr << "Error: Did not receive readyReadStderr()." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- return;
- }
- if (m_remoteData != StderrOutput) {
- std::cerr << "Error: Expected output '" << StderrOutput.data() << "', received '"
- << m_remoteData.data() << "'." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- return;
- }
- std::cout << "Ok.\nAll tests succeeded." << std::endl;
- QCoreApplication::quit();
- break;
- case Inactive:
- Q_ASSERT(false);
- }
- break;
- case SshRemoteProcess::FailedToStart:
- if (m_started) {
- std::cerr << "Error: Got 'failed to start' signal for process "
- "that has not started yet." << std::endl;
- } else {
- std::cerr << "Error: Process failed to start." << std::endl;
- }
- QCoreApplication::exit(EXIT_FAILURE);
- break;
- case SshRemoteProcess::CrashExit:
- switch (m_state) {
- case TestingCrash:
- handleSuccessfulCrashTest();
- break;
- case TestingIoDevice:
- handleSuccessfulIoTest();
- break;
- default:
- std::cerr << "Error: Unexpected crash." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- return;
- }
- }
-}
-
-void RemoteProcessTest::handleTimeout()
-{
- std::cerr << "Error: Timeout waiting for progress." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
-}
-
-void RemoteProcessTest::handleConnected()
-{
- Q_ASSERT(m_state == TestingIoDevice);
-
- m_catProcess = m_sshConnection->createRemoteProcess(QString::fromLatin1("/bin/cat").toUtf8());
- connect(m_catProcess.data(), &SshRemoteProcess::started,
- this, &RemoteProcessTest::handleProcessStarted);
- connect(m_catProcess.data(), &SshRemoteProcess::closed,
- this, &RemoteProcessTest::handleProcessClosed);
- m_started = false;
- m_timeoutTimer->start();
- m_catProcess->start();
-}
-
-QString RemoteProcessTest::testString() const
-{
- return QLatin1String("x\r\n");
-}
-
-void RemoteProcessTest::handleReadyRead()
-{
- switch (m_state) {
- case TestingIoDevice: {
- const QString &data = QString::fromUtf8(m_catProcess->readAll());
- if (data != testString()) {
- std::cerr << "Testing of QIODevice functionality failed: Expected '"
- << qPrintable(testString()) << "', got '" << qPrintable(data) << "'." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
- }
- SshRemoteProcessRunner * const killer = new SshRemoteProcessRunner(this);
- killer->run("pkill -9 cat", m_sshParams);
- break;
- }
- case TestingProcessChannels:
- m_remoteData += m_echoProcess->readAll();
- break;
- default:
- qFatal("%s: Unexpected state %d.", Q_FUNC_INFO, m_state);
- }
-
-}
-
-void RemoteProcessTest::handleReadyReadStdout()
-{
- Q_ASSERT(m_state == TestingProcessChannels);
-
- std::cerr << "Error: Received unexpected stdout data." << std::endl;
- QCoreApplication::exit(EXIT_FAILURE);
-}
-
-void RemoteProcessTest::handleReadyReadStderr()
-{
- Q_ASSERT(m_state == TestingProcessChannels);
-
- m_remoteStderr = "dummy";
-}
-
-void RemoteProcessTest::handleSuccessfulCrashTest()
-{
- std::cout << "Ok.\nTesting remote process with terminal... " << std::flush;
- m_state = TestingTerminal;
- m_started = false;
- m_timeoutTimer->start();
- m_remoteRunner->runInTerminal("top -n 1", SshPseudoTerminal(), m_sshParams);
-}
-
-void RemoteProcessTest::handleSuccessfulIoTest()
-{
- std::cout << "Ok\nTesting process channels... " << std::flush;
- m_state = TestingProcessChannels;
- m_started = false;
- m_remoteStderr.clear();
- m_echoProcess = m_sshConnection->createRemoteProcess("printf " + StderrOutput + " >&2");
- m_echoProcess->setReadChannel(QProcess::StandardError);
- connect(m_echoProcess.data(), &SshRemoteProcess::started,
- this, &RemoteProcessTest::handleProcessStarted);
- connect(m_echoProcess.data(), &SshRemoteProcess::closed,
- this, &RemoteProcessTest::handleProcessClosed);
- connect(m_echoProcess.data(), &QIODevice::readyRead,
- this, &RemoteProcessTest::handleReadyRead);
- connect(m_echoProcess.data(), &SshRemoteProcess::readyReadStandardError,
- this, &RemoteProcessTest::handleReadyReadStderr);
- m_echoProcess->start();
- m_timeoutTimer->start();
-}
diff --git a/tests/manual/ssh/remoteprocess/remoteprocesstest.h b/tests/manual/ssh/remoteprocess/remoteprocesstest.h
deleted file mode 100644
index b3c8ebc3e3..0000000000
--- a/tests/manual/ssh/remoteprocess/remoteprocesstest.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include <ssh/sshremoteprocessrunner.h>
-
-#include <QObject>
-
-QT_FORWARD_DECLARE_CLASS(QTextStream)
-QT_FORWARD_DECLARE_CLASS(QTimer)
-
-class RemoteProcessTest : public QObject
-{
- Q_OBJECT
-public:
- RemoteProcessTest(const QSsh::SshConnectionParameters &params);
- ~RemoteProcessTest();
- void run();
-
-private:
- enum State {
- Inactive, TestingSuccess, TestingFailure, TestingCrash, TestingTerminal, TestingIoDevice,
- TestingProcessChannels
- };
-
- void handleConnectionError();
- void handleProcessStarted();
- void handleProcessStdout();
- void handleProcessStderr();
- void handleProcessClosed(int exitStatus);
- void handleTimeout();
- void handleReadyRead();
- void handleReadyReadStdout();
- void handleReadyReadStderr();
- void handleConnected();
-
- QString testString() const;
- void handleSuccessfulCrashTest();
- void handleSuccessfulIoTest();
-
- const QSsh::SshConnectionParameters m_sshParams;
- QTimer * const m_timeoutTimer;
- QTextStream *m_textStream;
- QSsh::SshRemoteProcess::Ptr m_catProcess;
- QSsh::SshRemoteProcess::Ptr m_echoProcess;
- QSsh::SshConnection *m_sshConnection;
- QSsh::SshRemoteProcessRunner * const m_remoteRunner;
- QByteArray m_remoteStdout;
- QByteArray m_remoteStderr;
- QByteArray m_remoteData;
- State m_state;
- bool m_started;
-};
diff --git a/tests/manual/ssh/sftp/argumentscollector.cpp b/tests/manual/ssh/sftp/argumentscollector.cpp
deleted file mode 100644
index be8cb743b0..0000000000
--- a/tests/manual/ssh/sftp/argumentscollector.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "argumentscollector.h"
-
-#include <iostream>
-
-using namespace QSsh;
-
-using namespace std;
-
-ArgumentsCollector::ArgumentsCollector(const QStringList &args)
- : m_arguments(args)
-{
-}
-
-Parameters ArgumentsCollector::collect(bool &success) const
-{
- Parameters parameters;
- parameters.sshParams.options &= ~SshIgnoreDefaultProxy;
- try {
- bool authTypeGiven = false;
- bool portGiven = false;
- bool timeoutGiven = false;
- bool smallFileCountGiven = false;
- bool bigFileSizeGiven = false;
- bool proxySettingGiven = false;
- int pos;
- int port = 22;
- for (pos = 1; pos < m_arguments.count() - 1; ++pos) {
- QString host;
- QString user;
- if (checkAndSetStringArg(pos, host, "-h") || checkAndSetStringArg(pos, user, "-u")) {
- parameters.sshParams.setHost(host);
- parameters.sshParams.setUserName(user);
- continue;
- }
- if (checkAndSetIntArg(pos, port, portGiven, "-p")
- || checkAndSetIntArg(pos, parameters.sshParams.timeout, timeoutGiven, "-t")
- || checkAndSetIntArg(pos, parameters.smallFileCount, smallFileCountGiven, "-c")
- || checkAndSetIntArg(pos, parameters.bigFileSize, bigFileSizeGiven, "-s"))
- continue;
- QString pass;
- if (checkAndSetStringArg(pos, pass, "-pwd")) {
- parameters.sshParams.setPassword(pass);
- if (!parameters.sshParams.privateKeyFile.isEmpty())
- throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
- parameters.sshParams.authenticationType
- = SshConnectionParameters::AuthenticationTypeTryAllPasswordBasedMethods;
- authTypeGiven = true;
- continue;
- }
- if (checkAndSetStringArg(pos, parameters.sshParams.privateKeyFile, "-k")) {
- if (!parameters.sshParams.password().isEmpty())
- throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
- parameters.sshParams.authenticationType
- = SshConnectionParameters::AuthenticationTypePublicKey;
- authTypeGiven = true;
- continue;
- }
- if (!checkForNoProxy(pos, parameters.sshParams.options, proxySettingGiven))
- throw ArgumentErrorException(QLatin1String("unknown option ") + m_arguments.at(pos));
- }
-
- Q_ASSERT(pos <= m_arguments.count());
- if (pos == m_arguments.count() - 1) {
- if (!checkForNoProxy(pos, parameters.sshParams.options, proxySettingGiven))
- throw ArgumentErrorException(QLatin1String("unknown option ") + m_arguments.at(pos));
- }
-
- if (!authTypeGiven)
- throw ArgumentErrorException(QLatin1String("No authentication argument given."));
- if (parameters.sshParams.host().isEmpty())
- throw ArgumentErrorException(QLatin1String("No host given."));
- if (parameters.sshParams.userName().isEmpty())
- throw ArgumentErrorException(QLatin1String("No user name given."));
-
- parameters.sshParams.setPort(portGiven ? port : 22);
- if (!timeoutGiven)
- parameters.sshParams.timeout = 30;
- if (!smallFileCountGiven)
- parameters.smallFileCount = 1000;
- if (!bigFileSizeGiven)
- parameters.bigFileSize = 1024;
- success = true;
- } catch (ArgumentErrorException &ex) {
- cerr << "Error: " << qPrintable(ex.error) << endl;
- printUsage();
- success = false;
- }
- return parameters;
-}
-
-void ArgumentsCollector::printUsage() const
-{
- cerr << "Usage: " << qPrintable(m_arguments.first())
- << " -h <host> -u <user> "
- << "-pwd <password> | -k <private key file> [ -p <port> ] "
- << "[ -t <timeout> ] [ -c <small file count> ] "
- << "[ -s <big file size in MB> ] [ -no-proxy ]" << endl;
-}
-
-bool ArgumentsCollector::checkAndSetStringArg(int &pos, QString &arg, const char *opt) const
-{
- if (m_arguments.at(pos) == QLatin1String(opt)) {
- if (!arg.isEmpty()) {
- throw ArgumentErrorException(QLatin1String("option ") + QLatin1String(opt)
- + QLatin1String(" was given twice."));
- }
- arg = m_arguments.at(++pos);
- if (arg.isEmpty() && QLatin1String(opt) != QLatin1String("-pwd"))
- throw ArgumentErrorException(QLatin1String("empty argument not allowed here."));
- return true;
- }
- return false;
-}
-
-bool ArgumentsCollector::checkAndSetIntArg(int &pos, int &val,
- bool &alreadyGiven, const char *opt) const
-{
- if (m_arguments.at(pos) == QLatin1String(opt)) {
- if (alreadyGiven) {
- throw ArgumentErrorException(QLatin1String("option ") + QLatin1String(opt)
- + QLatin1String(" was given twice."));
- }
- bool isNumber;
- val = m_arguments.at(++pos).toInt(&isNumber);
- if (!isNumber) {
- throw ArgumentErrorException(QLatin1String("option ") + QLatin1String(opt)
- + QLatin1String(" needs integer argument"));
- }
- alreadyGiven = true;
- return true;
- }
- return false;
-}
-
-bool ArgumentsCollector::checkForNoProxy(int &pos, SshConnectionOptions &options,
- bool &alreadyGiven) const
-{
- if (m_arguments.at(pos) == QLatin1String("-no-proxy")) {
- if (alreadyGiven)
- throw ArgumentErrorException(QLatin1String("proxy setting given twice."));
- options |= SshIgnoreDefaultProxy;
- alreadyGiven = true;
- return true;
- }
- return false;
-}
diff --git a/tests/manual/ssh/sftp/argumentscollector.h b/tests/manual/ssh/sftp/argumentscollector.h
deleted file mode 100644
index 67b69a7f47..0000000000
--- a/tests/manual/ssh/sftp/argumentscollector.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include "parameters.h"
-
-#include <QStringList>
-
-class ArgumentsCollector
-{
-public:
- ArgumentsCollector(const QStringList &args);
- Parameters collect(bool &success) const;
-private:
- struct ArgumentErrorException
- {
- ArgumentErrorException(const QString &error) : error(error) {}
- const QString error;
- };
-
- void printUsage() const;
- bool checkAndSetStringArg(int &pos, QString &arg, const char *opt) const;
- bool checkAndSetIntArg(int &pos, int &val, bool &alreadyGiven,
- const char *opt) const;
- bool checkForNoProxy(int &pos, QSsh::SshConnectionOptions &options,
- bool &alreadyGiven) const;
-
- const QStringList m_arguments;
-};
diff --git a/tests/manual/ssh/sftp/main.cpp b/tests/manual/ssh/sftp/main.cpp
deleted file mode 100644
index 2eccedee32..0000000000
--- a/tests/manual/ssh/sftp/main.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "argumentscollector.h"
-#include "sftptest.h"
-
-#include <ssh/sftpchannel.h>
-#include <ssh/sshconnection.h>
-
-#include <QCoreApplication>
-#include <QObject>
-#include <QStringList>
-
-#include <cstdlib>
-#include <iostream>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
- bool parseSuccess;
- const Parameters parameters = ArgumentsCollector(app.arguments()).collect(parseSuccess);
- if (!parseSuccess)
- return EXIT_FAILURE;
- SftpTest sftpTest(parameters);
- sftpTest.run();
- return app.exec();
-}
diff --git a/tests/manual/ssh/sftp/parameters.h b/tests/manual/ssh/sftp/parameters.h
deleted file mode 100644
index d947fa9d7d..0000000000
--- a/tests/manual/ssh/sftp/parameters.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include <ssh/sshconnection.h>
-
-struct Parameters {
- QSsh::SshConnectionParameters sshParams;
- int smallFileCount;
- int bigFileSize;
-};
diff --git a/tests/manual/ssh/sftp/sftp.pro b/tests/manual/ssh/sftp/sftp.pro
deleted file mode 100644
index abb26a865c..0000000000
--- a/tests/manual/ssh/sftp/sftp.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-include(../ssh.pri)
-
-TARGET = sftp
-SOURCES = main.cpp sftptest.cpp argumentscollector.cpp
-HEADERS = sftptest.h argumentscollector.h parameters.h
-
diff --git a/tests/manual/ssh/sftp/sftptest.cpp b/tests/manual/ssh/sftp/sftptest.cpp
deleted file mode 100644
index 928c53f6e3..0000000000
--- a/tests/manual/ssh/sftp/sftptest.cpp
+++ /dev/null
@@ -1,631 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "sftptest.h"
-
-#include <QCoreApplication>
-#include <QDateTime>
-#include <QDir>
-#include <QFile>
-#include <QFileInfo>
-
-#include <iostream>
-
-#include <cstdlib>
-
-using namespace QSsh;
-
-SftpTest::SftpTest(const Parameters &params)
- : m_parameters(params), m_state(Inactive), m_error(false), m_connection(0),
- m_bigFileUploadJob(SftpInvalidJob),
- m_bigFileDownloadJob(SftpInvalidJob),
- m_bigFileRemovalJob(SftpInvalidJob),
- m_mkdirJob(SftpInvalidJob),
- m_statDirJob(SftpInvalidJob),
- m_lsDirJob(SftpInvalidJob),
- m_rmDirJob(SftpInvalidJob)
-{
-}
-
-SftpTest::~SftpTest()
-{
- removeFiles(true);
- delete m_connection;
-}
-
-void SftpTest::run()
-{
- m_connection = new SshConnection(m_parameters.sshParams);
- connect(m_connection, &SshConnection::connected, this, &SftpTest::handleConnected);
- connect(m_connection, &SshConnection::error, this, &SftpTest::handleError);
- connect(m_connection, &SshConnection::disconnected, this, &SftpTest::handleDisconnected);
- std::cout << "Connecting to host '"
- << qPrintable(m_parameters.sshParams.host()) << "'..." << std::endl;
- m_state = Connecting;
- m_connection->connectToHost();
-}
-
-void SftpTest::handleConnected()
-{
- if (m_state != Connecting) {
- std::cerr << "Unexpected state " << m_state << " in function "
- << Q_FUNC_INFO << "." << std::endl;
- earlyDisconnectFromHost();
- } else {
- std::cout << "Connected. Initializing SFTP channel..." << std::endl;
- m_channel = m_connection->createSftpChannel();
- connect(m_channel.data(), &SftpChannel::initialized,
- this, &SftpTest::handleChannelInitialized);
- connect(m_channel.data(), &SftpChannel::channelError,
- this, &SftpTest::handleChannelInitializationFailure);
- connect(m_channel.data(), &SftpChannel::finished,
- this, static_cast<void (SftpTest::*)(QSsh::SftpJobId, const QString &)>(
- &SftpTest::handleJobFinished));
- connect(m_channel.data(), &SftpChannel::fileInfoAvailable,
- this, &SftpTest::handleFileInfo);
- connect(m_channel.data(), &SftpChannel::closed,
- this, &SftpTest::handleChannelClosed);
- m_state = InitializingChannel;
- m_channel->initialize();
- }
-}
-
-void SftpTest::handleDisconnected()
-{
- if (m_state != Disconnecting) {
- std::cerr << "Unexpected state " << m_state << " in function "
- << Q_FUNC_INFO << std::endl;
- m_error = true;
- } else {
- std::cout << "Connection closed." << std::endl;
- }
- std::cout << "Test finished. ";
- if (m_error)
- std::cout << "There were errors.";
- else
- std::cout << "No errors encountered.";
- std::cout << std::endl;
- QCoreApplication::exit(m_error ? EXIT_FAILURE : EXIT_SUCCESS);
-}
-
-void SftpTest::handleError()
-{
- std::cerr << "Encountered SSH error: "
- << qPrintable(m_connection->errorString()) << "." << std::endl;
- m_error = true;
- m_state = Disconnecting;
- QCoreApplication::exit(EXIT_FAILURE);
-}
-
-void SftpTest::handleChannelInitialized()
-{
- if (m_state != InitializingChannel) {
- std::cerr << "Unexpected state " << m_state << "in function "
- << Q_FUNC_INFO << "." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
-
- std::cout << "Creating " << m_parameters.smallFileCount
- << " files of 1 KB each ..." << std::endl;
- std::srand(QDateTime::currentDateTime().toSecsSinceEpoch());
- for (int i = 0; i < m_parameters.smallFileCount; ++i) {
- const QString fileName
- = QLatin1String("sftptestfile") + QString::number(i + 1);
- const FilePtr file(new QFile(QDir::tempPath() + QLatin1Char('/')
- + fileName));
- bool success = true;
- if (!file->open(QIODevice::WriteOnly | QIODevice::Truncate))
- success = false;
- if (success) {
- int content[1024/sizeof(int)];
- for (size_t j = 0; j < sizeof content / sizeof content[0]; ++j)
- content[j] = qrand();
- file->write(reinterpret_cast<char *>(content), sizeof content);
- file->close();
- }
- success = success && file->error() == QFile::NoError;
- if (!success) {
- std::cerr << "Error creating local file "
- << qPrintable(file->fileName()) << "." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- m_localSmallFiles << file;
- }
- std::cout << "Files created. Now uploading..." << std::endl;
- foreach (const FilePtr &file, m_localSmallFiles) {
- const QString localFilePath = file->fileName();
- const QString remoteFp
- = remoteFilePath(QFileInfo(localFilePath).fileName());
- const SftpJobId uploadJob = m_channel->uploadFile(file->fileName(),
- remoteFp, SftpOverwriteExisting);
- if (uploadJob == SftpInvalidJob) {
- std::cerr << "Error uploading local file "
- << qPrintable(localFilePath) << " to remote file "
- << qPrintable(remoteFp) << "." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- m_smallFilesUploadJobs.insert(uploadJob, remoteFp);
- }
- m_state = UploadingSmall;
-}
-
-void SftpTest::handleChannelInitializationFailure(const QString &reason)
-{
- std::cerr << "Could not initialize SFTP channel: " << qPrintable(reason)
- << "." << std::endl;
- earlyDisconnectFromHost();
-}
-
-void SftpTest::handleChannelClosed()
-{
- if (m_state != ChannelClosing) {
- std::cerr << "Unexpected state " << m_state << " in function "
- << Q_FUNC_INFO << "." << std::endl;
- } else {
- std::cout << "SFTP channel closed. Now disconnecting..." << std::endl;
- }
- m_state = Disconnecting;
- m_connection->disconnectFromHost();
-}
-
-void SftpTest::handleJobFinished(SftpJobId job, const QString &error)
-{
- switch (m_state) {
- case UploadingSmall:
- if (!handleJobFinished(job, m_smallFilesUploadJobs, error, "uploading"))
- return;
- if (m_smallFilesUploadJobs.isEmpty()) {
- std::cout << "Uploading finished, now downloading for comparison..."
- << std::endl;
- foreach (const FilePtr &file, m_localSmallFiles) {
- const QString localFilePath = file->fileName();
- const QString remoteFp
- = remoteFilePath(QFileInfo(localFilePath).fileName());
- const QString downloadFilePath = cmpFileName(localFilePath);
- const SftpJobId downloadJob = m_channel->downloadFile(remoteFp,
- downloadFilePath, SftpOverwriteExisting);
- if (downloadJob == SftpInvalidJob) {
- std::cerr << "Error downloading remote file "
- << qPrintable(remoteFp) << " to local file "
- << qPrintable(downloadFilePath) << "." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- m_smallFilesDownloadJobs.insert(downloadJob, remoteFp);
- }
- m_state = DownloadingSmall;
- }
- break;
- case DownloadingSmall:
- if (!handleJobFinished(job, m_smallFilesDownloadJobs, error, "downloading"))
- return;
- if (m_smallFilesDownloadJobs.isEmpty()) {
- std::cout << "Downloading finished, now comparing..." << std::endl;
- foreach (const FilePtr &ptr, m_localSmallFiles) {
- if (!ptr->open(QIODevice::ReadOnly)) {
- std::cerr << "Error opening local file "
- << qPrintable(ptr->fileName()) << "." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- const QString downloadedFilePath = cmpFileName(ptr->fileName());
- QFile downloadedFile(downloadedFilePath);
- if (!downloadedFile.open(QIODevice::ReadOnly)) {
- std::cerr << "Error opening downloaded file "
- << qPrintable(downloadedFilePath) << "." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- if (!compareFiles(ptr.data(), &downloadedFile))
- return;
- }
-
- std::cout << "Comparisons successful, now removing files..."
- << std::endl;
- QList<QString> remoteFilePaths;
- foreach (const FilePtr &ptr, m_localSmallFiles) {
- const QString downloadedFilePath = cmpFileName(ptr->fileName());
- remoteFilePaths
- << remoteFilePath(QFileInfo(ptr->fileName()).fileName());
- if (!ptr->remove()) {
- std::cerr << "Error: Failed to remove local file '"
- << qPrintable(ptr->fileName()) << "'." << std::endl;
- earlyDisconnectFromHost();
- }
- if (!QFile::remove(downloadedFilePath)) {
- std::cerr << "Error: Failed to remove downloaded file '"
- << qPrintable(downloadedFilePath) << "'." << std::endl;
- earlyDisconnectFromHost();
- }
- }
- m_localSmallFiles.clear();
- foreach (const QString &remoteFp, remoteFilePaths) {
- m_smallFilesRemovalJobs.insert(m_channel->removeFile(remoteFp),
- remoteFp);
- }
- m_state = RemovingSmall;
- }
- break;
- case RemovingSmall:
- if (!handleJobFinished(job, m_smallFilesRemovalJobs, error, "removing"))
- return;
- if (m_smallFilesRemovalJobs.isEmpty()) {
- std::cout << "Small files successfully removed. "
- << "Now creating big file..." << std::endl;
- const QLatin1String bigFileName("sftpbigfile");
- m_localBigFile = FilePtr(new QFile(QDir::tempPath()
- + QLatin1Char('/') + bigFileName));
- bool success = m_localBigFile->open(QIODevice::WriteOnly);
- const int blockSize = 8192;
- const quint64 blockCount
- = static_cast<quint64>(m_parameters.bigFileSize)*1024*1024/blockSize;
- for (quint64 block = 0; block < blockCount; ++block) {
- int content[blockSize/sizeof(int)];
- for (size_t j = 0; j < sizeof content / sizeof content[0]; ++j)
- content[j] = qrand();
- m_localBigFile->write(reinterpret_cast<char *>(content),
- sizeof content);
- }
- m_localBigFile->close();
- success = success && m_localBigFile->error() == QFile::NoError;
- if (!success) {
- std::cerr << "Error trying to create big file '"
- << qPrintable(m_localBigFile->fileName()) << "'."
- << std::endl;
- earlyDisconnectFromHost();
- return;
- }
-
- std::cout << "Big file created. Now uploading ..." << std::endl;
- m_bigJobTimer.start();
- m_bigFileUploadJob
- = m_channel->uploadFile(m_localBigFile->fileName(),
- remoteFilePath(bigFileName), SftpOverwriteExisting);
- if (m_bigFileUploadJob == SftpInvalidJob) {
- std::cerr << "Error uploading file '" << bigFileName.latin1()
- << "'." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- m_state = UploadingBig;
- }
- break;
- case UploadingBig: {
- if (!handleBigJobFinished(job, m_bigFileUploadJob, error, "uploading"))
- return;
- const qint64 msecs = m_bigJobTimer.elapsed();
- std::cout << "Successfully uploaded big file. Took " << (msecs/1000)
- << " seconds for " << m_parameters.bigFileSize << " MB."
- << std::endl;
- const QString localFilePath = m_localBigFile->fileName();
- const QString downloadedFilePath = cmpFileName(localFilePath);
- const QString remoteFp
- = remoteFilePath(QFileInfo(localFilePath).fileName());
- std::cout << "Now downloading big file for comparison..." << std::endl;
- m_bigJobTimer.start();
- m_bigFileDownloadJob = m_channel->downloadFile(remoteFp,
- downloadedFilePath, SftpOverwriteExisting);
- if (m_bigFileDownloadJob == SftpInvalidJob) {
- std::cerr << "Error downloading remote file '"
- << qPrintable(remoteFp) << "' to local file '"
- << qPrintable(downloadedFilePath) << "'." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- m_state = DownloadingBig;
- break;
- }
- case DownloadingBig: {
- if (!handleBigJobFinished(job, m_bigFileDownloadJob, error, "downloading"))
- return;
- const qint64 msecs = m_bigJobTimer.elapsed();
- std::cout << "Successfully downloaded big file. Took " << (msecs/1000)
- << " seconds for " << m_parameters.bigFileSize << " MB."
- << std::endl;
- std::cout << "Now comparing big files..." << std::endl;
- QFile downloadedFile(cmpFileName(m_localBigFile->fileName()));
- if (!downloadedFile.open(QIODevice::ReadOnly)) {
- std::cerr << "Error opening downloaded file '"
- << qPrintable(downloadedFile.fileName()) << "': "
- << qPrintable(downloadedFile.errorString()) << "." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- if (!m_localBigFile->open(QIODevice::ReadOnly)) {
- std::cerr << "Error opening big file '"
- << qPrintable(m_localBigFile->fileName()) << "': "
- << qPrintable(m_localBigFile->errorString()) << "."
- << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- if (!compareFiles(m_localBigFile.data(), &downloadedFile))
- return;
- std::cout << "Comparison successful. Now removing big files..."
- << std::endl;
- if (!m_localBigFile->remove()) {
- std::cerr << "Error: Could not remove file '"
- << qPrintable(m_localBigFile->fileName()) << "'." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- if (!downloadedFile.remove()) {
- std::cerr << "Error: Could not remove file '"
- << qPrintable(downloadedFile.fileName()) << "'." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- const QString remoteFp
- = remoteFilePath(QFileInfo(m_localBigFile->fileName()).fileName());
- m_bigFileRemovalJob = m_channel->removeFile(remoteFp);
- m_state = RemovingBig;
- break;
- }
- case RemovingBig:
- if (!handleBigJobFinished(job, m_bigFileRemovalJob, error, "removing"))
- return;
- std::cout << "Big files successfully removed. "
- << "Now creating remote directory..." << std::endl;
- m_remoteDirPath = QLatin1String("/tmp/sftptest-") + QDateTime::currentDateTime().toString();
- m_mkdirJob = m_channel->createDirectory(m_remoteDirPath);
- m_state = CreatingDir;
- break;
- case CreatingDir:
- if (!handleJobFinished(job, m_mkdirJob, error, "creating remote directory"))
- return;
- std::cout << "Directory successfully created. Now checking directory attributes..."
- << std::endl;
- m_statDirJob = m_channel->statFile(m_remoteDirPath);
- m_state = CheckingDirAttributes;
- break;
- case CheckingDirAttributes: {
- if (!handleJobFinished(job, m_statDirJob, error, "checking directory attributes"))
- return;
- if (m_dirInfo.type != FileTypeDirectory) {
- std::cerr << "Error: Newly created directory has file type " << m_dirInfo.type
- << ", expected was " << FileTypeDirectory << "." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- const QString fileName = QFileInfo(m_remoteDirPath).fileName();
- if (m_dirInfo.name != fileName) {
- std::cerr << "Error: Remote directory reports file name '"
- << qPrintable(m_dirInfo.name) << "', expected '" << qPrintable(fileName) << "'."
- << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- std::cout << "Directory attributes ok. Now checking directory contents..." << std::endl;
- m_lsDirJob = m_channel->listDirectory(m_remoteDirPath);
- m_state = CheckingDirContents;
- break;
- }
- case CheckingDirContents:
- if (!handleJobFinished(job, m_lsDirJob, error, "checking directory contents"))
- return;
- if (m_dirContents.count() != 2) {
- std::cerr << "Error: Remote directory has " << m_dirContents.count()
- << " entries, expected 2." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- foreach (const SftpFileInfo &fi, m_dirContents) {
- if (fi.type != FileTypeDirectory) {
- std::cerr << "Error: Remote directory has entry of type " << fi.type
- << ", expected " << FileTypeDirectory << "." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- if (fi.name != QLatin1String(".") && fi.name != QLatin1String("..")) {
- std::cerr << "Error: Remote directory has entry '" << qPrintable(fi.name)
- << "', expected '.' or '..'." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- }
- if (m_dirContents.first().name == m_dirContents.last().name) {
- std::cerr << "Error: Remote directory has two entries of the same name." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- std::cout << "Directory contents ok. Now removing directory..." << std::endl;
- m_rmDirJob = m_channel->removeDirectory(m_remoteDirPath);
- m_state = RemovingDir;
- break;
- case RemovingDir:
- if (!handleJobFinished(job, m_rmDirJob, error, "removing directory"))
- return;
- std::cout << "Directory successfully removed. Now closing the SFTP channel..." << std::endl;
- m_state = ChannelClosing;
- m_channel->closeChannel();
- break;
- case Disconnecting:
- break;
- default:
- if (!m_error) {
- std::cerr << "Unexpected state " << m_state << " in function "
- << Q_FUNC_INFO << "." << std::endl;
- earlyDisconnectFromHost();
- }
- }
-}
-
-void SftpTest::handleFileInfo(SftpJobId job, const QList<SftpFileInfo> &fileInfoList)
-{
- switch (m_state) {
- case CheckingDirAttributes: {
- static int count = 0;
- if (!checkJobId(job, m_statDirJob, "checking directory attributes"))
- return;
- if (++count > 1) {
- std::cerr << "Error: More than one reply for directory attributes check." << std::endl;
- earlyDisconnectFromHost();
- return;
- }
- m_dirInfo = fileInfoList.first();
- break;
- }
- case CheckingDirContents:
- if (!checkJobId(job, m_lsDirJob, "checking directory contents"))
- return;
- m_dirContents << fileInfoList;
- break;
- default:
- std::cerr << "Error: Unexpected file info in state " << m_state << "." << std::endl;
- earlyDisconnectFromHost();
- }
-}
-
-void SftpTest::removeFile(const FilePtr &file, bool remoteToo)
-{
- if (!file)
- return;
- const QString localFilePath = file->fileName();
- file->remove();
- QFile::remove(cmpFileName(localFilePath));
- if (remoteToo && m_channel
- && m_channel->state() == SftpChannel::Initialized)
- m_channel->removeFile(remoteFilePath(QFileInfo(localFilePath).fileName()));
-}
-
-QString SftpTest::cmpFileName(const QString &fileName) const
-{
- return fileName + QLatin1String(".cmp");
-}
-
-QString SftpTest::remoteFilePath(const QString &localFileName) const
-{
- return QLatin1String("/tmp/") + localFileName + QLatin1String(".upload");
-}
-
-void SftpTest::earlyDisconnectFromHost()
-{
- m_error = true;
- removeFiles(true);
- if (m_channel)
- disconnect(m_channel.data(), 0, this, 0);
- m_state = Disconnecting;
- m_connection->disconnectFromHost();
-}
-
-bool SftpTest::checkJobId(SftpJobId job, SftpJobId expectedJob, const char *activity)
-{
- if (job != expectedJob) {
- std::cerr << "Error " << activity << ": Expected job id " << expectedJob
- << ", got job id " << job << '.' << std::endl;
- earlyDisconnectFromHost();
- return false;
- }
- return true;
-}
-
-void SftpTest::removeFiles(bool remoteToo)
-{
- foreach (const FilePtr &file, m_localSmallFiles)
- removeFile(file, remoteToo);
- removeFile(m_localBigFile, remoteToo);
-}
-
-bool SftpTest::handleJobFinished(SftpJobId job, JobMap &jobMap,
- const QString &error, const char *activity)
-{
- JobMap::Iterator it = jobMap.find(job);
- if (it == jobMap.end()) {
- std::cerr << "Error: Unknown job " << job << "finished."
- << std::endl;
- earlyDisconnectFromHost();
- return false;
- }
- if (!error.isEmpty()) {
- std::cerr << "Error " << activity << " file " << qPrintable(it.value())
- << ": " << qPrintable(error) << "." << std::endl;
- earlyDisconnectFromHost();
- return false;
- }
- jobMap.erase(it);
- return true;
-}
-
-bool SftpTest::handleJobFinished(SftpJobId job, SftpJobId expectedJob, const QString &error,
- const char *activity)
-{
- if (!checkJobId(job, expectedJob, activity))
- return false;
- if (!error.isEmpty()) {
- std::cerr << "Error " << activity << ": " << qPrintable(error) << "." << std::endl;
- earlyDisconnectFromHost();
- return false;
- }
- return true;
-}
-
-bool SftpTest::handleBigJobFinished(SftpJobId job, SftpJobId expectedJob,
- const QString &error, const char *activity)
-{
- if (job != expectedJob) {
- std::cerr << "Error " << activity << " file '"
- << qPrintable(m_localBigFile->fileName())
- << "': Expected job id " << expectedJob
- << ", got job id " << job << '.' << std::endl;
- earlyDisconnectFromHost();
- return false;
- }
- if (!error.isEmpty()) {
- std::cerr << "Error " << activity << " file '"
- << qPrintable(m_localBigFile->fileName()) << "': "
- << qPrintable(error) << std::endl;
- earlyDisconnectFromHost();
- return false;
- }
- return true;
-}
-
-bool SftpTest::compareFiles(QFile *orig, QFile *copy)
-{
- bool success = orig->size() == copy->size();
- qint64 bytesLeft = orig->size();
- orig->seek(0);
- while (success && bytesLeft > 0) {
- const qint64 bytesToRead = qMin(bytesLeft, Q_INT64_C(1024*1024));
- const QByteArray origBlock = orig->read(bytesToRead);
- const QByteArray copyBlock = copy->read(bytesToRead);
- if (origBlock.size() != bytesToRead || origBlock != copyBlock)
- success = false;
- bytesLeft -= bytesToRead;
- }
- orig->close();
- success = success && orig->error() == QFile::NoError
- && copy->error() == QFile::NoError;
- if (!success) {
- std::cerr << "Error: Original file '" << qPrintable(orig->fileName())
- << "'' differs from downloaded file '"
- << qPrintable(copy->fileName()) << "'." << std::endl;
- earlyDisconnectFromHost();
- }
- return success;
-}
diff --git a/tests/manual/ssh/sftp/sftptest.h b/tests/manual/ssh/sftp/sftptest.h
deleted file mode 100644
index 97b13217ee..0000000000
--- a/tests/manual/ssh/sftp/sftptest.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include "parameters.h"
-
-#include <ssh/sftpchannel.h>
-#include <ssh/sshconnection.h>
-
-#include <QElapsedTimer>
-#include <QHash>
-#include <QList>
-#include <QObject>
-#include <QSharedPointer>
-
-QT_FORWARD_DECLARE_CLASS(QFile);
-
-class SftpTest : public QObject
-{
- Q_OBJECT
-public:
- SftpTest(const Parameters &params);
- ~SftpTest();
- void run();
-
-private:
- typedef QHash<QSsh::SftpJobId, QString> JobMap;
- typedef QSharedPointer<QFile> FilePtr;
- enum State {
- Inactive, Connecting, InitializingChannel, UploadingSmall, DownloadingSmall,
- RemovingSmall, UploadingBig, DownloadingBig, RemovingBig, CreatingDir,
- CheckingDirAttributes, CheckingDirContents, RemovingDir, ChannelClosing, Disconnecting
- };
-
- void handleConnected();
- void handleError();
- void handleDisconnected();
- void handleChannelInitialized();
- void handleChannelInitializationFailure(const QString &reason);
- void handleJobFinished(QSsh::SftpJobId job, const QString &error);
- void handleFileInfo(QSsh::SftpJobId job, const QList<QSsh::SftpFileInfo> &fileInfoList);
- void handleChannelClosed();
-
- void removeFile(const FilePtr &filePtr, bool remoteToo);
- void removeFiles(bool remoteToo);
- QString cmpFileName(const QString &localFileName) const;
- QString remoteFilePath(const QString &localFileName) const;
- void earlyDisconnectFromHost();
- bool checkJobId(QSsh::SftpJobId job, QSsh::SftpJobId expectedJob, const char *activity);
- bool handleJobFinished(QSsh::SftpJobId job, JobMap &jobMap,
- const QString &error, const char *activity);
- bool handleJobFinished(QSsh::SftpJobId job, QSsh::SftpJobId expectedJob, const QString &error,
- const char *activity);
- bool handleBigJobFinished(QSsh::SftpJobId job, QSsh::SftpJobId expectedJob,
- const QString &error, const char *activity);
- bool compareFiles(QFile *orig, QFile *copy);
-
- const Parameters m_parameters;
- State m_state;
- bool m_error;
- QSsh::SshConnection *m_connection;
- QSsh::SftpChannel::Ptr m_channel;
- QList<FilePtr> m_localSmallFiles;
- JobMap m_smallFilesUploadJobs;
- JobMap m_smallFilesDownloadJobs;
- JobMap m_smallFilesRemovalJobs;
- FilePtr m_localBigFile;
- QSsh::SftpJobId m_bigFileUploadJob;
- QSsh::SftpJobId m_bigFileDownloadJob;
- QSsh::SftpJobId m_bigFileRemovalJob;
- QSsh::SftpJobId m_mkdirJob;
- QSsh::SftpJobId m_statDirJob;
- QSsh::SftpJobId m_lsDirJob;
- QSsh::SftpJobId m_rmDirJob;
- QElapsedTimer m_bigJobTimer;
- QString m_remoteDirPath;
- QSsh::SftpFileInfo m_dirInfo;
- QList<QSsh::SftpFileInfo> m_dirContents;
-};
diff --git a/tests/manual/ssh/remoteprocess/argumentscollector.cpp b/tests/manual/ssh/shell/argumentscollector.cpp
index cc9839363a..cc9839363a 100644
--- a/tests/manual/ssh/remoteprocess/argumentscollector.cpp
+++ b/tests/manual/ssh/shell/argumentscollector.cpp
diff --git a/tests/manual/ssh/remoteprocess/argumentscollector.h b/tests/manual/ssh/shell/argumentscollector.h
index 5f195cf1f0..5f195cf1f0 100644
--- a/tests/manual/ssh/remoteprocess/argumentscollector.h
+++ b/tests/manual/ssh/shell/argumentscollector.h
diff --git a/tests/manual/ssh/shell/main.cpp b/tests/manual/ssh/shell/main.cpp
index 894eac6898..8890342d45 100644
--- a/tests/manual/ssh/shell/main.cpp
+++ b/tests/manual/ssh/shell/main.cpp
@@ -23,7 +23,7 @@
**
****************************************************************************/
-#include "../remoteprocess/argumentscollector.h"
+#include "argumentscollector.h"
#include "shell.h"
#include <ssh/sshconnection.h>
diff --git a/tests/manual/ssh/shell/shell.pro b/tests/manual/ssh/shell/shell.pro
index ed3b0d987e..f7d0b174f0 100644
--- a/tests/manual/ssh/shell/shell.pro
+++ b/tests/manual/ssh/shell/shell.pro
@@ -2,5 +2,5 @@ include(../ssh.pri)
QT += network
TARGET=shell
-SOURCES=main.cpp shell.cpp ../remoteprocess/argumentscollector.cpp
-HEADERS=shell.h ../remoteprocess/argumentscollector.h
+SOURCES=main.cpp shell.cpp argumentscollector.cpp
+HEADERS=shell.h argumentscollector.h
diff --git a/tests/manual/ssh/ssh.pro b/tests/manual/ssh/ssh.pro
index fdfd768132..1801bd1d9b 100644
--- a/tests/manual/ssh/ssh.pro
+++ b/tests/manual/ssh/ssh.pro
@@ -5,4 +5,4 @@
#-------------------------------------------------
TEMPLATE = subdirs
-SUBDIRS = errorhandling sftp remoteprocess shell sftpfsmodel tunnel
+SUBDIRS = shell sftpfsmodel
diff --git a/tests/manual/ssh/tunnel/argumentscollector.cpp b/tests/manual/ssh/tunnel/argumentscollector.cpp
deleted file mode 100644
index 15d73901d2..0000000000
--- a/tests/manual/ssh/tunnel/argumentscollector.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "argumentscollector.h"
-
-#include <QDir>
-#include <QProcessEnvironment>
-
-#include <iostream>
-
-using namespace QSsh;
-
-using namespace std;
-
-ArgumentsCollector::ArgumentsCollector(const QStringList &args)
- : m_arguments(args)
-{
-}
-
-SshConnectionParameters ArgumentsCollector::collect(bool &success) const
-{
- SshConnectionParameters parameters;
- parameters.options &= ~SshIgnoreDefaultProxy;
- parameters.setHost("localhost");
-
- try {
- bool authTypeGiven = false;
- bool portGiven = false;
- bool timeoutGiven = false;
- bool proxySettingGiven = false;
- int pos;
- int port = 22;
-
- for (pos = 1; pos < m_arguments.count() - 1; ++pos) {
- QString user;
- if (checkAndSetStringArg(pos, user, "-u")) {
- parameters.setUserName(user);
- continue;
- }
- if (checkAndSetIntArg(pos, port, portGiven, "-p")
- || checkAndSetIntArg(pos, parameters.timeout, timeoutGiven, "-t"))
- continue;
- QString pass;
- if (checkAndSetStringArg(pos, pass, "-pwd")) {
- parameters.setPassword(pass);
- if (!parameters.privateKeyFile.isEmpty())
- throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
- parameters.authenticationType
- = SshConnectionParameters::AuthenticationTypeTryAllPasswordBasedMethods;
- authTypeGiven = true;
- continue;
- }
- if (checkAndSetStringArg(pos, parameters.privateKeyFile, "-k")) {
- if (!parameters.password().isEmpty())
- throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
- parameters.authenticationType
- = SshConnectionParameters::AuthenticationTypePublicKey;
- authTypeGiven = true;
- continue;
- }
- if (!checkForNoProxy(pos, parameters.options, proxySettingGiven))
- throw ArgumentErrorException(QLatin1String("unknown option ") + m_arguments.at(pos));
- }
-
- Q_ASSERT(pos <= m_arguments.count());
- if (pos == m_arguments.count() - 1) {
- if (!checkForNoProxy(pos, parameters.options, proxySettingGiven))
- throw ArgumentErrorException(QLatin1String("unknown option ") + m_arguments.at(pos));
- }
-
- if (!authTypeGiven) {
- parameters.authenticationType = SshConnectionParameters::AuthenticationTypePublicKey;
- parameters.privateKeyFile = QDir::homePath() + QLatin1String("/.ssh/id_rsa");
- }
-
- if (parameters.userName().isEmpty())
- parameters.setUserName(QProcessEnvironment::systemEnvironment().value("USER"));
- if (parameters.userName().isEmpty())
- throw ArgumentErrorException(QLatin1String("No user name given."));
-
- if (parameters.host().isEmpty())
- throw ArgumentErrorException(QLatin1String("No host given."));
-
- parameters.setPort(portGiven ? port : 22);
- if (!timeoutGiven)
- parameters.timeout = 30;
- success = true;
- } catch (ArgumentErrorException &ex) {
- cerr << "Error: " << qPrintable(ex.error) << endl;
- printUsage();
- success = false;
- }
- return parameters;
-}
-
-void ArgumentsCollector::printUsage() const
-{
- cerr << "Usage: " << qPrintable(m_arguments.first())
- << "[ -u <user> ] "
- << "[ -pwd <password> | -k <private key file> ] [ -p <port> ] "
- << "[ -t <timeout> ] [ -no-proxy ]" << endl;
-}
-
-bool ArgumentsCollector::checkAndSetStringArg(int &pos, QString &arg, const char *opt) const
-{
- if (m_arguments.at(pos) == QLatin1String(opt)) {
- if (!arg.isEmpty()) {
- throw ArgumentErrorException(QLatin1String("option ") + QLatin1String(opt)
- + QLatin1String(" was given twice."));
- }
- arg = m_arguments.at(++pos);
- if (arg.isEmpty() && QLatin1String(opt) != QLatin1String("-pwd"))
- throw ArgumentErrorException(QLatin1String("empty argument not allowed here."));
- return true;
- }
- return false;
-}
-
-bool ArgumentsCollector::checkAndSetIntArg(int &pos, int &val,
- bool &alreadyGiven, const char *opt) const
-{
- if (m_arguments.at(pos) == QLatin1String(opt)) {
- if (alreadyGiven) {
- throw ArgumentErrorException(QLatin1String("option ") + QLatin1String(opt)
- + QLatin1String(" was given twice."));
- }
- bool isNumber;
- val = m_arguments.at(++pos).toInt(&isNumber);
- if (!isNumber) {
- throw ArgumentErrorException(QLatin1String("option ") + QLatin1String(opt)
- + QLatin1String(" needs integer argument"));
- }
- alreadyGiven = true;
- return true;
- }
- return false;
-}
-
-bool ArgumentsCollector::checkForNoProxy(int &pos, SshConnectionOptions &options,
- bool &alreadyGiven) const
-{
- if (m_arguments.at(pos) == QLatin1String("-no-proxy")) {
- if (alreadyGiven)
- throw ArgumentErrorException(QLatin1String("proxy setting given twice."));
- options |= SshIgnoreDefaultProxy;
- alreadyGiven = true;
- return true;
- }
- return false;
-}
diff --git a/tests/manual/ssh/tunnel/argumentscollector.h b/tests/manual/ssh/tunnel/argumentscollector.h
deleted file mode 100644
index 5f195cf1f0..0000000000
--- a/tests/manual/ssh/tunnel/argumentscollector.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include <ssh/sshconnection.h>
-
-#include <QStringList>
-
-class ArgumentsCollector
-{
-public:
- ArgumentsCollector(const QStringList &args);
- QSsh::SshConnectionParameters collect(bool &success) const;
-private:
- struct ArgumentErrorException
- {
- ArgumentErrorException(const QString &error) : error(error) {}
- const QString error;
- };
-
- void printUsage() const;
- bool checkAndSetStringArg(int &pos, QString &arg, const char *opt) const;
- bool checkAndSetIntArg(int &pos, int &val, bool &alreadyGiven,
- const char *opt) const;
- bool checkForNoProxy(int &pos, QSsh::SshConnectionOptions &options, bool &alreadyGiven) const;
-
- const QStringList m_arguments;
-};
diff --git a/tests/manual/ssh/tunnel/directtunnel.cpp b/tests/manual/ssh/tunnel/directtunnel.cpp
deleted file mode 100644
index 54f4c3a3e5..0000000000
--- a/tests/manual/ssh/tunnel/directtunnel.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "directtunnel.h"
-
-#include <ssh/sshconnection.h>
-#include <ssh/sshdirecttcpiptunnel.h>
-
-#include <QCoreApplication>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QTimer>
-
-#include <cstdlib>
-#include <iostream>
-
-const QByteArray ServerDataPrefix("Received the following data: ");
-const QByteArray TestData("Urgsblubb?");
-
-using namespace QSsh;
-
-DirectTunnel::DirectTunnel(const SshConnectionParameters &parameters, QObject *parent)
- : QObject(parent),
- m_connection(new SshConnection(parameters, this)),
- m_targetServer(new QTcpServer(this)),
- m_expectingChannelClose(false)
-{
- connect(m_connection, &SshConnection::connected, this, &DirectTunnel::handleConnected);
- connect(m_connection, &SshConnection::error, this, &DirectTunnel::handleConnectionError);
-}
-
-DirectTunnel::~DirectTunnel()
-{
-}
-
-void DirectTunnel::run()
-{
- std::cout << "Connecting to SSH server..." << std::endl;
- m_connection->connectToHost();
-}
-
-void DirectTunnel::handleConnectionError()
-{
- std::cerr << "SSH connection error: " << qPrintable(m_connection->errorString()) << std::endl;
- emit finished(EXIT_FAILURE);
-}
-
-void DirectTunnel::handleConnected()
-{
- std::cout << "Opening server side..." << std::endl;
- if (!m_targetServer->listen(QHostAddress::LocalHost)) {
- std::cerr << "Error opening port: "
- << m_targetServer->errorString().toLocal8Bit().constData() << std::endl;
- emit finished(EXIT_FAILURE);
- return;
- }
- m_targetPort = m_targetServer->serverPort();
- connect(m_targetServer, &QTcpServer::newConnection, this, &DirectTunnel::handleNewConnection);
-
- m_tunnel = m_connection->createDirectTunnel(QLatin1String("localhost"), 1024, // made-up values
- QLatin1String("localhost"), m_targetPort);
- connect(m_tunnel.data(), &SshDirectTcpIpTunnel::initialized,
- this, &DirectTunnel::handleInitialized);
- connect(m_tunnel.data(), &SshDirectTcpIpTunnel::error,
- this, &DirectTunnel::handleTunnelError);
- connect(m_tunnel.data(), &QIODevice::readyRead, this, &DirectTunnel::handleServerData);
- connect(m_tunnel.data(), &QIODevice::aboutToClose, this, &DirectTunnel::handleTunnelClosed);
-
- std::cout << "Initializing tunnel..." << std::endl;
- m_tunnel->initialize();
-}
-
-void DirectTunnel::handleInitialized()
-{
- std::cout << "Writing data into the tunnel..." << std::endl;
- m_tunnel->write(TestData);
- QTimer * const timeoutTimer = new QTimer(this);
- connect(timeoutTimer, &QTimer::timeout, this, &DirectTunnel::handleTimeout);
- timeoutTimer->start(10000);
-}
-
-void DirectTunnel::handleServerData()
-{
- m_dataReceivedFromServer += m_tunnel->readAll();
- if (m_dataReceivedFromServer == ServerDataPrefix + TestData) {
- std::cout << "Data exchange successful. Closing server socket..." << std::endl;
- m_expectingChannelClose = true;
- m_targetSocket->close();
- }
-}
-
-void DirectTunnel::handleTunnelError(const QString &reason)
-{
- std::cerr << "Tunnel error: " << reason.toLocal8Bit().constData() << std::endl;
- emit finished(EXIT_FAILURE);
-}
-
-void DirectTunnel::handleTunnelClosed()
-{
- if (m_expectingChannelClose) {
- std::cout << "Successfully detected channel close." << std::endl;
- std::cout << "Test finished successfully." << std::endl;
- emit finished(EXIT_SUCCESS);
- } else {
- std::cerr << "Error: Remote host closed channel." << std::endl;
- emit finished(EXIT_FAILURE);
- }
-}
-
-void DirectTunnel::handleNewConnection()
-{
- m_targetSocket = m_targetServer->nextPendingConnection();
- m_targetServer->close();
- connect(m_targetSocket,
- static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error),
- this, &DirectTunnel::handleSocketError);
- connect(m_targetSocket, &QIODevice::readyRead, this, &DirectTunnel::handleClientData);
- handleClientData();
-}
-
-void DirectTunnel::handleSocketError()
-{
- std::cerr << "Socket error: " << m_targetSocket->errorString().toLocal8Bit().constData()
- << std::endl;
- emit finished(EXIT_FAILURE);
-}
-
-void DirectTunnel::handleClientData()
-{
- m_dataReceivedFromClient += m_targetSocket->readAll();
- if (m_dataReceivedFromClient == TestData) {
- std::cout << "Client data successfully received by server, now sending data to client..."
- << std::endl;
- m_targetSocket->write(ServerDataPrefix + m_dataReceivedFromClient);
- }
-}
-
-void DirectTunnel::handleTimeout()
-{
- std::cerr << "Error: Timeout waiting for test completion." << std::endl;
- emit finished(EXIT_FAILURE);
-}
diff --git a/tests/manual/ssh/tunnel/directtunnel.h b/tests/manual/ssh/tunnel/directtunnel.h
deleted file mode 100644
index b73fcd9d63..0000000000
--- a/tests/manual/ssh/tunnel/directtunnel.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include <QObject>
-#include <QSharedPointer>
-
-QT_BEGIN_NAMESPACE
-class QTcpServer;
-class QTcpSocket;
-QT_END_NAMESPACE
-
-namespace QSsh {
-class SshConnection;
-class SshConnectionParameters;
-class SshDirectTcpIpTunnel;
-}
-
-class DirectTunnel : public QObject
-{
- Q_OBJECT
-public:
- DirectTunnel(const QSsh::SshConnectionParameters &parameters, QObject *parent = 0);
- ~DirectTunnel();
-
- void run();
-
-signals:
- void finished(int errorCode);
-
-private:
- void handleConnected();
- void handleConnectionError();
- void handleServerData();
- void handleInitialized();
- void handleTunnelError(const QString &reason);
- void handleTunnelClosed();
- void handleNewConnection();
- void handleSocketError();
- void handleClientData();
- void handleTimeout();
-
- QSsh::SshConnection * const m_connection;
- QSharedPointer<QSsh::SshDirectTcpIpTunnel> m_tunnel;
- QTcpServer * const m_targetServer;
- QTcpSocket *m_targetSocket;
- quint16 m_targetPort;
- QByteArray m_dataReceivedFromServer;
- QByteArray m_dataReceivedFromClient;
- bool m_expectingChannelClose;
-};
diff --git a/tests/manual/ssh/tunnel/forwardtunnel.cpp b/tests/manual/ssh/tunnel/forwardtunnel.cpp
deleted file mode 100644
index e80dbad30b..0000000000
--- a/tests/manual/ssh/tunnel/forwardtunnel.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "forwardtunnel.h"
-
-#include <ssh/sshconnection.h>
-#include <ssh/sshtcpipforwardserver.h>
-
-#include <QCoreApplication>
-#include <QTcpServer>
-#include <QTcpSocket>
-
-#include <iostream>
-
-const QByteArray ClientDataPrefix("Received the following data: ");
-const QByteArray TestData("Urgsblubb?");
-
-ForwardTunnel::ForwardTunnel(const QSsh::SshConnectionParameters &parameters, QObject *parent)
- : QObject(parent),
- m_connection(new QSsh::SshConnection(parameters, this)),
- m_targetSocket(0),
- m_targetPort(0)
-{
- connect(m_connection, &QSsh::SshConnection::connected, this, &ForwardTunnel::handleConnected);
- connect(m_connection, &QSsh::SshConnection::error, this, &ForwardTunnel::handleConnectionError);
-}
-
-void ForwardTunnel::run()
-{
- std::cout << "Connecting to SSH server..." << std::endl;
- m_connection->connectToHost();
-}
-
-void ForwardTunnel::handleConnected()
-{
- {
- QTcpServer server;
- if (server.listen(QHostAddress::LocalHost)) {
- m_targetPort = server.serverPort();
- } else {
- std::cerr << "Error while searching for free port: "
- << server.errorString().toLocal8Bit().constData() << std::endl;
- emit finished(EXIT_FAILURE);
- }
- }
-
- std::cout << "Initializing tunnel..." << std::endl;
- m_server = m_connection->createForwardServer(QLatin1String("localhost"), m_targetPort);
- connect(m_server.data(), &QSsh::SshTcpIpForwardServer::newConnection,
- this, &ForwardTunnel::handleNewConnection);
- connect(m_server.data(), &QSsh::SshTcpIpForwardServer::stateChanged,
- this, [this](QSsh::SshTcpIpForwardServer::State state) {
- if (state == QSsh::SshTcpIpForwardServer::Listening)
- handleInitialized();
- else if (state == QSsh::SshTcpIpForwardServer::Inactive)
- handleServerClosed();
- });
- connect(m_server.data(), &QSsh::SshTcpIpForwardServer::error,
- this, &ForwardTunnel::handleServerError);
-
- m_server->initialize();
-}
-
-void ForwardTunnel::handleConnectionError(QSsh::SshError error)
-{
- std::cout << "SSH connection error: " << error << " " << qPrintable(m_connection->errorString())
- << std::endl;
- emit finished(EXIT_FAILURE);
-}
-
-void ForwardTunnel::handleInitialized()
-{
- std::cout << "Forward tunnel initialized, connecting ..." << std::endl;
- m_targetSocket = new QTcpSocket(this);
- connect(m_targetSocket, &QTcpSocket::connected, this, [this](){
- m_targetSocket->write(ClientDataPrefix + TestData);
- });
-
- connect(m_targetSocket, &QTcpSocket::readyRead, this, [this](){
- m_dataReceivedFromServer += m_targetSocket->readAll();
- if (m_dataReceivedFromServer == ClientDataPrefix + TestData) {
- std::cout << "Data exchange successful. Closing client socket..." << std::endl;
- m_targetSocket->close();
- }
- });
- m_targetSocket->connectToHost(QLatin1String("localhost"), m_targetPort);
-}
-
-void ForwardTunnel::handleServerError(const QString &reason)
-{
- std::cerr << "Tunnel error:" << reason.toUtf8().constData() << std::endl;
- emit finished(EXIT_FAILURE);
-}
-
-void ForwardTunnel::handleServerClosed()
-{
- std::cout << "Forward tunnel closed" << std::endl;
- emit finished(EXIT_SUCCESS);
-}
-
-void ForwardTunnel::handleNewConnection()
-{
- std::cout << "Connection established" << std::endl;
- QSsh::SshForwardedTcpIpTunnel::Ptr tunnel = m_server->nextPendingConnection();
-
- connect(tunnel.data(), &QIODevice::readyRead, this, [this, tunnel](){
- m_dataReceivedFromClient += tunnel->readAll();
- if (m_dataReceivedFromClient == ClientDataPrefix + TestData) {
- std::cout << "Data received successful. Sending it back..." << std::endl;
- tunnel->write(m_dataReceivedFromClient);
- }
- });
-
- connect(tunnel.data(), &QIODevice::aboutToClose, this, [this](){
- std::cout << "Server Connection closed, closing tunnel" << std::endl;
- m_server->close();
- });
-}
-
-void ForwardTunnel::handleSocketError()
-{
- std::cerr << "Socket error" << std::endl;
- emit finished(EXIT_FAILURE);
-}
diff --git a/tests/manual/ssh/tunnel/forwardtunnel.h b/tests/manual/ssh/tunnel/forwardtunnel.h
deleted file mode 100644
index fd3bf35d40..0000000000
--- a/tests/manual/ssh/tunnel/forwardtunnel.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include "ssh/ssherrors.h"
-
-#include <QObject>
-#include <QSharedPointer>
-
-QT_BEGIN_NAMESPACE
-class QTcpSocket;
-QT_END_NAMESPACE
-
-namespace QSsh {
-class SshConnection;
-class SshConnectionParameters;
-class SshTcpIpForwardServer;
-}
-
-class ForwardTunnel : public QObject
-{
- Q_OBJECT
-public:
- ForwardTunnel(const QSsh::SshConnectionParameters &parameters,
- QObject *parent = 0);
- void run();
-
-signals:
- void finished(int exitCode);
-
-private:
- void handleConnected();
- void handleConnectionError(QSsh::SshError error);
- void handleInitialized();
- void handleServerError(const QString &reason);
- void handleServerClosed();
- void handleNewConnection();
- void handleSocketError();
-
- QSsh::SshConnection * const m_connection;
- QSharedPointer<QSsh::SshTcpIpForwardServer> m_server;
- QTcpSocket *m_targetSocket;
- quint16 m_targetPort;
-
- QByteArray m_dataReceivedFromServer;
- QByteArray m_dataReceivedFromClient;
-};
diff --git a/tests/manual/ssh/tunnel/main.cpp b/tests/manual/ssh/tunnel/main.cpp
deleted file mode 100644
index e9c2061845..0000000000
--- a/tests/manual/ssh/tunnel/main.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "../remoteprocess/argumentscollector.h"
-#include "directtunnel.h"
-#include "forwardtunnel.h"
-
-#include <ssh/sshconnection.h>
-
-#include <QCoreApplication>
-#include <QObject>
-#include <QStringList>
-
-#include <cstdlib>
-#include <iostream>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
- bool parseSuccess;
- QSsh::SshConnectionParameters parameters
- = ArgumentsCollector(app.arguments()).collect(parseSuccess);
- parameters.setHost("127.0.0.1");
- if (!parseSuccess)
- return EXIT_FAILURE;
-
- DirectTunnel direct(parameters);
-
- parameters.setHost("127.0.0.2");
- ForwardTunnel forward(parameters);
- forward.run();
-
- QObject::connect(&forward, &ForwardTunnel::finished, &direct, &DirectTunnel::run);
- QObject::connect(&direct, &DirectTunnel::finished, &app, &QCoreApplication::exit);
-
- return app.exec();
-}
diff --git a/tests/manual/ssh/tunnel/tunnel.pro b/tests/manual/ssh/tunnel/tunnel.pro
deleted file mode 100644
index 3d36634f7c..0000000000
--- a/tests/manual/ssh/tunnel/tunnel.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-include(../ssh.pri)
-
-TARGET =tunnel
-SOURCES = \
- main.cpp \
- argumentscollector.cpp \
- directtunnel.cpp \
- forwardtunnel.cpp
-HEADERS = \
- argumentscollector.h \
- directtunnel.h \
- forwardtunnel.h