You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2015/12/03 12:21:37 UTC
ambari git commit: AMBARI-14179 Add Config Group name validaton
(akovalenko)
Repository: ambari
Updated Branches:
refs/heads/trunk c17d6ddf7 -> 6019649ec
AMBARI-14179 Add Config Group name validaton (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6019649e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6019649e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6019649e
Branch: refs/heads/trunk
Commit: 6019649ecee59f4f94f4abd0d2b5a873b8b9ec15
Parents: c17d6dd
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Thu Dec 3 13:19:20 2015 +0200
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Thu Dec 3 13:19:20 2015 +0200
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 +
.../main/service/configs/config_overridable.js | 15 ++--
.../service/configs/config_overridable_test.js | 95 ++++++++++++++++++++
3 files changed, 106 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/6019649e/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 23460b7..e497aa2 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -149,6 +149,7 @@ var files = [
'test/mixins/common/widget_mixin_test',
'test/mixins/main/host/details/host_components/decommissionable_test',
'test/mixins/main/service/configs/widget_popover_support_test',
+ 'test/mixins/main/service/configs/config_overridable_test',
'test/mixins/routers/redirections_test',
'test/mixins/wizard/addSeccurityConfigs_test',
'test/mixins/wizard/wizard_menu_view_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/6019649e/ambari-web/app/mixins/main/service/configs/config_overridable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/configs/config_overridable.js b/ambari-web/app/mixins/main/service/configs/config_overridable.js
index f0a7f56..9005725 100644
--- a/ambari-web/app/mixins/main/service/configs/config_overridable.js
+++ b/ambari-web/app/mixins/main/service/configs/config_overridable.js
@@ -17,7 +17,7 @@
*/
var App = require('app');
-var arrayUtils = require('utils/array_utils');
+var validator = require('utils/validator');
/**
* Mixin with methods for config groups and overrides processing
@@ -170,10 +170,15 @@ App.ConfigOverridable = Em.Mixin.create({
var isWarning = false;
var optionSelect = this.get('optionSelectConfigGroup');
if (!optionSelect) {
- var nn = this.get('newConfigGroupName');
- if (nn && configGroups.mapProperty('name').contains(nn.trim())) {
- msg = Em.I18n.t("config.group.selection.dialog.err.name.exists");
- isWarning = true;
+ var nn = this.get('newConfigGroupName').trim();
+ if (nn) {
+ if (!validator.isValidConfigGroupName(nn)) {
+ msg = Em.I18n.t("form.validator.configGroupName");
+ isWarning = true;
+ } else if (configGroups.mapProperty('name').contains(nn)) {
+ msg = Em.I18n.t("config.group.selection.dialog.err.name.exists");
+ isWarning = true;
+ }
}
}
this.set('warningMessage', msg);
http://git-wip-us.apache.org/repos/asf/ambari/blob/6019649e/ambari-web/test/mixins/main/service/configs/config_overridable_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/main/service/configs/config_overridable_test.js b/ambari-web/test/mixins/main/service/configs/config_overridable_test.js
new file mode 100644
index 0000000..3c88819
--- /dev/null
+++ b/ambari-web/test/mixins/main/service/configs/config_overridable_test.js
@@ -0,0 +1,95 @@
+/**
+ * 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');
+
+require('mixins/main/service/configs/config_overridable');
+
+var configOverridable;
+
+var configGroups = [
+ Em.Object.create({name: 'configGroup1'}),
+ Em.Object.create({name: 'configGroup2'}),
+ Em.Object.create({name: 'configGroup3'})
+];
+
+describe('App.Decommissionable', function () {
+
+ beforeEach(function () {
+ configOverridable = Em.Object.create(App.ConfigOverridable);
+ });
+
+ describe('#validate of Config Group Selection Creation Dialog', function () {
+
+ var testCases = [
+ {
+ text: 'fail validation because of disallowed symbols',
+ name: '123=',
+ isWarn: true,
+ errorMessage: Em.I18n.t("form.validator.configGroupName"),
+ option: false
+ },
+ {
+ text: 'fail validation because of the same name',
+ name: 'configGroup1',
+ isWarn: true,
+ errorMessage: Em.I18n.t("config.group.selection.dialog.err.name.exists"),
+ option: false
+ },
+ {
+ text: 'pass validation',
+ name: '123',
+ isWarn: false,
+ errorMessage: ' ',
+ option: false
+ },
+ {
+ text: 'pass validation as another option is selected',
+ name: '123',
+ isWarn: false,
+ errorMessage: ' ',
+ option: true
+ },
+ {
+ text: 'pass validation because there is no value entered',
+ name: '',
+ isWarn: false,
+ errorMessage: ' ',
+ option: true
+ },
+ {
+ text: 'pass validation because there is no value entered',
+ name: ' ',
+ isWarn: false,
+ errorMessage: ' ',
+ option: true
+ }
+ ];
+
+ testCases.forEach(function (item) {
+ it('should ' + item.text, function () {
+ var popup = configOverridable.launchConfigGroupSelectionCreationDialog('service', configGroups, Em.Object.create());
+ popup.set('newConfigGroupName', item.name);
+ popup.set('optionSelectConfigGroup', item.option);
+ expect(popup.get('isWarning')).to.equal(item.isWarn);
+ expect(popup.get('warningMessage')).to.equal(item.errorMessage);
+ });
+ });
+ });
+
+});