Browse Source

AMBARI-9553. Ranger:Add Service wizard navigates to 'Configure Identities' step for unsecure cluster. (akovalenko)

Aleksandr Kovalenko 10 years ago
parent
commit
e52dbb5f47

+ 4 - 0
ambari-web/app/controllers/main/admin/kerberos/step4_controller.js

@@ -31,6 +31,10 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
   },
   
   loadStep: function() {
+    if (this.get('wizardController.skipConfigureIdentitiesStep')) {
+      App.router.send('next');
+      return;
+    }
     var self = this;
     this.clearStep();
     this.getDescriptorConfigs().then(function(properties) {

+ 1 - 0
ambari-web/app/controllers/main/service/add_controller.js

@@ -547,6 +547,7 @@ App.AddServiceController = App.WizardController.extend({
   checkSecurityStatus: function() {
     if (App.supports.automatedKerberos) {
       if (!App.router.get('mainAdminKerberosController.securityEnabled')) {
+        this.set('skipConfigureIdentitiesStep', true);
         this.get('isStepDisabled').findProperty('step', 5).set('value', true);
       }
     }

+ 50 - 1
ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js

@@ -247,6 +247,55 @@ describe('App.KerberosWizardStep4Controller', function() {
       controller.set('wizardController.name', 'KerberosWizard');
       expect(controller.createCategoryForServices()).to.eql([App.ServiceConfigCategory.create({ name: 'HDFS', displayName: 'HDFS', collapsedByDefault: true})]);
     });
-  })
+  });
+
+  describe('#loadStep', function() {
+
+    describe('skip "Configure Identities" step', function() {
+      beforeEach(function() {
+        this.controller = App.KerberosWizardStep4Controller.create({});
+        this.wizardController = App.AddServiceController.create({});
+        this.controller.set('wizardController', this.wizardController);
+        sinon.stub(this.controller, 'clearStep').returns(true);
+        sinon.stub(this.controller, 'getDescriptorConfigs').returns((new $.Deferred()).resolve(true).promise());
+        sinon.stub(this.controller, 'setStepConfigs').returns(true);
+        sinon.stub(App.router, 'send').withArgs('next');
+      });
+
+      afterEach(function() {
+        this.controller.clearStep.restore();
+        this.controller.getDescriptorConfigs.restore();
+        this.controller.setStepConfigs.restore();
+        App.router.send.restore();
+      });
+
+      var tests = [
+        {
+          securityEnabled: true,
+          stepSkipped: false,
+        },
+        {
+          securityEnabled: false,
+          stepSkipped: true
+        }
+      ];
+
+      tests.forEach(function(test) {
+        it('security {0} configure identities step should be {1}'.format(!!test.securityEnabled ? 'enabled' : 'disabled', !!test.stepSkipped ? 'skipped' : 'not skipped'), function() {
+          sinon.stub(App.router, 'get').withArgs('mainAdminKerberosController.securityEnabled').returns(test.securityEnabled);
+          this.wizardController.checkSecurityStatus();
+          App.router.get.restore();
+          this.controller.loadStep();
+          expect(App.router.send.calledWith('next')).to.be.eql(test.stepSkipped);
+        });
+      }, this);
+
+      it('step should not be disabled for Add Kerberos wizard', function() {
+        this.controller.set('wizardController', App.KerberosWizardController.create({}));
+        this.controller.loadStep();
+        expect(App.router.send.calledWith('next')).to.be.false;
+      });
+    });
+  });
 
 });