Commit ddabeea Initial commit for upstream inclusion

4 files Merged and Committed by rasibley 10 months ago
Initial commit for upstream inclusion

    
 1 @@ -0,0 +1,64 @@
 2 + [root@host-172-16-36-46 smoke]# cat Makefile 
 3 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4 + #
 5 + #   Makefile of /CoreOS/fetchmail/Sanity/smoke
 6 + #   Description: fetches mail via pop3 and imap from one user and delivers it to another
 7 + #   Author: Ales Zelinka <azelinka@redhat.com>
 8 + #
 9 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 + #
11 + #   Copyright (c) 2009 Red Hat, Inc.
12 + #
13 + #   This copyrighted material is made available to anyone wishing
14 + #   to use, modify, copy, or redistribute it subject to the terms
15 + #   and conditions of the GNU General Public License version 2.
16 + #
17 + #   This program is distributed in the hope that it will be
18 + #   useful, but WITHOUT ANY WARRANTY; without even the implied
19 + #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 + #   PURPOSE. See the GNU General Public License for more details.
21 + #
22 + #   You should have received a copy of the GNU General Public
23 + #   License along with this program; if not, write to the Free
24 + #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 + #   Boston, MA 02110-1301, USA.
26 + #
27 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 + 
29 + export TEST=/CoreOS/fetchmail/Sanity/smoke
30 + export TESTVERSION=1.1
31 + 
32 + BUILT_FILES=
33 + 
34 + FILES=$(METADATA) runtest.sh Makefile PURPOSE
35 + 
36 + .PHONY: all install download clean
37 + 
38 + run: $(FILES) build
39 + »       ./runtest.sh
40 + 
41 + build: $(BUILT_FILES)
42 + »       chmod a+x runtest.sh
43 + 
44 + clean:
45 + »       rm -f *~ $(BUILT_FILES)
46 + 
47 + 
48 + include /usr/share/rhts/lib/rhts-make.include
49 + 
50 + $(METADATA): Makefile
51 + »       @echo "Owner:           Ales Zelinka <azelinka@redhat.com>" > $(METADATA)
52 + »       @echo "Name:            $(TEST)" >> $(METADATA)
53 + »       @echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)
54 + »       @echo "Path:            $(TEST_DIR)" >> $(METADATA)
55 + »       @echo "Description:     fetches mail via pop3 and imap from one user and delivers it to another" >> $(METADATA)
56 + »       @echo "Type:            Sanity" >> $(METADATA)
57 + »       @echo "TestTime:        15m" >> $(METADATA)
58 + »       @echo "RunFor:          fetchmail dovecot" >> $(METADATA)
59 + »       @echo "Requires:        fetchmail dovecot postfix mailx" >> $(METADATA)
60 + »       @echo "Priority:        Normal" >> $(METADATA)
61 + »       @echo "License:         GPLv2" >> $(METADATA)
62 + »       @echo "Confidential:    no" >> $(METADATA)
63 + »       @echo "Destructive:     no" >> $(METADATA)
64 + »       @echo "Releases:        -RHEL2.1 -RHEL3" >> $(METADATA)
65 + »       @echo "Bug:             520765" >> $(METADATA)
1 @@ -0,0 +1,3 @@
2 + PURPOSE of /CoreOS/fetchmail/Sanity/smoke
3 + Description: fetches mail via pop3 and imap from one user and delivers it to another
4 + Author: Ales Zelinka <azelinka@redhat.com>
  1 @@ -0,0 +1,152 @@
  2 + #!/bin/bash
  3 + # vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
  4 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5 + #
  6 + #   runtest.sh of /CoreOS/fetchmail/Sanity/smoke
  7 + #   Description: fetches mail via pop3 and imap from one user and delivers it to another
  8 + #   Author: Ales Zelinka <azelinka@redhat.com>
  9 + #
 10 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 11 + #
 12 + #   Copyright (c) 2009 Red Hat, Inc. All rights reserved.
 13 + #
 14 + #   This copyrighted material is made available to anyone wishing
 15 + #   to use, modify, copy, or redistribute it subject to the terms
 16 + #   and conditions of the GNU General Public License version 2.
 17 + #
 18 + #   This program is distributed in the hope that it will be
 19 + #   useful, but WITHOUT ANY WARRANTY; without even the implied
 20 + #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 21 + #   PURPOSE. See the GNU General Public License for more details.
 22 + #
 23 + #   You should have received a copy of the GNU General Public
 24 + #   License along with this program; if not, write to the Free
 25 + #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 26 + #   Boston, MA 02110-1301, USA.
 27 + #
 28 + #
 29 + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 30 + 
 31 + # Include rhts environment
 32 + . /usr/bin/rhts-environment.sh
 33 + . /usr/share/rhts-library/rhtslib.sh
 34 + 
 35 + PACKAGE="fetchmail"
 36 + 
 37 + function waitForMail() {
 38 +     for i in `seq 20`; do
 39 +         sleep .5
 40 +         grep 'fetchmail smoke test' $1 > /dev/null
 41 +         if [ $? -eq 0 ]; then
 42 +             break
 43 +         fi
 44 +     done
 45 + }
 46 + 
 47 + mkfmrc() {
 48 +     #
 49 +     # Drop fetchmail rc file for user $1
 50 +     #
 51 +     local user="$1"
 52 +     local path="/home/$user/.fetchmailrc"
 53 +     {
 54 +         echo "poll localhost"
 55 +         echo "proto $PROTOCOL"
 56 +         echo "auth password"
 57 +         echo "user joe_at_work password joe_at_work"
 58 +         echo "fetchall"
 59 +     } >"$path"
 60 +     chmod 600 "$path"
 61 +     chown "$user:$user" "$path"
 62 +     restorecon -v "$path"
 63 + }
 64 + 
 65 + mkmsg() {
 66 +     #
 67 +     # Create a test message
 68 +     #
 69 +     echo "Subject: subject of fetchmail smoke test mail ($PROTOCOL)"
 70 +     echo ""
 71 +     echo "body of fetchmail smoke test mail ($PROTOCOL)"
 72 + }
 73 + 
 74 + 
 75 + rlJournalStart
 76 + 
 77 +     rlPhaseStartSetup Setup-Common
 78 +         rlFileBackup  --clean "/var/lib/misc/postfix.aliasesdb-stamp"
 79 +         rlAssertRpm dovecot
 80 +         rlAssertRpm mailx
 81 +         rlAssertRpm postfix
 82 +         rlIsRHEL 5 && DOVECOT_CONF="/etc/dovecot.conf" || DOVECOT_CONF="/etc/dovecot/dovecot.conf"
 83 +         rlFileBackup $DOVECOT_CONF
 84 +         # make sure dovecot serves via both imap and pop3
 85 +         if grep ^protocols $DOVECOT_CONF ; then
 86 +             sed -i '/^protocols / d' $DOVECOT_CONF
 87 +         fi
 88 +         echo "protocols = imap pop3" >> $DOVECOT_CONF
 89 +         if ! rlIsRHEL 4 ; then
 90 +             echo "mail_access_groups = mail" >> $DOVECOT_CONF
 91 +             # make sure dovecot can find user's mbox
 92 +             if grep ^mail_location $DOVECOT_CONF; then
 93 +                 sed -i '/^mail_location/ d' $DOVECOT_CONF
 94 +             fi
 95 +             echo "mail_location = mbox:~/mail:INBOX=/var/mail/%u" >> $DOVECOT_CONF
 96 +         fi
 97 +         rlServiceStart dovecot postfix
 98 +         sleep 5
 99 + 
