Skip to content

Commit

Permalink
fix(policy): remove sealing to allow extension of policy methods
Browse files Browse the repository at this point in the history
Since we returned a sealed object from the PolicyBase function, we
could not actually extend the `parseAddress` and `parseLinkAddress`
methods. Removing that line fixes it, and two tests are included
  • Loading branch information
mbroadst committed Oct 25, 2016
1 parent d1ae649 commit d0bdfc7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/policies/policy.js
Expand Up @@ -103,7 +103,7 @@ function Policy(overrides) {
},
});

return Object.seal(this);
return this;
}

/**
Expand Down
14 changes: 14 additions & 0 deletions test/unit/policies/policy.test.js
Expand Up @@ -43,6 +43,20 @@ describe('Default Policy', function() {
});
});

it('should allow redefinition of parseAddress', function() {
var policy = amqp.Policy.merge({}, amqp.Policy.DefaultPolicy);
policy.parseAddress = function() { return { name: 'llamas' }; };
var addr = policy.parseAddress('testing');
expect(addr).to.eql({ name: 'llamas' });
});

it('should allow redefinition of parseLinkAddress', function() {
var policy = amqp.Policy.merge({}, amqp.Policy.DefaultPolicy);
policy.parseLinkAddress = function() { return { name: 'llamas' }; };
var addr = policy.parseLinkAddress('testing');
expect(addr).to.eql({ name: 'llamas' });
});

it('should not add a SASL layer for anonymous auth by default', function() {
var policy = amqp.Policy.merge({
connect: {
Expand Down

0 comments on commit d0bdfc7

Please sign in to comment.