Search in sources :

Example 31 with AuthorizerConfigurationContext

use of org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext in project nifi-registry by apache.

the class LdapUserGroupProviderTest method testSearchUsersWithCnIdentityAttribute.

@Test
public void testSearchUsersWithCnIdentityAttribute() throws Exception {
    final AuthorizerConfigurationContext configurationContext = getBaseConfiguration(USER_SEARCH_BASE, null);
    when(configurationContext.getProperty(PROP_USER_IDENTITY_ATTRIBUTE)).thenReturn(new StandardPropertyValue("cn"));
    ldapUserGroupProvider.onConfigured(configurationContext);
    assertEquals(8, ldapUserGroupProvider.getUsers().size());
    assertNotNull(ldapUserGroupProvider.getUserByIdentity("User 1"));
    assertTrue(ldapUserGroupProvider.getGroups().isEmpty());
}
Also used : StandardPropertyValue(org.apache.nifi.registry.util.StandardPropertyValue) AuthorizerConfigurationContext(org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext) Test(org.junit.Test)

Example 32 with AuthorizerConfigurationContext

use of org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext in project nifi-registry by apache.

the class LdapUserGroupProviderTest method testSearchUsersWithGroupingNoGroupName.

@Test
public void testSearchUsersWithGroupingNoGroupName() throws Exception {
    final AuthorizerConfigurationContext configurationContext = getBaseConfiguration(USER_SEARCH_BASE, null);
    when(configurationContext.getProperty(PROP_USER_IDENTITY_ATTRIBUTE)).thenReturn(new StandardPropertyValue("uid"));
    // using description in lieu of memberof
    when(configurationContext.getProperty(PROP_USER_GROUP_ATTRIBUTE)).thenReturn(new StandardPropertyValue("description"));
    ldapUserGroupProvider.onConfigured(configurationContext);
    assertEquals(8, ldapUserGroupProvider.getUsers().size());
    assertEquals(2, ldapUserGroupProvider.getGroups().size());
    final UserAndGroups userAndGroups = ldapUserGroupProvider.getUserAndGroups("user4");
    assertNotNull(userAndGroups.getUser());
    assertEquals(1, userAndGroups.getGroups().size());
    assertEquals("cn=team1,ou=groups,o=nifi", userAndGroups.getGroups().iterator().next().getName());
}
Also used : UserAndGroups(org.apache.nifi.registry.security.authorization.UserAndGroups) StandardPropertyValue(org.apache.nifi.registry.util.StandardPropertyValue) AuthorizerConfigurationContext(org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext) Test(org.junit.Test)

Example 33 with AuthorizerConfigurationContext

use of org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext in project nifi-registry by apache.

the class LdapUserGroupProviderTest method testUserSearchBaseSpecifiedButNoUserObjectClass.

@Test(expected = SecurityProviderCreationException.class)
public void testUserSearchBaseSpecifiedButNoUserObjectClass() throws Exception {
    final AuthorizerConfigurationContext configurationContext = getBaseConfiguration(USER_SEARCH_BASE, null);
    when(configurationContext.getProperty(PROP_USER_OBJECT_CLASS)).thenReturn(new StandardPropertyValue(null));
    ldapUserGroupProvider.onConfigured(configurationContext);
}
Also used : StandardPropertyValue(org.apache.nifi.registry.util.StandardPropertyValue) AuthorizerConfigurationContext(org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext) Test(org.junit.Test)

Example 34 with AuthorizerConfigurationContext

use of org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext in project nifi-registry by apache.

the class LdapUserGroupProviderTest method testSearchUsersWithFilter.

@Test
public void testSearchUsersWithFilter() throws Exception {
    final AuthorizerConfigurationContext configurationContext = getBaseConfiguration(USER_SEARCH_BASE, null);
    when(configurationContext.getProperty(PROP_USER_IDENTITY_ATTRIBUTE)).thenReturn(new StandardPropertyValue("uid"));
    when(configurationContext.getProperty(PROP_USER_SEARCH_FILTER)).thenReturn(new StandardPropertyValue("(uid=user1)"));
    ldapUserGroupProvider.onConfigured(configurationContext);
    assertEquals(1, ldapUserGroupProvider.getUsers().size());
    assertNotNull(ldapUserGroupProvider.getUserByIdentity("user1"));
    assertTrue(ldapUserGroupProvider.getGroups().isEmpty());
}
Also used : StandardPropertyValue(org.apache.nifi.registry.util.StandardPropertyValue) AuthorizerConfigurationContext(org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext) Test(org.junit.Test)

Example 35 with AuthorizerConfigurationContext

use of org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext in project nifi-registry by apache.

the class LdapUserGroupProviderTest method testSearchUsersWithNoIdentityAttribute.

@Test
public void testSearchUsersWithNoIdentityAttribute() throws Exception {
    final AuthorizerConfigurationContext configurationContext = getBaseConfiguration(USER_SEARCH_BASE, null);
    ldapUserGroupProvider.onConfigured(configurationContext);
    assertEquals(8, ldapUserGroupProvider.getUsers().size());
    assertNotNull(ldapUserGroupProvider.getUserByIdentity("cn=User 1,ou=users,o=nifi"));
    assertTrue(ldapUserGroupProvider.getGroups().isEmpty());
}
Also used : AuthorizerConfigurationContext(org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext) Test(org.junit.Test)

Aggregations

AuthorizerConfigurationContext (org.apache.nifi.registry.security.authorization.AuthorizerConfigurationContext)37 Test (org.junit.Test)36 StandardPropertyValue (org.apache.nifi.registry.util.StandardPropertyValue)33 Group (org.apache.nifi.registry.security.authorization.Group)13 UserAndGroups (org.apache.nifi.registry.security.authorization.UserAndGroups)10 Properties (java.util.Properties)9 NiFiRegistryProperties (org.apache.nifi.registry.properties.NiFiRegistryProperties)9 Set (java.util.Set)8 CreateLdapServer (org.apache.directory.server.annotations.CreateLdapServer)8 CreateTransport (org.apache.directory.server.annotations.CreateTransport)8 ApplyLdifFiles (org.apache.directory.server.core.annotations.ApplyLdifFiles)8 CreateDS (org.apache.directory.server.core.annotations.CreateDS)8 CreatePartition (org.apache.directory.server.core.annotations.CreatePartition)8 AbstractLdapTestUnit (org.apache.directory.server.core.integ.AbstractLdapTestUnit)8 FrameworkRunner (org.apache.directory.server.core.integ.FrameworkRunner)8 UserGroupProviderInitializationContext (org.apache.nifi.registry.security.authorization.UserGroupProviderInitializationContext)8 SecurityProviderCreationException (org.apache.nifi.registry.security.exception.SecurityProviderCreationException)8 LdapAuthenticationStrategy (org.apache.nifi.registry.security.ldap.LdapAuthenticationStrategy)8 ReferralStrategy (org.apache.nifi.registry.security.ldap.ReferralStrategy)8 PROP_AUTHENTICATION_STRATEGY (org.apache.nifi.registry.security.ldap.tenants.LdapUserGroupProvider.PROP_AUTHENTICATION_STRATEGY)8