use of org.apache.cloudstack.api.response.LdapUserResponse in project cloudstack by apache.
the class LdapImportUsersCmdTest method successfulResponseFromExecute.
@Test
public void successfulResponseFromExecute() throws Exception {
List<LdapUser> users = new ArrayList();
users.add(new LdapUser("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,ou=engineering,dc=cloudstack,dc=org", "engineering", false, null));
users.add(new LdapUser("bob", "bob@test.com", "Robert", "Young", "cn=bob,ou=engineering,dc=cloudstack,dc=org", "engineering", false, null));
when(ldapManager.getUsers(null)).thenReturn(users);
LdapUserResponse response1 = new LdapUserResponse("rmurphy", "rmurphy@test.com", "Ryan", "Murphy", "cn=rmurphy,ou=engineering,dc=cloudstack,dc=org", "engineering");
LdapUserResponse response2 = new LdapUserResponse("bob", "bob@test.com", "Robert", "Young", "cn=bob,ou=engineering,dc=cloudstack,dc=org", "engineering");
when(ldapManager.createLdapUserResponse(any(LdapUser.class))).thenReturn(response1).thenReturn(response2);
Domain domain = new DomainVO("engineering", 1L, 1L, "engineering", UUID.randomUUID().toString());
when(domainService.getDomainByName("engineering", 1L)).thenReturn(null, domain);
when(domainService.createDomain(eq("engineering"), eq(1L), eq("engineering"), anyString())).thenReturn(domain);
ldapImportUsersCmd.execute();
ListResponse<LdapUserResponse> resp = (ListResponse<LdapUserResponse>) ldapImportUsersCmd.getResponseObject();
assertEquals(" when LdapListUsersCmd is executed, a list of size 2 should be returned", 2, resp.getResponses().size());
}
use of org.apache.cloudstack.api.response.LdapUserResponse in project cloudstack by apache.
the class LdapUserSearchCmd method createLdapUserResponse.
private List<LdapUserResponse> createLdapUserResponse(final List<LdapUser> users) {
final List<LdapUserResponse> ldapUserResponses = new ArrayList<LdapUserResponse>();
if (users != null) {
for (final LdapUser user : users) {
final LdapUserResponse ldapUserResponse = _ldapManager.createLdapUserResponse(user);
ldapUserResponse.setObjectName("LdapUser");
ldapUserResponses.add(ldapUserResponse);
}
}
return ldapUserResponses;
}
use of org.apache.cloudstack.api.response.LdapUserResponse in project cloudstack by apache.
the class LdapImportUsersCmd method createLdapUserResponse.
private List<LdapUserResponse> createLdapUserResponse(List<LdapUser> users) {
final List<LdapUserResponse> ldapResponses = new ArrayList<LdapUserResponse>();
for (final LdapUser user : users) {
final LdapUserResponse ldapResponse = _ldapManager.createLdapUserResponse(user);
ldapResponse.setObjectName("LdapUser");
ldapResponses.add(ldapResponse);
}
return ldapResponses;
}
use of org.apache.cloudstack.api.response.LdapUserResponse in project cloudstack by apache.
the class LdapListUsersCmd method filterAnyDomain.
/**
* filter the list of ldap users. no users visible to the caller should be in the returned list
* @param input ldap response list of users
* @return a list of ldap users not already in ACS
*/
public List<LdapUserResponse> filterAnyDomain(List<LdapUserResponse> input) {
if (s_logger.isTraceEnabled()) {
s_logger.trace("filtering existing users");
}
final List<LdapUserResponse> ldapResponses = new ArrayList<LdapUserResponse>();
for (final LdapUserResponse user : input) {
if (isNotAlreadyImportedInTheCurrentDomain(user)) {
ldapResponses.add(user);
}
}
annotateUserListWithSources(ldapResponses);
return ldapResponses;
}
use of org.apache.cloudstack.api.response.LdapUserResponse in project cloudstack by apache.
the class LdapListUsersCmd method createLdapUserResponse.
/**
* (as a check for isACloudstackUser is done) only non cloudstack users should be shown
* @param users a list of {@code LdapUser}s
* @return a (filtered?) list of user response objects
*/
private List<LdapUserResponse> createLdapUserResponse(final List<LdapUser> users) {
final List<LdapUserResponse> ldapResponses = new ArrayList<LdapUserResponse>();
for (final LdapUser user : users) {
final LdapUserResponse ldapResponse = _ldapManager.createLdapUserResponse(user);
ldapResponse.setObjectName("LdapUser");
ldapResponses.add(ldapResponse);
}
return ldapResponses;
}
Aggregations