File: validate

package info (click to toggle)
nullmailer 1:2.2-3
  • links: PTS
  • area: main
  • in suites: buster, sid
  • size: 1,228 kB
  • sloc: cpp: 6,785; sh: 504; makefile: 221; perl: 184
file content (54 lines) | stat: -rwxr-xr-x 1,251 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
. functions

queuedir=$QUEUEDIR/queue
queue-test() {
    rm -f $queuedir/*
    echo "Testing queue from <$1> to <$2>"
    queue "$@"
}

queue-good() {
    if ! queue-test "$@"
    then
        fail "nullmailer-queue failed to accept good envelope"
    fi
    qc=$( find $queuedir -type f | wc -l )
    if [ $qc -eq 0 ]
    then
        fail "nullmailer-queue did not queue a message despite succeeding"
    fi
    if [ $qc -gt 1 ]
    then
        fail "nullmailer-queue queued multiple messages ?!?"
    fi
    qm=$queuedir/*
    sed -e '1,/^$/d' $qm | grep -q '^Subject:' || fail "queued message did not contain body"
}

check-sender() {
    qm=$queuedir/*
    head -n 1 $qm | grep -q "^$1$" || fail "queued message contained wrong sender"
}

check-recipient() {
    qm=$queuedir/*
    sed -e '1d;q' $qm | grep -q "^$1$" || fail "queued message contained wrong sender"
}

queue-bad() {
    if queue-test "$@"
    then
        fail "nullmailer-queue failed to reject bad envelope"
    fi
    qc=$( find $queuedir -type f | wc -l )
    if [ $qc -ne 0 ]
    then
        fail "nullmailer-queue queued a message after rejecting it"
    fi
}

queue-good "a@b.c" "d@e.f"
queue-bad "@b.c" "d@e.f"
queue-bad "a@b.c" "@e.f"
queue-good "" "d@e.f"