Search in sources :

Example 1 with NiFiRegistryProperties

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();
}
Also used : ExtensionManager(org.apache.nifi.registry.extension.ExtensionManager) NiFiRegistryProperties(org.apache.nifi.registry.properties.NiFiRegistryProperties) Test(org.junit.Test)

Example 2 with NiFiRegistryProperties

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();
}
Also used : ExtensionManager(org.apache.nifi.registry.extension.ExtensionManager) NiFiRegistryProperties(org.apache.nifi.registry.properties.NiFiRegistryProperties) Test(org.junit.Test)

Example 3 with NiFiRegistryProperties

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();
}
Also used : ExtensionManager(org.apache.nifi.registry.extension.ExtensionManager) NiFiRegistryProperties(org.apache.nifi.registry.properties.NiFiRegistryProperties) Test(org.junit.Test)

Example 4 with NiFiRegistryProperties

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"));
}
Also used : ExtensionManager(org.apache.nifi.registry.extension.ExtensionManager) FlowPersistenceProvider(org.apache.nifi.registry.flow.FlowPersistenceProvider) NiFiRegistryProperties(org.apache.nifi.registry.properties.NiFiRegistryProperties) Test(org.junit.Test)

Example 5 with NiFiRegistryProperties

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"));
}
Also used : StandardPropertyValue(org.apache.nifi.registry.util.StandardPropertyValue) NiFiRegistryProperties(org.apache.nifi.registry.properties.NiFiRegistryProperties) Properties(java.util.Properties) NiFiRegistryProperties(org.apache.nifi.registry.properties.NiFiRegistryProperties) AuthorizerConfigurationContext(org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext) Test(org.junit.Test)

Aggregations

NiFiRegistryProperties (org.apache.nifi.registry.properties.NiFiRegistryProperties)9 Test (org.junit.Test)5 ExtensionManager (org.apache.nifi.registry.extension.ExtensionManager)4 Properties (java.util.Properties)1 FlowPersistenceProvider (org.apache.nifi.registry.flow.FlowPersistenceProvider)1 SensitivePropertyProtectionException (org.apache.nifi.registry.properties.SensitivePropertyProtectionException)1 AuthorizerConfigurationContext (org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext)1 BootstrapFileCryptoKeyProvider (org.apache.nifi.registry.security.crypto.BootstrapFileCryptoKeyProvider)1 CryptoKeyProvider (org.apache.nifi.registry.security.crypto.CryptoKeyProvider)1 MissingCryptoKeyException (org.apache.nifi.registry.security.crypto.MissingCryptoKeyException)1 StandardPropertyValue (org.apache.nifi.registry.util.StandardPropertyValue)1 IntegrationTestBase.loadNiFiRegistryProperties (org.apache.nifi.registry.web.api.IntegrationTestBase.loadNiFiRegistryProperties)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Bean (org.springframework.context.annotation.Bean)1