@Test public void testUpdateAuthToLocalRules() throws AmbariException { KerberosDescriptor oldValue = KERBEROS_DESCRIPTOR_FACTORY.createInstance( "{\n" + " \"auth_to_local_properties\" : [\n" + " \"core-site/hadoop.security.auth_to_local\",\n" + " \"some-site/to.be.removed\"\n" + " ]\n" + "}\n"); KerberosDescriptor newValue = KERBEROS_DESCRIPTOR_FACTORY.createInstance( "{\n" + " \"auth_to_local_properties\" : [\n" + " \"core-site/hadoop.security.auth_to_local\",\n" + " \"some-site/to.be.added\"\n" + " ]\n" + "}\n"); KerberosDescriptor userValue = KERBEROS_DESCRIPTOR_FACTORY.createInstance( "{\n" + " \"auth_to_local_properties\" : [\n" + " \"core-site/hadoop.security.auth_to_local\",\n" + " \"some-site/added.by.user\"\n" + " ]\n" + "}\n"); KerberosDescriptor updatedUserValue = KerberosDescriptorUpdateHelper.updateUserKerberosDescriptor( oldValue, newValue, userValue); Assert.assertEquals( KERBEROS_DESCRIPTOR_FACTORY.createInstance( "{\n" + " \"auth_to_local_properties\" : [\n" + " \"core-site/hadoop.security.auth_to_local\",\n" + " \"some-site/to.be.added\",\n" + " \"some-site/added.by.user\"\n" + " ]\n" + "}\n"), updatedUserValue); }
public static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor, KerberosDescriptor endingStackKerberosDescriptor, KerberosDescriptor userKerberosDescriptor) { KerberosDescriptor updated = new KerberosDescriptor(userKerberosDescriptor.toMap()); updated.setProperties(processProperties( beginningStackKerberosDescriptor.getProperties(), endingStackKerberosDescriptor.getProperties(), updated.getProperties())); updated.setConfigurations(processConfigurations( beginningStackKerberosDescriptor.getConfigurations(), endingStackKerberosDescriptor.getConfigurations(), updated.getConfigurations())); updated.setIdentities(processIdentities( beginningStackKerberosDescriptor.getIdentities(), endingStackKerberosDescriptor.getIdentities(), updated.getIdentities())); updated.setAuthToLocalProperties(processAuthToLocalProperties( beginningStackKerberosDescriptor.getAuthToLocalProperties(), endingStackKerberosDescriptor.getAuthToLocalProperties(), updated.getAuthToLocalProperties())); updated.setServices(processServices( beginningStackKerberosDescriptor.getServices(), endingStackKerberosDescriptor.getServices(), updated.getServices())); return updated; }
KerberosDescriptorUpdateHelper { public static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor, KerberosDescriptor endingStackKerberosDescriptor, KerberosDescriptor userKerberosDescriptor) { KerberosDescriptor updated = new KerberosDescriptor(userKerberosDescriptor.toMap()); updated.setProperties(processProperties( beginningStackKerberosDescriptor.getProperties(), endingStackKerberosDescriptor.getProperties(), updated.getProperties())); updated.setConfigurations(processConfigurations( beginningStackKerberosDescriptor.getConfigurations(), endingStackKerberosDescriptor.getConfigurations(), updated.getConfigurations())); updated.setIdentities(processIdentities( beginningStackKerberosDescriptor.getIdentities(), endingStackKerberosDescriptor.getIdentities(), updated.getIdentities())); updated.setAuthToLocalProperties(processAuthToLocalProperties( beginningStackKerberosDescriptor.getAuthToLocalProperties(), endingStackKerberosDescriptor.getAuthToLocalProperties(), updated.getAuthToLocalProperties())); updated.setServices(processServices( beginningStackKerberosDescriptor.getServices(), endingStackKerberosDescriptor.getServices(), updated.getServices())); return updated; } }
KerberosDescriptorUpdateHelper { public static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor, KerberosDescriptor endingStackKerberosDescriptor, KerberosDescriptor userKerberosDescriptor) { KerberosDescriptor updated = new KerberosDescriptor(userKerberosDescriptor.toMap()); updated.setProperties(processProperties( beginningStackKerberosDescriptor.getProperties(), endingStackKerberosDescriptor.getProperties(), updated.getProperties())); updated.setConfigurations(processConfigurations( beginningStackKerberosDescriptor.getConfigurations(), endingStackKerberosDescriptor.getConfigurations(), updated.getConfigurations())); updated.setIdentities(processIdentities( beginningStackKerberosDescriptor.getIdentities(), endingStackKerberosDescriptor.getIdentities(), updated.getIdentities())); updated.setAuthToLocalProperties(processAuthToLocalProperties( beginningStackKerberosDescriptor.getAuthToLocalProperties(), endingStackKerberosDescriptor.getAuthToLocalProperties(), updated.getAuthToLocalProperties())); updated.setServices(processServices( beginningStackKerberosDescriptor.getServices(), endingStackKerberosDescriptor.getServices(), updated.getServices())); return updated; }  }
KerberosDescriptorUpdateHelper { public static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor, KerberosDescriptor endingStackKerberosDescriptor, KerberosDescriptor userKerberosDescriptor) { KerberosDescriptor updated = new KerberosDescriptor(userKerberosDescriptor.toMap()); updated.setProperties(processProperties( beginningStackKerberosDescriptor.getProperties(), endingStackKerberosDescriptor.getProperties(), updated.getProperties())); updated.setConfigurations(processConfigurations( beginningStackKerberosDescriptor.getConfigurations(), endingStackKerberosDescriptor.getConfigurations(), updated.getConfigurations())); updated.setIdentities(processIdentities( beginningStackKerberosDescriptor.getIdentities(), endingStackKerberosDescriptor.getIdentities(), updated.getIdentities())); updated.setAuthToLocalProperties(processAuthToLocalProperties( beginningStackKerberosDescriptor.getAuthToLocalProperties(), endingStackKerberosDescriptor.getAuthToLocalProperties(), updated.getAuthToLocalProperties())); updated.setServices(processServices( beginningStackKerberosDescriptor.getServices(), endingStackKerberosDescriptor.getServices(), updated.getServices())); return updated; }  static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor,
                                                                KerberosDescriptor endingStackKerberosDescriptor,
                                                                KerberosDescriptor userKerberosDescriptor); }
