@Test
public void testFailure()
throws Exception
{
PlexusResource pr = this.lookup(PlexusResource.class, "LdapUserAndGroupConfigTestPlexusResource");
LdapServerRequest ldapServerRequest = new LdapServerRequest();
ldapServerRequest.setData(new LdapServerConfigurationDTO());
ldapServerRequest.getData().setName("testFailure");
LdapConnectionInfoDTO connDto = new LdapConnectionInfoDTO();
ldapServerRequest.getData().setConnectionInfo(connDto);
connDto.setAuthScheme("simple");
connDto.setHost("invalidHost");
connDto.setPort(this.getLdapServer("default").getPort());
connDto.setProtocol("ldap");
connDto.setSystemPassword(encodeBase64("secret"));
connDto.setSystemUsername(encodeBase64("uid=admin,ou=system"));
connDto.setSearchBase("o=sonatype");
LdapUserAndGroupAuthConfigurationDTO userGroupDto = new LdapUserAndGroupAuthConfigurationDTO();
ldapServerRequest.getData().setUserAndGroupConfig(userGroupDto);
userGroupDto.setGroupMemberFormat("cn=${username},ou=groups,o=sonatype");
userGroupDto.setGroupObjectClass("organizationalRole");
userGroupDto.setGroupBaseDn("ou=groups");
userGroupDto.setGroupIdAttribute("cn");
userGroupDto.setGroupMemberAttribute("uniqueMember");
userGroupDto.setUserObjectClass("inetOrgPerson");
userGroupDto.setUserBaseDn("ou=people");
userGroupDto.setUserIdAttribute("uid");
userGroupDto.setUserPasswordAttribute("userPassword");
userGroupDto.setUserRealNameAttribute("sn");
userGroupDto.setUserMemberOfAttribute("businesscategory");
userGroupDto.setEmailAddressAttribute("mail");
userGroupDto.setLdapGroupsAsRoles(true);
Request request = new Request();
Response response = new Response(request);
try {
pr.put(null, request, response, ldapServerRequest);
Assert.fail("expected ResourceException");
}
catch (ResourceException e) {
// expected
}