You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ad...@apache.org on 2018/01/20 21:48:08 UTC

[ambari] branch trunk updated: [AMBARI-22820] Fix KerberosOperationHandlerTests due to changes from AMBARI-22697

This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new d54d340  [AMBARI-22820] Fix KerberosOperationHandlerTests due to changes from AMBARI-22697
d54d340 is described below

commit d54d3404110e0a16545b5978e38b41b5a35aa017
Author: Robert Levas <rl...@hortonworks.com>
AuthorDate: Sat Jan 20 15:41:38 2018 -0500

    [AMBARI-22820] Fix KerberosOperationHandlerTests due to changes from AMBARI-22697
---
 .../kerberos/ADKerberosOperationHandlerTest.java      | 15 +++++++++------
 .../kerberos/IPAKerberosOperationHandlerTest.java     | 19 ++++++++++---------
 .../kerberos/KerberosOperationHandlerTest.java        | 10 ++++++++++
 .../kerberos/MITKerberosOperationHandlerTest.java     | 19 +++++++++----------
 4 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandlerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandlerTest.java
index 8b3c19a..18f1e6f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandlerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandlerTest.java
@@ -29,6 +29,7 @@ import static org.easymock.EasyMock.replay;
 
 import java.lang.reflect.Method;
 import java.nio.charset.Charset;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -71,12 +72,14 @@ public class ADKerberosOperationHandlerTest extends KerberosOperationHandlerTest
   private static final String DEFAULT_LDAP_URL = "ldaps://10.0.100.4";
   private static final String DEFAULT_PRINCIPAL_CONTAINER_DN = "ou=HDP,DC=HDP01,DC=LOCAL";
   private static final String DEFAULT_REALM = "HDP01.LOCAL";