KerberosDescriptorUpdateHelper { public static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor, KerberosDescriptor endingStackKerberosDescriptor, KerberosDescriptor userKerberosDescriptor) { KerberosDescriptor updated = new KerberosDescriptor(userKerberosDescriptor.toMap()); updated.setProperties(processProperties( beginningStackKerberosDescriptor.getProperties(), endingStackKerberosDescriptor.getProperties(), updated.getProperties())); updated.setConfigurations(processConfigurations( beginningStackKerberosDescriptor.getConfigurations(), endingStackKerberosDescriptor.getConfigurations(), updated.getConfigurations())); updated.setIdentities(processIdentities( beginningStackKerberosDescriptor.getIdentities(), endingStackKerberosDescriptor.getIdentities(), updated.getIdentities())); updated.setAuthToLocalProperties(processAuthToLocalProperties( beginningStackKerberosDescriptor.getAuthToLocalProperties(), endingStackKerberosDescriptor.getAuthToLocalProperties(), updated.getAuthToLocalProperties())); updated.setServices(processServices( beginningStackKerberosDescriptor.getServices(), endingStackKerberosDescriptor.getServices(), updated.getServices())); return updated; }  static KerberosDescriptor updateUserKerberosDescriptor(KerberosDescriptor beginningStackKerberosDescriptor,
                                                                KerberosDescriptor endingStackKerberosDescriptor,
                                                                KerberosDescriptor userKerberosDescriptor);  }