Moving tests to fedora repo

/CoreOS/telnet/Regression/telnet-is-logging-hostname-in-utmp-not-IP
/CoreOS/telnet/Regression/bz1367415-RFE-telnet-add-option-to-specify-IPv6-or-IPv4
This commit is contained in:
František Hrdina 2022-11-08 13:27:04 +01:00
commit 92fa925171
5 changed files with 223 additions and 0 deletions

View file

@ -0,0 +1,25 @@
summary: Test for BZ#1367415 ([RFE] telnet add option to specify IPv6 or IPv4)
description: |
Bug summary: [RFE] telnet: add option to specify IPv6 or IPv4 explicitly
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1367415
contact: fhrdina@redhat.com
component:
- telnet
test: ./runtest.sh
framework: beakerlib
recommend:
- telnet
duration: 5m
enabled: true
tag:
- Tier1
tier: '1'
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1367415
adjust:
- enabled: false
when: distro < rhel-7
continue: false
extra-nitrate: TC#0552016
extra-summary: /CoreOS/telnet/Regression/bz1367415-RFE-telnet-add-option-to-specify-IPv6-or-IPv4
extra-task: /CoreOS/telnet/Regression/bz1367415-RFE-telnet-add-option-to-specify-IPv6-or-IPv4

View file

@ -0,0 +1,65 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/telnet/Regression/bz1367415-RFE-telnet-add-option-to-specify-IPv6-or-IPv4
# Description: Test for BZ#1367415 ([RFE] telnet add option to specify IPv6 or IPv4)
# Author: Karel Volny <kvolny@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2017 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="telnet"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
rlRun -s "telnet localhost 3" 1 "Trying to connect to localhost without specifying protocol"
rlLogInfo "telnet should try both protocols (as default distro config resolves localhost both for IPv4 and IPv6)"
rlAssertGrep "::1" $rlRun_LOG
rlAssertGrep "127.0.0.1" $rlRun_LOG
rm $rlRun_LOG
rlRun -s "telnet -6 localhost 3" 1 "Trying to connect to localhost with IPv6 explicitly"
rlLogInfo "telnet should try just IPv6"
rlAssertGrep "::1" $rlRun_LOG
rlAssertNotGrep "127.0.0.1" $rlRun_LOG
rm $rlRun_LOG
rlRun -s "telnet -4 localhost 3" 1 "Trying to connect to localhost with IPv4 explicitly"
rlLogInfo "telnet should try just IPv4"
rlAssertNotGrep "::1" $rlRun_LOG
rlAssertGrep "127.0.0.1" $rlRun_LOG
rm $rlRun_LOG
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,31 @@
summary: Test for BZ#1323094 ([RFE] telnet is logging hostname in utmp not IP)
description: |
Bug summary: [RFE] telnet is logging hostname in utmp not IP address.
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1323094
contact: fhrdina@redhat.com
component:
- telnet
test: ./runtest.sh
framework: beakerlib
recommend:
- telnet
- telnet-server
- expect
duration: 15m
enabled: true
tag:
- Tier1
tier: '1'
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1323094
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1637085
adjust:
- enabled: false
when: distro < rhel-7
continue: false
- enabled: false
when: arch != x86_64
continue: false
extra-nitrate: TC#0533310
extra-summary: /CoreOS/telnet/Regression/telnet-is-logging-hostname-in-utmp-not-IP
extra-task: /CoreOS/telnet/Regression/telnet-is-logging-hostname-in-utmp-not-IP

View file

@ -0,0 +1,78 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/telnet/Regression/telnet-is-logging-hostname-in-utmp-not-IP
# Description: Test for BZ#1323094 ([RFE] telnet is logging hostname in utmp not IP)
# Author: Andrej Dzilsky <adzilsky@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016 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="telnet"
LOGIN_xyzyxz="telnet-test"
PASSWORD_xyzyxz="test"
rlJournalStart
########## SETUP PHASE ##########
rlPhaseStartSetup
rlAssertRequired
rlFileBackup --clean --no-missing-ok "/etc/systemd/system" `readlink -f /etc/systemd/system`
rlRun "useradd -m $LOGIN_xyzyxz"
rlRun "echo -n $PASSWORD_xyzyxz | passwd --stdin $LOGIN_xyzyxz"
rlRun "systemctl daemon-reload"
rlRun "systemctl stop telnet.socket"
rlPhaseEnd
########## SETUP PHASE ##########
rlPhaseStartSetup "Start telnet service"
rlRun "cp /usr/lib/systemd/system/telnet\@.service /etc/systemd/system/"
rlRun "cp /usr/lib/systemd/system/telnet.socket /etc/systemd/system/"
rlRun "sed -i 's;\\(ExecStart=-/usr/sbin/in.telnetd\\);\\1 -i;' /etc/systemd/system/telnet\@.service"
#debug
rlLog "########### cat /etc/systemd/system/telnet.socket"
cat /usr/lib/systemd/system/telnet.socket
rlLog "########### cat /etc/systemd/system/telnet\@.service"
cat /usr/lib/systemd/system/telnet\@.service
rlRun "systemctl --no-pager start telnet.socket"
sleep 20
#debug
systemctl --no-pagerstatus telnet.socket
rlPhaseEnd
#################### REBUILD/TEST PHASE ####################
rlPhaseStartTest "Connect and get information from UTMP"
rlRun -s "expect telnet.expect $LOGIN_xyzyxz $PASSWORD_xyzyxz"
rlAssertGrep "127.0.0.1" $rlRun_LOG -x
rlPhaseEnd
########## CLEANUP PHASE ##########
rlPhaseStartCleanup
rlRun "systemctl stop telnet.socket"
rlFileRestore
rlRun "userdel -fr telnet-test"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,24 @@
#!/usr/bin/expect -d
log_user 0
exp_internal -f dbg 1
set timeout 30
set login [lindex $argv 0]
set password [lindex $argv 1]
spawn telnet -d 127.0.0.1
expect "Escape character is '^]'."
sleep 5
send -- "$login\r"
expect "Password:"
sleep 5
send -- "$password\r"
expect "telnet-test"
log_user 1
#send -- "w | grep \"telnet-t\" | grep -o \"::1\"\r"
spawn utmpdump /var/run/utmp
sleep 5
send "utmpdump /var/run/utmp | grep \"telnet-test\" | cut -d'\\\[' -f7 | grep -o '127.0.0.1'\r"
expect "127.0.0.1"
puts $expect_out(0,string)