-  private static final Map<String, String> KERBEROS_ENV_MAP = new HashMap<String, String>() {
-    {
-      put(ADKerberosOperationHandler.KERBEROS_ENV_PRINCIPAL_CONTAINER_DN, DEFAULT_PRINCIPAL_CONTAINER_DN);
-      put(ADKerberosOperationHandler.KERBEROS_ENV_LDAP_URL, DEFAULT_LDAP_URL);
-    }
-  };
+  private static final Map<String, String> KERBEROS_ENV_MAP;
+
+  static {
+    Map<String, String> map = new HashMap<>(DEFAULT_KERBEROS_ENV_MAP);
+    map.put(ADKerberosOperationHandler.KERBEROS_ENV_PRINCIPAL_CONTAINER_DN, DEFAULT_PRINCIPAL_CONTAINER_DN);
+    map.put(ADKerberosOperationHandler.KERBEROS_ENV_LDAP_URL, DEFAULT_LDAP_URL);
+    KERBEROS_ENV_MAP = Collections.unmodifiableMap(map);
+  }
 
   private static Method methodCreateInitialLdapContext;
 
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/IPAKerberosOperationHandlerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/IPAKerberosOperationHandlerTest.java
index 558ca79..f9ee5b7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/IPAKerberosOperationHandlerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/IPAKerberosOperationHandlerTest.java
@@ -23,6 +23,7 @@ import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 
 import java.lang.reflect.Method;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -39,17 +40,17 @@ import com.google.inject.Injector;
 
 public class IPAKerberosOperationHandlerTest extends KDCKerberosOperationHandlerTest {
 
-  private static final Map<String, String> KERBEROS_ENV_MAP = new HashMap<String, String>() {
-    {
-      put(IPAKerberosOperationHandler.KERBEROS_ENV_ENCRYPTION_TYPES, null);
-      put(IPAKerberosOperationHandler.KERBEROS_ENV_KDC_HOSTS, "localhost");
-      put(IPAKerberosOperationHandler.KERBEROS_ENV_ADMIN_SERVER_HOST, "localhost");
-      put(IPAKerberosOperationHandler.KERBEROS_ENV_USER_PRINCIPAL_GROUP, "");
-    }
-  };
-
   private static Injector injector;
 
+  private static final Map<String, String> KERBEROS_ENV_MAP;
+
+  static {
+    Map<String, String> map = new HashMap<>(DEFAULT_KERBEROS_ENV_MAP);
+    map.put(IPAKerberosOperationHandler.KERBEROS_ENV_USER_PRINCIPAL_GROUP, "");
+    KERBEROS_ENV_MAP = Collections.unmodifiableMap(map);
+  }
+
+
   @BeforeClass
   public static void beforeIPAKerberosOperationHandlerTest() throws Exception {
     injector = Guice.createInjector(new AbstractModule() {
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandlerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandlerTest.java
index 5a0ca79..fbe6029 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandlerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandlerTest.java
@@ -21,6 +21,7 @@ package org.apache.ambari.server.serveraction.kerberos;
 import java.io.File;
 import java.io.FileInputStream;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -44,6 +45,15 @@ public abstract class KerberosOperationHandlerTest extends EasyMockSupport {
   static final String DEFAULT_ADMIN_PASSWORD = "hadoop";
   static final String DEFAULT_REALM = "EXAMPLE.COM";
   static final PrincipalKeyCredential DEFAULT_ADMIN_CREDENTIALS = new PrincipalKeyCredential(DEFAULT_ADMIN_PRINCIPAL, DEFAULT_ADMIN_PASSWORD);
+  static final Map<String, String> DEFAULT_KERBEROS_ENV_MAP;
+
+  static {
+    Map<String, String> map = new HashMap<>();
+    map.put(KerberosOperationHandler.KERBEROS_ENV_ENCRYPTION_TYPES, "aes des3-cbc-sha1 rc4 des-cbc-md5");
+    map.put(IPAKerberosOperationHandler.KERBEROS_ENV_KDC_HOSTS, "localhost");
+    map.put(IPAKerberosOperationHandler.KERBEROS_ENV_ADMIN_SERVER_HOST, "localhost");
+    DEFAULT_KERBEROS_ENV_MAP = Collections.unmodifiableMap(map);
+  }
 
   @Rule
   public TemporaryFolder folder = new TemporaryFolder();
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandlerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandlerTest.java
index f94adbe..c7c26c3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandlerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/MITKerberosOperationHandlerTest.java
@@ -24,6 +24,7 @@ import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.newCapture;
 
 import java.lang.reflect.Method;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -45,22 +46,20 @@ import junit.framework.Assert;
 
 public class MITKerberosOperationHandlerTest extends KDCKerberosOperationHandlerTest {
 
-  private static final Map<String, String> KERBEROS_ENV_MAP = new HashMap<String, String>() {
-    {
-      put(MITKerberosOperationHandler.KERBEROS_ENV_ENCRYPTION_TYPES, null);
-      put(MITKerberosOperationHandler.KERBEROS_ENV_KDC_HOSTS, "localhost");
-      put(MITKerberosOperationHandler.KERBEROS_ENV_ADMIN_SERVER_HOST, "localhost");
-      put(MITKerberosOperationHandler.KERBEROS_ENV_AD_CREATE_ATTRIBUTES_TEMPLATE, "AD Create Template");
-      put(MITKerberosOperationHandler.KERBEROS_ENV_KDC_CREATE_ATTRIBUTES, "-attr1 -attr2 foo=345");
-    }
-  };
-
   private static Method methodIsOpen;
 
   private static Method methodPrincipalExists;
 
   private static Method methodInvokeKAdmin;
 
+  private static final Map<String, String> KERBEROS_ENV_MAP;
+
+  static {
+    Map<String, String> map = new HashMap<>(DEFAULT_KERBEROS_ENV_MAP);
+    map.put(MITKerberosOperationHandler.KERBEROS_ENV_KDC_CREATE_ATTRIBUTES, "-attr1 -attr2 foo=345");
+    KERBEROS_ENV_MAP = Collections.unmodifiableMap(map);
+  }
+
   private Injector injector;
 
   @BeforeClass

-- 
To stop receiving notification emails like this one, please contact
['"commits@ambari.apache.org" <co...@ambari.apache.org>'].