use of org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator in project directory-ldap-api by apache.
the class PasswordPolicyTest method testDecodeRespWithGraceAuthWarningOnly.
@Test
public void testDecodeRespWithGraceAuthWarningOnly() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(7);
bb.put(new byte[] { 0x30, 0x05, (byte) 0xA0, 0x03, // graceAuthNsRemaining
(byte) 0x81, // graceAuthNsRemaining
0x01, // graceAuthNsRemaining
0x01 });
bb.flip();
PasswordPolicyDecorator control = new PasswordPolicyDecorator(codec, true);
PasswordPolicy passwordPolicy = (PasswordPolicy) control.decode(bb.array());
assertTrue(passwordPolicy.hasResponse());
assertEquals(1, passwordPolicy.getResponse().getGraceAuthNRemaining());
ByteBuffer encoded = ((PasswordPolicyDecorator) passwordPolicy).encode(ByteBuffer.allocate(((PasswordPolicyDecorator) passwordPolicy).computeLength()));
assertEquals(Strings.dumpBytes(bb.array()), Strings.dumpBytes(encoded.array()));
}
use of org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator in project directory-ldap-api by apache.
the class PasswordPolicyTest method testDecodeRespWithoutWarningAndError.
@Test
public void testDecodeRespWithoutWarningAndError() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(2);
bb.put(new byte[] { 0x30, 0x00 });
bb.flip();
PasswordPolicyDecorator control = new PasswordPolicyDecorator(codec, true);
PasswordPolicy passwordPolicy = (PasswordPolicy) control.decode(bb.array());
assertNotNull(passwordPolicy);
assertTrue(passwordPolicy.hasResponse());
ByteBuffer encoded = ((PasswordPolicyDecorator) passwordPolicy).encode(ByteBuffer.allocate(((PasswordPolicyDecorator) passwordPolicy).computeLength()));
assertEquals(Strings.dumpBytes(bb.array()), Strings.dumpBytes(encoded.array()));
}
Aggregations