123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- /**
- * 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.
- */
- var App = require('app');
- describe('App.MainAdminKerberosController', function() {
- var controller = App.MainAdminKerberosController.create({});
- describe('#prepareConfigProperties', function() {
- beforeEach(function() {
- sinon.stub(App.Service, 'find').returns([
- Em.Object.create({ serviceName: 'KERBEROS'}),
- Em.Object.create({ serviceName: 'HDFS' })
- ]);
- this.result = controller.prepareConfigProperties([
- Em.Object.create({ name: 'prop1', isEditable: true, serviceName: 'SERVICE1'}),
- Em.Object.create({ name: 'prop2', isEditable: true, serviceName: 'KERBEROS'}),
- Em.Object.create({ name: 'prop3', isEditable: true, serviceName: 'HDFS'}),
- Em.Object.create({ name: 'prop4', isEditable: true, serviceName: 'Cluster'}),
- Em.Object.create({ name: 'prop5', isEditable: true, serviceName: 'SERVICE1'}),
- ]);
- });
- afterEach(function() {
- App.Service.find.restore();
- });
- ['prop1', 'prop5'].forEach(function(item) {
- it('property `{0}` should be absent'.format(item), function() {
- expect(this.result.findProperty('name', item)).to.be.undefined;
- });
- });
- ['prop2', 'prop3', 'prop4'].forEach(function(item) {
- it('property `{0}` should be present and not editable'.format(item), function() {
- var prop = this.result.findProperty('name', item);
- expect(prop).to.be.ok;
- expect(prop.get('isEditable')).to.be.false;
- });
- });
- it('should take displayType from predefinedSiteProperties', function () {
- sinon.stub(App.config, 'get').withArgs('preDefinedSiteProperties').returns([
- {
- name: 'hadoop.security.auth_to_local',
- displayType: 'multiLine'
- }
- ]);
- expect(controller.prepareConfigProperties([
- Em.Object.create({
- name: 'hadoop.security.auth_to_local',
- serviceName: 'HDFS'
- })
- ])[0].get('displayType')).to.equal('multiLine');
- App.config.get.restore();
- });
- });
- describe("#runSecurityCheckSuccess()", function () {
- beforeEach(function () {
- sinon.stub(App, 'showClusterCheckPopup', Em.K);
- sinon.stub(controller, 'startKerberosWizard', Em.K);
- });
- afterEach(function () {
- App.showClusterCheckPopup.restore();
- controller.startKerberosWizard.restore();
- });
- it("shows popup", function () {
- var check = { items: [{
- UpgradeChecks: {
- "check": "Work-preserving RM/NM restart is enabled in YARN configs",
- "status": "FAIL",
- "reason": "FAIL",
- "failed_on": [],
- "check_type": "SERVICE"
- }
- }]};
- controller.runSecurityCheckSuccess(check,null,{label: "name"});
- expect(controller.startKerberosWizard.called).to.be.false;
- expect(App.showClusterCheckPopup.called).to.be.true;
- });
- it("runs startKerberosWizard", function () {
- var check = { items: [{
- UpgradeChecks: {
- "check": "Work-preserving RM/NM restart is enabled in YARN configs",
- "status": "PASS",
- "reason": "OK",
- "failed_on": [],
- "check_type": "SERVICE"
- }
- }]};
- controller.runSecurityCheckSuccess(check,null,{label: "name"});
- expect(controller.startKerberosWizard.called).to.be.true;
- expect(App.showClusterCheckPopup.called).to.be.false;
- });
- });
- describe('#regenerateKeytabs()', function () {
- beforeEach(function () {
- sinon.spy(App.ModalPopup, "show");
- sinon.stub(App.ajax, 'send', Em.K);
- sinon.spy(controller, 'restartServicesAfterRegenerate');
- sinon.spy(controller, 'restartAllServices');
- });
- afterEach(function () {
- App.ModalPopup.show.restore();
- App.ajax.send.restore();
- controller.restartServicesAfterRegenerate.restore();
- controller.restartAllServices.restore();
- });
- it('both confirmation popups should be displayed', function () {
- var popup = controller.regenerateKeytabs();
- expect(App.ModalPopup.show.calledOnce).to.be.true;
- popup.onPrimary();
- expect(controller.restartServicesAfterRegenerate.calledOnce).to.be.true;
- expect(App.ModalPopup.show.calledTwice).to.be.true;
- });
- it('user checked regeneration only for missing host/components', function () {
- var popup = controller.regenerateKeytabs();
- popup.set('regenerateKeytabsOnlyForMissing', true);
- var popup2 = popup.onPrimary();
- popup2.set('restartComponents', true)
- popup2.onPrimary();
- expect(App.ajax.send.args[0][0].data.type).to.equal('missing');
- });
- it('user didn\'t check regeneration only for missing host/components', function () {
- var popup = controller.regenerateKeytabs();
- popup.set('regenerateKeytabsOnlyForMissing', false);
- var popup2 = popup.onPrimary();
- popup2.set('restartComponents', true)
- popup2.onPrimary();
- expect(App.ajax.send.args[0][0].data.type).to.equal('all');
- });
- it('user checked restart services automatically', function () {
- var popup = controller.regenerateKeytabs();
- popup.set('regenerateKeytabsOnlyForMissing', true);
- var popup2 = popup.onPrimary();
- popup2.set('restartComponents', true)
- popup2.onPrimary();
- expect(App.ajax.send.args[0][0].data.withAutoRestart).to.be.true;
- });
- it('user didn\'t check restart services automatically', function () {
- var popup = controller.regenerateKeytabs();
- popup.set('regenerateKeytabsOnlyForMissing', true);
- var popup2 = popup.onPrimary();
- popup2.set('restartComponents', false)
- popup2.onPrimary();
- expect(App.ajax.send.args[0][0].data.withAutoRestart).to.be.false;
- });
- });
- describe('#getSecurityTypeSuccess', function() {
- var tests = [
- {
- data: { },
- e: 'none'
- },
- {
- data: {
- items: []
- },
- e: 'none'
- },
- {
- data: {
- items: [
- {
- configurations: []
- }
- ]
- },
- e: 'none'
- },
- {
- data: {
- items: [
- {
- configurations: [
- {
- type: 'krb-conf',
- properties: {
- 'kdc_type': 'mit'
- }
- }
- ]
- }
- ]
- },
- e: 'none'
- },
- {
- data: {
- items: [
- {
- configurations: [
- {
- type: 'kerberos-env',
- properties: {
- 'kdc_type': 'mit'
- }
- }
- ]
- }
- ]
- },
- e: 'mit'
- },
- {
- data: {
- items: [
- {
- configurations: [
- {
- type: 'kerberos-env',
- properties: {
- 'kdc_type': 'none'
- }
- }
- ]
- }
- ]
- },
- e: 'none'
- }
- ].forEach(function(test) {
- it('json is ' + JSON.stringify(test.data) + ' kdc type should be ' + test.e, function() {
- controller.set('isManualKerberos', undefined);
- controller.getSecurityTypeSuccess(test.data, {}, {});
- expect(controller.get('kdc_type')).to.eql(test.e);
- });
- });
- });
- });
|