ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject [1/4] ambari git commit: AMBARI-18335. After upgrading cluster from HDP-2.4.x to HDP-2.5.x and added atlas service - missing kafka security properties (rlevas)
Date Fri, 09 Sep 2016 19:41:28 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 79afcb9a2 -> 7aff03f59


http://git-wip-us.apache.org/repos/asf/ambari/blob/7aff03f5/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosIdentityDescriptorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosIdentityDescriptorTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosIdentityDescriptorTest.java
index 874da31..ef1c7bb 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosIdentityDescriptorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosIdentityDescriptorTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -24,9 +24,9 @@ import org.apache.ambari.server.AmbariException;
 import org.junit.Test;
 
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.TreeMap;
 
 public class KerberosIdentityDescriptorTest {
   public static final String JSON_VALUE =
@@ -40,50 +40,44 @@ public class KerberosIdentityDescriptorTest {
           "  \"when\": {\"contains\" : [\"services\", \"HIVE\"]}" +
           "}";
 
-  public static final Map<String, Object> MAP_VALUE =
-      new HashMap<String, Object>() {
-        {
-          put("name", "identity_1");
-          put("principal", KerberosPrincipalDescriptorTest.MAP_VALUE);
-          put("keytab", KerberosKeytabDescriptorTest.MAP_VALUE);
-          put("password", "secret");
-        }
-      };
-
-  public static final Map<String, Object> MAP_VALUE_ALT =
-      new HashMap<String, Object>() {
-        {
-          put("name", "identity_2");
-          put("principal", KerberosPrincipalDescriptorTest.MAP_VALUE);
-          put("keytab", KerberosKeytabDescriptorTest.MAP_VALUE);
-          put("password", "secret2");
-        }
-      };
-
-  public static final Map<String, Object> MAP_VALUE_REFERENCE =
-      new HashMap<String, Object>() {
-        {
-          put("name", "shared_identity");
-          put("reference", "/shared");
-          put("keytab", new HashMap<String, Object>() {
-            {
-              put("file", "/home/user/me/subject.service.keytab");
-
-              put("owner", new HashMap<String, Object>() {{
-                put("name", "me");
-                put("access", "rw");
-              }});
-
-              put("group", new HashMap<String, Object>() {{
-                put("name", "nobody");
-                put("access", "");
-              }});
-
-              put("configuration", "service-site/me.component.keytab.file");
-            }
-          });
-        }
-      };
+  static final Map<String, Object> MAP_VALUE;
+  static final Map<String, Object> MAP_VALUE_ALT;
+  static final Map<String, Object> MAP_VALUE_REFERENCE;
+
+  static {
+    MAP_VALUE = new TreeMap<String, Object>();
+    MAP_VALUE.put("name", "identity_1");
+    MAP_VALUE.put("principal", KerberosPrincipalDescriptorTest.MAP_VALUE);
+    MAP_VALUE.put("keytab", KerberosKeytabDescriptorTest.MAP_VALUE);
+    MAP_VALUE.put("password", "secret");
+
+    MAP_VALUE_ALT = new TreeMap<String, Object>();
+    MAP_VALUE_ALT.put("name", "identity_2");
+    MAP_VALUE_ALT.put("principal", KerberosPrincipalDescriptorTest.MAP_VALUE);
+    MAP_VALUE_ALT.put("keytab", KerberosKeytabDescriptorTest.MAP_VALUE);
+    MAP_VALUE_ALT.put("password", "secret2");
+
+    TreeMap<String, Object> ownerMap = new TreeMap<String, Object>();
+    ownerMap.put("name", "me");
+    ownerMap.put("access", "rw");
+
+    TreeMap<String, Object> groupMap = new TreeMap<String, Object>();
+    groupMap.put("name", "nobody");
+    groupMap.put("access", "");
+
+
+    TreeMap<String, Object> keytabMap = new TreeMap<String, Object>();
+    keytabMap.put("file", "/home/user/me/subject.service.keytab");
+    keytabMap.put("owner", ownerMap);
+    keytabMap.put("group", groupMap);
+    keytabMap.put("configuration", "service-site/me.component.keytab.file");
+
+    MAP_VALUE_REFERENCE = new TreeMap<String, Object>();
+    MAP_VALUE_REFERENCE.put("name", "shared_identity");
+    MAP_VALUE_REFERENCE.put("reference", "/shared");
+    MAP_VALUE_REFERENCE.put("keytab", keytabMap);
+  }
+
 
   public static void validateFromJSON(KerberosIdentityDescriptor identityDescriptor) {
     Assert.assertNotNull(identityDescriptor);
@@ -161,7 +155,7 @@ public class KerberosIdentityDescriptorTest {
   public void testShouldInclude() {
     KerberosIdentityDescriptor identityDescriptor = createFromJSON();
 
-    Map<String, Object> context = new HashMap<String, Object>();
+    Map<String, Object> context = new TreeMap<String, Object>();
 
     context.put("services", new HashSet<String>(Arrays.asList("HIVE", "HDFS", "ZOOKEEPER")));
     Assert.assertTrue(identityDescriptor.shouldInclude(context));

http://git-wip-us.apache.org/repos/asf/ambari/blob/7aff03f5/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosKeytabDescriptorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosKeytabDescriptorTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosKeytabDescriptorTest.java
index c10d106..79350eb 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosKeytabDescriptorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosKeytabDescriptorTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -23,8 +23,8 @@ import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.junit.Test;
 
-import java.util.HashMap;
 import java.util.Map;
+import java.util.TreeMap;
 
 public class KerberosKeytabDescriptorTest {
   public static final String JSON_VALUE =
@@ -41,24 +41,23 @@ public class KerberosKeytabDescriptorTest {
           "  \"configuration\": \"service-site/service.component.keytab.file\"" +
           "}";
 
-  public static final Map<String, Object> MAP_VALUE =
-      new HashMap<String, Object>() {
-        {
-          put("file", "/etc/security/keytabs/subject.service.keytab");
+  public static final Map<String, Object> MAP_VALUE;
 
-          put("owner", new HashMap<String, Object>() {{
-            put("name", "root");
-            put("access", "rw");
-          }});
+  static {
+    TreeMap<String, Object> ownerMap = new TreeMap<String, Object>();
+    ownerMap.put("name", "root");
+    ownerMap.put("access", "rw");
 
-          put("group", new HashMap<String, Object>() {{
-            put("name", "hadoop");
-            put("access", "r");
-          }});
+    TreeMap<String, Object> groupMap = new TreeMap<String, Object>();
+    groupMap.put("name", "hadoop");
+    groupMap.put("access", "r");
 
-          put("configuration", "service-site/service2.component.keytab.file");
-        }
-      };
+    MAP_VALUE = new TreeMap<String, Object>();
+    MAP_VALUE.put("file", "/etc/security/keytabs/subject.service.keytab");
+    MAP_VALUE.put("owner", ownerMap);
+    MAP_VALUE.put("group", groupMap);
+    MAP_VALUE.put("configuration", "service-site/service2.component.keytab.file");
+  }
 
   public static void validateFromJSON(KerberosKeytabDescriptor keytabDescriptor) {
     Assert.assertNotNull(keytabDescriptor);

http://git-wip-us.apache.org/repos/asf/ambari/blob/7aff03f5/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosPrincipalDescriptorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosPrincipalDescriptorTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosPrincipalDescriptorTest.java
index 5c249e2..635cc30 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosPrincipalDescriptorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosPrincipalDescriptorTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -39,22 +39,20 @@ public class KerberosPrincipalDescriptorTest {
           "\"value\": \"serviceOther/_HOST@_REALM\"" +
           "}";
 
-  public static final Map<String, Object> MAP_VALUE =
-      new HashMap<String, Object>() {
-        {
-          put("value", "user@_REALM");
-          put("configuration", "service-site/service.component.kerberos.https.principal");
-          put("type", "user");
-          put("local_username", null);
-        }
-      };
-
-  public static final Map<String, Object> MAP_VALUE_SPARSE =
-      new HashMap<String, Object>() {
-        {
-          put("value", "userOther@_REALM");
-        }
-      };
+  public static final Map<String, Object> MAP_VALUE;
+  public static final Map<String, Object> MAP_VALUE_SPARSE;
+
+  static {
+    MAP_VALUE = new TreeMap<String, Object>();
+    MAP_VALUE.put("value", "user@_REALM");
+    MAP_VALUE.put("configuration", "service-site/service.component.kerberos.https.principal");
+    MAP_VALUE.put("type", "user");
+    MAP_VALUE.put("local_username", null);
+
+    MAP_VALUE_SPARSE = new TreeMap<String, Object>();
+    MAP_VALUE_SPARSE.put("value", "userOther@_REALM");
+  }
+
 
   public static void validateFromJSON(KerberosPrincipalDescriptor principalDescriptor) {
     Assert.assertNotNull(principalDescriptor);

http://git-wip-us.apache.org/repos/asf/ambari/blob/7aff03f5/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosServiceDescriptorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosServiceDescriptorTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosServiceDescriptorTest.java
index e1af515..9896317 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosServiceDescriptorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosServiceDescriptorTest.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -17,6 +17,7 @@
  */
 package org.apache.ambari.server.state.kerberos;
 
+import com.google.gson.Gson;
 import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.junit.Test;
@@ -25,11 +26,12 @@ import java.io.File;
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeMap;
 import java.util.TreeSet;
 
 public class KerberosServiceDescriptorTest {
@@ -98,33 +100,35 @@ public class KerberosServiceDescriptorTest {
           "]" +
           "}";
 
-  public static final Map<String, Object> MAP_VALUE =
-      new HashMap<String, Object>() {
-        {
-          put("name", "A_DIFFERENT_SERVICE_NAME");
-          put(AbstractKerberosDescriptor.Type.IDENTITY.getDescriptorPluralName(), new ArrayList<Object>()
{{
-            add(KerberosIdentityDescriptorTest.MAP_VALUE);
-          }});
-          put(AbstractKerberosDescriptor.Type.COMPONENT.getDescriptorPluralName(), new ArrayList<Object>()
{{
-            add(KerberosComponentDescriptorTest.MAP_VALUE);
-          }});
-          put(AbstractKerberosDescriptor.Type.CONFIGURATION.getDescriptorPluralName(), new
ArrayList<Map<String, Object>>() {{
-            add(new HashMap<String, Object>() {
-              {
-                put("service-site", new HashMap<String, String>() {
-                  {
-                    put("service.property1", "red");
-                    put("service.property", "green");
-                  }
-                });
-              }
-            });
-          }});
-          put(AbstractKerberosDescriptor.Type.AUTH_TO_LOCAL_PROPERTY.getDescriptorPluralName(),
new ArrayList<String>() {{
-            add("service.name.rules2");
-          }});
-        }
-      };
+  public static final Map<String, Object> MAP_VALUE;
+
+  static {
+    Map<String, Object> identitiesMap = new TreeMap<String, Object>();
+    identitiesMap.put((String) KerberosIdentityDescriptorTest.MAP_VALUE.get("name"), KerberosIdentityDescriptorTest.MAP_VALUE);
+
+    Map<String, Object> componentsMap = new TreeMap<String, Object>();
+    componentsMap.put((String) KerberosComponentDescriptorTest.MAP_VALUE.get("name"), KerberosComponentDescriptorTest.MAP_VALUE);
+
+    Map<String, Object> serviceSiteProperties = new TreeMap<String, Object>();
+    serviceSiteProperties.put("service.property1", "red");
+    serviceSiteProperties.put("service.property", "green");
+
+    Map<String, Map<String, Object>> serviceSiteMap = new TreeMap<String,
Map<String, Object>>();
+    serviceSiteMap.put("service-site", serviceSiteProperties);
+
+    TreeMap<String, Map<String, Map<String, Object>>> configurationsMap
= new TreeMap<String, Map<String, Map<String, Object>>>();
+    configurationsMap.put("service-site", serviceSiteMap);
+
+    Collection<String> authToLocalRules = new ArrayList<String>();
+    authToLocalRules.add("service.name.rules2");
+
+    MAP_VALUE = new TreeMap<String, Object>();
+    MAP_VALUE.put("name", "A_DIFFERENT_SERVICE_NAME");
+    MAP_VALUE.put(AbstractKerberosDescriptor.Type.IDENTITY.getDescriptorPluralName(), identitiesMap.values());
+    MAP_VALUE.put(AbstractKerberosDescriptor.Type.COMPONENT.getDescriptorPluralName(), componentsMap.values());
+    MAP_VALUE.put(AbstractKerberosDescriptor.Type.CONFIGURATION.getDescriptorPluralName(),
configurationsMap.values());
+    MAP_VALUE.put(AbstractKerberosDescriptor.Type.AUTH_TO_LOCAL_PROPERTY.getDescriptorPluralName(),
authToLocalRules);
+  }
 
   private static final KerberosServiceDescriptorFactory KERBEROS_SERVICE_DESCRIPTOR_FACTORY
= new KerberosServiceDescriptorFactory();
 
@@ -356,9 +360,10 @@ public class KerberosServiceDescriptorTest {
 
   @Test
   public void testToMap() throws AmbariException {
+    Gson gson = new Gson();
     KerberosServiceDescriptor descriptor = createFromMap();
     Assert.assertNotNull(descriptor);
-    Assert.assertEquals(MAP_VALUE, descriptor.toMap());
+    Assert.assertEquals(gson.toJson(MAP_VALUE), gson.toJson(descriptor.toMap()));
   }
 
   @Test
@@ -376,6 +381,7 @@ public class KerberosServiceDescriptorTest {
 
   /**
    * Test a JSON object in which only only a Service and configs are defined, but no Components.
+   *
    * @throws AmbariException
    */
   @Test
@@ -393,7 +399,9 @@ public class KerberosServiceDescriptorTest {
             "  ]" +
             "}";
 
-    HashMap<String, Object> CHANGE_NAME = new HashMap<String, Object>() {{ put("name",
"A_DIFFERENT_SERVICE_NAME"); }};
+    TreeMap<String, Object> CHANGE_NAME = new TreeMap<String, Object>() {{
+      put("name", "A_DIFFERENT_SERVICE_NAME");
+    }};
 
     KerberosServiceDescriptor serviceDescriptor = KERBEROS_SERVICE_DESCRIPTOR_FACTORY.createInstance("SERVICE_NAME",
JSON_VALUE_ONLY_NAME_AND_CONFIGS);
     KerberosServiceDescriptor updatedServiceDescriptor = new KerberosServiceDescriptor(CHANGE_NAME);


Mime
View raw message