From 5d2292f14c727c1eebb84d59bf9123bcaceacacc Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Sat, 15 Nov 2014 15:20:03 +0200 Subject: [PATCH] [WO-730] Do not run 'CAPABILITY' before upgrading connection with the requireTLS option --- src/browserbox.js | 7 +++++++ test/unit/browserbox-test.js | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/browserbox.js b/src/browserbox.js index 18fcfc2e..9c2def3f 100644 --- a/src/browserbox.js +++ b/src/browserbox.js @@ -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); diff --git a/test/unit/browserbox-test.js b/test/unit/browserbox-test.js index a3479f41..11c92998 100644 --- a/test/unit/browserbox-test.js +++ b/test/unit/browserbox-test.js @@ -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() {