소스 검색

Revert "AMBARI-7526. Unable to logout from Admin View, when ambari-server is stopped. (jaimin)"

This reverts commit 3843209c127aeab29c63799c5c38df2b54b2b9f1.
Yusaku Sako 10 년 전
부모
커밋
9db24dad0d

+ 1 - 16
ambari-admin/pom.xml

@@ -15,7 +15,7 @@
    limitations under the License.
    limitations under the License.
 -->
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
   <parent>
     <groupId>org.apache.ambari</groupId>
     <groupId>org.apache.ambari</groupId>
     <artifactId>ambari-project</artifactId>
     <artifactId>ambari-project</artifactId>
@@ -122,21 +122,6 @@
               </arguments>
               </arguments>
             </configuration>
             </configuration>
           </execution>
           </execution>
-          <execution>
-            <id>unit test</id>
-            <phase>test</phase>
-            <goals>
-              <goal>exec</goal>
-            </goals>
-            <configuration>
-              <workingDirectory>${basedir}/src/main/resources/ui/admin-web</workingDirectory>
-              <executable>npm</executable>
-              <arguments>
-                <argument>run</argument>
-                <argument>test-single-run</argument>
-              </arguments>
-            </configuration>
-          </execution>
         </executions>
         </executions>
       </plugin>
       </plugin>
       <plugin>
       <plugin>

+ 1 - 1
ambari-admin/src/main/resources/ui/admin-web/app/index.html

@@ -52,7 +52,7 @@
             <ul class="nav navbar-nav navbar-right">
             <ul class="nav navbar-nav navbar-right">
               <li>
               <li>
                 <div class="btn-group" dropdown is-open="status.isopen">
                 <div class="btn-group" dropdown is-open="status.isopen">
-                  <button type="button" class="btn btn-default dropdown-toggle navbar-btn" ng-disabled="disabled">
+                <button type="button" class="btn btn-default dropdown-toggle navbar-btn" ng-disabled="disabled">
                     <i class="fa fa-user"></i> {{currentUser}} <span class="caret"></span>
                     <i class="fa fa-user"></i> {{currentUser}} <span class="caret"></span>
                   </button>
                   </button>
                   <ul class="dropdown-menu" role="menu">
                   <ul class="dropdown-menu" role="menu">

+ 6 - 9
ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js

@@ -18,16 +18,13 @@
 'use strict';
 'use strict';
 
 
 angular.module('ambariAdminConsole')
 angular.module('ambariAdminConsole')
