use of org.apache.nifi.authorization.util.IdentityMapping in project nifi by apache.
the class NiFiAuthenticationProviderTest method testNoMappings.
@Test
public void testNoMappings() {
Properties properties = new Properties();
final NiFiProperties nifiProperties = getNiFiProperties(properties);
TestableNiFiAuthenticationProvider provider = new TestableNiFiAuthenticationProvider(nifiProperties);
List<IdentityMapping> mappings = provider.getMappings();
assertEquals(0, mappings.size());
final String identity = "john";
assertEquals(identity, provider.mapIdentity(identity));
}
use of org.apache.nifi.authorization.util.IdentityMapping in project nifi by apache.
the class NiFiAuthenticationProviderTest method testPatternPropertyWithNoValue.
@Test
public void testPatternPropertyWithNoValue() {
Properties properties = new Properties();
properties.setProperty("nifi.security.identity.mapping.pattern.dn", "");
properties.setProperty("nifi.security.identity.mapping.value.dn", "value");
final NiFiProperties nifiProperties = getNiFiProperties(properties);
TestableNiFiAuthenticationProvider provider = new TestableNiFiAuthenticationProvider(nifiProperties);
List<IdentityMapping> mappings = provider.getMappings();
assertEquals(0, mappings.size());
}
use of org.apache.nifi.authorization.util.IdentityMapping in project nifi by apache.
the class NiFiAuthenticationProviderTest method testValidPropertiesProvided.
@Test
public void testValidPropertiesProvided() {
final String pattern = "^cn=(.*?),dc=(.*?),dc=(.*?)$";
final String value = "$1@$2.$3";
Properties properties = new Properties();
properties.setProperty("nifi.security.identity.mapping.pattern.dn", pattern);
properties.setProperty("nifi.security.identity.mapping.value.dn", value);
final NiFiProperties nifiProperties = getNiFiProperties(properties);
TestableNiFiAuthenticationProvider provider = new TestableNiFiAuthenticationProvider(nifiProperties);
List<IdentityMapping> mappings = provider.getMappings();
assertEquals(1, mappings.size());
assertEquals("dn", mappings.get(0).getKey());
assertEquals(pattern, mappings.get(0).getPattern().pattern());
assertEquals(value, mappings.get(0).getReplacementValue());
}
use of org.apache.nifi.authorization.util.IdentityMapping in project nifi by apache.
the class NiFiAuthenticationProviderTest method testPatternPropertyWithNoCorrespondingValueProperty.
@Test
public void testPatternPropertyWithNoCorrespondingValueProperty() {
Properties properties = new Properties();
properties.setProperty("nifi.security.identity.mapping.pattern.dn", "");
final NiFiProperties nifiProperties = getNiFiProperties(properties);
TestableNiFiAuthenticationProvider provider = new TestableNiFiAuthenticationProvider(nifiProperties);
List<IdentityMapping> mappings = provider.getMappings();
assertEquals(0, mappings.size());
}
use of org.apache.nifi.authorization.util.IdentityMapping in project nifi by apache.
the class NiFiAuthenticationProviderTest method testMultipleMappings.
@Test
public void testMultipleMappings() {
Properties properties = new Properties();
properties.setProperty("nifi.security.identity.mapping.pattern.1", "pattern1");
properties.setProperty("nifi.security.identity.mapping.value.1", "value1");
properties.setProperty("nifi.security.identity.mapping.pattern.2", "pattern2");
properties.setProperty("nifi.security.identity.mapping.value.2", "value2");
properties.setProperty("nifi.security.identity.mapping.pattern.3", "pattern3");
properties.setProperty("nifi.security.identity.mapping.value.3", "value3");
final NiFiProperties nifiProperties = getNiFiProperties(properties);
TestableNiFiAuthenticationProvider provider = new TestableNiFiAuthenticationProvider(nifiProperties);
List<IdentityMapping> mappings = provider.getMappings();
assertEquals(3, mappings.size());
}
Aggregations