use of org.apache.nifi.registry.flow.VersionControlInformation in project nifi by apache.
the class ControllerSearchServiceTest method testSearchInThirdLevelParentNotAuthorizedWithVersionControlInTheGroup.
@Test
public void testSearchInThirdLevelParentNotAuthorizedWithVersionControlInTheGroup() {
// root level PG
final ProcessGroup rootProcessGroup = setupMockedProcessGroup("root", null, true, variableRegistry, null);
// first level PGs
final ProcessGroup firstLevelAProcessGroup = setupMockedProcessGroup("firstLevelA", rootProcessGroup, true, variableRegistry, null);
final ProcessGroup firstLevelBProcessGroup = setupMockedProcessGroup("firstLevelB", rootProcessGroup, true, variableRegistry, null);
// second level PGs
final ProcessGroup secondLevelAProcessGroup = setupMockedProcessGroup("secondLevelA", firstLevelAProcessGroup, true, variableRegistry, null);
final ProcessGroup secondLevelBProcessGroup = setupMockedProcessGroup("secondLevelB", firstLevelBProcessGroup, true, variableRegistry, null);
// third level PGs - not authorized
final VersionControlInformation versionControlInformation = setupVC();
final ProcessGroup thirdLevelAProcessGroup = setupMockedProcessGroup("thirdLevelA", secondLevelAProcessGroup, false, variableRegistry, versionControlInformation);
final ProcessGroup thirdLevelBProcessGroup = setupMockedProcessGroup("thirdLevelB", secondLevelAProcessGroup, false, variableRegistry, null);
// link PGs together
Mockito.doReturn(new HashSet<ProcessGroup>() {
{
add(firstLevelAProcessGroup);
add(firstLevelBProcessGroup);
}
}).when(rootProcessGroup).getProcessGroups();
Mockito.doReturn(new HashSet<ProcessGroup>() {
{
add(secondLevelAProcessGroup);
}
}).when(firstLevelAProcessGroup).getProcessGroups();
Mockito.doReturn(new HashSet<ProcessGroup>() {
{
add(secondLevelBProcessGroup);
}
}).when(firstLevelBProcessGroup).getProcessGroups();
Mockito.doReturn(new HashSet<ProcessGroup>() {
{
add(thirdLevelAProcessGroup);
add(thirdLevelBProcessGroup);
}
}).when(secondLevelAProcessGroup).getProcessGroups();
// setup processor
setupMockedProcessor("foobar", thirdLevelAProcessGroup, true, variableRegistry);
// perform search
service.search(searchResultsDTO, "foo", rootProcessGroup);
assertTrue(searchResultsDTO.getProcessorResults().size() == 1);
assertTrue(searchResultsDTO.getProcessorResults().get(0).getId().equals("foobarId"));
assertTrue(searchResultsDTO.getProcessorResults().get(0).getParentGroup().getId().equals("thirdLevelAId"));
assertTrue(searchResultsDTO.getProcessorResults().get(0).getParentGroup().getName() == null);
assertTrue(searchResultsDTO.getProcessorResults().get(0).getVersionedGroup() != null);
assertTrue(searchResultsDTO.getProcessorResults().get(0).getVersionedGroup().getId().equals("thirdLevelAId"));
assertTrue(searchResultsDTO.getProcessorResults().get(0).getVersionedGroup().getName() == null);
}
use of org.apache.nifi.registry.flow.VersionControlInformation in project nifi by apache.
the class StandardProcessGroupDAO method verifyDeleteFlowRegistry.
@Override
public void verifyDeleteFlowRegistry(String registryId) {
final ProcessGroup rootGroup = flowController.getRootGroup();
final VersionControlInformation versionControlInformation = rootGroup.getVersionControlInformation();
if (versionControlInformation != null && versionControlInformation.getRegistryIdentifier().equals(registryId)) {
throw new IllegalStateException("The Registry cannot be removed because a Process Group currently under version control is tracking to it.");
}
final Set<VersionControlInformation> trackedVersionControlInformation = rootGroup.findAllProcessGroups().stream().map(group -> group.getVersionControlInformation()).filter(Objects::nonNull).filter(vci -> vci.getRegistryIdentifier().equals(registryId)).collect(Collectors.toSet());
if (!trackedVersionControlInformation.isEmpty()) {
throw new IllegalStateException("The Registry cannot be removed because a Process Group currently under version control is tracking to it.");
}
}
Aggregations