@Test public void testGetUserSearchFilter() throws Exception { assertEquals( INCORRECT_USER_SEARCH_FILTER, "(uid={0})", ldapServerProperties.getUserSearchFilter()); ldapServerProperties.setUsernameAttribute("anotherName"); assertEquals( INCORRECT_USER_SEARCH_FILTER, "(anotherName={0})", ldapServerProperties.getUserSearchFilter()); }
@Test public void testGetLdapUrls() throws Exception { List<String> urls = ldapServerProperties.getLdapUrls(); assertEquals(INCORRECT_URL_LIST, 1, urls.size()); assertEquals(INCORRECT_URL_LIST, "ldap://1.2.3.4:389", urls.get(0)); ldapServerProperties.setSecondaryUrl("4.3.2.1:1234"); urls = ldapServerProperties.getLdapUrls(); assertEquals(INCORRECT_URL_LIST, 2, urls.size()); assertEquals(INCORRECT_URL_LIST, "ldap://4.3.2.1:1234", urls.get(1)); ldapServerProperties.setUseSsl(true); urls = ldapServerProperties.getLdapUrls(); assertEquals(INCORRECT_URL_LIST, "ldaps://1.2.3.4:389", urls.get(0)); assertEquals(INCORRECT_URL_LIST, "ldaps://4.3.2.1:1234", urls.get(1)); }
@Before public void setUp() throws Exception { ldapServerProperties = new LdapServerProperties(); ldapServerProperties.setAnonymousBind(true); ldapServerProperties.setBaseDN("dc=ambari,dc=apache,dc=org"); ldapServerProperties.setManagerDn("uid=manager," + ldapServerProperties.getBaseDN()); ldapServerProperties.setManagerPassword("password"); ldapServerProperties.setUseSsl(false); ldapServerProperties.setPrimaryUrl("1.2.3.4:389"); ldapServerProperties.setUsernameAttribute("uid"); }
@Test public void testEquals() throws Exception { LdapServerProperties properties1 = configuration.getLdapServerProperties(); LdapServerProperties properties2 = configuration.getLdapServerProperties(); assertTrue("Properties object is same", properties1 != properties2); assertTrue("Objects are not equal", properties1.equals(properties2)); assertTrue("Hash codes are not equal", properties1.hashCode() == properties2.hashCode()); properties2.setSecondaryUrl("5.6.7.8:389"); assertFalse("Objects are equal", properties1.equals(properties2)); }