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());
}
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());
}
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());
}
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();
}
}
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());
}
Aggregations