Search in sources :

Example 51 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class DistinguishedNameMatchingRuleTestCase method testNormalizeInvalid.

/**
 * Tests to ensure that the {@code normalize} method throws an exception when
 * given values that aren't valid DNs.
 *
 * @param  invalidDN  A string that cannot be parsed as a valid DN.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(dataProvider = "testInvalidDNs", expectedExceptions = { LDAPException.class })
public void testNormalizeInvalid(String invalidDN) throws Exception {
    DistinguishedNameMatchingRule mr = DistinguishedNameMatchingRule.getInstance();
    mr.normalize(new ASN1OctetString(invalidDN));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 52 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class DistinguishedNameMatchingRuleTestCase method testNormalizeSubstring.

/**
 * Tests to ensure that the {@code normalizeSubstring} method always throws an
 * exception.
 *
 * @param  dn1  The first DN.
 * @param  dn2  The second DN.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(dataProvider = "testValidDNs", expectedExceptions = { LDAPException.class })
public void testNormalizeSubstring(String dn1, String dn2) throws Exception {
    DistinguishedNameMatchingRule mr = DistinguishedNameMatchingRule.getInstance();
    mr.normalizeSubstring(new ASN1OctetString(dn1), (byte) 0x80);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 53 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class DistinguishedNameMatchingRuleTestCase method testValuesMatchInvalid.

/**
 * Tests the {@code valuesMatch} method with an invalid DN.
 *
 * @param  invalidDN  The invalid DN to compare.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(dataProvider = "testInvalidDNs")
public void testValuesMatchInvalid(String invalidDN) throws Exception {
    DistinguishedNameMatchingRule mr = DistinguishedNameMatchingRule.getInstance();
    try {
        mr.valuesMatch(new ASN1OctetString(invalidDN), new ASN1OctetString("dc=example,dc=com"));
        fail("Expected an exception with an invalid first DN.");
    } catch (LDAPException le) {
    // This was expected.
    }
    try {
        mr.valuesMatch(new ASN1OctetString("dc=example,dc=com"), new ASN1OctetString(invalidDN));
        fail("Expected an exception with an invalid second DN.");
    } catch (LDAPException le) {
    // This was expected.
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) LDAPException(com.unboundid.ldap.sdk.LDAPException) Test(org.testng.annotations.Test)

Example 54 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class GeneralizedTimeMatchingRuleTestCase method testNormalizeInvalid.

/**
 * Tests to ensure that the {@code normalize} method throws an exception when
 * given values that aren't valid timestamps.
 *
 * @param  invalidValue  A string that cannot be parsed as a valid timestamp.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(dataProvider = "testInvalidValues", expectedExceptions = { LDAPException.class })
public void testNormalizeInvalid(String invalidValue) throws Exception {
    GeneralizedTimeMatchingRule mr = GeneralizedTimeMatchingRule.getInstance();
    mr.normalize(new ASN1OctetString(invalidValue));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 55 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class GeneralizedTimeMatchingRuleTestCase method testValuesMatchInvalid.

/**
 * Tests the {@code valuesMatch} method with an invalid value.
 *
 * @param  invalidValue  The invalid value to compare.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(dataProvider = "testInvalidValues")
public void testValuesMatchInvalid(String invalidValue) throws Exception {
    GeneralizedTimeMatchingRule mr = GeneralizedTimeMatchingRule.getInstance();
    try {
        mr.valuesMatch(new ASN1OctetString(invalidValue), new ASN1OctetString("20080101000000Z"));
        fail("Expected an exception with an invalid first value.");
    } catch (LDAPException le) {
    // This was expected.
    }
    try {
        mr.valuesMatch(new ASN1OctetString("20080101000000Z"), new ASN1OctetString(invalidValue));
        fail("Expected an exception with an invalid second value.");
    } catch (LDAPException le) {
    // This was expected.
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) LDAPException(com.unboundid.ldap.sdk.LDAPException) Test(org.testng.annotations.Test)

Aggregations

ASN1OctetString (com.unboundid.asn1.ASN1OctetString)1173 Test (org.testng.annotations.Test)852 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)382 Control (com.unboundid.ldap.sdk.Control)310 ASN1Element (com.unboundid.asn1.ASN1Element)237 ArrayList (java.util.ArrayList)204 NotNull (com.unboundid.util.NotNull)191 LDAPException (com.unboundid.ldap.sdk.LDAPException)142 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)133 ExtendedResult (com.unboundid.ldap.sdk.ExtendedResult)99 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)92 IOException (java.io.IOException)88 ASN1Integer (com.unboundid.asn1.ASN1Integer)80 ExtendedRequest (com.unboundid.ldap.sdk.ExtendedRequest)69 DN (com.unboundid.ldap.sdk.DN)65 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)64 ByteArrayInputStream (java.io.ByteArrayInputStream)56 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)53 ASN1Boolean (com.unboundid.asn1.ASN1Boolean)52 AuthorizationIdentityResponseControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityResponseControl)49