mirror of
https://github.com/wekan/wekan.git
synced 2026-02-17 21:48:07 +01:00
Fixed Non-ASCII attachment filename will crash when downloading.
Thanks to xet7 ! Fixes #2759
This commit is contained in:
parent
843ff8eaaa
commit
c2da477735
277 changed files with 30568 additions and 52 deletions
100
packages/wekan-request/tests/test-timeout.js
Normal file
100
packages/wekan-request/tests/test-timeout.js
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
var server = require('./server')
|
||||
, events = require('events')
|
||||
, stream = require('stream')
|
||||
, assert = require('assert')
|
||||
, request = require('../index')
|
||||
;
|
||||
|
||||
var s = server.createServer();
|
||||
var expectedBody = "waited";
|
||||
var remainingTests = 6;
|
||||
|
||||
s.listen(s.port, function () {
|
||||
// Request that waits for 200ms
|
||||
s.on('/timeout', function (req, resp) {
|
||||
setTimeout(function(){
|
||||
resp.writeHead(200, {'content-type':'text/plain'})
|
||||
resp.write(expectedBody)
|
||||
resp.end()
|
||||
}, 200);
|
||||
});
|
||||
|
||||
// Scenario that should timeout
|
||||
var shouldTimeout = {
|
||||
url: s.url + "/timeout",
|
||||
timeout:100
|
||||
}
|
||||
|
||||
|
||||
request(shouldTimeout, function (err, resp, body) {
|
||||
assert.equal(err.code, "ETIMEDOUT");
|
||||
checkDone();
|
||||
})
|
||||
|
||||
|
||||
var shouldTimeoutWithEvents = {
|
||||
url: s.url + "/timeout",
|
||||
timeout:100
|
||||
}
|
||||
|
||||
var eventsEmitted = 0;
|
||||
request(shouldTimeoutWithEvents)
|
||||
.on('error', function (err) {
|
||||
eventsEmitted++;
|
||||
assert.equal(err.code, eventsEmitted == 1 ? "ETIMEDOUT" : "ECONNRESET");
|
||||
checkDone();
|
||||
})
|
||||
|
||||
// Scenario that shouldn't timeout
|
||||
var shouldntTimeout = {
|
||||
url: s.url + "/timeout",
|
||||
timeout:300
|
||||
}
|
||||
|
||||
request(shouldntTimeout, function (err, resp, body) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(expectedBody, body)
|
||||
checkDone();
|
||||
})
|
||||
|
||||
// Scenario with no timeout set, so shouldn't timeout
|
||||
var noTimeout = {
|
||||
url: s.url + "/timeout"
|
||||
}
|
||||
|
||||
request(noTimeout, function (err, resp, body) {
|
||||
assert.equal(err);
|
||||
assert.equal(expectedBody, body)
|
||||
checkDone();
|
||||
})
|
||||
|
||||
// Scenario with a negative timeout value, should be treated a zero or the minimum delay
|
||||
var negativeTimeout = {
|
||||
url: s.url + "/timeout",
|
||||
timeout:-1000
|
||||
}
|
||||
|
||||
request(negativeTimeout, function (err, resp, body) {
|
||||
assert.equal(err.code, "ETIMEDOUT");
|
||||
checkDone();
|
||||
})
|
||||
|
||||
// Scenario with a float timeout value, should be rounded by setTimeout anyway
|
||||
var floatTimeout = {
|
||||
url: s.url + "/timeout",
|
||||
timeout: 100.76
|
||||
}
|
||||
|
||||
request(floatTimeout, function (err, resp, body) {
|
||||
assert.equal(err.code, "ETIMEDOUT");
|
||||
checkDone();
|
||||
})
|
||||
|
||||
function checkDone() {
|
||||
if(--remainingTests == 0) {
|
||||
s.close();
|
||||
console.log("All tests passed.");
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue