mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-12-27 10:21:11 +08:00
fixed tests
This commit is contained in:
parent
7383276cda
commit
07bc93bad0
6 changed files with 30 additions and 17 deletions
|
@ -664,7 +664,6 @@ module.exports.getQueryResponse = function(query, message, options) {
|
|||
if (!mimeTree) {
|
||||
mimeTree = indexer.parseMimeTree(message.raw);
|
||||
}
|
||||
console.log(item);
|
||||
value = indexer.getContents(mimeTree, item, {
|
||||
startFrom: item.partial && item.partial.startFrom,
|
||||
maxLength: item.partial && item.partial.maxLength
|
||||
|
|
|
@ -6,7 +6,7 @@ echo "Clearing DB"
|
|||
mongo "$DBNAME" --eval "db.getCollectionNames().forEach(function(key){db[key].deleteMany({});})" > /dev/null
|
||||
|
||||
echo "Creating user"
|
||||
USERRESPONSE=`curl --silent -XPOST http://localhost:8080/users \
|
||||
USERRESPONSE=`curl --silent -XPOST http://127.0.0.1:8080/users \
|
||||
-H 'Content-type: application/json' \
|
||||
-d '{
|
||||
"username": "testuser",
|
||||
|
@ -17,38 +17,38 @@ echo "UR: $USERRESPONSE"
|
|||
USERID=`echo "$USERRESPONSE" | jq -r '.id'`
|
||||
|
||||
echo "Reading Mailbox ID"
|
||||
MAILBOXLIST=`curl --silent "http://localhost:8080/users/$USERID/mailboxes"`
|
||||
MAILBOXLIST=`curl --silent "http://127.0.0.1:8080/users/$USERID/mailboxes"`
|
||||
echo "ML: $MAILBOXLIST"
|
||||
echo "$MAILBOXLIST" | jq
|
||||
INBOXID=`echo "$MAILBOXLIST" | jq -r '.results[0].id'`
|
||||
SENTID=`echo "$MAILBOXLIST" | jq -r '.results[3].id'`
|
||||
|
||||
curl --silent -XPUT "http://localhost:8080/users/$USERID/mailboxes/$SENTID" \
|
||||
curl --silent -XPUT "http://127.0.0.1:8080/users/$USERID/mailboxes/$SENTID" \
|
||||
-H 'Content-type: application/json' \
|
||||
-d '{
|
||||
"path": "[Gmail]/Sent Mail"
|
||||
}'
|
||||
|
||||
MAILBOXLIST=`curl --silent "http://localhost:8080/users/$USERID/mailboxes"`
|
||||
MAILBOXLIST=`curl --silent "http://127.0.0.1:8080/users/$USERID/mailboxes"`
|
||||
echo "$MAILBOXLIST" | jq
|
||||
|
||||
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?date=14-Sep-2013%2021%3A22%3A28%20-0300&unseen=true" \
|
||||
curl --silent -XPOST "http://127.0.0.1:8080/users/$USERID/mailboxes/$INBOXID/messages?date=14-Sep-2013%2021%3A22%3A28%20-0300&unseen=true" \
|
||||
-H 'Content-type: message/rfc822' \
|
||||
--data-binary "@fixtures/fix1.eml"
|
||||
|
||||
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=false" \
|
||||
curl --silent -XPOST "http://127.0.0.1:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=false" \
|
||||
-H 'Content-type: message/rfc822' \
|
||||
--data-binary "@fixtures/fix2.eml"
|
||||
|
||||
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=false" \
|
||||
curl --silent -XPOST "http://127.0.0.1:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=false" \
|
||||
-H 'Content-type: message/rfc822' \
|
||||
--data-binary "@fixtures/fix3.eml"
|
||||
|
||||
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=true" \
|
||||
curl --silent -XPOST "http://127.0.0.1:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=true" \
|
||||
-H 'Content-type: message/rfc822' \
|
||||
--data-binary "@fixtures/fix4.eml"
|
||||
|
||||
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=true" \
|
||||
curl --silent -XPOST "http://127.0.0.1:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=true" \
|
||||
-H 'Content-type: message/rfc822' \
|
||||
--data-binary "from: sender@example.com
|
||||
to: receiver@example.com
|
||||
|
@ -57,7 +57,7 @@ subject: test5
|
|||
hello 5
|
||||
"
|
||||
|
||||
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=true" \
|
||||
curl --silent -XPOST "http://127.0.0.1:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=true" \
|
||||
-H 'Content-type: message/rfc822' \
|
||||
--data-binary "from: sender@example.com
|
||||
to: receiver@example.com
|
||||
|
@ -71,4 +71,4 @@ db.messages.updateOne({mailbox: ObjectId('$INBOXID'), uid:1}, {\$set:{modseq: 10
|
|||
db.messages.updateOne({mailbox: ObjectId('$INBOXID'), uid:2}, {\$set:{modseq: 5000}});
|
||||
db.messages.updateMany({}, {\$inc:{uid: 100}});" > /dev/null
|
||||
|
||||
# curl --silent "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages" | jq
|
||||
# curl --silent "http://127.0.0.1:8080/users/$USERID/mailboxes/$INBOXID/messages" | jq
|
||||
|
|
|
@ -18,9 +18,11 @@ describe('IMAP Protocol integration tests', function() {
|
|||
let port = 9993;
|
||||
|
||||
beforeEach(function(done) {
|
||||
exec(__dirname + '/prepare.sh ' + config.dbs.dbname, { cwd: __dirname }, (err /*, stdout, stderr*/) => {
|
||||
// console.log(stdout.toString());
|
||||
// console.log(stderr.toString());
|
||||
exec(__dirname + '/prepare.sh ' + config.dbs.dbname, { cwd: __dirname }, (err, stdout, stderr) => {
|
||||
if (process.env.DEBUG_CONSOLE) {
|
||||
console.log(stdout.toString());
|
||||
console.log(stderr.toString());
|
||||
}
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
|
|
@ -1821,7 +1821,17 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler) => {
|
|||
decode = false;
|
||||
}
|
||||
|
||||
let attachmentStream = messageHandler.attachmentStorage.createReadStream(attachmentId, attachmentData);
|
||||
let attachmentStream;
|
||||
try {
|
||||
attachmentStream = messageHandler.attachmentStorage.createReadStream(attachmentId, attachmentData);
|
||||
} catch (err) {
|
||||
res.status(500);
|
||||
res.json({
|
||||
error: 'Failed to read attachment',
|
||||
code: 'InternalError'
|
||||
});
|
||||
return next();
|
||||
}
|
||||
|
||||
attachmentStream.once('error', err => {
|
||||
log.error('API', 'message=%s attachment=%s error=%s', messageData._id, attachmentId, err.message);
|
||||
|
|
|
@ -291,6 +291,8 @@ class GridstoreStorage {
|
|||
}
|
||||
|
||||
createReadStream(id, attachmentData, options) {
|
||||
options = options || {};
|
||||
|
||||
let encoderOptions = {};
|
||||
let streamOptions = {};
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ const transporter = nodemailer.createTransport({
|
|||
const expect = chai.expect;
|
||||
chai.config.includeStack = true;
|
||||
|
||||
const URL = 'http://localhost:8080';
|
||||
const URL = 'http://127.0.0.1:8080';
|
||||
const user2PubKey = fs.readFileSync(__dirname + '/fixtures/user2-public.key', 'utf-8');
|
||||
const user3PubKey = fs.readFileSync(__dirname + '/fixtures/user3-public.key', 'utf-8');
|
||||
|
||||
|
|
Loading…
Reference in a new issue