Search in sources :

Example 1 with FileBasedVariableRegistry

use of org.apache.nifi.registry.variable.FileBasedVariableRegistry in project nifi by apache.

the class StandardControllerServiceProviderTest method setupSuite.

@BeforeClass
public static void setupSuite() throws Exception {
    System.setProperty(NiFiProperties.PROPERTIES_FILE_PATH, StandardControllerServiceProviderTest.class.getResource("/conf/nifi.properties").getFile());
    nifiProperties = NiFiProperties.createBasicNiFiProperties(null, null);
    NarClassLoaders.getInstance().init(nifiProperties.getFrameworkWorkingDirectory(), nifiProperties.getExtensionsWorkingDirectory());
    // load the system bundle
    systemBundle = SystemBundle.create(nifiProperties);
    ExtensionManager.discoverExtensions(systemBundle, NarClassLoaders.getInstance().getBundles());
    variableRegistry = new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths());
}
Also used : FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) BeforeClass(org.junit.BeforeClass)

Example 2 with FileBasedVariableRegistry

use of org.apache.nifi.registry.variable.FileBasedVariableRegistry in project nifi by apache.

the class StandardFlowServiceTest method setup.

@Before
public void setup() throws Exception {
    properties = NiFiProperties.createBasicNiFiProperties(null, null);
    variableRegistry = new FileBasedVariableRegistry(properties.getVariableRegistryPropertiesPaths());
    mockFlowFileEventRepository = mock(FlowFileEventRepository.class);
    authorizer = mock(Authorizer.class);
    mockAuditService = mock(AuditService.class);
    revisionManager = mock(RevisionManager.class);
    flowController = FlowController.createStandaloneInstance(mockFlowFileEventRepository, properties, authorizer, mockAuditService, mockEncryptor, new VolatileBulletinRepository(), variableRegistry, mock(FlowRegistryClient.class));
    flowService = StandardFlowService.createStandaloneInstance(flowController, properties, mockEncryptor, revisionManager, authorizer);
}
Also used : VolatileBulletinRepository(org.apache.nifi.events.VolatileBulletinRepository) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) Authorizer(org.apache.nifi.authorization.Authorizer) RevisionManager(org.apache.nifi.web.revision.RevisionManager) AuditService(org.apache.nifi.admin.service.AuditService) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) Before(org.junit.Before)

Example 3 with FileBasedVariableRegistry

use of org.apache.nifi.registry.variable.FileBasedVariableRegistry in project nifi by apache.

the class TestFlowController method setup.

@Before
public void setup() {
    flowFileEventRepo = Mockito.mock(FlowFileEventRepository.class);
    auditService = Mockito.mock(AuditService.class);
    final Map<String, String> otherProps = new HashMap<>();
    otherProps.put(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
    otherProps.put("nifi.remote.input.socket.port", "");
    otherProps.put("nifi.remote.input.secure", "");
    nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps);
    encryptor = StringEncryptor.createEncryptor(nifiProperties);
    // use the system bundle
    systemBundle = SystemBundle.create(nifiProperties);
    ExtensionManager.discoverExtensions(systemBundle, Collections.emptySet());
    User user1 = new User.Builder().identifier("user-id-1").identity("user-1").build();
    User user2 = new User.Builder().identifier("user-id-2").identity("user-2").build();
    Group group1 = new Group.Builder().identifier("group-id-1").name("group-1").addUser(user1.getIdentifier()).build();
    Group group2 = new Group.Builder().identifier("group-id-2").name("group-2").build();
    AccessPolicy policy1 = new AccessPolicy.Builder().identifier("policy-id-1").resource("resource1").action(RequestAction.READ).addUser(user1.getIdentifier()).addUser(user2.getIdentifier()).build();
    AccessPolicy policy2 = new AccessPolicy.Builder().identifier("policy-id-2").resource("resource2").action(RequestAction.READ).addGroup(group1.getIdentifier()).addGroup(group2.getIdentifier()).addUser(user1.getIdentifier()).addUser(user2.getIdentifier()).build();
    Set<Group> groups1 = new LinkedHashSet<>();
    groups1.add(group1);
    groups1.add(group2);
    Set<User> users1 = new LinkedHashSet<>();
    users1.add(user1);
    users1.add(user2);
    Set<AccessPolicy> policies1 = new LinkedHashSet<>();
    policies1.add(policy1);
    policies1.add(policy2);
    authorizer = new MockPolicyBasedAuthorizer(groups1, users1, policies1);
    variableRegistry = new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths());
    bulletinRepo = Mockito.mock(BulletinRepository.class);
    controller = FlowController.createStandaloneInstance(flowFileEventRepo, nifiProperties, authorizer, auditService, encryptor, bulletinRepo, variableRegistry, Mockito.mock(FlowRegistryClient.class));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ProcessGroup(org.apache.nifi.groups.ProcessGroup) Group(org.apache.nifi.authorization.Group) BulletinRepository(org.apache.nifi.reporting.BulletinRepository) User(org.apache.nifi.authorization.User) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) AccessPolicy(org.apache.nifi.authorization.AccessPolicy) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) MockProvenanceRepository(org.apache.nifi.provenance.MockProvenanceRepository) MockPolicyBasedAuthorizer(org.apache.nifi.authorization.MockPolicyBasedAuthorizer) AuditService(org.apache.nifi.admin.service.AuditService) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) Before(org.junit.Before)

