private void initializeCConf() throws IOException { cConf.unset(KafkaConstants.ConfigKeys.ZOOKEEPER_NAMESPACE_CONFIG); cConf.set(Constants.CFG_LOCAL_DATA_DIR, tmpFolder.newFolder().getAbsolutePath()); cConf.set(Constants.Zookeeper.QUORUM, zkServer.getConnectionStr()); for (Map.Entry<String, String> entry : extraConfigs.entrySet()) { cConf.set(entry.getKey(), entry.getValue()); } }
@Test(expected = IllegalArgumentException.class) public void testMaxNotConfigured() throws Exception { CConfiguration cConfiguration = CConfiguration.create(); cConfiguration.unset(TxConstants.Manager.CFG_TX_MAX_TIMEOUT); run(cConfiguration); }
@Test(expected = IllegalArgumentException.class) public void testDefaultNotConfigured() throws Exception { CConfiguration cConfiguration = CConfiguration.create(); cConfiguration.unset(TxConstants.Manager.CFG_TX_TIMEOUT); run(cConfiguration); }
@Test public void testGetACLs() throws Exception { CConfiguration kerbConf = CConfiguration.create(); kerbConf.set(Constants.Security.KERBEROS_ENABLED, "true"); kerbConf.set(Constants.Security.CFG_CDAP_MASTER_KRB_PRINCIPAL, "prinicpal@REALM.NET"); kerbConf.set(Constants.Security.CFG_CDAP_MASTER_KRB_KEYTAB_PATH, "/path/to/keytab"); Assert.assertEquals(ZooDefs.Ids.CREATOR_ALL_ACL, DistributedKeyManager.getACLs(kerbConf)); CConfiguration noKerbConf = CConfiguration.create(); noKerbConf.unset(Constants.Security.CFG_CDAP_MASTER_KRB_PRINCIPAL); Assert.assertEquals(ZooDefs.Ids.OPEN_ACL_UNSAFE, DistributedKeyManager.getACLs(noKerbConf)); }
@Test public void isKerberosEnabled() throws Exception { CConfiguration kerbConf = CConfiguration.create(); kerbConf.set(Constants.Security.KERBEROS_ENABLED, "true"); kerbConf.set(Constants.Security.CFG_CDAP_MASTER_KRB_PRINCIPAL, "prinicpal@REALM.NET"); kerbConf.set(Constants.Security.CFG_CDAP_MASTER_KRB_KEYTAB_PATH, "/path/to/keytab"); Assert.assertTrue(SecurityUtil.isKerberosEnabled(kerbConf)); CConfiguration noPrincipalConf = CConfiguration.create(); kerbConf.set(Constants.Security.KERBEROS_ENABLED, "false"); noPrincipalConf.unset(Constants.Security.CFG_CDAP_MASTER_KRB_PRINCIPAL); noPrincipalConf.set(Constants.Security.CFG_CDAP_MASTER_KRB_KEYTAB_PATH, "/path/to/keytab"); Assert.assertFalse(SecurityUtil.isKerberosEnabled(noPrincipalConf)); CConfiguration noKeyTabConf = CConfiguration.create(); kerbConf.set(Constants.Security.KERBEROS_ENABLED, "false"); noKeyTabConf.unset(Constants.Security.CFG_CDAP_MASTER_KRB_KEYTAB_PATH); noKeyTabConf.set(Constants.Security.CFG_CDAP_MASTER_KRB_PRINCIPAL, "prinicpal@REALM.NET"); Assert.assertFalse(SecurityUtil.isKerberosEnabled(noKeyTabConf)); }