Forráskód Böngészése

AMBARI-8667. oozie setting for oozie.authentication.kerberos.principal should be fixed in Ambari (alexantonenko)

Alex Antonenko 10 éve
szülő
commit
836df671ab

+ 8 - 3
ambari-web/app/controllers/main/admin/security/add/step2.js

@@ -339,10 +339,15 @@ App.MainAdminSecurityAddStep2Controller = Em.Controller.extend({
       var host = service.configs.findProperty('name', hostConfigName);
       var principal = service.configs.findProperty('name', principalConfigName);
       var versionNumber = App.get('currentStackVersionNumber');
-      if(principalConfigName == 'storm_principal_name' && stringUtils.compareVersions(versionNumber, "2.2") >= 0){
-        principal.defaultValue = defaultPrimaryName;
+      var special22ConfigsMap = {
+        storm_principal_name: defaultPrimaryName,
+        oozie_http_principal_name: defaultPrimaryName + '_HOST'
+      };
+      if (stringUtils.compareVersions(versionNumber, "2.2") >= 0 && special22ConfigsMap[principalConfigName]) {
+        principal.defaultValue = special22ConfigsMap[principalConfigName];
         return true;
-      } else if (host && principal) {
+      }
+      if (host && principal) {
         var host_defaultValue = Array.isArray(host.defaultValue) ? host.defaultValue[0] : host.defaultValue;
         principal.defaultValue = defaultPrimaryName + host_defaultValue;
         return true;

+ 60 - 0
ambari-web/test/controllers/main/admin/security/add/step2_test.js

@@ -385,6 +385,66 @@ describe('App.MainAdminSecurityAddStep2Controller', function () {
      // expect(controller.get('content.services')[0].configs[0].defaultValue).to.equal('Value1');
       expect(controller.get('content.services')[0].configs[1].defaultValue).to.equal('name1Value1');
     });
+    it('stack 2.2 `storm_principal_name` config should be set to `storm`', function() {
+      sinon.stub(App, 'get').withArgs('currentStackVersionNumber').returns('2.2');
+      controller.set('content.services', [
+        {
+          serviceName: 'STORM',
+          configs: [
+            {
+              name: 'nimbus_host',
+              defaultValue: 'Value1'
+            },
+            {
+              name: 'storm_principal_name'
+            }
+          ]
+        }
+      ]);
+      controller.setHostToPrincipal('STORM', 'nimbus_host', 'storm_principal_name', 'storm');
+      App.get.restore();
+      expect(controller.get('content.services')[0].configs[1].defaultValue).to.equal('storm');
+    });
+    it('stack 2.1 `oozie_http_principal_name` value should contains OOZIE_SERVER host', function() {
+      sinon.stub(App, 'get').withArgs('currentStackVersionNumber').returns('2.1');
+      controller.set('content.services', [
+        {
+          serviceName: 'OOZIE',
+          configs: [
+            {
+              name: 'oozie_servername',
+              defaultValue: 'host1.com'
+            },
+            {
+              name: 'oozie_http_principal_name'
+            }
+          ]
+        }
+      ]);
+      controller.setHostToPrincipal('OOZIE', 'oozie_servername', 'oozie_http_principal_name', 'HTTP/');
+      App.get.restore();
+      expect(controller.get('content.services')[0].configs[1].defaultValue).to.equal('HTTP/host1.com');
+    });
+    it('stack 2.2 `oozie_http_principal_name` value should be set to HTTP/_HOST', function() {
+      sinon.stub(App, 'get').withArgs('currentStackVersionNumber').returns('2.2');
+      controller.set('content.services', [
+        {
+          serviceName: 'OOZIE',
+          configs: [
+            {
+              name: 'oozie_servername',
+              defaultValue: 'host1.com'
+            },
+            {
+              name: 'oozie_http_principal_name'
+            }
+          ]
+        }
+      ]);
+      controller.setHostToPrincipal('OOZIE', 'oozie_servername', 'oozie_http_principal_name', 'HTTP/');
+      App.get.restore();
+      expect(controller.get('content.services')[0].configs[1].defaultValue).to.equal('HTTP/_HOST');
+    });
   });
 
   describe('#loadUsers()', function () {