]> diplodocus.org Git - nmh/blobdiff - test/inc/test-pop
msgchk.c: Remove UUCP tests; unused since `#ifdef MF'.
[nmh] / test / inc / test-pop
index 580f0cdaaed314d2e0fb6b3058cdf9ea9b8a7410..64620173fb4e09907b364435f807a6663cad6708 100755 (executable)
@@ -24,7 +24,8 @@ setup_test
 
 TESTUSER=testuser
 TESTPASS=testuserpass
 
 TESTUSER=testuser
 TESTPASS=testuserpass
-testport=65413
+arith_eval 64001 + $$ % 1000
+testport=$arith_val
 
 HOME="${MH_TEST_DIR}"; export HOME
 netrc="${HOME}/.netrc"
 
 HOME="${MH_TEST_DIR}"; export HOME
 netrc="${HOME}/.netrc"
@@ -37,7 +38,7 @@ actual=$MH_TEST_DIR/$$.actual
 actual_err=$MH_TEST_DIR/$$.actual_err
 testmessage=$MH_TEST_DIR/testmessage
 
 actual_err=$MH_TEST_DIR/$$.actual_err
 testmessage=$MH_TEST_DIR/testmessage
 
-cat > $testmessage <<EOM
+cat > "$testmessage" <<EOM
 Received: From somewhere
 From: No Such User <nosuch@example.com>
 To: Some Other User <someother@example.com>
 Received: From somewhere
 From: No Such User <nosuch@example.com>
 To: Some Other User <someother@example.com>
@@ -49,15 +50,83 @@ Hey man, how's it going?
 Hope you're doing better.
 EOM
 
 Hope you're doing better.
 EOM
 
-pid=`"${MH_OBJ_DIR}/test/fakepop" "$testmessage" "$testport" \
-                       "$TESTUSER" "$TESTPASS"`
+cat > "${testmessage}.2" <<EOM
+Received: From somewhere
+From: A Real User <real@example.com>
+To: Some Other User <someother@example.com>
+Subject: Anything new?
+Date: Monday, 18 Dec 2006 14:13:14 -0500
+
+What's been happening at your place?
+EOM
+
+cat > "${testmessage}.3" <<EOM
+Received: From somewhere
+From: Nathan Explosion <nathan@dethklok.com>
+To: Some Other User <someother@example.com>
+Subject: Brutal
+Date: Tuesday, 19 Dec 2006 4:15:16 -0500
+
+Dude, nmh is totally brutal.
+EOM
+
+# Check netrc's permissions test
+pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" '' '' "$testmessage"`
+chmod g=w,o=x $netrc
+run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport" \
+        "inc: group or other permissions, 0100621, forbidden: $netrc
+inc: Remove password or correct file permissions."
+chmod go= $netrc
+
+pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" \
+                       "$TESTUSER" "$TESTPASS" "$testmessage"`
 
 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80" \
        "Incorporating new mail into inbox...
 
 
 run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80" \
        "Incorporating new mail into inbox...
 
-  11+ 12/17 No Such User       Hello<<Hey man, how's it going? . Hope you're do"
+  11+ 12/17 No Such User       Hello<<Hey man, how's it going? . Hope you're do\
+i"
+check "$testmessage" `mhpath +inbox 11` 'keep first'
+
+# Check multiple messages at once
+
+pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" \
+                       "$TESTUSER" "$TESTPASS" "$testmessage" \
+                       "${testmessage}.2" "${testmessage}.3"`
+
+run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 80" \
+       "Incorporating new mail into inbox...
+
+  11+ 12/17 No Such User       Hello<<Hey man, how's it going? . Hope you're doi
+  12  12/18 A Real User        Anything new?<<What's been happening at your plac
+  13  12/19 Nathan Explosion   Brutal<<Dude, nmh is totally brutal. >>"
+
+check "$testmessage" `mhpath +inbox 11` 'keep first'
+check "${testmessage}.2" `mhpath +inbox 12`
+check "${testmessage}.3" `mhpath +inbox 13`
+
+rm -f "$netrc"
+
+# check credentials: file
+# Redirect stdin so that inc doesn't wait on the user if it can't
+# read the netrc file, even though that shouldn't happen.
+TESTUSER=differenuser
+TESTPASS=differentpass
+
+netrc="${HOME}/.mhnetrc"
+echo "default login ${TESTUSER} password ${TESTPASS}" > "$netrc"
+chmod 600 "$netrc"
+echo "credentials: file:${netrc}" >>$MH
+
+pid=`"${MH_OBJ_DIR}/test/fakepop" "$testport" \
+                       "$TESTUSER" "$TESTPASS" "$testmessage"`
+
+run_test "inc -user ${TESTUSER} -host 127.0.0.1 -port $testport -width 65" \
+       "Incorporating new mail into inbox...
+
+  11+ 12/17 No Such User       Hello<<Hey man, how's it going? . " </dev/null
+check $testmessage `mhpath +inbox 11`
 
 
-check `mhpath +inbox 11` $testmessage
-rm -f $testmessage "$netrc"
+rm -f "$netrc"
 
 exit ${failed:-0}
 
 exit ${failed:-0}