use of org.apache.directory.api.ldap.extras.extended.ads_impl.pwdModify.PasswordModifyResponseDecorator in project directory-ldap-api by apache.
the class PasswordModifyResponseTest method testDecodePasswordModifyResponseEmpty.
/**
* Test the decoding of a PasswordModifyResponse with nothing in it
*/
@Test
public void testDecodePasswordModifyResponseEmpty() {
Asn1Decoder decoder = new Asn1Decoder();
ByteBuffer bb = ByteBuffer.allocate(0x02);
bb.put(new byte[] { // PasswordModifyResponse ::= SEQUENCE {
0x30, // PasswordModifyResponse ::= SEQUENCE {
0x00 });
String decodedPdu = Strings.dumpBytes(bb.array());
bb.flip();
PasswordModifyResponseContainer container = new PasswordModifyResponseContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
de.printStackTrace();
fail(de.getMessage());
}
PasswordModifyResponse pwdModifyResponse = container.getPwdModifyResponse();
assertNull(pwdModifyResponse.getGenPassword());
// Check the length
assertEquals(0x02, ((PasswordModifyResponseDecorator) pwdModifyResponse).computeLengthInternal());
// Check the encoding
ByteBuffer bb1 = ((PasswordModifyResponseDecorator) pwdModifyResponse).encodeInternal();
String encodedPdu = Strings.dumpBytes(bb1.array());
assertEquals(encodedPdu, decodedPdu);
}
use of org.apache.directory.api.ldap.extras.extended.ads_impl.pwdModify.PasswordModifyResponseDecorator in project directory-ldap-api by apache.
the class PasswordModifyResponseTest method testDecodePasswordModifyResponseUserIdentityNull.
/**
* Test the decoding of a PasswordModifyResponse with an empty genPassword
*/
@Test
public void testDecodePasswordModifyResponseUserIdentityNull() {
Asn1Decoder decoder = new Asn1Decoder();
ByteBuffer bb = ByteBuffer.allocate(0x04);
bb.put(new byte[] { // PasswordModifyResponse ::= SEQUENCE {
0x30, // PasswordModifyResponse ::= SEQUENCE {
0x02, (byte) 0x80, // genPassword [0] OCTET STRING OPTIONAL
0x00 });
String decodedPdu = Strings.dumpBytes(bb.array());
bb.flip();
PasswordModifyResponseContainer container = new PasswordModifyResponseContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
de.printStackTrace();
fail(de.getMessage());
}
PasswordModifyResponse pwdModifyResponse = container.getPwdModifyResponse();
assertNotNull(pwdModifyResponse.getGenPassword());
assertEquals(0, pwdModifyResponse.getGenPassword().length);
// Check the length
assertEquals(0x04, ((PasswordModifyResponseDecorator) pwdModifyResponse).computeLengthInternal());
// Check the encoding
ByteBuffer bb1 = ((PasswordModifyResponseDecorator) pwdModifyResponse).encodeInternal();
String encodedPdu = Strings.dumpBytes(bb1.array());
assertEquals(encodedPdu, decodedPdu);
}
use of org.apache.directory.api.ldap.extras.extended.ads_impl.pwdModify.PasswordModifyResponseDecorator in project directory-ldap-api by apache.
the class PasswordModifyResponseTest method testDecodePasswordModifyResponseUserIdentityValue.
/**
* Test the decoding of a PasswordModifyResponse with a genPassword
*/
@Test
public void testDecodePasswordModifyResponseUserIdentityValue() {
Asn1Decoder decoder = new Asn1Decoder();
ByteBuffer bb = ByteBuffer.allocate(0x08);
bb.put(new byte[] { // PasswordModifyResponse ::= SEQUENCE {
0x30, // PasswordModifyResponse ::= SEQUENCE {
0x06, (byte) 0x80, // genPassword [0] OCTET STRING OPTIONAL
0x04, 'a', 'b', 'c', 'd' });
String decodedPdu = Strings.dumpBytes(bb.array());
bb.flip();
PasswordModifyResponseContainer container = new PasswordModifyResponseContainer();
try {
decoder.decode(bb, container);
} catch (DecoderException de) {
de.printStackTrace();
fail(de.getMessage());
}
PasswordModifyResponse pwdModifyResponse = container.getPwdModifyResponse();
assertNotNull(pwdModifyResponse.getGenPassword());
assertEquals("abcd", Strings.utf8ToString(pwdModifyResponse.getGenPassword()));
// Check the length
assertEquals(0x08, ((PasswordModifyResponseDecorator) pwdModifyResponse).computeLengthInternal());
// Check the encoding
ByteBuffer bb1 = ((PasswordModifyResponseDecorator) pwdModifyResponse).encodeInternal();
String encodedPdu = Strings.dumpBytes(bb1.array());
assertEquals(encodedPdu, decodedPdu);
}
Aggregations