|
@@ -417,15 +417,25 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
|
|
|
|
@Test(expected = IllegalArgumentException.class)
|
|
@Test(expected = IllegalArgumentException.class)
|
|
public void testGetActiveIdentities_MissingCluster() throws Exception {
|
|
public void testGetActiveIdentities_MissingCluster() throws Exception {
|
|
- testGetActiveIdentities(null, null, null, null, true);
|
|
|
|
|
|
+ testGetActiveIdentities(null, null, null, null, true, SecurityType.KERBEROS);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- public void testGetActiveIdentities_All() throws Exception {
|
|
|
|
- Map<String, Collection<KerberosIdentityDescriptor>> identities = testGetActiveIdentities("c1", null, null, null, true);
|
|
|
|
|
|
+ public void testGetActiveIdentities_SecurityTypeKerberos_All() throws Exception {
|
|
|
|
+ testGetActiveIdentities_All(SecurityType.KERBEROS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testGetActiveIdentities_SecurityTypeNone_All() throws Exception {
|
|
|
|
+ testGetActiveIdentities_All(SecurityType.NONE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testGetActiveIdentities_SingleHost() throws Exception {
|
|
|
|
+ Map<String, Collection<KerberosIdentityDescriptor>> identities = testGetActiveIdentities("c1", "host1", null, null, true, SecurityType.KERBEROS);
|
|
|
|
|
|
Assert.assertNotNull(identities);
|
|
Assert.assertNotNull(identities);
|
|
- Assert.assertEquals(2, identities.size());
|
|
|
|
|
|
+ Assert.assertEquals(1, identities.size());
|
|
|
|
|
|
Collection<KerberosIdentityDescriptor> hostIdentities;
|
|
Collection<KerberosIdentityDescriptor> hostIdentities;
|
|
|
|
|
|
@@ -482,15 +492,25 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}});
|
|
}});
|
|
-
|
|
|
|
- hostIdentities = identities.get("host2");
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testGetActiveIdentities_SingleService() throws Exception {
|
|
|
|
+ Map<String, Collection<KerberosIdentityDescriptor>> identities = testGetActiveIdentities("c1", null, "SERVICE1", null, true, SecurityType.KERBEROS);
|
|
|
|
+
|
|
|
|
+ Assert.assertNotNull(identities);
|
|
|
|
+ Assert.assertEquals(2, identities.size());
|
|
|
|
+
|
|
|
|
+ Collection<KerberosIdentityDescriptor> hostIdentities;
|
|
|
|
+
|
|
|
|
+ hostIdentities = identities.get("host1");
|
|
Assert.assertNotNull(hostIdentities);
|
|
Assert.assertNotNull(hostIdentities);
|
|
- Assert.assertEquals(3, hostIdentities.size());
|
|
|
|
|
|
+ Assert.assertEquals(2, hostIdentities.size());
|
|
|
|
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
put("identity1", new HashMap<String, Object>() {
|
|
put("identity1", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
- put("principal_name", "component1/host2@EXAMPLE.COM");
|
|
|
|
|
|
+ put("principal_name", "component1/host1@EXAMPLE.COM");
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_configuration", "service1-site/component1.kerberos.principal");
|
|
put("principal_configuration", "service1-site/component1.kerberos.principal");
|
|
put("principal_local_username", "service1");
|
|
put("principal_local_username", "service1");
|
|
@@ -504,25 +524,9 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- put("identity2", new HashMap<String, Object>() {
|
|
|
|
- {
|
|
|
|
- put("principal_name", "component2/host2@EXAMPLE.COM");
|
|
|
|
- put("principal_type", KerberosPrincipalType.SERVICE);
|
|
|
|
- put("principal_configuration", "service2-site/component2.kerberos.principal");
|
|
|
|
- put("principal_local_username", "service2");
|
|
|
|
- put("keytab_file", "${keytab_dir}/service2.keytab");
|
|
|
|
- put("keytab_owner_name", "service2");
|
|
|
|
- put("keytab_owner_access", "rw");
|
|
|
|
- put("keytab_group_name", "hadoop");
|
|
|
|
- put("keytab_group_access", "");
|
|
|
|
- put("keytab_configuration", "service2-site/component2.keytab.file");
|
|
|
|
- put("keytab_cachable", false);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
put("identity3", new HashMap<String, Object>() {
|
|
put("identity3", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
- put("principal_name", "service1/host2@EXAMPLE.COM");
|
|
|
|
|
|
+ put("principal_name", "service1/host1@EXAMPLE.COM");
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_configuration", "service1-site/service1.kerberos.principal");
|
|
put("principal_configuration", "service1-site/service1.kerberos.principal");
|
|
put("principal_local_username", "service1");
|
|
put("principal_local_username", "service1");
|
|
@@ -536,25 +540,15 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}});
|
|
}});
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testGetActiveIdentities_SingleHost() throws Exception {
|
|
|
|
- Map<String, Collection<KerberosIdentityDescriptor>> identities = testGetActiveIdentities("c1", "host1", null, null, true);
|
|
|
|
-
|
|
|
|
- Assert.assertNotNull(identities);
|
|
|
|
- Assert.assertEquals(1, identities.size());
|
|
|
|
-
|
|
|
|
- Collection<KerberosIdentityDescriptor> hostIdentities;
|
|
|
|
-
|
|
|
|
- hostIdentities = identities.get("host1");
|
|
|
|
|
|
+
|
|
|
|
+ hostIdentities = identities.get("host2");
|
|
Assert.assertNotNull(hostIdentities);
|
|
Assert.assertNotNull(hostIdentities);
|
|
- Assert.assertEquals(3, hostIdentities.size());
|
|
|
|
|
|
+ Assert.assertEquals(2, hostIdentities.size());
|
|
|
|
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
put("identity1", new HashMap<String, Object>() {
|
|
put("identity1", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
- put("principal_name", "component1/host1@EXAMPLE.COM");
|
|
|
|
|
|
+ put("principal_name", "component1/host2@EXAMPLE.COM");
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_configuration", "service1-site/component1.kerberos.principal");
|
|
put("principal_configuration", "service1-site/component1.kerberos.principal");
|
|
put("principal_local_username", "service1");
|
|
put("principal_local_username", "service1");
|
|
@@ -568,25 +562,9 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- put("identity2", new HashMap<String, Object>() {
|
|
|
|
- {
|
|
|
|
- put("principal_name", "component2/host1@EXAMPLE.COM");
|
|
|
|
- put("principal_type", KerberosPrincipalType.SERVICE);
|
|
|
|
- put("principal_configuration", "service2-site/component2.kerberos.principal");
|
|
|
|
- put("principal_local_username", "service2");
|
|
|
|
- put("keytab_file", "${keytab_dir}/service2.keytab");
|
|
|
|
- put("keytab_owner_name", "service2");
|
|
|
|
- put("keytab_owner_access", "rw");
|
|
|
|
- put("keytab_group_name", "hadoop");
|
|
|
|
- put("keytab_group_access", "");
|
|
|
|
- put("keytab_configuration", "service2-site/component2.keytab.file");
|
|
|
|
- put("keytab_cachable", false);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
put("identity3", new HashMap<String, Object>() {
|
|
put("identity3", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
- put("principal_name", "service1/host1@EXAMPLE.COM");
|
|
|
|
|
|
+ put("principal_name", "service1/host2@EXAMPLE.COM");
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_configuration", "service1-site/service1.kerberos.principal");
|
|
put("principal_configuration", "service1-site/service1.kerberos.principal");
|
|
put("principal_local_username", "service1");
|
|
put("principal_local_username", "service1");
|
|
@@ -599,26 +577,25 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
put("keytab_cachable", false);
|
|
put("keytab_cachable", false);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- }});
|
|
|
|
- }
|
|
|
|
|
|
+ }}); }
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- public void testGetActiveIdentities_SingleService() throws Exception {
|
|
|
|
- Map<String, Collection<KerberosIdentityDescriptor>> identities = testGetActiveIdentities("c1", null, "SERVICE1", null, true);
|
|
|
|
|
|
+ public void testGetActiveIdentities_SingleServiceSingleHost() throws Exception {
|
|
|
|
+ Map<String, Collection<KerberosIdentityDescriptor>> identities = testGetActiveIdentities("c1", "host2", "SERVICE1", null, true, SecurityType.KERBEROS);
|
|
|
|
|
|
Assert.assertNotNull(identities);
|
|
Assert.assertNotNull(identities);
|
|
- Assert.assertEquals(2, identities.size());
|
|
|
|
|
|
+ Assert.assertEquals(1, identities.size());
|
|
|
|
|
|
Collection<KerberosIdentityDescriptor> hostIdentities;
|
|
Collection<KerberosIdentityDescriptor> hostIdentities;
|
|
|
|
|
|
- hostIdentities = identities.get("host1");
|
|
|
|
|
|
+ hostIdentities = identities.get("host2");
|
|
Assert.assertNotNull(hostIdentities);
|
|
Assert.assertNotNull(hostIdentities);
|
|
Assert.assertEquals(2, hostIdentities.size());
|
|
Assert.assertEquals(2, hostIdentities.size());
|
|
|
|
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
put("identity1", new HashMap<String, Object>() {
|
|
put("identity1", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
- put("principal_name", "component1/host1@EXAMPLE.COM");
|
|
|
|
|
|
+ put("principal_name", "component1/host2@EXAMPLE.COM");
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_configuration", "service1-site/component1.kerberos.principal");
|
|
put("principal_configuration", "service1-site/component1.kerberos.principal");
|
|
put("principal_local_username", "service1");
|
|
put("principal_local_username", "service1");
|
|
@@ -634,7 +611,7 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
|
|
|
|
put("identity3", new HashMap<String, Object>() {
|
|
put("identity3", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
- put("principal_name", "service1/host1@EXAMPLE.COM");
|
|
|
|
|
|
+ put("principal_name", "service1/host2@EXAMPLE.COM");
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_configuration", "service1-site/service1.kerberos.principal");
|
|
put("principal_configuration", "service1-site/service1.kerberos.principal");
|
|
put("principal_local_username", "service1");
|
|
put("principal_local_username", "service1");
|
|
@@ -648,62 +625,78 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}});
|
|
}});
|
|
-
|
|
|
|
- hostIdentities = identities.get("host2");
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testGetActiveIdentities_SingleComponent() throws Exception {
|
|
|
|
+ Map<String, Collection<KerberosIdentityDescriptor>> identities = testGetActiveIdentities("c1", null, null, "COMPONENT2", true, SecurityType.KERBEROS);
|
|
|
|
+
|
|
|
|
+ Assert.assertNotNull(identities);
|
|
|
|
+ Assert.assertEquals(2, identities.size());
|
|
|
|
+
|
|
|
|
+ Collection<KerberosIdentityDescriptor> hostIdentities;
|
|
|
|
+
|
|
|
|
+ hostIdentities = identities.get("host1");
|
|
Assert.assertNotNull(hostIdentities);
|
|
Assert.assertNotNull(hostIdentities);
|
|
- Assert.assertEquals(2, hostIdentities.size());
|
|
|
|
|
|
+ Assert.assertEquals(1, hostIdentities.size());
|
|
|
|
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
- put("identity1", new HashMap<String, Object>() {
|
|
|
|
|
|
+ put("identity2", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
- put("principal_name", "component1/host2@EXAMPLE.COM");
|
|
|
|
|
|
+ put("principal_name", "component2/host1@EXAMPLE.COM");
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
- put("principal_configuration", "service1-site/component1.kerberos.principal");
|
|
|
|
- put("principal_local_username", "service1");
|
|
|
|
- put("keytab_file", "${keytab_dir}/service1.keytab");
|
|
|
|
- put("keytab_owner_name", "service1");
|
|
|
|
|
|
+ put("principal_configuration", "service2-site/component2.kerberos.principal");
|
|
|
|
+ put("principal_local_username", "service2");
|
|
|
|
+ put("keytab_file", "${keytab_dir}/service2.keytab");
|
|
|
|
+ put("keytab_owner_name", "service2");
|
|
put("keytab_owner_access", "rw");
|
|
put("keytab_owner_access", "rw");
|
|
put("keytab_group_name", "hadoop");
|
|
put("keytab_group_name", "hadoop");
|
|
put("keytab_group_access", "");
|
|
put("keytab_group_access", "");
|
|
- put("keytab_configuration", "service1-site/component1.keytab.file");
|
|
|
|
|
|
+ put("keytab_configuration", "service2-site/component2.keytab.file");
|
|
put("keytab_cachable", false);
|
|
put("keytab_cachable", false);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ }});
|
|
|
|
|
|
- put("identity3", new HashMap<String, Object>() {
|
|
|
|
|
|
+ hostIdentities = identities.get("host2");
|
|
|
|
+ Assert.assertNotNull(hostIdentities);
|
|
|
|
+ Assert.assertEquals(1, hostIdentities.size());
|
|
|
|
+
|
|
|
|
+ validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
|
|
+ put("identity2", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
- put("principal_name", "service1/host2@EXAMPLE.COM");
|
|
|
|
|
|
+ put("principal_name", "component2/host2@EXAMPLE.COM");
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
- put("principal_configuration", "service1-site/service1.kerberos.principal");
|
|
|
|
- put("principal_local_username", "service1");
|
|
|
|
- put("keytab_file", "${keytab_dir}/service1.service.keytab");
|
|
|
|
- put("keytab_owner_name", "service1");
|
|
|
|
|
|
+ put("principal_configuration", "service2-site/component2.kerberos.principal");
|
|
|
|
+ put("principal_local_username", "service2");
|
|
|
|
+ put("keytab_file", "${keytab_dir}/service2.keytab");
|
|
|
|
+ put("keytab_owner_name", "service2");
|
|
put("keytab_owner_access", "rw");
|
|
put("keytab_owner_access", "rw");
|
|
put("keytab_group_name", "hadoop");
|
|
put("keytab_group_name", "hadoop");
|
|
put("keytab_group_access", "");
|
|
put("keytab_group_access", "");
|
|
- put("keytab_configuration", "service1-site/service1.keytab.file");
|
|
|
|
|
|
+ put("keytab_configuration", "service2-site/component2.keytab.file");
|
|
put("keytab_cachable", false);
|
|
put("keytab_cachable", false);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- }}); }
|
|
|
|
|
|
+ }});
|
|
|
|
+ }
|
|
|
|
|
|
- @Test
|
|
|
|
- public void testGetActiveIdentities_SingleServiceSingleHost() throws Exception {
|
|
|
|
- Map<String, Collection<KerberosIdentityDescriptor>> identities = testGetActiveIdentities("c1", "host2", "SERVICE1", null, true);
|
|
|
|
|
|
+ private void testGetActiveIdentities_All(SecurityType clusterSecurityType) throws Exception {
|
|
|
|
+ Map<String, Collection<KerberosIdentityDescriptor>> identities = testGetActiveIdentities("c1", null, null, null, true, clusterSecurityType);
|
|
|
|
|
|
Assert.assertNotNull(identities);
|
|
Assert.assertNotNull(identities);
|
|
- Assert.assertEquals(1, identities.size());
|
|
|
|
|
|
+ Assert.assertEquals(2, identities.size());
|
|
|
|
|
|
Collection<KerberosIdentityDescriptor> hostIdentities;
|
|
Collection<KerberosIdentityDescriptor> hostIdentities;
|
|
|
|
|
|
- hostIdentities = identities.get("host2");
|
|
|
|
|
|
+ hostIdentities = identities.get("host1");
|
|
Assert.assertNotNull(hostIdentities);
|
|
Assert.assertNotNull(hostIdentities);
|
|
- Assert.assertEquals(2, hostIdentities.size());
|
|
|
|
|
|
+ Assert.assertEquals(3, hostIdentities.size());
|
|
|
|
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
put("identity1", new HashMap<String, Object>() {
|
|
put("identity1", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
- put("principal_name", "component1/host2@EXAMPLE.COM");
|
|
|
|
|
|
+ put("principal_name", "component1/host1@EXAMPLE.COM");
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_configuration", "service1-site/component1.kerberos.principal");
|
|
put("principal_configuration", "service1-site/component1.kerberos.principal");
|
|
put("principal_local_username", "service1");
|
|
put("principal_local_username", "service1");
|
|
@@ -717,9 +710,25 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ put("identity2", new HashMap<String, Object>() {
|
|
|
|
+ {
|
|
|
|
+ put("principal_name", "component2/host1@EXAMPLE.COM");
|
|
|
|
+ put("principal_type", KerberosPrincipalType.SERVICE);
|
|
|
|
+ put("principal_configuration", "service2-site/component2.kerberos.principal");
|
|
|
|
+ put("principal_local_username", "service2");
|
|
|
|
+ put("keytab_file", "${keytab_dir}/service2.keytab");
|
|
|
|
+ put("keytab_owner_name", "service2");
|
|
|
|
+ put("keytab_owner_access", "rw");
|
|
|
|
+ put("keytab_group_name", "hadoop");
|
|
|
|
+ put("keytab_group_access", "");
|
|
|
|
+ put("keytab_configuration", "service2-site/component2.keytab.file");
|
|
|
|
+ put("keytab_cachable", false);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
put("identity3", new HashMap<String, Object>() {
|
|
put("identity3", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
- put("principal_name", "service1/host2@EXAMPLE.COM");
|
|
|
|
|
|
+ put("principal_name", "service1/host1@EXAMPLE.COM");
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_configuration", "service1-site/service1.kerberos.principal");
|
|
put("principal_configuration", "service1-site/service1.kerberos.principal");
|
|
put("principal_local_username", "service1");
|
|
put("principal_local_username", "service1");
|
|
@@ -733,44 +742,28 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}});
|
|
}});
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testGetActiveIdentities_SingleComponent() throws Exception {
|
|
|
|
- Map<String, Collection<KerberosIdentityDescriptor>> identities = testGetActiveIdentities("c1", null, null, "COMPONENT2", true);
|
|
|
|
-
|
|
|
|
- Assert.assertNotNull(identities);
|
|
|
|
- Assert.assertEquals(2, identities.size());
|
|
|
|
-
|
|
|
|
- Collection<KerberosIdentityDescriptor> hostIdentities;
|
|
|
|
|
|
|
|
- hostIdentities = identities.get("host1");
|
|
|
|
|
|
+ hostIdentities = identities.get("host2");
|
|
Assert.assertNotNull(hostIdentities);
|
|
Assert.assertNotNull(hostIdentities);
|
|
- Assert.assertEquals(1, hostIdentities.size());
|
|
|
|
|
|
+ Assert.assertEquals(3, hostIdentities.size());
|
|
|
|
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
- put("identity2", new HashMap<String, Object>() {
|
|
|
|
|
|
+ put("identity1", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
- put("principal_name", "component2/host1@EXAMPLE.COM");
|
|
|
|
|
|
+ put("principal_name", "component1/host2@EXAMPLE.COM");
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
put("principal_type", KerberosPrincipalType.SERVICE);
|
|
- put("principal_configuration", "service2-site/component2.kerberos.principal");
|
|
|
|
- put("principal_local_username", "service2");
|
|
|
|
- put("keytab_file", "${keytab_dir}/service2.keytab");
|
|
|
|
- put("keytab_owner_name", "service2");
|
|
|
|
|
|
+ put("principal_configuration", "service1-site/component1.kerberos.principal");
|
|
|
|
+ put("principal_local_username", "service1");
|
|
|
|
+ put("keytab_file", "${keytab_dir}/service1.keytab");
|
|
|
|
+ put("keytab_owner_name", "service1");
|
|
put("keytab_owner_access", "rw");
|
|
put("keytab_owner_access", "rw");
|
|
put("keytab_group_name", "hadoop");
|
|
put("keytab_group_name", "hadoop");
|
|
put("keytab_group_access", "");
|
|
put("keytab_group_access", "");
|
|
- put("keytab_configuration", "service2-site/component2.keytab.file");
|
|
|
|
|
|
+ put("keytab_configuration", "service1-site/component1.keytab.file");
|
|
put("keytab_cachable", false);
|
|
put("keytab_cachable", false);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- }});
|
|
|
|
-
|
|
|
|
- hostIdentities = identities.get("host2");
|
|
|
|
- Assert.assertNotNull(hostIdentities);
|
|
|
|
- Assert.assertEquals(1, hostIdentities.size());
|
|
|
|
|
|
|
|
- validateIdentities(hostIdentities, new HashMap<String, Map<String, Object>>() {{
|
|
|
|
put("identity2", new HashMap<String, Object>() {
|
|
put("identity2", new HashMap<String, Object>() {
|
|
{
|
|
{
|
|
put("principal_name", "component2/host2@EXAMPLE.COM");
|
|
put("principal_name", "component2/host2@EXAMPLE.COM");
|
|
@@ -786,6 +779,22 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
put("keytab_cachable", false);
|
|
put("keytab_cachable", false);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ put("identity3", new HashMap<String, Object>() {
|
|
|
|
+ {
|
|
|
|
+ put("principal_name", "service1/host2@EXAMPLE.COM");
|
|
|
|
+ put("principal_type", KerberosPrincipalType.SERVICE);
|
|
|
|
+ put("principal_configuration", "service1-site/service1.kerberos.principal");
|
|
|
|
+ put("principal_local_username", "service1");
|
|
|
|
+ put("keytab_file", "${keytab_dir}/service1.service.keytab");
|
|
|
|
+ put("keytab_owner_name", "service1");
|
|
|
|
+ put("keytab_owner_access", "rw");
|
|
|
|
+ put("keytab_group_name", "hadoop");
|
|
|
|
+ put("keytab_group_access", "");
|
|
|
|
+ put("keytab_configuration", "service1-site/service1.keytab.file");
|
|
|
|
+ put("keytab_cachable", false);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}});
|
|
}});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2877,7 +2886,13 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
verifyAll();
|
|
verifyAll();
|
|
}
|
|
}
|
|
|
|
|
|
- private Map<String, Collection<KerberosIdentityDescriptor>> testGetActiveIdentities(String clusterName, String hostName, String serviceName, String compnentName, boolean replaceHostnames) throws Exception {
|
|
|
|
|
|
+ private Map<String, Collection<KerberosIdentityDescriptor>> testGetActiveIdentities(String clusterName,
|
|
|
|
+ String hostName,
|
|
|
|
+ String serviceName,
|
|
|
|
+ String componentName,
|
|
|
|
+ boolean replaceHostNames,
|
|
|
|
+ SecurityType clusterSecurityType)
|
|
|
|
+ throws Exception {
|
|
|
|
|
|
KerberosHelper kerberosHelper = injector.getInstance(KerberosHelper.class);
|
|
KerberosHelper kerberosHelper = injector.getInstance(KerberosHelper.class);
|
|
|
|
|
|
@@ -2936,7 +2951,7 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
.anyTimes();
|
|
.anyTimes();
|
|
|
|
|
|
final Cluster cluster = createMock(Cluster.class);
|
|
final Cluster cluster = createMock(Cluster.class);
|
|
- expect(cluster.getSecurityType()).andReturn(SecurityType.KERBEROS).anyTimes();
|
|
|
|
|
|
+ expect(cluster.getSecurityType()).andReturn(clusterSecurityType).anyTimes();
|
|
expect(cluster.getClusterName()).andReturn(clusterName).anyTimes();
|
|
expect(cluster.getClusterName()).andReturn(clusterName).anyTimes();
|
|
expect(cluster.getServiceComponentHosts("host1"))
|
|
expect(cluster.getServiceComponentHosts("host1"))
|
|
.andReturn(new ArrayList<ServiceComponentHost>() {
|
|
.andReturn(new ArrayList<ServiceComponentHost>() {
|
|
@@ -3097,7 +3112,7 @@ public class KerberosHelperTest extends EasyMockSupport {
|
|
metaInfo.init();
|
|
metaInfo.init();
|
|
|
|
|
|
Map<String, Collection<KerberosIdentityDescriptor>> identities;
|
|
Map<String, Collection<KerberosIdentityDescriptor>> identities;
|
|
- identities = kerberosHelper.getActiveIdentities(clusterName, hostName, serviceName, compnentName, replaceHostnames);
|
|
|
|
|
|
+ identities = kerberosHelper.getActiveIdentities(clusterName, hostName, serviceName, componentName, replaceHostNames);
|
|
|
|
|
|
verifyAll();
|
|
verifyAll();
|
|
|
|
|