use of org.apache.nifi.registry.properties.NiFiRegistryProperties in project nifi-registry by apache.
the class TestStandardProviderFactory method testFlowProviderClassNotFound.
@Test(expected = ProviderFactoryException.class)
public void testFlowProviderClassNotFound() {
final NiFiRegistryProperties props = new NiFiRegistryProperties();
props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-class-not-found.xml");
final ExtensionManager extensionManager = Mockito.mock(ExtensionManager.class);
when(extensionManager.getExtensionClassLoader(any(String.class))).thenReturn(this.getClass().getClassLoader());
final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager);
providerFactory.initialize();
providerFactory.getFlowPersistenceProvider();
}
use of org.apache.nifi.registry.properties.NiFiRegistryProperties in project nifi-registry by apache.
the class TestStandardProviderFactory method testGetFlowProviderBeforeInitializingShouldThrowException.
@Test(expected = ProviderFactoryException.class)
public void testGetFlowProviderBeforeInitializingShouldThrowException() {
final NiFiRegistryProperties props = new NiFiRegistryProperties();
props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-good.xml");
final ExtensionManager extensionManager = Mockito.mock(ExtensionManager.class);
when(extensionManager.getExtensionClassLoader(any(String.class))).thenReturn(this.getClass().getClassLoader());
final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager);
providerFactory.getFlowPersistenceProvider();
}
use of org.apache.nifi.registry.properties.NiFiRegistryProperties in project nifi-registry by apache.
the class TestStandardProviderFactory method testProvidersConfigDoesNotExist.
@Test(expected = ProviderFactoryException.class)
public void testProvidersConfigDoesNotExist() {
final NiFiRegistryProperties props = new NiFiRegistryProperties();
props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-does-not-exist.xml");
final ExtensionManager extensionManager = Mockito.mock(ExtensionManager.class);
when(extensionManager.getExtensionClassLoader(any(String.class))).thenReturn(this.getClass().getClassLoader());
final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager);
providerFactory.initialize();
}
use of org.apache.nifi.registry.properties.NiFiRegistryProperties in project nifi-registry by apache.
the class TestStandardProviderFactory method testGetProvidersSuccess.
@Test
public void testGetProvidersSuccess() {
final NiFiRegistryProperties props = new NiFiRegistryProperties();
props.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, "src/test/resources/provider/providers-good.xml");
final ExtensionManager extensionManager = Mockito.mock(ExtensionManager.class);
when(extensionManager.getExtensionClassLoader(any(String.class))).thenReturn(this.getClass().getClassLoader());
final ProviderFactory providerFactory = new StandardProviderFactory(props, extensionManager);
providerFactory.initialize();
final FlowPersistenceProvider flowPersistenceProvider = providerFactory.getFlowPersistenceProvider();
assertNotNull(flowPersistenceProvider);
final MockFlowPersistenceProvider mockFlowProvider = (MockFlowPersistenceProvider) flowPersistenceProvider;
assertNotNull(mockFlowProvider.getProperties());
assertEquals("flow foo", mockFlowProvider.getProperties().get("Flow Property 1"));
assertEquals("flow bar", mockFlowProvider.getProperties().get("Flow Property 2"));
}
use of org.apache.nifi.registry.properties.NiFiRegistryProperties in project nifi-registry by apache.
the class LdapUserGroupProviderTest method testUserIdentityMapping.
@Test
public void testUserIdentityMapping() throws Exception {
final Properties props = new Properties();
props.setProperty("nifi.registry.security.identity.mapping.pattern.dn1", "^cn=(.*?),o=(.*?)$");
props.setProperty("nifi.registry.security.identity.mapping.value.dn1", "$1");
final NiFiRegistryProperties properties = getNiFiProperties(props);
ldapUserGroupProvider.setNiFiProperties(properties);
final AuthorizerConfigurationContext configurationContext = getBaseConfiguration(USER_SEARCH_BASE, null);
when(configurationContext.getProperty(PROP_USER_SEARCH_FILTER)).thenReturn(new StandardPropertyValue("(uid=user1)"));
ldapUserGroupProvider.onConfigured(configurationContext);
assertEquals(1, ldapUserGroupProvider.getUsers().size());
assertNotNull(ldapUserGroupProvider.getUserByIdentity("User 1,ou=users"));
}
Aggregations