Kaynağa Gözat

AMBARI-14118 All Kerberos-related fields are to be made read-only in the service configuration screens. (atkach)

Andrii Tkach 9 yıl önce
ebeveyn
işleme
6c945804b5

+ 6 - 0
ambari-web/app/app.js

@@ -37,6 +37,12 @@ module.exports = Em.Application.create({
   isOperator: false,
   isPermissionDataLoaded: false,
 
+  /**
+   * @type {boolean}
+   * @default false
+   */
+  isKerberosEnabled: false,
+
   /**
    * state of stack upgrade process
    * states:

+ 1 - 1
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);
 

+ 11 - 0
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]);
@@ -252,6 +253,16 @@ App.config = Em.Object.create({
     return configs;
   },
 
+  /**
+   * 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

+ 58 - 1
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);
+      });
+    });
+  });
 });