From 25f9d2214c53189f73955ea0203b1dbe9871bd61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20Vit=C3=A9?= Date: Thu, 6 Feb 2025 22:09:49 +0100 Subject: [PATCH] TestSSHAgent: Skip testDestinationConstraints() on OpenSSH < 8.9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Konrad Vité --- tests/TestSSHAgent.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/TestSSHAgent.cpp b/tests/TestSSHAgent.cpp index 152cb3fd6..58a09d6ed 100644 --- a/tests/TestSSHAgent.cpp +++ b/tests/TestSSHAgent.cpp @@ -24,6 +24,7 @@ #include "sshagent/SSHAgent.h" #include +#include QTEST_GUILESS_MAIN(TestSSHAgent) @@ -364,6 +365,21 @@ void TestSSHAgent::testConfirmConstraint() void TestSSHAgent::testDestinationConstraints() { + // ssh-agent does not support destination constraints before OpenSSH + // version 8.9. Therefore we want to skip this test on older versions. + // Unfortunately ssh-agent does not give us any way to retrieve its version + // number neither via protocol nor on the command line. Therefore we use + // the version number of the SSH client and assume it to be the same. + QProcess ssh; + ssh.setReadChannel(QProcess::StandardError); + ssh.start("ssh", QStringList() << "-V"); + ssh.waitForFinished(); + auto ssh_version = QString::fromUtf8(ssh.readLine()); + ssh_version.remove(QRegExp("^OpenSSH_")); + if (QVersionNumber ::fromString(ssh_version) < QVersionNumber(8, 9)) { + QSKIP("Test requires ssh-agent >= 8.9"); + } + SSHAgent agent; agent.setEnabled(true); agent.setAuthSockOverride(m_agentSocketFileName);