Search in sources :

Example 76 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class LdapUrlTest method testLdapURLExtensionWithRFC3986ReservedCharsAndRFC4616Exception.

/**
 * Test with RFC 3986 reserved characters in extension value.
 *
 *   reserved    = gen-delims / sub-delims
 *   gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"
 *   sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
 *                 / "*" / "+" / "," / ";" / "="
 *
 * RFC 4516 specifies that '?' and a ',' must be percent encoded.
 */
@Test
public void testLdapURLExtensionWithRFC3986ReservedCharsAndRFC4616Exception() throws Exception {
    LdapUrl url1 = new LdapUrl();
    url1.setHost("localhost");
    url1.setPort(123);
    url1.setDn(Dn.EMPTY_DN);
    url1.getExtensions().add(new Extension(false, "X-CONNECTION-NAME", ":/?#[]@!$&'()*+,;="));
    assertEquals("ldap://localhost:123/????X-CONNECTION-NAME=:/%3F#[]@!$&'()*+%2c;=", url1.toString());
    LdapUrl url2 = new LdapUrl("ldap://localhost:123/????X-CONNECTION-NAME=:/%3f#[]@!$&'()*+%2c;=");
    assertEquals(":/?#[]@!$&'()*+,;=", url1.getExtensionValue("X-CONNECTION-NAME"));
    assertEquals("ldap://localhost:123/????X-CONNECTION-NAME=:/%3F#[]@!$&'()*+%2c;=", url2.toString());
}
Also used : Extension(org.apache.directory.api.ldap.model.url.LdapUrl.Extension) LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) Test(org.junit.Test)

Example 77 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class LdapUrlTest method testLdapURLNoDNNoAttrsScope.

/**
 * test a LdapUrl with no Dn, no attributes an scope
 */
@Test
public void testLdapURLNoDNNoAttrsScope() throws LdapURLEncodingException {
    LdapUrl url = new LdapUrl("ldap://localhost:123/??sub");
    assertEquals("ldap://localhost:123/??sub", url.toString());
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) Test(org.junit.Test)

Example 78 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class LdapUrlTest method testLdapURLDNAttrsScopeBaseFilterExtension.

/**
 * test a LdapUrl with a Dn, some attributes, a base scope, a filter and some extensions
 */
@Test
public void testLdapURLDNAttrsScopeBaseFilterExtension() throws LdapURLEncodingException {
    LdapUrl url = new LdapUrl("ldap://localhost:123/ou=system?cn,ou,dc?base?(cn=test)?!a=b,!c");
    assertEquals("ldap://localhost:123/ou=system?cn,ou,dc??(cn=test)?!a=b,!c", url.toString());
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) Test(org.junit.Test)

Example 79 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class LdapUrlTest method testLdapURLNoHostDN.

/**
 * test a LdapUrl without a host but with a Dn
 */
@Test
public void testLdapURLNoHostDN() throws LdapURLEncodingException {
    try {
        LdapUrl url = new LdapUrl("ldap:///ou=system");
        assertEquals("ldap:///ou=system", url.toString());
    } catch (LdapURLEncodingException luee) {
        fail();
    }
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Test(org.junit.Test)

Example 80 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class LdapUrlTest method testLdapURLNoDNNoAttrsNoScopeFilter.

/**
 * test a LdapUrl with no Dn, no attributes, no scope and filter
 */
@Test
public void testLdapURLNoDNNoAttrsNoScopeFilter() throws LdapURLEncodingException {
    LdapUrl url = new LdapUrl("ldap://localhost:123/???(cn=test)");
    assertEquals("ldap://localhost:123/???(cn=test)", url.toString());
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) Test(org.junit.Test)

Aggregations

LdapUrl (org.apache.directory.api.ldap.model.url.LdapUrl)98 Test (org.junit.Test)95 LdapURLEncodingException (org.apache.directory.api.ldap.model.exception.LdapURLEncodingException)27 AbstractResponseTest (org.apache.directory.api.dsmlv2.AbstractResponseTest)24 Dsmlv2ResponseParser (org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser)24 LdapResult (org.apache.directory.api.ldap.model.message.LdapResult)23 DecoderException (org.apache.directory.api.asn1.DecoderException)5 SearchResponse (org.apache.directory.api.dsmlv2.response.SearchResponse)5 Dn (org.apache.directory.api.ldap.model.name.Dn)5 Extension (org.apache.directory.api.ldap.model.url.LdapUrl.Extension)5 BindResponse (org.apache.directory.api.ldap.model.message.BindResponse)3 CompareResponse (org.apache.directory.api.ldap.model.message.CompareResponse)3 DeleteResponse (org.apache.directory.api.ldap.model.message.DeleteResponse)3 ExtendedResponse (org.apache.directory.api.ldap.model.message.ExtendedResponse)3 ModifyDnResponse (org.apache.directory.api.ldap.model.message.ModifyDnResponse)3 ModifyResponse (org.apache.directory.api.ldap.model.message.ModifyResponse)3 SearchResultDone (org.apache.directory.api.ldap.model.message.SearchResultDone)3 SearchResultReference (org.apache.directory.api.ldap.model.message.SearchResultReference)3 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)2 Referral (org.apache.directory.api.ldap.model.message.Referral)2