Search in sources :

Example 1 with JpaGroupRoleProvider

use of org.opencastproject.userdirectory.JpaGroupRoleProvider in project opencast by opencast.

the class OpencastLdapAuthoritiesPopulatorTest method testMultivaluedAttributeSimpleRoles.

@Test
public void testMultivaluedAttributeSimpleRoles() {
    OpencastLdapAuthoritiesPopulator populator;
    // Prepare the mappings
    mappings.put("myAttribute", new String[] { " value1 ", " value2 ", " value3 ", " value4 ", GROUP_ROLE });
    String attributes = StringUtils.join(mappings.keySet(), ", ");
    // Test several argument combinations
    for (String prefix : PREFIX_TESTS) {
        for (String[] excludePrefixes : EXCLUDE_PREFIXES_TESTS) {
            for (boolean upper : UPPERCASE_TESTS) {
                for (JpaGroupRoleProvider groupRoleProvider : groupRoleProviderTests) {
                    for (String[] extraRoles : EXTRA_ROLES_TESTS) {
                        populator = new OpencastLdapAuthoritiesPopulator(attributes, prefix, excludePrefixes, upper, org, securityService, groupRoleProvider, extraRoles);
                        doTest(populator, mappings, prefix, excludePrefixes, upper, extraRoles, groupRoleProvider);
                    }
                }
            }
        }
    }
}
Also used : JpaGroupRoleProvider(org.opencastproject.userdirectory.JpaGroupRoleProvider) Test(org.junit.Test)

Example 2 with JpaGroupRoleProvider

use of org.opencastproject.userdirectory.JpaGroupRoleProvider in project opencast by opencast.

the class OpencastLdapAuthoritiesPopulatorTest method testAttributesWithWhitespaces.

@Test
public void testAttributesWithWhitespaces() {
    OpencastLdapAuthoritiesPopulator populator;
    // Prepare the mappings
    mappings.put("attribute1", new String[] { " ", "\n", "\t", "\r", " \n \t", " \nthis\tis an attribute" });
    mappings.put("attribute2", new String[] { format("value_2_1 , value\nwith\n\n multiple\t whitespaces, value____with several_underscores", "normal_value , normalvalue2, %s", GROUP_ROLE) });
    String attributes = StringUtils.join(mappings.keySet(), ", ");
    // Test several argument combinations
    for (String prefix : PREFIX_TESTS) {
        for (String[] excludePrefixes : EXCLUDE_PREFIXES_TESTS) {
            for (boolean upper : UPPERCASE_TESTS) {
                for (JpaGroupRoleProvider groupRoleProvider : groupRoleProviderTests) {
                    for (String[] extraRoles : EXTRA_ROLES_TESTS) {
                        populator = new OpencastLdapAuthoritiesPopulator(attributes, prefix, excludePrefixes, upper, org, securityService, groupRoleProvider, extraRoles);
                        doTest(populator, mappings, prefix, excludePrefixes, upper, extraRoles, groupRoleProvider);
                    }
                }
            }
        }
    }
}
Also used : JpaGroupRoleProvider(org.opencastproject.userdirectory.JpaGroupRoleProvider) Test(org.junit.Test)

Example 3 with JpaGroupRoleProvider

use of org.opencastproject.userdirectory.JpaGroupRoleProvider in project opencast by opencast.

the class OpencastLdapAuthoritiesPopulatorTest method testAttributeNotFound.