Example 4 with FileBasedVariableRegistry

use of org.apache.nifi.registry.variable.FileBasedVariableRegistry in project nifi by apache.

the class TestStandardReportingContext method setup.

@Before
public void setup() {
    flowFileEventRepo = Mockito.mock(FlowFileEventRepository.class);
    auditService = Mockito.mock(AuditService.class);
    final Map<String, String> otherProps = new HashMap<>();
    otherProps.put(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
    otherProps.put("nifi.remote.input.socket.port", "");
    otherProps.put("nifi.remote.input.secure", "");
    nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, otherProps);
    encryptor = StringEncryptor.createEncryptor(nifiProperties);
    // use the system bundle
    systemBundle = SystemBundle.create(nifiProperties);
    ExtensionManager.discoverExtensions(systemBundle, Collections.emptySet());
    User user1 = new User.Builder().identifier("user-id-1").identity("user-1").build();
    User user2 = new User.Builder().identifier("user-id-2").identity("user-2").build();
    Group group1 = new Group.Builder().identifier("group-id-1").name("group-1").addUser(user1.getIdentifier()).build();
    Group group2 = new Group.Builder().identifier("group-id-2").name("group-2").build();
    AccessPolicy policy1 = new AccessPolicy.Builder().identifier("policy-id-1").resource("resource1").action(RequestAction.READ).addUser(user1.getIdentifier()).addUser(user2.getIdentifier()).build();
    AccessPolicy policy2 = new AccessPolicy.Builder().identifier("policy-id-2").resource("resource2").action(RequestAction.READ).addGroup(group1.getIdentifier()).addGroup(group2.getIdentifier()).addUser(user1.getIdentifier()).addUser(user2.getIdentifier()).build();
    Set<Group> groups1 = new LinkedHashSet<>();
    groups1.add(group1);
    groups1.add(group2);
    Set<User> users1 = new LinkedHashSet<>();
    users1.add(user1);
    users1.add(user2);
    Set<AccessPolicy> policies1 = new LinkedHashSet<>();
    policies1.add(policy1);
    policies1.add(policy2);
    authorizer = new MockPolicyBasedAuthorizer(groups1, users1, policies1);
    variableRegistry = new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths());
    flowRegistry = Mockito.mock(FlowRegistryClient.class);
    bulletinRepo = Mockito.mock(BulletinRepository.class);
    controller = FlowController.createStandaloneInstance(flowFileEventRepo, nifiProperties, authorizer, auditService, encryptor, bulletinRepo, variableRegistry, flowRegistry);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Group(org.apache.nifi.authorization.Group) BulletinRepository(org.apache.nifi.reporting.BulletinRepository) User(org.apache.nifi.authorization.User) HashMap(java.util.HashMap) FlowRegistryClient(org.apache.nifi.registry.flow.FlowRegistryClient) AccessPolicy(org.apache.nifi.authorization.AccessPolicy) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) MockProvenanceRepository(org.apache.nifi.provenance.MockProvenanceRepository) MockPolicyBasedAuthorizer(org.apache.nifi.authorization.MockPolicyBasedAuthorizer) AuditService(org.apache.nifi.admin.service.AuditService) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry) Before(org.junit.Before)

