depend on it being in a specific order. Also, clean up test
tmp files.
- pop_message=${MH_TEST_DIR}/testmessage
+ pop_message=${MHTMPDIR}/testmessage
cat > "${pop_message}" <<EOM
Received: From somewhere
From: No Such User <nosuch@example.com>
cat > "${pop_message}" <<EOM
Received: From somewhere
From: No Such User <nosuch@example.com>
+clean_fakesmtp() {
+ rm "${testname}.smtp-req"
+}
+
fake_creds() {
cat > "${MHTMPDIR}/oauth-test"
}
fake_creds() {
cat > "${MHTMPDIR}/oauth-test"
}
cat >> "${testname}.http-res"
}
cat >> "${testname}.http-res"
}
+clean_fakehttp() {
+ rm -f "${testname}.http-res"
+}
+
fake_json_response() {
(echo 'Content-Type: application/json';
echo;
fake_json_response() {
(echo 'Content-Type: application/json';
echo;
# The format of the POST request is mostly dependent on curl, and could possibly
# change with newer or older curl versions, or by configuration. curl 7.39.0
# makes POST requests like this on FreeBSD 10 and Ubuntu 14.04. If you find
# The format of the POST request is mostly dependent on curl, and could possibly
# change with newer or older curl versions, or by configuration. curl 7.39.0
# makes POST requests like this on FreeBSD 10 and Ubuntu 14.04. If you find
-# this failing, you'll need to make this a smarter comparison.
+# this failing, you'll need to make this a smarter comparison. Note that it is
+# sorted, so that it doesn't depend on the JSON being in a specific order.
- cat > "${testname}.expected-http-req" <<EOF
+ sort > "${testname}.expected-http-req" <<EOF
POST /oauth/token HTTP/1.1
User-Agent: nmh/${MH_VERSION} ${CURL_USER_AGENT}
Host: 127.0.0.1:${http_port}
POST /oauth/token HTTP/1.1
User-Agent: nmh/${MH_VERSION} ${CURL_USER_AGENT}
Host: 127.0.0.1:${http_port}
- cat > "${testname}.expected-creds"
+ cat > "${MHTMPDIR}/$$.expected-creds"
test_send() {
start_fakehttp
test_send_only_fakesmtp "$@"
test_send() {
start_fakehttp
test_send_only_fakesmtp "$@"
- check "${testname}.http-req" "${testname}.expected-http-req"
+ sort -o "${testname}.http-req.sorted" "${testname}.http-req"
+ rm "${testname}.http-req"
+ check "${testname}.http-req.sorted" "${testname}.expected-http-req"
- check "${testname}.http-req" "${testname}.expected-http-req"
+ sort -o "${testname}.http-req.sorted" "${testname}.http-req"
+ rm "${testname}.http-req"
+ check "${testname}.http-req.sorted" "${testname}.expected-http-req"
}
check_creds_private() {
}
check_creds_private() {
f="${MHTMPDIR}/oauth-test"
sed 's/^expire:.*/expire:/' "$f" > "$f".notime
f="${MHTMPDIR}/oauth-test"
sed 's/^expire:.*/expire:/' "$f" > "$f".notime
- check "$f".notime "${testname}.expected-creds"
+ check "$f".notime "${MHTMPDIR}/$$.expected-creds"
-expect_creds <<EOF
-access: test-access
-refresh: test-refresh
-expire:
-EOF
-
start_fakehttp
start_pop_xoauth
start_fakehttp
start_pop_xoauth
test_inc 'inc: POP server does not support SASL'
test_inc 'inc: POP server does not support SASL'
. "${srcdir}/test/oauth/common.sh"
expect_no_creds() {
. "${srcdir}/test/oauth/common.sh"
expect_no_creds() {
- cat /dev/null > "${testname}.expected-creds"
+ cat /dev/null > "${MHTMPDIR}/$$.expected-creds"
cat /dev/null > "${MHTMPDIR}/oauth-test"
chmod 600 "${MHTMPDIR}/oauth-test"
}
cat /dev/null > "${MHTMPDIR}/oauth-test"
chmod 600 "${MHTMPDIR}/oauth-test"
}
test_mhlogin 'mhlogin: error exchanging code for OAuth2 token
mhlogin: bad OAuth request; re-run with -snoop and send REDACTED output to nmh-workers'
test_mhlogin 'mhlogin: error exchanging code for OAuth2 token
mhlogin: bad OAuth request; re-run with -snoop and send REDACTED output to nmh-workers'
test_send_only_fakesmtp 'post: problem initializing server; [BHST] SMTP server does not support SASL XOAUTH2
send: message not delivered to anyone'
test_send_only_fakesmtp 'post: problem initializing server; [BHST] SMTP server does not support SASL XOAUTH2
send: message not delivered to anyone'
+clean_fakesmtp
+clean_fakehttp
+
start_pop_xoauth
test_inc_success
start_pop_xoauth
test_inc_success
+clean_fakesmtp
+clean_fakehttp
+