use of com.unboundid.ldap.sdk.examples.LDAPSearch in project ldapsdk by pingidentity.
the class LDAPCommandLineToolTestCase method testPropertiesFilePropertyInvalidValue.
/**
* Tests the behavior with a properties file that has a property line that has
* an invalid value for a property.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testPropertiesFilePropertyInvalidValue() throws Exception {
final File propertiesFile = createTempFile("# The hostname", "hostname=127.0.0.1", "", "# The port", "port=invalid");
final LDAPSearch ldapSearch = new LDAPSearch(null, null);
final ResultCode rc = ldapSearch.runTool("--propertiesFilePath", propertiesFile.getAbsolutePath(), "--baseDN", "", "(objectClass=*)");
assertFalse(rc == ResultCode.SUCCESS);
}
use of com.unboundid.ldap.sdk.examples.LDAPSearch in project ldapsdk by pingidentity.
the class LDAPCommandLineToolTestCase method testSASLMissingRequiredOption.
/**
* Provides a test with a missing required option.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSASLMissingRequiredOption() throws Exception {
LDAPSearch ldapSearch = new LDAPSearch(null, null);
ResultCode rc = ldapSearch.runTool("-h", getTestHost(), "-p", String.valueOf(getTestPort()), "-o", "mech=PLAIN", "-w", getTestBindPassword(), "-b", "", "-s", "base", "(objectClass=*)");
assertFalse(rc == ResultCode.SUCCESS);
}
use of com.unboundid.ldap.sdk.examples.LDAPSearch in project ldapsdk by pingidentity.
the class LDAPCommandLineToolTestCase method testSASLMalformedOption.
/**
* Provides a test with a malformed SASL option.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSASLMalformedOption() throws Exception {
LDAPSearch ldapSearch = new LDAPSearch(null, null);
ResultCode rc = ldapSearch.runTool("-h", getTestHost(), "-p", String.valueOf(getTestPort()), "-o", "mech=PLAIN", "-o", "malformed", "-o", "authID=dn:" + getTestBindDN(), "-w", getTestBindPassword(), "-b", "", "-s", "base", "(objectClass=*)");
assertFalse(rc == ResultCode.SUCCESS);
}
use of com.unboundid.ldap.sdk.examples.LDAPSearch in project ldapsdk by pingidentity.
the class SASLUtilsTestCase method testValidTOTPBindWithStaticPasswordPrompt.
/**
* Tests the ability to create a valid UNBOUNDID-TOTP bind request when
* prompting for the static password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testValidTOTPBindWithStaticPasswordPrompt() throws Exception {
final LDAPSearch tool = new LDAPSearch(null, null);
final BindRequest bindRequest;
try {
PasswordReader.setTestReader(new BufferedReader(new InputStreamReader(new ByteArrayInputStream("password\n".getBytes("UTF-8")))));
bindRequest = SASLUtils.createBindRequest(null, (byte[]) null, false, tool, null, Arrays.asList("mech=UNBOUNDID-TOTP", "authID=u:test.user", "totpPassword=123456", "promptForStaticPassword=true"));
} finally {
PasswordReader.setTestReader(null);
}
assertNotNull(bindRequest);
assertTrue(bindRequest instanceof SingleUseTOTPBindRequest);
final SingleUseTOTPBindRequest totpBind = (SingleUseTOTPBindRequest) bindRequest;
assertNotNull(totpBind.getAuthenticationID());
assertEquals(totpBind.getAuthenticationID(), "u:test.user");
assertNull(totpBind.getAuthorizationID());
assertNotNull(totpBind.getStaticPassword());
assertEquals(totpBind.getStaticPassword().stringValue(), "password");
assertNotNull(totpBind.getTOTPPassword());
assertEquals(totpBind.getTOTPPassword(), "123456");
}
Aggregations