minor improvement: tests for CugConfiguration
*/
package org.apache.jackrabbit.oak.spi.security.authorization.cug.impl;
-import java.lang.reflect.Field;
import java.security.Principal;
import java.util.List;
import java.util.Set;
@@ -29,15 +28,20 @@ import com.google.common.collect.ImmutableSet;
import org.apache.jackrabbit.oak.AbstractSecurityTest;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.security.SecurityProviderImpl;
+import org.apache.jackrabbit.oak.spi.commit.CommitHook;
+import org.apache.jackrabbit.oak.spi.commit.MoveTracker;
+import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
import org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration;
import org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider;
import org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider;
+import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider;
import org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal;
import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal;
import org.apache.jackrabbit.oak.spi.security.principal.SystemPrincipal;
import org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal;
+import org.apache.jackrabbit.oak.spi.xml.ProtectedItemImporter;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -53,7 +57,38 @@ public class CugConfigurationTest extends AbstractSecurityTest {
@Test
public void testGetName() {
- assertEquals(AuthorizationConfiguration.NAME, createConfiguration(ConfigurationParameters.EMPTY).getName());
+ assertEquals(AuthorizationConfiguration.NAME, new CugConfiguration().getName());
+ }
+
+ @Test
+ public void testGetRestrictionProvider() {
+ assertSame(RestrictionProvider.EMPTY, new CugConfiguration().getRestrictionProvider());
+ }
+
+ @Test
+ public void testGetCommitHooks() {
+ List<? extends CommitHook> l = new CugConfiguration().getCommitHooks("wspName");
+ assertEquals(1, l.size());
+ assertTrue(l.iterator().next() instanceof NestedCugHook);
+ }
+
+ @Test
+ public void testGetValidators() {
+ List<? extends ValidatorProvider> l = new CugConfiguration().getValidators("wspName", ImmutableSet.of(), new MoveTracker());
+ assertEquals(1, l.size());
+ assertTrue(l.iterator().next() instanceof CugValidatorProvider);
+ }
+
+ @Test
+ public void testGetProtectedItemImporters() {
+ List<ProtectedItemImporter> l = new CugConfiguration().getProtectedItemImporters();
+ assertEquals(1, l.size());
+ assertTrue(l.iterator().next() instanceof CugImporter);
+ }
+
+ @Test
+ public void testGetContext() {
+ assertSame(CugContext.INSTANCE, new CugConfiguration().getContext());
}
@Test
