You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2015/12/01 19:20:30 UTC
[40/50] ambari git commit: AMBARI-14118 All Kerberos-related fields
are to be made read-only in the service configuration screens. (atkach)
AMBARI-14118 All Kerberos-related fields are to be made read-only in the service configuration screens. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6c945804
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6c945804
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6c945804
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 6c945804b5971eae9158ebb98d1a044d47f910f6
Parents: 878c61d
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Mon Nov 30 19:40:48 2015 +0200
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Tue Dec 1 12:50:42 2015 +0200
----------------------------------------------------------------------
ambari-web/app/app.js | 6 ++
.../configs/stack_config_properties_mapper.js | 2 +-
ambari-web/app/utils/config.js | 11 ++++
ambari-web/test/utils/config_test.js | 59 +++++++++++++++++++-
4 files changed, 76 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/6c945804/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index f2548f8..0932964 100644
--- a/ambari-web/app/app.js
+++ b/ambari-web/app/app.js
@@ -38,6 +38,12 @@ module.exports = Em.Application.create({
isPermissionDataLoaded: false,
/**
+ * @type {boolean}
+ * @default false
+ */
+ isKerberosEnabled: false,
+
+ /**
* state of stack upgrade process
* states:
* - INIT
http://git-wip-us.apache.org/repos/asf/ambari/blob/6c945804/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
index 750a7af..3cc08a4 100644
--- a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
+++ b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
@@ -143,7 +143,7 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({
var staticConfigInfo = this.parseIt(config, this.get('configToPlain'));
var v = Em.isNone(staticConfigInfo.recommendedValue) ? staticConfigInfo.recommendedValue : staticConfigInfo.value;
staticConfigInfo.value = staticConfigInfo.recommendedValue = App.config.formatPropertyValue(staticConfigInfo, v);
- staticConfigInfo.isSecure = App.config.getIsSecure(staticConfigInfo.name);
+ staticConfigInfo.isSecureConfig = App.config.getIsSecure(staticConfigInfo.name);
staticConfigInfo.isUserProperty = false;
App.configsCollection.add(staticConfigInfo);
http://git-wip-us.apache.org/repos/asf/ambari/blob/6c945804/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index c27ed68..f1240bc 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -235,6 +235,7 @@ App.config = Em.Object.create({
for (var index in properties) {
var advancedConfig = App.configsCollection.getConfigByName(index, siteConfig.type);
var serviceConfigObj = advancedConfig || this.createDefaultConfig(index, serviceName, filename, false);
+ this.restrictSecureProperties(serviceConfigObj);
if (serviceConfigObj.isRequiredByAgent !== false) {
var formattedValue = this.formatPropertyValue(serviceConfigObj, properties[index]);
@@ -253,6 +254,16 @@ App.config = Em.Object.create({
},
/**
+ * put secure properties in read-only mode
+ * @param {object} config
+ */
+ restrictSecureProperties: function (config) {
+ var isReadOnly = config.isSecureConfig && App.get('isKerberosEnabled');
+ config.isReconfigurable = !isReadOnly;
+ config.isOverridable = !isReadOnly;
+ },
+
+ /**
* This method sets default values for config property
* These property values has the lowest priority and can be overridden be stack/UI
* config property but is used when such properties are absent in stack/UI configs
http://git-wip-us.apache.org/repos/asf/ambari/blob/6c945804/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js
index 62a6689..ff770f0 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -1010,5 +1010,62 @@ describe('App.config', function () {
"index": 0
})
});
- })
+ });
+
+ describe("#restrictSecureProperties()", function() {
+ var testCases = [
+ {
+ input: {
+ isSecureConfig: true,
+ isKerberosEnabled: true
+ },
+ expected: {
+ isReconfigurable: false,
+ isOverridable: false
+ }
+ },
+ {
+ input: {
+ isSecureConfig: false,
+ isKerberosEnabled: true
+ },
+ expected: {
+ isReconfigurable: true,
+ isOverridable: true
+ }
+ },
+ {
+ input: {
+ isSecureConfig: true,
+ isKerberosEnabled: false
+ },
+ expected: {
+ isReconfigurable: true,
+ isOverridable: true
+ }
+ },
+ {
+ input: {
+ isSecureConfig: false,
+ isKerberosEnabled: false
+ },
+ expected: {
+ isReconfigurable: true,
+ isOverridable: true
+ }
+ }
+ ];
+
+ testCases.forEach(function(test) {
+ it("isSecureConfig = " + test.input.isSecureConfig + "; isKerberosEnabled = " + test.input.isKerberosEnabled, function() {
+ var config = {
+ isSecureConfig: test.input.isSecureConfig
+ };
+ App.set('isKerberosEnabled', test.input.isKerberosEnabled);
+ App.config.restrictSecureProperties(config);
+ expect(config.isReconfigurable).to.equal(test.expected.isReconfigurable);
+ expect(config.isOverridable).to.equal(test.expected.isOverridable);
+ });
+ });
+ });
});