Search in sources :

Example 61 with LdapUrl

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

the class LdapUrlTest method testLdapURLNoDNNoAttrsNoScopeNoFilterExtension.

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

Example 62 with LdapUrl

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

the class LdapUrlTest method testLdapURLNoDNAttrsNoScopeFilterExtension.

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

Example 63 with LdapUrl

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

the class LdapUrlTest method testLdapURLExtensionWithRFC3986UnreservedChars.

/**
 * Test with RFC 3986 unreserved characters in extension value.
 *
 *   unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
 */
@Test
public void testLdapURLExtensionWithRFC3986UnreservedChars() 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", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~"));
    assertEquals("ldap://localhost:123/????X-CONNECTION-NAME=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~", url1.toString());
    LdapUrl url2 = new LdapUrl("ldap://localhost:123/????X-CONNECTION-NAME=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~");
    assertEquals("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~", url1.getExtensionValue("X-CONNECTION-NAME"));
    assertEquals("ldap://localhost:123/????X-CONNECTION-NAME=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~", 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 64 with LdapUrl

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

the class LdapUrlTest method testDnSetScope.

/**
 * test the setScope() method
 */
@Test
public void testDnSetScope() throws LdapURLEncodingException, LdapInvalidDnException {
    LdapUrl url = new LdapUrl();
    assertEquals(SearchScope.OBJECT, url.getScope());
    url.setDn(new Dn("dc=example,dc=com"));
    url.setScope(SearchScope.ONELEVEL);
    assertEquals(SearchScope.ONELEVEL, url.getScope());
    assertEquals("ldap:///dc=example,dc=com??one", url.toString());
    url.setScope(SearchScope.SUBTREE);
    assertEquals(SearchScope.SUBTREE, url.getScope());
    assertEquals("ldap:///dc=example,dc=com??sub", url.toString());
    url.setScope(-1);
    assertEquals(SearchScope.OBJECT, url.getScope());
    assertEquals("ldap:///dc=example,dc=com", url.toString());
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) Dn(org.apache.directory.api.ldap.model.name.Dn) Test(org.junit.Test)

Example 65 with LdapUrl

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

the class LdapUrlTest method testLdapURLNoDNAttrs.

/**
 * test a LdapUrl with no Dn and attributes
 */
@Test
public void testLdapURLNoDNAttrs() throws LdapURLEncodingException {
    LdapUrl url = new LdapUrl("ldap://localhost:123/?ou,dc,cn");
    assertEquals("ldap://localhost:123/?ou,dc,cn", 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