use of com.github.zhenwei.core.asn1.ASN1Sequence in project ldapsdk by pingidentity.
the class ModificationTestCase method testConstructor2.
/**
* Tests the second constructor, which takes a modification type, an attribute
* name, and a single string value.
*
* @param modificationType The modification type to use for the test
* modification.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "testModificationTypes")
public void testConstructor2(ModificationType modificationType) throws Exception {
Modification mod = new Modification(modificationType, "cn", "John Doe");
assertEquals(mod.getModificationType(), modificationType);
assertEquals(mod.getAttribute(), new Attribute("cn", "John Doe"));
assertEquals(mod.getAttributeName(), "cn");
assertTrue(mod.hasValue());
assertEquals(mod.getValues().length, 1);
assertEquals(mod.getValueByteArrays().length, 1);
ASN1Sequence modSequence = mod.encode();
Modification decodedMod = Modification.decode(modSequence);
assertEquals(decodedMod, mod);
assertEquals(decodedMod.hashCode(), mod.hashCode());
assertNotNull(mod.toString());
final ArrayList<String> toCodeLines = new ArrayList<String>(10);
mod.toCode(toCodeLines, 0, null, null);
assertFalse(toCodeLines.isEmpty());
toCodeLines.clear();
mod.toCode(toCodeLines, 4, "FirstLinePrefix-", "-LastLineSuffix");
assertFalse(toCodeLines.isEmpty());
}
use of com.github.zhenwei.core.asn1.ASN1Sequence in project ldapsdk by pingidentity.
the class ModificationTestCase method testConstructor1.
/**
* Tests the first constructor, which takes a modification type and an
* attribute name.
*
* @param modificationType The modification type to use for the test
* modification.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "testModificationTypes")
public void testConstructor1(ModificationType modificationType) throws Exception {
Modification mod = new Modification(modificationType, "cn");
assertEquals(mod.getModificationType(), modificationType);
assertEquals(mod.getAttribute(), new Attribute("cn"));
assertEquals(mod.getAttributeName(), "cn");
assertFalse(mod.hasValue());
assertEquals(mod.getValues().length, 0);
assertEquals(mod.getValueByteArrays().length, 0);
ASN1Sequence modSequence = mod.encode();
Modification decodedMod = Modification.decode(modSequence);
assertEquals(decodedMod, mod);
assertEquals(decodedMod.hashCode(), mod.hashCode());
assertNotNull(mod.toString());
final ArrayList<String> toCodeLines = new ArrayList<String>(10);
mod.toCode(toCodeLines, 0, null, null);
assertFalse(toCodeLines.isEmpty());
toCodeLines.clear();
mod.toCode(toCodeLines, 4, "FirstLinePrefix-", "-LastLineSuffix");
assertFalse(toCodeLines.isEmpty());
}
use of com.github.zhenwei.core.asn1.ASN1Sequence in project ldapsdk by pingidentity.
the class GenerateTOTPSharedSecretExtendedRequestTestCase method testDecodeRequestValueEmptySequence.
/**
* Tests the behavior of the extended request when trying to decode a generic
* request that has a value that is an empty ASN.1 sequence.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeRequestValueEmptySequence() throws Exception {
final ExtendedRequest r = new ExtendedRequest("1.3.6.1.4.1.30221.2.6.56", new ASN1OctetString(new ASN1Sequence().encode()));
new GenerateTOTPSharedSecretExtendedRequest(r);
}
use of com.github.zhenwei.core.asn1.ASN1Sequence in project ldapsdk by pingidentity.
the class GenerateTOTPSharedSecretExtendedRequestTestCase method testDecodeRequestValueSequenceUnrecognizedElementType.
/**
* Tests the behavior of the extended request when trying to decode a generic
* request that has a value that is an ASN.1 sequence with an unrecognized
* element type.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeRequestValueSequenceUnrecognizedElementType() throws Exception {
final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "u:test.user"), new ASN1OctetString((byte) 0x12, "invalid-type"));
final ExtendedRequest r = new ExtendedRequest("1.3.6.1.4.1.30221.2.6.56", new ASN1OctetString(valueSequence.encode()));
new GenerateTOTPSharedSecretExtendedRequest(r);
}
use of com.github.zhenwei.core.asn1.ASN1Sequence in project ldapsdk by pingidentity.
the class GetChangelogBatchExtendedRequestTestCase method testDecodeValueSequenceInvalidChangeType.
/**
* Provides test coverage for an attempt to decode an extended request with a
* value sequence with an invalid change type.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceInvalidChangeType() throws Exception {
final ASN1Set changeTypeSet = new ASN1Set((byte) 0xA4, new ASN1Enumerated(0), new ASN1Enumerated(5));
final ASN1Sequence valueSequence = new ASN1Sequence(new EndOfChangelogStartingPoint().encode(), new ASN1Integer(0), changeTypeSet);
new GetChangelogBatchExtendedRequest(new ExtendedRequest(GetChangelogBatchExtendedRequest.GET_CHANGELOG_BATCH_REQUEST_OID, new ASN1OctetString(valueSequence.encode())));
}
Aggregations