@Test
public void testAttributeNotFound() {
    OpencastLdapAuthoritiesPopulator populator;
    // Prepare the mappings
    // The attribute returns "null", i.e. does not exist in the LDAP user
    mappings.put("myAttribute", null);
    String attributes = StringUtils.join(mappings.keySet(), ", ");
    // Test several argument combinations
    for (String prefix : PREFIX_TESTS) {
        for (String[] excludePrefixes : EXCLUDE_PREFIXES_TESTS) {
            for (boolean upper : UPPERCASE_TESTS) {
                for (JpaGroupRoleProvider groupRoleProvider : groupRoleProviderTests) {
                    for (String[] extraRoles : EXTRA_ROLES_TESTS) {
                        populator = new OpencastLdapAuthoritiesPopulator(attributes, prefix, excludePrefixes, upper, org, securityService, groupRoleProvider, extraRoles);
                        doTest(populator, mappings, prefix, excludePrefixes, upper, extraRoles, groupRoleProvider);
                    }
                }
            }
        }
    }
}
Also used : JpaGroupRoleProvider(org.opencastproject.userdirectory.JpaGroupRoleProvider) Test(org.junit.Test)

Example 4 with JpaGroupRoleProvider

use of org.opencastproject.userdirectory.JpaGroupRoleProvider in project opencast by opencast.

the class OpencastLdapAuthoritiesPopulatorTest method testSingleAttributeMultipleRoles.

@Test
public void testSingleAttributeMultipleRoles() {
    OpencastLdapAuthoritiesPopulator populator;
    // Prepare the mappings
    mappings.put("myAttribute", new String[] { format(" value1, value2, value3 , value4 , %s ", GROUP_ROLE) });
    String attributes = StringUtils.join(mappings.keySet(), ", ");
    // Test several argument combinations
    for (String prefix : PREFIX_TESTS) {
        for (String[] excludePrefixes : EXCLUDE_PREFIXES_TESTS) {
            for (boolean upper : UPPERCASE_TESTS) {
                for (JpaGroupRoleProvider groupRoleProvider : groupRoleProviderTests) {
                    for (String[] extraRoles : EXTRA_ROLES_TESTS) {
                        populator = new OpencastLdapAuthoritiesPopulator(attributes, prefix, excludePrefixes, upper, org, securityService, groupRoleProvider, extraRoles);
                        doTest(populator, mappings, prefix, excludePrefixes, upper, extraRoles, groupRoleProvider);
                    }
                }
            }
        }
    }
}
Also used : JpaGroupRoleProvider(org.opencastproject.userdirectory.JpaGroupRoleProvider) Test(org.junit.Test)

Example 5 with JpaGroupRoleProvider

use of org.opencastproject.userdirectory.JpaGroupRoleProvider in project opencast by opencast.

the class OpencastLdapAuthoritiesPopulatorTest method testRolePrefix.

@Test
public void testRolePrefix() {
    OpencastLdapAuthoritiesPopulator populator;
    // Prepare the mappings
    mappings.put("attribute1", new String[] { " ", "\n", "\t", "\r", " \n \t", " \nthis\tis an attribute" });
    mappings.put("attribute2", new String[] { format("value_1 , exclude_value_1, value_2, exclude_value_2", "normal_value , normalvalue2 , %s", GROUP_ROLE) });
    String attributes = StringUtils.join(mappings.keySet(), ", ");
    // Define prefixes
    String[] prefixes = new String[] { "normal_" };
    String[][] excludePrefixesTest = new String[][] { null, new String[0], new String[] { "exclude" } };
    // Test several argument combinations
    for (String prefix : prefixes) {
        for (String[] excludePrefixes : excludePrefixesTest) {
            for (boolean upper : UPPERCASE_TESTS) {
                for (JpaGroupRoleProvider groupRoleProvider : groupRoleProviderTests) {
                    for (String[] extraRoles : EXTRA_ROLES_TESTS) {
                        populator = new OpencastLdapAuthoritiesPopulator(attributes, prefix, excludePrefixes, upper, org, securityService, groupRoleProvider, extraRoles);
                        doTest(populator, mappings, prefix, excludePrefixes, upper, extraRoles, groupRoleProvider);
                    }
                }
            }
        }
    }
}
Also used : JpaGroupRoleProvider(org.opencastproject.userdirectory.JpaGroupRoleProvider) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 JpaGroupRoleProvider (org.opencastproject.userdirectory.JpaGroupRoleProvider)8 Organization (org.opencastproject.security.api.Organization)1