Search in sources :

Example 71 with ASN1OctetString

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

the class NumericStringMatchingRuleTestCase method testMatchingValues.

/**
 * Tests the numeric string matching rule with a number of value pairs
 * that should be considered matches.
 *
 * @param  value1  The first value to compare.
 * @param  value2  The second value to compare.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(dataProvider = "testMatchingValues")
public void testMatchingValues(String value1, String value2) throws Exception {
    ASN1OctetString value1OS = new ASN1OctetString(value1);
    ASN1OctetString value2OS = new ASN1OctetString(value2);
    NumericStringMatchingRule matchingRule = NumericStringMatchingRule.getInstance();
    assertTrue(matchingRule.valuesMatch(value1OS, value2OS), value1 + ", " + value2);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 72 with ASN1OctetString

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

the class OctetStringMatchingRuleTestCase method testNormalizeSubstring.

/**
 * Tests the {@code normalizeSubstring} method with the provided information.
 *
 * @param  rawValue         The raw value to be normalized.
 * @param  substringType    The substring type to use when performing the
 *                          normalization.
 * @param  normalizedValue  The expected normalized representation of the
 *                          provided value.
 */
@Test(dataProvider = "testNormalizeSubstringValues")
public void testNormalizeSubstring(String rawValue, byte substringType, String normalizedValue) {
    ASN1OctetString rawOS = new ASN1OctetString(rawValue);
    OctetStringMatchingRule matchingRule = OctetStringMatchingRule.getInstance();
    ASN1OctetString gotOS = matchingRule.normalizeSubstring(rawOS, substringType);
    assertEquals(gotOS.stringValue(), normalizedValue);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 73 with ASN1OctetString

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

the class OctetStringMatchingRuleTestCase method testMatchingValues.

/**
 * Tests the octet string matching rule with a number of value pairs
 * that should be considered matches.
 *
 * @param  value1  The first value to compare.
 * @param  value2  The second value to compare.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(dataProvider = "testMatchingValues")
public void testMatchingValues(String value1, String value2) throws Exception {
    ASN1OctetString value1OS = new ASN1OctetString(value1);
    ASN1OctetString value2OS = new ASN1OctetString(value2);
    OctetStringMatchingRule matchingRule = OctetStringMatchingRule.getInstance();
    assertTrue(matchingRule.valuesMatch(value1OS, value2OS), value1 + ", " + value2);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 74 with ASN1OctetString

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

the class SimpleMatchingRuleTestCase method testCompareValuesNonMatching.

/**
 * Tests the {@code compareValues} method with values that should not be
 * considered matches.
 *
 * @param  value1  The first value to compare.
 * @param  value2  The second value to compare.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(dataProvider = "testNonMatchingValues")
public void testCompareValuesNonMatching(String value1, String value2) throws Exception {
    ASN1OctetString value1OS = new ASN1OctetString(value1);
    ASN1OctetString value2OS = new ASN1OctetString(value2);
    CaseIgnoreStringMatchingRule matchingRule = CaseIgnoreStringMatchingRule.getInstance();
    assertFalse(matchingRule.compareValues(value1OS, value2OS) == 0);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 75 with ASN1OctetString

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

the class SimpleMatchingRuleTestCase method testMatchingValues.

/**
 * Tests the {@code valuesMatch} method with a number of value pairs
 * that should be considered matches.
 *
 * @param  value1  The first value to compare.
 * @param  value2  The second value to compare.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test(dataProvider = "testMatchingValues")
public void testMatchingValues(String value1, String value2) throws Exception {
    ASN1OctetString value1OS = new ASN1OctetString(value1);
    ASN1OctetString value2OS = new ASN1OctetString(value2);
    CaseIgnoreStringMatchingRule matchingRule = CaseIgnoreStringMatchingRule.getInstance();
    assertTrue(matchingRule.valuesMatch(value1OS, value2OS));
    value2OS = new ASN1OctetString(value2 + 'x');
    assertFalse(matchingRule.valuesMatch(value1OS, value2OS));
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) 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