Skip to content

Commit

Permalink
Fix event emit on MQlobberServer
Browse files Browse the repository at this point in the history
  • Loading branch information
davedoesdev committed Sep 17, 2016
1 parent b3f8797 commit 0d4e1cc
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion coverage/coverage.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion coverage/lcov-report/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sat Sep 17 2016 07:36:17 GMT+0100 (BST)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sat Sep 17 2016 08:00:00 GMT+0100 (BST)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/mqlobber-access-control/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sat Sep 17 2016 07:36:17 GMT+0100 (BST)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sat Sep 17 2016 08:00:00 GMT+0100 (BST)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions coverage/lcov-report/mqlobber-access-control/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ <h1>
if (allow(ths._matchers.subscribe, topic))
{
if (!ths.emit('subscribe_requested', this, topic, done) &amp;&amp;
!this.emit('subscribe_requested', this, topic, done))
!this.emit('subscribe_requested', topic, done))
{
this.subscribe(topic, done);
}
Expand All @@ -1304,7 +1304,7 @@ <h1>
if (allow(ths._matchers.publish, topic))
{
if (!ths.emit('publish_requested', this, topic, duplex, options, done) &amp;&amp;
!this.emit('publish_requested', this, topic, duplex, options, done))
!this.emit('publish_requested', topic, duplex, options, done))
{
duplex.pipe(this.fsq.publish(topic, options, done));
}
Expand Down Expand Up @@ -1474,7 +1474,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sat Sep 17 2016 07:36:17 GMT+0100 (BST)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sat Sep 17 2016 08:00:00 GMT+0100 (BST)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function AccessControl(options)
if (allow(ths._matchers.subscribe, topic))
{
if (!ths.emit('subscribe_requested', this, topic, done) &&
!this.emit('subscribe_requested', this, topic, done))
!this.emit('subscribe_requested', topic, done))
{
this.subscribe(topic, done);
}
Expand All @@ -309,7 +309,7 @@ function AccessControl(options)
if (allow(ths._matchers.publish, topic))
{
if (!ths.emit('publish_requested', this, topic, duplex, options, done) &&
!this.emit('publish_requested', this, topic, duplex, options, done))
!this.emit('publish_requested', topic, duplex, options, done))
{
duplex.pipe(this.fsq.publish(topic, options, done));
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mqlobber-access-control",
"description": "Access control for mqlobber message queues",
"version": "1.2.0",
"version": "1.2.1",
"homepage": "https://github.com/davedoesdev/mqlobber-access-control",
"author": {
"name": "David Halls",
Expand Down
16 changes: 12 additions & 4 deletions test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,12 +749,14 @@ describe('dedup=' + dedup, function () {

ac.on('subscribe_requested', function (server, topic, cb)
{
expect(topic).to.equal('foo.*');
sub_event = true;
server.subscribe(topic, cb);
});

ac.on('publish_requested', function (server, topic, stream, options, cb)
{
expect(topic).to.equal('foo.bar');
pub_event = true;
stream.pipe(server.fsq.publish(topic, options, cb));
});
Expand Down Expand Up @@ -795,16 +797,18 @@ describe('dedup=' + dedup, function () {

ac.attach(mq.server);

mq.server.on('subscribe_requested', function (server, topic, cb)
mq.server.on('subscribe_requested', function (topic, cb)
{
expect(topic).to.equal('foo.*');
mq_sub_event = true;
server.subscribe(topic, cb);
this.subscribe(topic, cb);
});

mq.server.on('publish_requested', function (server, topic, stream, options, cb)
mq.server.on('publish_requested', function (topic, stream, options, cb)
{
expect(topic).to.equal('foo.bar');
mq_pub_event = true;
stream.pipe(server.fsq.publish(topic, options, cb));
stream.pipe(this.fsq.publish(topic, options, cb));
});

mq.client.subscribe('foo.*', function (s, info)
Expand Down Expand Up @@ -837,24 +841,28 @@ describe('dedup=' + dedup, function () {

ac.on('subscribe_requested', function (server, topic, cb)
{
expect(topic).to.equal('foo.*');
sub_event = true;
server.emit('subscribe_requested', topic, cb);
});

ac.on('publish_requested', function (server, topic, stream, options, cb)
{
expect(topic).to.equal('foo.bar');
pub_event = true;
server.emit('publish_requested', topic, stream, options, cb);
});

mq.server.on('subscribe_requested', function (topic, cb)
{
expect(topic).to.equal('foo.*');
mq_sub_event = true;
this.subscribe(topic, cb);
});

mq.server.on('publish_requested', function (topic, stream, options, cb)
{
expect(topic).to.equal('foo.bar');
mq_pub_event = true;
stream.pipe(this.fsq.publish(topic, options, cb));
});
Expand Down

0 comments on commit 0d4e1cc

Please sign in to comment.