ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [20/49] ambari git commit: MBARI-19675. Regenerate Keytabs action does not set cluster-env/security_enabled to true (echekanskiy via dlysnichenko)
Date Fri, 27 Jan 2017 18:17:31 GMT
MBARI-19675. Regenerate Keytabs action does not set cluster-env/security_enabled to true (echekanskiy
via dlysnichenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b6a06bd0
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b6a06bd0
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b6a06bd0

Branch: refs/heads/branch-dev-patch-upgrade
Commit: b6a06bd06d644f3ccd0e8b815f434fefe5989346
Parents: 03d90ae
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Thu Jan 26 14:35:29 2017 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Thu Jan 26 14:35:29 2017 +0200

----------------------------------------------------------------------
 .../UpdateKerberosConfigsServerAction.java      | 17 +++++++++++
 .../UpdateKerberosConfigsServerActionTest.java  | 31 ++++++++++++++++++++
 2 files changed, 48 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a06bd0/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/UpdateKerberosConfigsServerAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/UpdateKerberosConfigsServerAction.java
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/UpdateKerberosConfigsServerAction.java
index 9bf6b51..b75100e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/UpdateKerberosConfigsServerAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/UpdateKerberosConfigsServerAction.java
@@ -120,6 +120,23 @@ public class UpdateKerberosConfigsServerAction extends AbstractServerAction
{
             }
           }
 
+          // ensure that cluster-env/security_enabled have proper value
+          final String securityEnabled = cluster.getSecurityType() == SecurityType.KERBEROS
+              ? "true"
+              : "false";
+
+          if(!configTypes.contains("cluster-env")) {
+            configTypes.add("cluster-env");
+          }
+
+          Map<String, String> clusterEnvProperties = propertiesToSet.get("cluster-env");
+          if(clusterEnvProperties == null) {
+            clusterEnvProperties = new HashMap<>();
+            propertiesToSet.put("cluster-env", clusterEnvProperties);
+          }
+
+          clusterEnvProperties.put("security_enabled", securityEnabled);
+
           if (!configTypes.isEmpty()) {
             String configNote = getCommandParameterValue(getCommandParameters(), KerberosServerAction.UPDATE_CONFIGURATION_NOTE);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b6a06bd0/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/UpdateKerberosConfigsServerActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/UpdateKerberosConfigsServerActionTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/UpdateKerberosConfigsServerActionTest.java
index fc9c857..e756491 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/UpdateKerberosConfigsServerActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/UpdateKerberosConfigsServerActionTest.java
@@ -19,8 +19,10 @@
 package org.apache.ambari.server.serveraction.kerberos;
 
 import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.capture;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expectLastCall;
+import static org.junit.Assert.assertEquals;
 
 import java.io.File;
 import java.util.Collection;
@@ -34,6 +36,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.stack.OsFamily;
+import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.easymock.EasyMockSupport;
 import org.junit.Before;
@@ -140,4 +143,32 @@ public class UpdateKerberosConfigsServerActionTest extends EasyMockSupport{
 
     verifyAll();
   }
+
+  @Test
+  public void testUpdateConfigForceSecurityEnabled() throws Exception {
+    Map<String, String> commandParams = new HashMap<String, String>();
+    commandParams.put(KerberosServerAction.DATA_DIRECTORY, dataDir);
+
+    ExecutionCommand executionCommand = new ExecutionCommand();
+    executionCommand.setCommandParams(commandParams);
+
+    ConfigHelper configHelper = injector.getInstance(ConfigHelper.class);
+
+    Capture<String> configTypes = Capture.newInstance();
+    Capture<Map<String, String>> configUpdates = Capture.newInstance();
+    configHelper.updateConfigType(anyObject(Cluster.class), anyObject(AmbariManagementController.class),
+        capture(configTypes), capture(configUpdates), anyObject(Collection.class), anyObject(String.class),
anyObject(String.class));
+    expectLastCall().atLeastOnce();
+
+    replayAll();
+
+    action.setExecutionCommand(executionCommand);
+    action.execute(null);
+
+    assertEquals(configTypes.getValue(), "cluster-env");
+    assertEquals(configUpdates.getValue().get("security_enabled"), "false");
+    verifyAll();
+  }
+
+
 }


Mime
View raw message