Example 5 with FileBasedVariableRegistry

use of org.apache.nifi.registry.variable.FileBasedVariableRegistry in project nifi by apache.

the class TestProcessorLifecycle method buildFlowControllerForTest.

private FlowControllerAndSystemBundle buildFlowControllerForTest(final String propKey, final String propValue) throws Exception {
    final Map<String, String> addProps = new HashMap<>();
    addProps.put(NiFiProperties.ADMINISTRATIVE_YIELD_DURATION, "1 sec");
    addProps.put(NiFiProperties.STATE_MANAGEMENT_CONFIG_FILE, "target/test-classes/state-management.xml");
    addProps.put(NiFiProperties.STATE_MANAGEMENT_LOCAL_PROVIDER_ID, "local-provider");
    addProps.put(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
    addProps.put("nifi.remote.input.socket.port", "");
    addProps.put("nifi.remote.input.secure", "");
    if (propKey != null && propValue != null) {
        addProps.put(propKey, propValue);
    }
    final NiFiProperties nifiProperties = NiFiProperties.createBasicNiFiProperties(propsFile, addProps);
    final Bundle systemBundle = SystemBundle.create(nifiProperties);
    ExtensionManager.discoverExtensions(systemBundle, Collections.emptySet());
    final FlowController flowController = FlowController.createStandaloneInstance(mock(FlowFileEventRepository.class), nifiProperties, mock(Authorizer.class), mock(AuditService.class), null, new VolatileBulletinRepository(), new FileBasedVariableRegistry(nifiProperties.getVariableRegistryPropertiesPaths()), mock(FlowRegistryClient.class));
    return new FlowControllerAndSystemBundle(flowController, systemBundle);
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) VolatileBulletinRepository(org.apache.nifi.events.VolatileBulletinRepository) HashMap(java.util.HashMap) Bundle(org.apache.nifi.bundle.Bundle) SystemBundle(org.apache.nifi.nar.SystemBundle) FlowRegistryClient(org.apache.nifi.registry.flow.FlowRegistryClient) FlowFileEventRepository(org.apache.nifi.controller.repository.FlowFileEventRepository) Authorizer(org.apache.nifi.authorization.Authorizer) MockProvenanceRepository(org.apache.nifi.provenance.MockProvenanceRepository) FlowController(org.apache.nifi.controller.FlowController) AuditService(org.apache.nifi.admin.service.AuditService) FileBasedVariableRegistry(org.apache.nifi.registry.variable.FileBasedVariableRegistry)

Aggregations

FileBasedVariableRegistry (org.apache.nifi.registry.variable.FileBasedVariableRegistry)7 AuditService (org.apache.nifi.admin.service.AuditService)5 FlowFileEventRepository (org.apache.nifi.controller.repository.FlowFileEventRepository)5 HashMap (java.util.HashMap)4 MockProvenanceRepository (org.apache.nifi.provenance.MockProvenanceRepository)4 Before (org.junit.Before)4 MockPolicyBasedAuthorizer (org.apache.nifi.authorization.MockPolicyBasedAuthorizer)3 BulletinRepository (org.apache.nifi.reporting.BulletinRepository)3 LinkedHashSet (java.util.LinkedHashSet)2 AccessPolicy (org.apache.nifi.authorization.AccessPolicy)2 Authorizer (org.apache.nifi.authorization.Authorizer)2 Group (org.apache.nifi.authorization.Group)2 User (org.apache.nifi.authorization.User)2 VolatileBulletinRepository (org.apache.nifi.events.VolatileBulletinRepository)2 VariableRegistry (org.apache.nifi.registry.VariableRegistry)2 FlowRegistryClient (org.apache.nifi.registry.flow.FlowRegistryClient)2 NiFiProperties (org.apache.nifi.util.NiFiProperties)2 Path (java.nio.file.Path)1 LinkedHashMap (java.util.LinkedHashMap)1 AbstractPolicyBasedAuthorizer (org.apache.nifi.authorization.AbstractPolicyBasedAuthorizer)1