public void validateResourceResponse(LdapConnectionInfoDTO expected, LdapConnectionInfoDTO actual) throws Exception { Assert.assertEquals(expected.getAuthScheme(), actual.getAuthScheme()); Assert.assertEquals(expected.getHost(), actual.getHost()); Assert.assertEquals(expected.getPort(), actual.getPort()); Assert.assertEquals(expected.getProtocol(), actual.getProtocol()); Assert.assertEquals(expected.getRealm(), actual.getRealm()); Assert.assertEquals(expected.getSearchBase(), actual.getSearchBase()); Assert.assertEquals(expected.getSystemUsername(), actual.getSystemUsername()); // if the expectedPassword == null then the actual should be null // if its anything else the actual password should be "--FAKE-PASSWORD--" if (expected.getSystemPassword() == null) { Assert.assertNull(actual.getSystemPassword()); } else { Assert.assertEquals(LdapRealmPlexusResourceConst.FAKE_PASSWORD, actual.getSystemPassword()); } // also validate the file config this.validateLdapConfig(expected); }
@SuppressWarnings("unchecked") public void validateLdapConfig(LdapConnectionInfoDTO connInfo) throws Exception { CConnectionInfo fileConfig = LdapConfigurationUtil.getConfiguration().getConnectionInfo(); Assert.assertEquals(connInfo.getAuthScheme(), fileConfig.getAuthScheme()); Assert.assertEquals(connInfo.getHost(), fileConfig.getHost()); Assert.assertEquals(connInfo.getPort(), fileConfig.getPort()); Assert.assertEquals(connInfo.getProtocol(), fileConfig.getProtocol()); Assert.assertEquals(connInfo.getRealm(), fileConfig.getRealm()); Assert.assertEquals(connInfo.getSearchBase(), fileConfig.getSearchBase()); Assert.assertEquals(connInfo.getSystemUsername(), fileConfig.getSystemUsername()); // if the expectedPassword == null then the actual should be null if (connInfo.getSystemPassword() == null) { Assert.assertNull(fileConfig.getSystemPassword()); } else { // make sure its not clear text Assert.assertNotSame(connInfo.getSystemPassword(), fileConfig.getSystemPassword()); Assert.assertTrue(fileConfig.getSystemPassword().length() > 0); } }