Skip to content

Commit

Permalink
TestSSHAgent: Skip testDestinationConstraints() on OpenSSH < 8.9
Browse files Browse the repository at this point in the history
Signed-off-by: Konrad Gräfe <kgraefe@paktolos.net>
  • Loading branch information
kgraefe committed Feb 15, 2024
1 parent 58bf74c commit e6ff96b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/TestSSHAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "sshagent/SSHAgent.h"

#include <QTest>
#include <QVersionNumber>

QTEST_GUILESS_MAIN(TestSSHAgent)

Expand Down Expand Up @@ -365,6 +366,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);
Expand Down

0 comments on commit e6ff96b

Please sign in to comment.