couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [2/3] fauxton commit: updated refs/heads/master to 5de1fe6
Date Wed, 22 Jul 2015 12:17:08 GMT
Revert "Detect if we run on a backdoor port"

This reverts commit 9ab1292d4e926ecba7c15291a04feb0342b40b21.

PR: #480
PR-URL: https://github.com/apache/couchdb-fauxton/pull/480
Reviewed-By: garren smith <garren.smith@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/919a7f8e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/919a7f8e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/919a7f8e

Branch: refs/heads/master
Commit: 919a7f8e98c354f3646f12ce16d58e144a98635a
Parents: c754c6c
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Tue Jun 23 13:44:49 2015 +0200
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Wed Jul 22 14:17:08 2015 +0200

----------------------------------------------------------------------
 Gruntfile.js                     |  2 +-
 app/addons/auth/base.js          | 12 ++---
 app/addons/auth/test/baseSpec.js | 57 ++++++---------------
 app/app.js                       | 24 ---------
 app/tests/appSpec.js             | 96 -----------------------------------
 5 files changed, 19 insertions(+), 172 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/919a7f8e/Gruntfile.js
----------------------------------------------------------------------
diff --git a/Gruntfile.js b/Gruntfile.js
index 570a40f..7955f1a 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -373,7 +373,7 @@ module.exports = function (grunt) {
     mochaSetup: {
       default: {
         files: {
-          src: initHelper.watchFiles(['[Ss]pec.js'], ['./app/addons/**/*[Ss]pec.js', './app/addons/**/*[Ss]pec.react.js',
'./app/core/**/*[Ss]pec.js', './app/**/*[Ss]pec.js'])
+          src: initHelper.watchFiles(['[Ss]pec.js'], ['./app/addons/**/*[Ss]pec.js', './app/addons/**/*[Ss]pec.react.js',
'./app/core/**/*[Ss]pec.js'])
         },
         template: 'test/test.config.underscore',
         config: './app/config.js'

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/919a7f8e/app/addons/auth/base.js
----------------------------------------------------------------------
diff --git a/app/addons/auth/base.js b/app/addons/auth/base.js
index 4d0bb0c..8f4b1b3 100644
--- a/app/addons/auth/base.js
+++ b/app/addons/auth/base.js
@@ -13,13 +13,11 @@
 define([
   "app",
   "api",
-  'addons/auth/routes'
+  "addons/auth/routes"
 ],
 
 function (app, FauxtonAPI, Auth) {
 
-  var isRunningOnBackdoorPort = null;
-
   Auth.session = new Auth.Session();
   FauxtonAPI.setSession(Auth.session);
   app.session = Auth.session;
@@ -39,7 +37,6 @@ function (app, FauxtonAPI, Auth) {
       var link = {};
 
       if (session.isAdminParty()) {
-
         link = {
           id: "auth",
           title: "Admin Party!",
@@ -78,11 +75,8 @@ function (app, FauxtonAPI, Auth) {
 
     });
 
-    FauxtonAPI.isRunningOnBackdoorPort().then(function (res) {
-      isRunningOnBackdoorPort = res.runsOnBackportPort;
-      Auth.session.fetchUser().then(function () {
-        Auth.session.trigger('change');
-      });
+    Auth.session.fetchUser().then(function () {
+      Auth.session.trigger('change');
     });
 
     var auth = function (session, roles) {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/919a7f8e/app/addons/auth/test/baseSpec.js
----------------------------------------------------------------------
diff --git a/app/addons/auth/test/baseSpec.js b/app/addons/auth/test/baseSpec.js
index d22f710..cc5e83f 100644
--- a/app/addons/auth/test/baseSpec.js
+++ b/app/addons/auth/test/baseSpec.js
@@ -21,25 +21,12 @@ define([
 
     describe("failed login", function () {
 
-      after(function () {
-        FauxtonAPI.session.off('change');
-        testUtils.restore(FauxtonAPI.session.isAdminParty);
-        testUtils.restore(FauxtonAPI.isRunningOnBackdoorPort);
-        testUtils.restore(FauxtonAPI.navigate);
-      });
-
       it("redirects with replace: true set", function () {
         var navigateSpy = sinon.spy(FauxtonAPI, 'navigate');
-
-        var stub = sinon.stub(FauxtonAPI.session, 'isAdminParty').returns(true);
-        var deferred = FauxtonAPI.Deferred();
-        sinon.stub(FauxtonAPI, 'isRunningOnBackdoorPort').returns(deferred);
+        FauxtonAPI.auth = new Auth();
+        FauxtonAPI.session.isLoggedIn = function () { return false; };
         Base.initialize();
-
-        deferred.resolve({runsOnBackportPort: false});
-
         FauxtonAPI.auth.authDeniedCb();
-
         assert.ok(navigateSpy.withArgs('/login?urlback=', {replace: true}).calledOnce);
       });
     });
@@ -48,28 +35,20 @@ define([
   describe('auth session change', function () {
 
     afterEach(function () {
-      testUtils.restore(FauxtonAPI.updateHeaderLink);
-      testUtils.restore(FauxtonAPI.session.isAdminParty);
-      testUtils.restore(FauxtonAPI.isRunningOnBackdoorPort);
-      testUtils.restore(FauxtonAPI.session.isLoggedIn);
-      testUtils.restore(FauxtonAPI.session.user);
-      FauxtonAPI.session.off('change');
+      FauxtonAPI.updateHeaderLink.restore && FauxtonAPI.updateHeaderLink.restore();
+      FauxtonAPI.session.isAdminParty.restore && FauxtonAPI.session.isAdminParty.restore();
     });
 
     it('for admin party changes title to admin party', function () {
       var spy = sinon.spy(FauxtonAPI, 'updateHeaderLink');
       var stub = sinon.stub(FauxtonAPI.session, 'isAdminParty').returns(true);
-      var deferred = FauxtonAPI.Deferred();
-      sinon.stub(FauxtonAPI, 'isRunningOnBackdoorPort').returns(deferred);
-      Base.initialize();
-      deferred.resolve({runsOnBackportPort: true});
-
       FauxtonAPI.session.trigger('change');
 
       assert.ok(spy.calledOnce);
       var args = spy.getCall(0).args[0];
 
       assert.ok(args.title.match(/Admin Party/));
+      FauxtonAPI.session.isAdminParty.restore();
     });
 
     it('for login changes title to login', function () {
@@ -77,53 +56,47 @@ define([
       var stub = sinon.stub(FauxtonAPI.session, 'isAdminParty').returns(false);
       sinon.stub(FauxtonAPI.session, 'user').returns({name: 'test-user'});
       sinon.stub(FauxtonAPI.session, 'isLoggedIn').returns(true);
-      var deferred = FauxtonAPI.Deferred();
-      sinon.stub(FauxtonAPI, 'isRunningOnBackdoorPort').returns(deferred);
-      Base.initialize();
-      deferred.resolve({runsOnBackportPort: true});
-
       FauxtonAPI.session.trigger('change');
 
       assert.ok(spy.calledOnce);
       var args = spy.getCall(0).args[0];
 
       assert.equal(args.title, 'test-user');
-
+      FauxtonAPI.session.isLoggedIn.restore();
+      FauxtonAPI.session.user.restore();
+      FauxtonAPI.session.isAdminParty.restore();
     });
 
     it('for login adds logout link', function () {
+      var spy = sinon.spy(FauxtonAPI, 'addHeaderLink');
       var stub = sinon.stub(FauxtonAPI.session, 'isAdminParty').returns(false);
       sinon.stub(FauxtonAPI.session, 'user').returns({name: 'test-user'});
       sinon.stub(FauxtonAPI.session, 'isLoggedIn').returns(true);
-      var deferred = FauxtonAPI.Deferred();
-      sinon.stub(FauxtonAPI, 'isRunningOnBackdoorPort').returns(deferred);
-      Base.initialize();
-      deferred.resolve({runsOnBackportPort: false});
-      var spy = sinon.spy(FauxtonAPI, 'addHeaderLink');
       FauxtonAPI.session.trigger('change');
 
       assert.ok(spy.calledOnce);
       var args = spy.getCall(0).args[0];
 
       assert.equal(args.title, 'Logout');
+      FauxtonAPI.session.isLoggedIn.restore();
+      FauxtonAPI.session.user.restore();
+      FauxtonAPI.session.isAdminParty.restore();
     });
 
     it('for logout, removes logout link', function () {
       var spy = sinon.spy(FauxtonAPI, 'removeHeaderLink');
       var stub = sinon.stub(FauxtonAPI.session, 'isAdminParty').returns(false);
       sinon.stub(FauxtonAPI.session, 'isLoggedIn').returns(false);
-      var deferred = FauxtonAPI.Deferred();
-      sinon.stub(FauxtonAPI, 'isRunningOnBackdoorPort').returns(deferred);
-      Base.initialize();
-      deferred.resolve({runsOnBackportPort: true});
-
       FauxtonAPI.session.trigger('change');
 
       assert.ok(spy.calledOnce);
       var args = spy.getCall(0).args[0];
 
       assert.equal(args.id, 'logout');
+      FauxtonAPI.session.isLoggedIn.restore();
+      FauxtonAPI.session.isAdminParty.restore();
     });
 
+
   });
 });

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/919a7f8e/app/app.js
----------------------------------------------------------------------
diff --git a/app/app.js b/app/app.js
index a75949d..6483e5a 100644
--- a/app/app.js
+++ b/app/app.js
@@ -126,31 +126,7 @@ function (app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI,
Couchdb) {
           type: 'REMOVE_NAVBAR_LINK',
           link: link
       });
-    },
-
-    isRunningOnBackdoorPort: function () {
-      if (this._backdoorDeferred) {
-        return this._backdoorDeferred;
-      }
-
-      this._backdoorDeferred = FauxtonAPI.Deferred();
-
-      $.ajax({
-        type: 'GET',
-        url: app.host + '/_cluster_setup'
-      })
-      .then(function () {
-        this._backdoorDeferred.resolve({runsOnBackportPort: false});
-      }.bind(this))
-      .fail(function (res) {
-        this._backdoorDeferred.resolve({
-          runsOnBackportPort: res.status === 400
-        });
-      }.bind(this));
-
-      return this._backdoorDeferred;
     }
-
   });
 
   return app;

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/919a7f8e/app/tests/appSpec.js
----------------------------------------------------------------------
diff --git a/app/tests/appSpec.js b/app/tests/appSpec.js
deleted file mode 100644
index bf38f87..0000000
--- a/app/tests/appSpec.js
+++ /dev/null
@@ -1,96 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-define([
-  'app',
-  'api',
-  'testUtils',
-], function (app, FauxtonAPI, testUtils) {
-  var assert = testUtils.assert;
-
-  describe('app', function () {
-
-    describe('isRunningOnBackdoorPort', function () {
-      var server, appHost;
-      beforeEach(function () {
-        appHost = app.host;
-        app.host = 'http://example.com';
-        server = sinon.fakeServer.create();
-      });
-      afterEach(function () {
-        app.host = appHost;
-        testUtils.restore(server);
-        testUtils.restore($.ajax);
-        FauxtonAPI._backdoorDeferred = null;
-      });
-
-      it('caches content', function (done) {
-        server.respondWith('GET', 'http://example.com/_cluster_setup',
-            [200, { "Content-Type": "application/json" },
-             '[{ "id": 12, "comment": "Hey there" }]']);
-
-        var spyAjax = sinon.spy($, 'ajax');
-        var promise = FauxtonAPI.isRunningOnBackdoorPort();
-        server.respond();
-
-        promise.then(function (res) {
-          var promise2 = FauxtonAPI.isRunningOnBackdoorPort();
-          promise2.then(function (res) {
-
-            assert.ok(spyAjax.calledOnce);
-            done();
-          });
-        });
-      });
-
-      it('returns false on a 401', function (done) {
-        server.respondWith('GET', 'http://example.com/_cluster_setup',
-            [401, { "Content-Type": "application/json" }, '']);
-
-        var promise = FauxtonAPI.isRunningOnBackdoorPort();
-        server.respond();
-
-        promise.then(function (res) {
-          assert.deepEqual({runsOnBackportPort: false}, res);
-          done();
-        });
-      });
-
-      it('returns false on a 200', function (done) {
-        server.respondWith('GET', 'http://example.com/_cluster_setup',
-            [200, { "Content-Type": "application/json" }, '']);
-
-        var promise = FauxtonAPI.isRunningOnBackdoorPort();
-        server.respond();
-
-        promise.then(function (res) {
-          assert.deepEqual({runsOnBackportPort: false}, res);
-          done();
-        });
-      });
-
-
-      it('returns true on a 400', function (done) {
-        server.respondWith('GET', 'http://example.com/_cluster_setup',
-            [400, {'Content-Type': 'application/json' },
-             '[{ "id": 12, "comment": "Hey there" }]']);
-
-        var promise = FauxtonAPI.isRunningOnBackdoorPort();
-        server.respond();
-
-        promise.then(function (res) {
-          assert.deepEqual({runsOnBackportPort: true}, res);
-          done();
-        });
-      });
-    });
-  });
-});


Mime
View raw message