You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Wills on startup are not authorized
To Reproduce
Steps to reproduce the behavior:
Add test to will.js and npm run test
Expected behavior
Wills should be authorized
This seems to me that it will require adding to the persistence layer, as extra client information will need to be added, namely any important information like username, etc that gets passed to the authorizePublish handler.
Here is a failing test example.
test('authorize old will in case of a crash', function (t) {
t.plan(3)
const persistence = memory()
const will = {
topic: 'mywill',
payload: Buffer.from('last will'),
qos: 0,
retain: false
}
persistence.broker = {
id: 'anotherBroker'
}
persistence.putWill({
id: 'myClientId42'
}, will, function (err) {
t.error(err, 'no error')
const interval = 10 // ms, so that the will check happens fast!
const broker = aedes({
persistence: persistence,
heartbeatInterval: interval
})
let authorized = false
broker.authorizePublish = function (client, packet, callback) {
authorized = true
callback(null)
}
t.teardown(broker.close.bind(broker))
const start = Date.now()
broker.mq.on('mywill', check)
function check (packet, cb) {
broker.mq.removeListener('mywill', check)
t.ok(Date.now() - start >= 3 * interval, 'the will needs to be emitted after 3 heartbeats')
t.equal(authorized, true, 'topic authorized')
broker.mq.on('mywill', function (packet) {
t.fail('the will must be delivered only once')
})
cb()
}
})
})
The text was updated successfully, but these errors were encountered:
System Information
Describe the bug
Wills on startup are not authorized
To Reproduce
Steps to reproduce the behavior:
Add test to will.js and npm run test
Expected behavior
Wills should be authorized
This seems to me that it will require adding to the persistence layer, as extra client information will need to be added, namely any important information like username, etc that gets passed to the authorizePublish handler.
Here is a failing test example.
The text was updated successfully, but these errors were encountered: