From 19fe571c92abf54697beffd9fe75c42bd976ffed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Hrdina?= Date: Wed, 1 Mar 2023 13:09:48 +0100 Subject: [PATCH] Adding test /CoreOS/nmap/Regression/bz2140101-ncat-does-not-work-with-proxy --- .../main.fmf | 23 +++++++ .../runtest.sh | 68 +++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 Regression/bz2140101-ncat-does-not-work-with-proxy/main.fmf create mode 100755 Regression/bz2140101-ncat-does-not-work-with-proxy/runtest.sh diff --git a/Regression/bz2140101-ncat-does-not-work-with-proxy/main.fmf b/Regression/bz2140101-ncat-does-not-work-with-proxy/main.fmf new file mode 100644 index 0000000..d708b38 --- /dev/null +++ b/Regression/bz2140101-ncat-does-not-work-with-proxy/main.fmf @@ -0,0 +1,23 @@ +summary: ncat does not work with --proxy +description: '' +enabled: true +link: + - relates: https://bugzilla.redhat.com/show_bug.cgi?id=2140101 +tag: + - Tier1 +adjust: + - enabled: false + when: distro <= rhel-6 + continue: false +contact: fhrdina@redhat.com +component: + - nmap +test: ./runtest.sh +framework: beakerlib +recommend: + - nmap + - openssh-clients +duration: 1h +extra-nitrate: TC#0614605 +extra-summary: /CoreOS/nmap/Regression/bz2140101-ncat-does-not-work-with-proxy +extra-task: /CoreOS/nmap/Regression/bz2140101-ncat-does-not-work-with-proxy diff --git a/Regression/bz2140101-ncat-does-not-work-with-proxy/runtest.sh b/Regression/bz2140101-ncat-does-not-work-with-proxy/runtest.sh new file mode 100755 index 0000000..78da061 --- /dev/null +++ b/Regression/bz2140101-ncat-does-not-work-with-proxy/runtest.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/nmap/Regression/bz2140101-ncat-does-not-work-with-proxy +# Description: ncat does not work with --proxy +# Author: Martin Osvald +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2022 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="nmap" +SSH_LOG="ssh.log" +NCAT_LOG="ncat.log" + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlFileBackup --clean "/root/.ssh/" + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + HOSTNAME=$(/usr/bin/hostnamectl --transient 2>/dev/null) || \ + HOSTNAME=$(/usr/bin/hostname 2>/dev/null) || \ + HOSTNAME=$(/usr/bin/uname -n) + [ -z "$HOSTNAME" ] && rlFail "Cannot determine machine's hostname" + rlRun "ssh-keygen -a 1024 -t ed25519 -f /root/.ssh/id_ed25519_ncat-proxy-test -C ncat-proxy-test -N \"\"" 0 "Creating ssh keys" + rlRun "chmod 600 /root/.ssh/id_ed25519_ncat-proxy-test*" 0 + rlRun "cat /root/.ssh/id_ed25519_ncat-proxy-test.pub >> /root/.ssh/authorized_keys" 0 + rlRun "ssh -f -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i /root/.ssh/id_ed25519_ncat-proxy-test -D 1080 -NTv root@$HOSTNAME &> $SSH_LOG" 0 "Starting ssh" + rlLog "SSH LOG:" + SSH_LOG_OUTPUT=$(cat ${SSH_LOG}) + rlLog "$SSH_LOG_OUTPUT" + ncat -i 5 --proxy 127.0.0.1:1080 --proxy-type socks5 -vv github.com 22 2>&1 &> $NCAT_LOG + NCAT_LOG_OUTPUT=$(cat ${NCAT_LOG}) + rlLog "$NCAT_LOG_OUTPUT" + rlAssertGrep "Idle timeout expired" $NCAT_LOG + rlRun "killall ssh" 0 "Terminating ssh" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlFileRestore + rlPhaseEnd +rlJournalPrintText +rlJournalEnd