use of com.github.zhenwei.core.asn1.ASN1Boolean in project ldapsdk by pingidentity.
the class StreamDirectoryValuesExtendedRequestTestCase method testConstructor2NoBaseDN.
/**
* Tests the behavior of the second constructor with a request that does not
* have a base DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testConstructor2NoBaseDN() throws Exception {
ASN1Element[] idElements = { new ASN1Enumerated((byte) 0x80, 0x02), new ASN1Boolean((byte) 0x81, true) };
ASN1Element[] svElements = { new ASN1Sequence((byte) 0xA1, idElements), new ASN1Integer((byte) 0x83, -1) };
ExtendedRequest r = new ExtendedRequest(StreamDirectoryValuesExtendedRequest.STREAM_DIRECTORY_VALUES_REQUEST_OID, new ASN1OctetString(new ASN1Sequence(svElements).encode()));
new StreamDirectoryValuesExtendedRequest(r);
}
use of com.github.zhenwei.core.asn1.ASN1Boolean in project ldapsdk by pingidentity.
the class PasswordQualityRequirementValidationResultTestCase method testDecodeUnexpectedElementType.
/**
* Tests the behavior when trying to decode an ASN.1 element whose sequence
* contains an unexpected element type.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeUnexpectedElementType() throws Exception {
final ASN1Sequence s = new ASN1Sequence(new PasswordQualityRequirement("description").encode(), new ASN1Boolean(true), new ASN1OctetString((byte) 0x12, "unexpected element type"));
PasswordQualityRequirementValidationResult.decode(s);
}
use of com.github.zhenwei.core.asn1.ASN1Boolean in project ldapsdk by pingidentity.
the class UnboundIDExternallyProcessedAuthenticationBindRequestTestCase method testDecodeCredentialsMissingUserDN.
/**
* Tests the behavior when trying to decode an ASN.1 element that represents
* encoded credentials that would be valid except that it is missing the
* required userDN element.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeCredentialsMissingUserDN() throws Exception {
final ASN1Sequence credSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x81, "TEST"), new ASN1Boolean((byte) 0x82, true));
UnboundIDExternallyProcessedAuthenticationBindRequest.decodeSASLCredentials(new ASN1OctetString(credSequence.encode()));
}
use of com.github.zhenwei.core.asn1.ASN1Boolean in project ldapsdk by pingidentity.
the class UnboundIDExternallyProcessedAuthenticationBindRequestTestCase method testDecodeValidFullCredentials.
/**
* Tests the behavior when trying to decode an ASN.1 element that represents
* a valid set of encoded credentials with a full encoding.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDecodeValidFullCredentials() throws Exception {
final ASN1Sequence credSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "u:test.user"), new ASN1OctetString((byte) 0x81, "TEST"), new ASN1Boolean((byte) 0x82, false), new ASN1OctetString((byte) 0x83, "It didn't work"), new ASN1Boolean((byte) 0x84, true), new ASN1Boolean((byte) 0x85, true), new ASN1OctetString((byte) 0x86, "127.0.0.1"), new ASN1Sequence((byte) 0xA7, new ASN1Sequence(new ASN1OctetString("name1"), new ASN1OctetString("value1")), new ASN1Sequence(new ASN1OctetString("name2"), new ASN1OctetString("value2"))));
final UnboundIDExternallyProcessedAuthenticationBindRequest r = UnboundIDExternallyProcessedAuthenticationBindRequest.decodeSASLCredentials(new ASN1OctetString(credSequence.encode()), new Control("1.2.3.4"), new Control("5.6.7.8"));
assertNotNull(r);
assertNotNull(r.getSASLMechanismName());
assertEquals(r.getSASLMechanismName(), "UNBOUNDID-EXTERNALLY-PROCESSED-AUTHENTICATION");
assertNotNull(r.getAuthenticationID());
assertEquals(r.getAuthenticationID(), "u:test.user");
assertNotNull(r.getExternalMechanismName());
assertEquals(r.getExternalMechanismName(), "TEST");
assertFalse(r.externalAuthenticationWasSuccessful());
assertNotNull(r.getExternalAuthenticationFailureReason());
assertEquals(r.getExternalAuthenticationFailureReason(), "It didn't work");
assertTrue(r.externalAuthenticationWasPasswordBased());
assertTrue(r.externalAuthenticationWasSecure());
assertNotNull(r.getEndClientIPAddress());
assertEquals(r.getEndClientIPAddress(), "127.0.0.1");
assertNotNull(r.getAdditionalAccessLogProperties());
assertEquals(r.getAdditionalAccessLogProperties().size(), 2);
assertEquals(r.getAdditionalAccessLogProperties().get("name1"), "value1");
assertEquals(r.getAdditionalAccessLogProperties().get("name2"), "value2");
assertNotNull(r.getControls());
assertEquals(r.getControls().length, 2);
assertNotNull(r.toString());
final ArrayList<String> toCodeLineList = new ArrayList<String>(10);
r.toCode(toCodeLineList, "testMinimalConstructorSuccess", 5, true);
assertFalse(toCodeLineList.isEmpty());
}
use of com.github.zhenwei.core.asn1.ASN1Boolean in project ldapsdk by pingidentity.
the class AssuredReplicationResponseControlTestCase method testDecodeValueSequenceUnexpectedElement.
/**
* Tests the behavior when trying to decode a control whose value sequence
* contains an unexpected element.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeValueSequenceUnexpectedElement() throws Exception {
final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1Boolean((byte) 0x81, true), new ASN1Boolean((byte) 0x84, true), new ASN1OctetString((byte) 0x8F, "foo"));
new AssuredReplicationResponseControl("1.3.6.1.4.1.30221.2.5.29", false, new ASN1OctetString(valueSequence.encode()));
}
Aggregations