Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/browserbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,18 @@
callback = forced;
forced = undefined;
}

// skip request, if not forced update and capabilities are already loaded
if (!forced && this.capability.length) {
return callback(null, false);
}

// If STARTTLS is required then skip capability listing as we are going to try
// STARTTLS anyway and we re-check capabilities after connection is secured
if (!this.client.secureMode && this.options.requireTLS) {
return callback(null, false);
}

this.exec('CAPABILITY', function(err, response, next) {
if (err) {
callback(err);
Expand Down
11 changes: 11 additions & 0 deletions test/unit/browserbox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,17 @@

br.exec.restore();
});

it('should do nothing if connection is not yet upgraded', function() {
br.capability = [];
br.client.secureMode = false;
br.options.requireTLS = true;

br.updateCapability(function(err, updated) {
expect(err).to.not.exist;
expect(updated).to.be.false;
});
});
});

describe('#listNamespaces', function() {
Expand Down