sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsedd...@apache.org
Subject svn commit: r1771347 - in /sling/trunk/bundles/jcr/oak-server: ./ src/test/java/org/apache/sling/jcr/oak/server/internal/ src/test/java/org/apache/sling/jcr/oak/server/it/
Date Fri, 25 Nov 2016 17:05:14 GMT
Author: jsedding
Date: Fri Nov 25 17:05:13 2016
New Revision: 1771347

URL: http://svn.apache.org/viewvc?rev=1771347&view=rev
Log:
SLING-6329 - RR.isResourceType() broken with jcr.resource 2.8.2

- add a test that checks for an inherited resource type using a
  non-admin session, thus triggering creation of a resource-type resource resolver

Added:
    sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/it/ResourceTypeResolutionIT.java
  (with props)
Removed:
    sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/internal/
Modified:
    sling/trunk/bundles/jcr/oak-server/pom.xml
    sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/it/OakServerTestSupport.java

Modified: sling/trunk/bundles/jcr/oak-server/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/oak-server/pom.xml?rev=1771347&r1=1771346&r2=1771347&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/oak-server/pom.xml (original)
+++ sling/trunk/bundles/jcr/oak-server/pom.xml Fri Nov 25 17:05:13 2016
@@ -277,7 +277,7 @@
     <dependency>
       <groupId>org.apache.sling</groupId>
       <artifactId>org.apache.sling.resourceresolver</artifactId>
-      <version>1.5.2</version>
+      <version>1.5.5-SNAPSHOT</version>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/it/OakServerTestSupport.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/it/OakServerTestSupport.java?rev=1771347&r1=1771346&r2=1771347&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/it/OakServerTestSupport.java
(original)
+++ sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/it/OakServerTestSupport.java
Fri Nov 25 17:05:13 2016
@@ -50,6 +50,7 @@ import static org.junit.Assert.assertNot
 import static org.ops4j.pax.exam.CoreOptions.composite;
 import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.vmOption;
 import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
 
 public abstract class OakServerTestSupport extends TestSupport {

Added: sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/it/ResourceTypeResolutionIT.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/it/ResourceTypeResolutionIT.java?rev=1771347&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/it/ResourceTypeResolutionIT.java
(added)
+++ sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/it/ResourceTypeResolutionIT.java
Fri Nov 25 17:05:13 2016
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.oak.server.it;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.commons.JcrUtils;
+import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.Node;
+import java.util.HashMap;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+
+@RunWith(PaxExam.class)
+public class ResourceTypeResolutionIT extends OakServerTestSupport {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ResourceTypeResolutionIT.class);
+
+    @Test
+    public void checkResourceType() throws Exception {
+        JackrabbitSession adminSession = (JackrabbitSession)slingRepository.loginAdministrative(null);
+        Node contentBar = JcrUtils.getOrCreateByPath("/content/foo/bar", "nt:unstructured",
adminSession);
+        contentBar.setProperty("sling:resourceType", "types/foo/bar");
+
+        Node appsBar = JcrUtils.getOrCreateByPath("/apps/types/foo/bar", "nt:unstructured",
adminSession);
+        appsBar.setProperty("sling:resourceSuperType", "types/foo/parent");
+
+        JcrUtils.getOrCreateByPath("/apps/types/foo/parent", "nt:unstructured", adminSession);
+        adminSession.getUserManager().createUser("test-user", "test");
+        adminSession.save();
+        AccessControlUtils.allow(contentBar, "test-user", "jcr:read");
+        adminSession.save();
+        adminSession.logout();
+
+        HashMap<String, Object> authenticationInfo = new HashMap<>();
+        authenticationInfo.put(ResourceResolverFactory.USER, "test-user");
+        authenticationInfo.put(ResourceResolverFactory.PASSWORD, "test".toCharArray());
+
+        ResourceResolver testResolver = resourceResolverFactory.getResourceResolver(authenticationInfo);
+        try {
+            Resource resource = testResolver.getResource("/content/foo/bar");
+            assertNotNull(resource);
+            assertEquals("/content/foo/bar", resource.getPath());
+            assertTrue(resource.isResourceType("types/foo/bar"));
+
+            // this assertion causes the private ResourceResolverControl#getResourceTypeResourceResolver
+            // to be called, which needs to inject the resourceresolver bundle via the authenticationInfo
+            // see SLING-6329
+            assertTrue(resource.isResourceType("types/foo/parent"));
+        } finally {
+            testResolver.close();
+        }
+    }
+}

Propchange: sling/trunk/bundles/jcr/oak-server/src/test/java/org/apache/sling/jcr/oak/server/it/ResourceTypeResolutionIT.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message