### Question:
CuratorACLProviderFactory { public ACLProvider create(ZooKeeperClientConfig config){ return StringUtils.equalsIgnoreCase(config.getAuthType(),SASL_AUTH_SCHEME) ? new SaslACLProvider(config) : new DefaultACLProvider(); }  ACLProvider create(ZooKeeperClientConfig config); static final String SASL_AUTH_SCHEME; }### Answer:
@Test public void testSaslAuthSchemeNoHostNoRealm(){ final NiFiProperties nifiProperties; final CuratorACLProviderFactory factory; otherProps.put("nifi.zookeeper.kerberos.removeHostFromPrincipal", "true"); otherProps.put("nifi.zookeeper.kerberos.removeRealmFromPrincipal", "true"); nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps); factory = new CuratorACLProviderFactory(); ZooKeeperClientConfig config = ZooKeeperClientConfig.createConfig(nifiProperties); ACLProvider provider = factory.create(config); assertFalse(provider instanceof DefaultACLProvider); List<ACL> acls = provider.getDefaultAcl(); assertNotNull(acls); assertEquals(acls.get(0).getId().toString().trim(),"'sasl,'nifi"); }
@Test public void testSaslAuthSchemeHeadless(){ final NiFiProperties nifiProperties; final CuratorACLProviderFactory factory; otherProps.put("nifi.zookeeper.kerberos.removeHostFromPrincipal", "true"); otherProps.put("nifi.zookeeper.kerberos.removeRealmFromPrincipal", "true"); otherProps.put("nifi.kerberos.service.principal","nifi@REALM.COM"); nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps); factory = new CuratorACLProviderFactory(); ZooKeeperClientConfig config = ZooKeeperClientConfig.createConfig(nifiProperties); ACLProvider provider = factory.create(config); assertFalse(provider instanceof DefaultACLProvider); List<ACL> acls = provider.getDefaultAcl(); assertNotNull(acls); assertEquals(acls.get(0).getId().toString().trim(),"'sasl,'nifi"); }
@Test public void testSaslAuthSchemeNoHostWithRealm(){ final NiFiProperties nifiProperties; final CuratorACLProviderFactory factory; otherProps.put("nifi.zookeeper.kerberos.removeHostFromPrincipal", "true"); otherProps.put("nifi.zookeeper.kerberos.removeRealmFromPrincipal", "false"); nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps); factory = new CuratorACLProviderFactory(); ZooKeeperClientConfig config = ZooKeeperClientConfig.createConfig(nifiProperties); ACLProvider provider = factory.create(config); assertFalse(provider instanceof DefaultACLProvider); List<ACL> acls = provider.getDefaultAcl(); assertNotNull(acls); assertEquals(acls.get(0).getId().toString().trim(),"'sasl,'nifi@REALM.COM"); }
@Test public void testSaslAuthSchemeWithHostNoRealm(){ final NiFiProperties nifiProperties; final CuratorACLProviderFactory factory; otherProps.put("nifi.zookeeper.kerberos.removeHostFromPrincipal", "false"); otherProps.put("nifi.zookeeper.kerberos.removeRealmFromPrincipal", "true"); nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps); factory = new CuratorACLProviderFactory(); ZooKeeperClientConfig config = ZooKeeperClientConfig.createConfig(nifiProperties); ACLProvider provider = factory.create(config); assertFalse(provider instanceof DefaultACLProvider); List<ACL> acls = provider.getDefaultAcl(); assertNotNull(acls); assertEquals(acls.get(0).getId().toString().trim(),"'sasl,'nifi/host"); }