-.controller('MainCtrl',['$scope', '$window','Auth', 'uiAlert', '$modal', 'Cluster', function($scope, $window, Auth, uiAlert, $modal, Cluster) {
+.controller('MainCtrl',['$scope', 'Auth', 'uiAlert', '$modal', 'Cluster', function($scope, Auth, uiAlert, $modal, Cluster) {
   $scope.signOut = function() {
   $scope.signOut = function() {
-    var data = JSON.parse(localStorage.ambari);
-    delete data.app.authenticated;
-    delete data.app.loginName;
-    delete data.app.user;
-    localStorage.ambari = JSON.stringify(data);
-    $window.location.pathname = '';
-    $scope.hello = "hello";
-    Auth.signout();
+    Auth.signout().then(function() {
+     window.location.pathname = ''; // Change location hard, because Angular works only with relative urls
+    }).catch(function(data) {
+      uiAlert.danger(data.data.status, data.data.message);
+    });
   };
   };
 
 
   $scope.about = function() {
   $scope.about = function() {

+ 1 - 8
ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Auth.js

@@ -19,14 +19,7 @@
 
 
 angular.module('ambariAdminConsole')
 angular.module('ambariAdminConsole')
 .factory('Auth',['$http', 'Settings', function($http, Settings) {
 .factory('Auth',['$http', 'Settings', function($http, Settings) {
-  var ambari;
-  var currentUserName;
-  if (localStorage.ambari) {
-    ambari = JSON.parse(localStorage.ambari);
-    if (ambari && ambari.app && ambari.app.loginName) {
-      currentUserName = ambari.app.loginName;
-    }
-  }
+	var currentUserName = JSON.parse(localStorage.ambari).app.loginName;
   return {
   return {
     signout: function() {
     signout: function() {
       return $http({
       return $http({

+ 4 - 11
ambari-admin/src/main/resources/ui/admin-web/bower.json

@@ -3,21 +3,14 @@
   "private": true,
   "private": true,
   "dependencies": {
   "dependencies": {
     "bootstrap": "~3.1.1",
     "bootstrap": "~3.1.1",
-    "angular": "~1.2.25",
-    "angular-route": "~1.2.25",
+    "angular": "~1.2.18",
+    "angular-route": "~1.2.18",
     "angular-bootstrap": "~0.11.0",
     "angular-bootstrap": "~0.11.0",
-    "underscore": "~1.7.0",
     "restangular": "~1.4.0",
     "restangular": "~1.4.0",
     "angular-bootstrap-toggle-switch": "~0.5.1",
     "angular-bootstrap-toggle-switch": "~0.5.1",
-    "angular-animate": "~1.2.25",
+    "angular-animate": "~1.2.23",
     "angular-translate": "~2.2.0",
     "angular-translate": "~2.2.0",
     "font-awesome": "~4.2.0"
     "font-awesome": "~4.2.0"
   },
   },
-  "devDependencies": {
-    "angular-mocks": "~1.2.25",
-    "commonjs": "~0.2.0",
-    "chai": "~1.8.0",
-    "mocha": "~1.14.0",
-    "sinon": "~1.10.3"
-  }
+  "devDependencies": {}
 }
 }

+ 0 - 19
ambari-admin/src/main/resources/ui/admin-web/package.json

@@ -4,12 +4,6 @@
   "dependencies": {
   "dependencies": {
   },
   },
   "devDependencies": {
   "devDependencies": {
-    "karma": "^0.12.16",
-    "karma-phantomjs-launcher": "~0.1",
-    "karma-chrome-launcher": "^0.1.4",
-    "karma-jasmine": "^0.1.5",
-    "protractor": "~1.0.0",
-    "http-server": "^0.6.1",
     "bower": "1.3.8",
     "bower": "1.3.8",
     "gulp": "^3.6.0",
     "gulp": "^3.6.0",
     "gulp-autoprefixer": "^0.0.7",
     "gulp-autoprefixer": "^0.0.7",
@@ -24,19 +18,6 @@
     "gulp-useref": "^0.4.2",
     "gulp-useref": "^0.4.2",
     "gulp-plumber": "*"
     "gulp-plumber": "*"
   },
   },
-  "scripts": {
-    "postinstall": "bower install",
-    "prestart": "npm install",
-    "start": "http-server -a 0.0.0.0 -p 8000",
-    "pretest": "npm install",
-    "test": "node node_modules/karma/bin/karma start test/karma.conf.js",
-    "test-single-run": "node node_modules/karma/bin/karma start test/karma.conf.js  --single-run",
-    "preupdate-webdriver": "npm install",
-    "update-webdriver": "webdriver-manager update",
-    "preprotractor": "npm run update-webdriver",
-    "protractor": "protractor test/protractor-conf.js",
-    "update-index-async": "node -e \"require('shelljs/global'); sed('-i', /\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/, '//@@NG_LOADER_START@@\\n' + cat('bower_components/angular-loader/angular-loader.min.js') + '\\n//@@NG_LOADER_END@@', 'app/index-async.html');\""
-  },
   "engines": {
   "engines": {
     "node": ">=0.10.0"
     "node": ">=0.10.0"
   }
   }

+ 0 - 43
ambari-admin/src/main/resources/ui/admin-web/test/e2e/signout.js

@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-'use strict';
-describe('Ambari sign out from Admin view', function () {
-  describe('Admin view', function () {
-    var ptor = protractor.getInstance();
-    beforeEach(function () {
-      ptor.get('app/index.html');
-      ptor.waitForAngular();
-    });
-    it('should navigate to login page on clicking "Sign out" action', function () {
-      var userDropdownBtn = element(by.binding('currentUser'));
-      var signOutAction = element(by.css('[ng-click="signOut()"]'));
-      //Action-1: Click on user dropdown menu and
-      //Action-2: Click on SignOut action link
-      userDropdownBtn.click().then(function () {
-        signOutAction.click().then(function () {
-          //Validation
-          setTimeout(function () {
-            expect(ptor.getCurrentUrl()).toContain('#/login');
-          }, 3000);
-        });
-      });
-    });
-  });
-});
-
-

+ 0 - 58
ambari-admin/src/main/resources/ui/admin-web/test/karma.conf.js

@@ -1,58 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-
-module.exports = function(config){
-  config.set({
-
-    basePath : '../',
-
-    files : [
-      'app/bower_components/angular/angular.js',
-      'app/bower_components/angular-animate/angular-animate.js',
-      'app/bower_components/angular-bootstrap/ui-bootstrap.js',
-      'app/bower_components/angular-bootstrap-toggle-switch/angular-toggle-switch.js',
-      'app/bower_components/angular-route/angular-route.js',
-      'app/bower_components/angular-translate/angular-translate.js',
-      'app/bower_components/underscore/underscore.js',
-      'app/bower_components/restangular/dist/restangular.js',
-      'app/bower_components/mocha/mocha.js',
-      'app/bower_components/chai/chai.js',
-      'app/bower_components/sinon/lib/sinon.js',
-      'app/bower_components/angular-mocks/angular-mocks.js',
-      'app/scripts/**/*.js',
-      'test/unit/**/*.js'
-    ],
-
-    autoWatch : true,
-
-    frameworks: ['jasmine'],
-
-    browsers: ['PhantomJS'],
-
-    plugins : [
-            'karma-jasmine',
-            'karma-phantomjs-launcher'
-            ],
-
-    junitReporter : {
-      outputFile: 'test_out/unit.xml',
-      suite: 'unit'
-    }
-
-  });
-};

+ 10 - 31
ambari-admin/src/main/resources/ui/admin-web/test/protractor-conf.js → ambari-admin/src/main/resources/ui/admin-web/test/spec/test.js

@@ -15,37 +15,16 @@
  * See the License for the specific language governing permissions and
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * limitations under the License.
  */
  */
+/* global describe, it */
 
 
-exports.config = {
-  allScriptsTimeout: 11000,
+(function () {
+    'use strict';
 
 
-  specs: [
-    'e2e/*.js'
-  ],
-
-  capabilities: {
-    'browserName': 'chrome'
-  },
-
-  chromeOnly: true,
-
-  baseUrl: 'http://localhost:8000',
-
-  rootElement: 'body',
-
-  onPrepare: function() {
-
-  },
-
-
-  framework: 'jasmine',
-
-  jasmineNodeOpts: {
-    onComplete: null,
-    isVerbose: true,
-    showColors: true,
-    includeStackTrace: true,
-    defaultTimeoutInterval: 30000
-  }
-};
+    describe('Give it some context', function () {
+        describe('maybe a bit more context here', function () {
+            it('should run here few assertions', function () {
 
 
+            });
+        });
+    });
+})();

+ 0 - 54
ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/mainCtrl_test.js

@@ -1,54 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-
-describe('#Auth', function () {
-
-  describe('signout', function () {
-    var scope, ctrl, $httpBackend, $window, clusterService,deferred;
-    beforeEach(module('ambariAdminConsole', function($provide){
-      $provide.value('$window', {location: {pathname: 'http://c6401.ambari.apache.org:8080/views/ADMIN_VIEW/1.0.0/INSTANCE/#/'}});
-      localStorage.ambari = JSON.stringify({app: {authenticated: true, loginName: 'admin', user: 'user'}});
-    }));
-    afterEach(function() {
-      $httpBackend.verifyNoOutstandingExpectation();
-      $httpBackend.verifyNoOutstandingRequest();
-    });
-    beforeEach(inject(function (_$httpBackend_, $rootScope, $controller, _$window_, _Cluster_,_$q_) {
-      clusterService =  _Cluster_;
-      deferred = _$q_.defer();
-      spyOn(clusterService, 'getStatus').andReturn(deferred.promise);
-      deferred.resolve('c1');
-      $window = _$window_;
-      $httpBackend = _$httpBackend_;
-      $httpBackend.whenGET('/api/v1/logout').respond(200,{message: "successfully logged out"});
-      scope = $rootScope.$new();
-      scope.$apply();
-      ctrl = $controller('MainCtrl', {$scope: scope});
-    }));
-
-    it('should reset window.location and ambari localstorage', function () {
-      scope.signOut();
-      $httpBackend.flush();
-      chai.expect($window.location.pathname).to.be.empty;
-      var data = JSON.parse(localStorage.ambari);
-      chai.expect(data.app.authenticated).to.equal(undefined);
-      chai.expect(data.app.loginName).to.equal(undefined);
-      chai.expect(data.app.user).to.equal(undefined);
-    });
-  });
-});