use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class DbGroupDaoTest method testGetByNameWithInvalidName.
/**
* Ensures that, if the supplied name is invalid, then no group is returned.
*/
@Test
public void testGetByNameWithInvalidName() {
DbGroup result = dao.getByName("thisnameisinvalid");
assertNull(result);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class DbGroupDaoTest method testGetWithInvalidExternalId.
/**
* Ensures that trying to get a group with an invalid external id fails.
*/
@Test
public void testGetWithInvalidExternalId() {
DbGroup result = dao.getByExternalId("rhel", "0");
assertNull(result);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class BackendGroupsResourceTest method testAddGroupById.
/**
* Test that if the group identifier is provided it is used to search in the directory instead of the name.
*/
@Test
public void testAddGroupById() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpEntityQueryExpectations(QueryType.GetDomainList, QueryParametersBase.class, new String[] {}, new Object[] {}, setUpDomains());
setUpGetEntityExpectations(QueryType.GetDirectoryGroupById, DirectoryIdQueryParameters.class, new String[] { "Domain", "Id" }, new Object[] { DOMAIN, DirectoryEntryIdUtils.decode(EXTERNAL_IDS[0]) }, getDirectoryGroup(0));
setUpCreationExpectations(ActionType.AddGroup, AddGroupParameters.class, new String[] { "GroupToAdd" }, new Object[] { new DbGroup(getDirectoryGroup(0)) }, true, true, GUIDS[0], QueryType.GetDbGroupById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Group model = new Group();
model.setName(GROUP_NAMES[0]);
model.setId(EXTERNAL_IDS[0]);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Group);
verifyModel((Group) response.getEntity(), 0);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class BackendGroupsResourceTest method verifyModel.
@Override
protected void verifyModel(Group model, int index) {
DbGroup entity = getEntity(index);
assertEquals(entity.getId().toString(), model.getId());
assertEquals(entity.getName(), model.getName());
assertNotNull(model.getDomain());
assertEquals(DirectoryEntryIdUtils.encode(entity.getDomain()), model.getDomain().getId());
verifyLinks(model);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class PermissionListModel method onAdd.
private void onAdd() {
AdElementListModel model = (AdElementListModel) getWindow();
if (model.getProgress() != null) {
return;
}
if (model.getSearchType() != AdSearchType.EVERYONE && model.getSelectedItems() == null) {
cancel();
return;
}
ArrayList<DbUser> items = new ArrayList<>();
if (model.getSearchType() == AdSearchType.EVERYONE) {
DbUser tempVar = new DbUser();
tempVar.setId(ApplicationGuids.everyone.asGuid());
items.add(tempVar);
} else {
for (Object item : model.getItems()) {
EntityModel entityModel = (EntityModel) item;
if (entityModel.getIsSelected()) {
items.add((DbUser) entityModel.getEntity());
}
}
}
Role role = model.getRole().getSelectedItem();
// adGroup/user
ArrayList<ActionParametersBase> list = new ArrayList<>();
for (DbUser user : items) {
Permission perm = new Permission(user.getId(), role.getId(), getEntityGuid(), getObjectType());
if (user.isGroup()) {
DbGroup group = new DbGroup();
group.setId(user.getId());
group.setExternalId(user.getExternalId());
group.setName(user.getFirstName());
group.setDomain(user.getDomain());
group.setNamespace(user.getNamespace());
PermissionsOperationsParameters tempVar3 = new PermissionsOperationsParameters();
tempVar3.setPermission(perm);
tempVar3.setGroup(group);
list.add(tempVar3);
} else {
PermissionsOperationsParameters tempVar4 = new PermissionsOperationsParameters();
tempVar4.setPermission(perm);
tempVar4.setUser(user);
list.add(tempVar4);
}
}
model.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.AddPermission, list, result -> {
AdElementListModel localModel = (AdElementListModel) result.getState();
localModel.stopProgress();
cancel();
}, model);
}
Aggregations