100 +         rlRun "useradd joe_at_work"
101 +         rlRun "useradd joe_at_home"
102 +         rlRun "chpasswd <<<joe_at_work:joe_at_work"
103 +         rlRun "chpasswd <<<joe_at_home:joe_at_home"
104 +         rlBundleLogs dovecot.conf $DOVECOT_CONF
105 +     rlPhaseEnd
106 + 
107 +     for PROTOCOL in pop3 imap ; do
108 + 
109 +         rlPhaseStartSetup Setup-$PROTOCOL
110 +             rlRun "mkfmrc joe_at_home" \
111 +                 0 "making config file for joe_at_home"
112 +             rlRun "mkmsg | mail joe_at_work" \
113 +                 0 "sending email to joe_at_work"
114 +             rlRun "sendmail -q " \
115 +                 0 "flushing mail queues, forcing mail delivery"
116 +             waitForMail "/var/mail/joe_at_work"
117 +             rlRun "grep 'fetchmail smoke test' /var/mail/joe_at_work" \
118 +                 0 "mail delivered to joe_at_work's mailbox"
119 +         rlPhaseEnd
120 + 
121 +         rlPhaseStartTest Test-$PROTOCOL
122 +             # run fetchmail as if user joe_at_home would run it from terminal
123 +             rlRun "su -c 'runcon -t unconfined_t -- fetchmail -v -v -f /home/joe_at_home/.fetchmailrc' - joe_at_home" \
124 +                 0 "fetching joe_at_work's mail as joe_at_home"
125 +             rlRun "sendmail -q " \
126 +                 0 "flushing mail queues, forcing mail delivery"
127 +             waitForMail "/var/mail/joe_at_home"
128 +             rlRun "grep 'fetchmail smoke test' /var/mail/joe_at_home" \
129 +                 0 "mail delivered to joe_at_home's mailbox"
130 +             rlBundleLogs maillog-$PROTOCOL /var/log/maillog
131 +         rlPhaseEnd
132 + 
133 +         rlPhaseStartCleanup Cleanup-$PROTOCOL
134 +             rlRun "echo -n '' > /var/mail/joe_at_work" \
135 +                 0 "emptying joe_at_work's mailbox"
136 +             rlRun "echo -n '' > /var/mail/joe_at_home" \
137 +                 0 "emptying joe_at_home's mailbox"
138 +             rlRun "rm -f /home/joe_at_home/.fetchmailrc" \
139 +                 0 "removing customized config file"
140 +         rlPhaseEnd
141 +     done
142 + 
143 +     rlPhaseStartCleanup
144 +         rlServiceRestore dovecot postfix
145 +         rlRun "userdel -r joe_at_work"
146 +         rlRun "userdel -r joe_at_home"
147 +         rlFileRestore
148 +         rlBundleLogs auditlog /var/log/audit/audit.log
149 +     rlPhaseEnd
150 + 
151 + rlJournalPrintText
152 + rlJournalEnd
153 + 
 1 @@ -0,0 +1,14 @@
 2 + ---
 3 + # This first play always runs on the local staging system
 4 + - hosts: localhost
 5 +   roles:
 6 +   - role: standard-test-beakerlib
 7 +     tags:
 8 +     - classic
 9 +     tests:
10 +     - smoke
11 +     required_packages:
12 +     - fetchmail
13 +     - dovecot
14 +     - postfix
15 +     - mailx