Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A2204200B6B for ; Fri, 9 Sep 2016 21:41:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A0B35160AD5; Fri, 9 Sep 2016 19:41:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9FDAC160AA3 for ; Fri, 9 Sep 2016 21:41:29 +0200 (CEST) Received: (qmail 1327 invoked by uid 500); 9 Sep 2016 19:41:28 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 1312 invoked by uid 99); 9 Sep 2016 19:41:28 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Sep 2016 19:41:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B81D0E2EF4; Fri, 9 Sep 2016 19:41:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rlevas@apache.org To: commits@ambari.apache.org Date: Fri, 09 Sep 2016 19:41:28 -0000 Message-Id: <3cd2ccdd490c4fca8062c7e14594631a@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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) archived-at: Fri, 09 Sep 2016 19:41:30 -0000 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 MAP_VALUE = - new HashMap() { - { - put("name", "identity_1"); - put("principal", KerberosPrincipalDescriptorTest.MAP_VALUE); - put("keytab", KerberosKeytabDescriptorTest.MAP_VALUE); - put("password", "secret"); - } - }; - - public static final Map MAP_VALUE_ALT = - new HashMap() { - { - put("name", "identity_2"); - put("principal", KerberosPrincipalDescriptorTest.MAP_VALUE); - put("keytab", KerberosKeytabDescriptorTest.MAP_VALUE); - put("password", "secret2"); - } - }; - - public static final Map MAP_VALUE_REFERENCE = - new HashMap() { - { - put("name", "shared_identity"); - put("reference", "/shared"); - put("keytab", new HashMap() { - { - put("file", "/home/user/me/subject.service.keytab"); - - put("owner", new HashMap() {{ - put("name", "me"); - put("access", "rw"); - }}); - - put("group", new HashMap() {{ - put("name", "nobody"); - put("access", ""); - }}); - - put("configuration", "service-site/me.component.keytab.file"); - } - }); - } - }; + static final Map MAP_VALUE; + static final Map MAP_VALUE_ALT; + static final Map MAP_VALUE_REFERENCE; + + static { + MAP_VALUE = new TreeMap(); + 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(); + 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 ownerMap = new TreeMap(); + ownerMap.put("name", "me"); + ownerMap.put("access", "rw"); + + TreeMap groupMap = new TreeMap(); + groupMap.put("name", "nobody"); + groupMap.put("access", ""); + + + TreeMap keytabMap = new TreeMap(); + 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(); + 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 context = new HashMap(); + Map context = new TreeMap(); context.put("services", new HashSet(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 MAP_VALUE = - new HashMap() { - { - put("file", "/etc/security/keytabs/subject.service.keytab"); + public static final Map MAP_VALUE; - put("owner", new HashMap() {{ - put("name", "root"); - put("access", "rw"); - }}); + static { + TreeMap ownerMap = new TreeMap(); + ownerMap.put("name", "root"); + ownerMap.put("access", "rw"); - put("group", new HashMap() {{ - put("name", "hadoop"); - put("access", "r"); - }}); + TreeMap groupMap = new TreeMap(); + groupMap.put("name", "hadoop"); + groupMap.put("access", "r"); - put("configuration", "service-site/service2.component.keytab.file"); - } - }; + MAP_VALUE = new TreeMap(); + 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 MAP_VALUE = - new HashMap() { - { - put("value", "user@_REALM"); - put("configuration", "service-site/service.component.kerberos.https.principal"); - put("type", "user"); - put("local_username", null); - } - }; - - public static final Map MAP_VALUE_SPARSE = - new HashMap() { - { - put("value", "userOther@_REALM"); - } - }; + public static final Map MAP_VALUE; + public static final Map MAP_VALUE_SPARSE; + + static { + MAP_VALUE = new TreeMap(); + 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(); + 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 MAP_VALUE = - new HashMap() { - { - put("name", "A_DIFFERENT_SERVICE_NAME"); - put(AbstractKerberosDescriptor.Type.IDENTITY.getDescriptorPluralName(), new ArrayList() {{ - add(KerberosIdentityDescriptorTest.MAP_VALUE); - }}); - put(AbstractKerberosDescriptor.Type.COMPONENT.getDescriptorPluralName(), new ArrayList() {{ - add(KerberosComponentDescriptorTest.MAP_VALUE); - }}); - put(AbstractKerberosDescriptor.Type.CONFIGURATION.getDescriptorPluralName(), new ArrayList>() {{ - add(new HashMap() { - { - put("service-site", new HashMap() { - { - put("service.property1", "red"); - put("service.property", "green"); - } - }); - } - }); - }}); - put(AbstractKerberosDescriptor.Type.AUTH_TO_LOCAL_PROPERTY.getDescriptorPluralName(), new ArrayList() {{ - add("service.name.rules2"); - }}); - } - }; + public static final Map MAP_VALUE; + + static { + Map identitiesMap = new TreeMap(); + identitiesMap.put((String) KerberosIdentityDescriptorTest.MAP_VALUE.get("name"), KerberosIdentityDescriptorTest.MAP_VALUE); + + Map componentsMap = new TreeMap(); + componentsMap.put((String) KerberosComponentDescriptorTest.MAP_VALUE.get("name"), KerberosComponentDescriptorTest.MAP_VALUE); + + Map serviceSiteProperties = new TreeMap(); + serviceSiteProperties.put("service.property1", "red"); + serviceSiteProperties.put("service.property", "green"); + + Map> serviceSiteMap = new TreeMap>(); + serviceSiteMap.put("service-site", serviceSiteProperties); + + TreeMap>> configurationsMap = new TreeMap>>(); + configurationsMap.put("service-site", serviceSiteMap); + + Collection authToLocalRules = new ArrayList(); + authToLocalRules.add("service.name.rules2"); + + MAP_VALUE = new TreeMap(); + 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 CHANGE_NAME = new HashMap() {{ put("name", "A_DIFFERENT_SERVICE_NAME"); }}; + TreeMap CHANGE_NAME = new TreeMap() {{ + 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);