Fixed sanitizing of filter query sort parameters. Corrected name of TargetManagement method

Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com>
This commit is contained in:
Dominik Herbst
2016-10-04 11:57:56 +02:00
parent f481e097db
commit 339f45ca6a
9 changed files with 29 additions and 19 deletions

View File

@@ -244,32 +244,34 @@ public interface TargetManagement {
/**
* Finds all targets for all the given parameter {@link TargetFilterQuery}
* and that don't have the specified assigned distribution set.
* and returns not the full target but {@link TargetIdName}.
* and that don't have the specified distribution set in their action
* history.
*
* @param pageRequest
* the pageRequest to enhance the query for paging and sorting
* @param distributionSetId
* id of the {@link DistributionSet}
* @param targetFilterQuery
* {@link TargetFilterQuery}
* @return the found {@link TargetIdName}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Target> findAllTargetIdsByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest,
Long distributionSetId,
@NotNull TargetFilterQuery targetFilterQuery);
Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest, Long distributionSetId,
@NotNull TargetFilterQuery targetFilterQuery);
/**
* Counts all targets for all the given parameter {@link TargetFilterQuery}
* and that don't have the specified assigned distribution set. and returns
* not the full target but {@link TargetIdName}.
* and that don't have the specified distribution set in their action
* history.
*
* @param distributionSetId
* id of the {@link DistributionSet}
* @param targetFilterQuery
* {@link TargetFilterQuery}
* @return the found {@link TargetIdName}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Long countTargetByTargetFilterQueryAndNonDS(Long distributionSetId,
@NotNull TargetFilterQuery targetFilterQuery);
Long countTargetsByTargetFilterQueryAndNonDS(Long distributionSetId, @NotNull TargetFilterQuery targetFilterQuery);
/**
* retrieves {@link Target}s by the assigned {@link DistributionSet} without

View File

@@ -563,8 +563,8 @@ public class JpaTargetManagement implements TargetManagement {
}
@Override
public Page<Target> findAllTargetIdsByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest,
Long distributionSetId, @NotNull TargetFilterQuery targetFilterQuery) {
public Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest,
Long distributionSetId, @NotNull TargetFilterQuery targetFilterQuery) {
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class);
@@ -577,7 +577,7 @@ public class JpaTargetManagement implements TargetManagement {
}
@Override
public Long countTargetByTargetFilterQueryAndNonDS(Long distributionSetId, @NotNull TargetFilterQuery targetFilterQuery) {
public Long countTargetsByTargetFilterQueryAndNonDS(Long distributionSetId, @NotNull TargetFilterQuery targetFilterQuery) {
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class);
final List<Specification<JpaTarget>> specList = new ArrayList<>();
specList.add(spec);

View File

@@ -156,7 +156,7 @@ public class AutoAssignChecker {
* @return list of targets with action type
*/
private List<TargetWithActionType> getTargetsWithActionType(TargetFilterQuery targetFilterQuery, Long dsId, int count) {
Page<Target> targets = targetManagement.findAllTargetIdsByTargetFilterQueryAndNonDS(new PageRequest(0, count),
Page<Target> targets = targetManagement.findAllTargetsByTargetFilterQueryAndNonDS(new PageRequest(0, count),
dsId, targetFilterQuery);
return targets.getContent().stream()

View File

@@ -25,7 +25,6 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
import org.eclipse.hawkbit.repository.model.*;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.junit.Test;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice;
import com.google.common.collect.Lists;
@@ -733,7 +732,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
deploymentManagement.assignDistributionSet(assignedSet, assignedTargets);
List<Target> result = targetManagement.findAllTargetIdsByTargetFilterQueryAndNonDS(pageReq,
List<Target> result = targetManagement.findAllTargetsByTargetFilterQueryAndNonDS(pageReq,
assignedSet.getId(), tfq).getContent();
assertThat(result)
.as("count of targets").hasSize(unassignedTargets.size())

View File

@@ -73,7 +73,7 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
verifyThatTargetsHaveDistributionSetAssignment(setB, targets.subList(10, 20), targetsCount);
// Count the number of targets that will be assigned with setA
assertThat(targetManagement.countTargetByTargetFilterQueryAndNonDS(setA.getId(), targetFilterQuery))
assertThat(targetManagement.countTargetsByTargetFilterQueryAndNonDS(setA.getId(), targetFilterQuery))
.isEqualTo(90);
// Run the check