mirror of
https://github.com/wekan/wekan.git
synced 2026-03-12 00:22:34 +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
41
packages/wekan-request/tests/test-hawk.js
Executable file
41
packages/wekan-request/tests/test-hawk.js
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
try {
|
||||
require('hawk')
|
||||
} catch (e) {
|
||||
console.error('hawk must be installed to run this test.')
|
||||
console.error('skipping this test. please install hawk and run again if you need to test this feature.')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
var createServer = require('http').createServer
|
||||
, request = require('../index')
|
||||
, hawk = require('hawk')
|
||||
, assert = require('assert')
|
||||
;
|
||||
|
||||
var server = createServer(function (req, resp) {
|
||||
|
||||
var getCred = function (id, callback) {
|
||||
assert.equal(id, 'dh37fgj492je')
|
||||
var credentials =
|
||||
{ key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn'
|
||||
, algorithm: 'sha256'
|
||||
, user: 'Steve'
|
||||
}
|
||||
return callback(null, credentials)
|
||||
}
|
||||
|
||||
hawk.server.authenticate(req, getCred, {}, function (err, credentials, attributes) {
|
||||
resp.writeHead(!err ? 200 : 401, { 'Content-Type': 'text/plain' })
|
||||
resp.end(!err ? 'Hello ' + credentials.user : 'Shoosh!')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
server.listen(8080, function () {
|
||||
var creds = {key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn', algorithm: 'sha256', id:'dh37fgj492je'}
|
||||
request('http://localhost:8080', {hawk:{credentials:creds}}, function (e, r, b) {
|
||||
assert.equal(200, r.statusCode)
|
||||
assert.equal(b, 'Hello Steve')
|
||||
server.close()
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue