Adding test

/CoreOS/nmap/Regression/bz2140101-ncat-does-not-work-with-proxy
This commit is contained in:
František Hrdina 2023-03-01 13:09:48 +01:00
commit 19fe571c92
2 changed files with 91 additions and 0 deletions

View file

@ -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

View file

@ -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 <mosvald@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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