Repository: ambari Updated Branches: refs/heads/trunk 1469a0e62 -> a8a238742
AMBARI-13765. Encrypted value of the password is changed even when the value is not changed by the user (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a8a23874 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a8a23874 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a8a23874 Branch: refs/heads/trunk Commit: a8a2387428393715890e322b3ba03d8787fe7920 Parents: 1469a0e Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Fri Nov 6 14:52:22 2015 +0200 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Fri Nov 6 14:54:46 2015 +0200 ---------------------------------------------------------------------- .../controllers/main/service/info/configs.js | 13 ++++++++ ambari-web/app/messages.js | 3 ++ .../mixins/common/configs/configs_comparator.js | 7 +++++ .../app/mixins/common/configs/configs_saver.js | 10 +++++- .../configs/objects/service_config_property.js | 19 +++++++++++- .../common/configs/save_configuration.hbs | 3 ++ .../views/common/configs/config_history_flow.js | 10 +++++- ambari-web/app/views/common/controls_view.js | 2 +- .../main/service/info/config_test.js | 14 +++++++++ .../objects/service_config_property_test.js | 32 +++++++++++++++++++- 10 files changed, 108 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/a8a23874/ambari-web/app/controllers/main/service/info/configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js index f3bdc1a..b51711e 100644 --- a/ambari-web/app/controllers/main/service/info/configs.js +++ b/ambari-web/app/controllers/main/service/info/configs.js @@ -226,6 +226,19 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A }.property('propertyFilters', 'isCompareMode'), /** + * Detects of some of the `password`-configs has not default value + * + * @type {boolean} + */ + passwordConfigsAreChanged: function () { + return this.get('stepConfigs') + .findProperty('serviceName', this.get('selectedService.serviceName')) + .get('configs') + .filterProperty('displayType', 'password') + .someProperty('isNotDefaultValue'); + }.property('stepConfigs.[].configs', 'selectedService.serviceName'), + + /** * indicate whether service config version belongs to default config group * @param {object} version * @return {Boolean} http://git-wip-us.apache.org/repos/asf/ambari/blob/a8a23874/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 1ac2346..2cb7a97 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -1805,6 +1805,7 @@ Em.I18n.translations = { 'services.service.config.nothing.to.display': 'No properties to display.', 'services.service.config.final':'Final', + 'services.service.config.password.additionalDescription': 'For security purposes, password changes will not be shown in configuration version comparisons', 'services.service.config.saved':'Save Configuration Changes', 'services.service.config.notSaved':'Unable to Save Configuration Changes', 'services.service.config.restartService.TooltipMessage':'<b>Restart Service</b><br>Stale configuration used by {0} components on {1} hosts:{2}', @@ -2597,6 +2598,8 @@ Em.I18n.translations = { 'dashboard.configHistory.info-bar.save.popup.title': 'Save Configuration', 'dashboard.configHistory.info-bar.makeCurrent.popup.title': 'Make Current Confirmation', 'dashboard.configHistory.info-bar.save.popup.placeholder': 'What did you change?', + 'dashboard.configHistory.info-bar.save.popup.warningForPasswordChange': 'This configuration change includes a password change. The password change will be saved but for security purposes, password changes will not be shown in configuration version comparisons.', + 'dashboard.configHistory.info-bar.save.popup.notesForPasswordChange': 'Password change', 'dashboard.configHistory.info-bar.revert.button': 'Make Current', 'dashboard.configHistory.info-bar.revert.versionButton': 'Make {0} Current', 'dashboard.configHistory.info-bar.view.button.disabled': 'You are currently viewing this version.', http://git-wip-us.apache.org/repos/asf/ambari/blob/a8a23874/ambari-web/app/mixins/common/configs/configs_comparator.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/configs/configs_comparator.js b/ambari-web/app/mixins/common/configs/configs_comparator.js index bb7bc88..ab8cbb4 100644 --- a/ambari-web/app/mixins/common/configs/configs_comparator.js +++ b/ambari-web/app/mixins/common/configs/configs_comparator.js @@ -260,6 +260,8 @@ App.ConfigsComparator = Em.Mixin.create({ /** * check value and final attribute of original and compare config for differences + * if config is password, it won't be shown in the comparison + * * @param originalConfig * @param compareConfig * @return {Boolean} @@ -267,6 +269,11 @@ App.ConfigsComparator = Em.Mixin.create({ * @method hasCompareDiffs */ hasCompareDiffs: function (originalConfig, compareConfig) { + var displayType = Em.get(originalConfig, 'displayType'); + var notShownTypes = ['password']; + if (notShownTypes.contains(displayType)) { + return false; + } var originalValue = App.config.trimProperty({ value: Em.get(originalConfig, 'value'), displayType: 'string' }); var compareValue = App.config.trimProperty({ value: Em.get(compareConfig, 'value'), displayType: 'string' }); http://git-wip-us.apache.org/repos/asf/ambari/blob/a8a23874/ambari-web/app/mixins/common/configs/configs_saver.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/configs/configs_saver.js b/ambari-web/app/mixins/common/configs/configs_saver.js index 2214f0a..b2a96f4 100644 --- a/ambari-web/app/mixins/common/configs/configs_saver.js +++ b/ambari-web/app/mixins/common/configs/configs_saver.js @@ -818,20 +818,28 @@ App.ConfigsSaverMixin = Em.Mixin.create({ */ showSavePopup: function (path, callback) { var self = this; + var passwordWasChanged = this.get('passwordConfigsAreChanged'); return App.ModalPopup.show({ header: Em.I18n.t('common.warning'), bodyClass: Em.View.extend({ templateName: require('templates/common/configs/save_configuration'), showSaveWarning: true, + showPasswordChangeWarning: passwordWasChanged, notesArea: Em.TextArea.extend({ + value: passwordWasChanged ? Em.I18n.t('dashboard.configHistory.info-bar.save.popup.notesForPasswordChange') : '', classNames: ['full-width'], placeholder: Em.I18n.t('dashboard.configHistory.info-bar.save.popup.placeholder'), + didInsertElement: function () { + if (this.get('value')) { + this.onChangeValue(); + } + }, onChangeValue: function() { this.get('parentView.parentView').set('serviceConfigNote', this.get('value')); }.observes('value') }) }), - footerClass: Ember.View.extend({ + footerClass: Em.View.extend({ templateName: require('templates/main/service/info/save_popup_footer'), isSaveDisabled: function() { return self.get('isSubmitDisabled'); http://git-wip-us.apache.org/repos/asf/ambari/blob/a8a23874/ambari-web/app/models/configs/objects/service_config_property.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/objects/service_config_property.js b/ambari-web/app/models/configs/objects/service_config_property.js index d4bb2fd..33ca761 100644 --- a/ambari-web/app/models/configs/objects/service_config_property.js +++ b/ambari-web/app/models/configs/objects/service_config_property.js @@ -244,6 +244,7 @@ App.ServiceConfigProperty = Em.Object.extend({ this.set('recommendedValue', ''); } this.set('initialValue', this.get('value')); + this.updateDescription(); }, /** @@ -477,6 +478,22 @@ App.ServiceConfigProperty = Em.Object.extend({ } else { return false; } - }.property('displayType', 'name', 'App.isHadoop22Stack') + }.property('displayType', 'name', 'App.isHadoop22Stack'), + + /** + * Update description for `password`-config + * Add extra-message about their comparison + * + * @method updateDescription + */ + updateDescription: function () { + var description = this.get('description'); + var displayType = this.get('displayType'); + var additionalDescription = Em.I18n.t('services.service.config.password.additionalDescription'); + if ('password' === displayType && !description.contains(additionalDescription)) { + description += '<br />' + additionalDescription; + } + this.set('description', description); + } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/a8a23874/ambari-web/app/templates/common/configs/save_configuration.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/save_configuration.hbs b/ambari-web/app/templates/common/configs/save_configuration.hbs index 8ef4efd..8ba7bb6 100644 --- a/ambari-web/app/templates/common/configs/save_configuration.hbs +++ b/ambari-web/app/templates/common/configs/save_configuration.hbs @@ -20,6 +20,9 @@ <div class="span12 alert alert-warning">{{t services.service.config.exitPopup.body}}</div> </div> {{/if}} +{{#if view.showPasswordChangeWarning}} + <p class="alert alert-warning">{{t dashboard.configHistory.info-bar.save.popup.warningForPasswordChange}}</p> +{{/if}} <div class="row-fluid"> <div class="span1">{{t common.notes}}</div> <div class="span10">{{view view.notesArea}}</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/a8a23874/ambari-web/app/views/common/configs/config_history_flow.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/config_history_flow.js b/ambari-web/app/views/common/configs/config_history_flow.js index 26b6cd9..da748af 100644 --- a/ambari-web/app/views/common/configs/config_history_flow.js +++ b/ambari-web/app/views/common/configs/config_history_flow.js @@ -450,20 +450,28 @@ App.ConfigHistoryFlowView = Em.View.extend({ */ save: function () { var self = this; + var passwordWasChanged = this.get('controller.passwordConfigsAreChanged'); return App.ModalPopup.show({ header: Em.I18n.t('dashboard.configHistory.info-bar.save.popup.title'), serviceConfigNote: '', bodyClass: Em.View.extend({ templateName: require('templates/common/configs/save_configuration'), + showPasswordChangeWarning: passwordWasChanged, notesArea: Em.TextArea.extend({ classNames: ['full-width'], + value: passwordWasChanged ? Em.I18n.t('dashboard.configHistory.info-bar.save.popup.notesForPasswordChange') : '', placeholder: Em.I18n.t('dashboard.configHistory.info-bar.save.popup.placeholder'), + didInsertElement: function () { + if (this.get('value')) { + this.onChangeValue(); + } + }, onChangeValue: function() { this.get('parentView.parentView').set('serviceConfigNote', this.get('value')); }.observes('value') }) }), - footerClass: Ember.View.extend({ + footerClass: Em.View.extend({ templateName: require('templates/main/service/info/save_popup_footer') }), primary: Em.I18n.t('common.save'), http://git-wip-us.apache.org/repos/asf/ambari/blob/a8a23874/ambari-web/app/views/common/controls_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/controls_view.js b/ambari-web/app/views/common/controls_view.js index d58ac9f..1d11ad3 100644 --- a/ambari-web/app/views/common/controls_view.js +++ b/ambari-web/app/views/common/controls_view.js @@ -223,7 +223,7 @@ App.ServiceConfigTextFieldWithUnit = Ember.View.extend(App.ServiceConfigPopoverS * Password control * @type {*} */ -App.ServiceConfigPasswordField = Ember.TextField.extend({ +App.ServiceConfigPasswordField = Ember.TextField.extend(App.ServiceConfigPopoverSupport, { serviceConfig: null, type: 'password', http://git-wip-us.apache.org/repos/asf/ambari/blob/a8a23874/ambari-web/test/controllers/main/service/info/config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js index ea22fef..e48d9fd 100644 --- a/ambari-web/test/controllers/main/service/info/config_test.js +++ b/ambari-web/test/controllers/main/service/info/config_test.js @@ -116,6 +116,9 @@ describe("App.MainServiceInfoConfigsController", function () { ]; beforeEach(function () { + mainServiceInfoConfigsController.reopen({ + passwordConfigsAreChanged: false + }); sinon.stub(mainServiceInfoConfigsController, "get", function(key) { return key == 'isSubmitDisabled' ? false : Em.get(mainServiceInfoConfigsController, key); }); @@ -822,4 +825,15 @@ describe("App.MainServiceInfoConfigsController", function () { }); + describe('#hasCompareDiffs', function () { + + it('should return false for `password`-configs', function () { + + var hasCompareDiffs = mainServiceInfoConfigsController.hasCompareDiffs({displayType: 'password'}, {}); + expect(hasCompareDiffs).to.be.false; + + }); + + }); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/a8a23874/ambari-web/test/models/configs/objects/service_config_property_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/configs/objects/service_config_property_test.js b/ambari-web/test/models/configs/objects/service_config_property_test.js index da9e7af..f640a78 100644 --- a/ambari-web/test/models/configs/objects/service_config_property_test.js +++ b/ambari-web/test/models/configs/objects/service_config_property_test.js @@ -478,6 +478,36 @@ describe('App.ServiceConfigProperty', function () { it('should be defined as empty array', function () { expect(serviceConfigProperty.get('overrideIsFinalValues')).to.eql([]); }); - }) + }); + + describe('#updateDescription', function () { + + beforeEach(function () { + serviceConfigProperty.setProperties({ + displayType: 'password', + description: '' + }); + }); + + it('should add extra-message to the description for `password`-configs', function () { + + var extraMessage = Em.I18n.t('services.service.config.password.additionalDescription'); + serviceConfigProperty.updateDescription(); + expect(serviceConfigProperty.get('description')).to.contain(extraMessage); + + }); + + it('should not add extra-message to the description if it already contains it', function () { + + var extraMessage = Em.I18n.t('services.service.config.password.additionalDescription'); + serviceConfigProperty.updateDescription(); + serviceConfigProperty.updateDescription(); + serviceConfigProperty.updateDescription(); + expect(serviceConfigProperty.get('description')).to.contain(extraMessage); + var subd = serviceConfigProperty.get('description').replace(extraMessage, ''); + expect(subd).to.not.contain(extraMessage); + }); + + }); });