Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C9E69184E8 for ; Sun, 31 May 2015 20:08:45 +0000 (UTC) Received: (qmail 98799 invoked by uid 500); 31 May 2015 20:08:45 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 98706 invoked by uid 500); 31 May 2015 20:08:45 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 98619 invoked by uid 99); 31 May 2015 20:08:45 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 31 May 2015 20:08:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 73829DFDAE; Sun, 31 May 2015 20:08:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: alexantonenko@apache.org To: commits@ambari.apache.org Date: Sun, 31 May 2015 20:08:46 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/3] ambari git commit: AMBARI-11574. Kerberos: ignore some properties in stack advisor for manually enabled Kerberos. (alexantonenko) AMBARI-11574. Kerberos: ignore some properties in stack advisor for manually enabled Kerberos. (alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2ea32f88 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2ea32f88 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2ea32f88 Branch: refs/heads/trunk Commit: 2ea32f886d06f30acb1ba03449447894cbbe5492 Parents: f4631d7 Author: Alex Antonenko Authored: Sun May 31 21:50:43 2015 +0300 Committer: Alex Antonenko Committed: Sun May 31 23:06:29 2015 +0300 ---------------------------------------------------------------------- .../app/controllers/wizard/step7_controller.js | 40 ++++++++++++++++ .../test/controllers/wizard/step7_test.js | 50 ++++++++++++++++++++ 2 files changed, 90 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/2ea32f88/ambari-web/app/controllers/wizard/step7_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js index 3cc31f0..8550932 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -443,6 +443,8 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E var serviceConfig = App.config.createServiceConfig(serviceName); service.set('selectedConfigGroup', this.get('preSelectedConfigGroup')); this.loadComponentConfigs(service.get('configs'), serviceConfig, service); + // override if a property isRequired or not + this._overrideConfigIsRequired(serviceName); service.set('configs', serviceConfig.get('configs')); }, @@ -1437,5 +1439,43 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E $('a[href="#' + service.serviceName + '"]').tab('show'); } } + }, + + /** + * Override isRequired property of the configurations in given situation + * @param serviceName - make changes only for properties from this service + * @private + */ + _overrideConfigIsRequired: function (serviceName) { + var excludeProperties = [ + { + name: 'KERBEROS', // affected service + exclude: ['kdc_host', 'admin_server_host', 'admin_principal', 'admin_password'], // affected properties + condition: 'false', // check this condition + conditionalProperty: 'manage_identities' // against this property + } + ]; + + var configs = this.get('stepConfigs'), + service = excludeProperties.findProperty('name', serviceName), + serviceConfigs = configs.findProperty('serviceName', serviceName); + if (service && !Em.isEmpty(serviceConfigs.configs)) { + var conditionProperty = serviceConfigs.configs.findProperty('name', service.conditionalProperty); + if (conditionProperty && conditionProperty.get('savedValue') === service.condition) { + service.exclude.forEach(function(property) { + var serviceProperty = serviceConfigs.configs.findProperty('name', property); + if (serviceProperty) { + Em.set(serviceProperty, "isRequired", false); + if (serviceProperty.get('value')==='') { + // clear validation errors because validation does not clear isRequired validations + Em.set(serviceProperty, "error", false); + Em.set(serviceProperty, "errorMessage", ''); + } + // validate property + serviceProperty.validate(); + } + }) + }; + } } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/2ea32f88/ambari-web/test/controllers/wizard/step7_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js index 72e2753..0d69d36 100644 --- a/ambari-web/test/controllers/wizard/step7_test.js +++ b/ambari-web/test/controllers/wizard/step7_test.js @@ -2107,4 +2107,54 @@ describe('App.InstallerStep7Controller', function () { }); + describe('#_overrideConfigIsRequired', function () { + var controller; + beforeEach(function() { + controller = App.WizardStep7Controller.create({}); + var configs = Em.A([ + App.ServiceConfigProperty.create({ name: 'manage_identities', value: 'true', savedValue: 'true', category: 'KDC', serviceName: 'KERBEROS'}), + App.ServiceConfigProperty.create({ name: 'kdc_host', value: '', category: 'KDC', serviceName: 'KERBEROS'}), + App.ServiceConfigProperty.create({ name: 'admin_server_host', value: '', category: 'KDC', serviceName: 'KERBEROS'}), + App.ServiceConfigProperty.create({ name: 'admin_principal', value: '', category: 'KDC', serviceName: 'KERBEROS'}), + App.ServiceConfigProperty.create({ name: 'admin_password', value: '', category: 'KDC', serviceName: 'KERBEROS'}) + ]); + configs.forEach(function(config) { + config.validate(); // make isRequired to trigger validation and to set every property's error flag to true + }); + var serviceConfigs = Em.A([ + App.ServiceConfig.create({ + 'serviceName': 'KERBEROS', + 'configs': configs + }) + ]); + controller.set('stepConfigs', serviceConfigs); + }); + + + it('manage_identities = true should warn user that fields are required', function () { + controller._overrideConfigIsRequired("KERBEROS"); + + var allTrue = true; + controller.get('stepConfigs')[0].configs.forEach(function(p) { + allTrue = allTrue && !p.error; + }); + // should have error + expect(allTrue).to.be.false; + }); + + it('manage_identities = false should NOT warn user that fields are required', function () { + // manage_identities = false + Em.set(controller.get('stepConfigs')[0].configs.findProperty('name','manage_identities'), 'savedValue', 'false'); + + controller._overrideConfigIsRequired("KERBEROS"); + + var allTrue = true; + controller.get('stepConfigs')[0].configs.forEach(function(p) { + allTrue = allTrue && !p.error; + }); + + expect(allTrue).to.be.true; + }); + }); + });