You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by pa...@apache.org on 2022/01/26 16:18:42 UTC

[sling-org-apache-sling-scripting-bundle-tracker-it] branch issues/SLING-11093 created (now 5e105fe)

This is an automated email from the ASF dual-hosted git repository.

pauls pushed a change to branch issues/SLING-11093
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-bundle-tracker-it.git.


      at 5e105fe  SLING-11093: add a test that checks that we only register the absolute resource type if the relative resource type is the same

This branch includes the following new commits:

     new 5e105fe  SLING-11093: add a test that checks that we only register the absolute resource type if the relative resource type is the same

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[sling-org-apache-sling-scripting-bundle-tracker-it] 01/01: SLING-11093: add a test that checks that we only register the absolute resource type if the relative resource type is the same

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pauls pushed a commit to branch issues/SLING-11093
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-bundle-tracker-it.git

commit 5e105fe2bdfe2ff18cc4f336e39b4cdf05c18dc7
Author: Karl Pauls <ka...@gmail.com>
AuthorDate: Wed Jan 26 17:18:31 2022 +0100

    SLING-11093: add a test that checks that we only register the absolute resource type if the relative resource type is the same
---
 .../src/main/scripts/libs/rtsuper/extends          |  1 +
 .../src/main/scripts/apps/rtsuper/rtsuper.html     | 19 +++++++++++++++++
 it/pom.xml                                         |  2 +-
 .../it/ExampleBundlePrecompiledTeleportedIT.java   | 24 ++++++++++++++++++++++
 4 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/examples/org-apache-sling-scripting-examplebundle-precompiled-extend1/src/main/scripts/libs/rtsuper/extends b/examples/org-apache-sling-scripting-examplebundle-precompiled-extend1/src/main/scripts/libs/rtsuper/extends
new file mode 100644
index 0000000..f9263f5
--- /dev/null
+++ b/examples/org-apache-sling-scripting-examplebundle-precompiled-extend1/src/main/scripts/libs/rtsuper/extends
@@ -0,0 +1 @@
+/apps/rtsuper
\ No newline at end of file
diff --git a/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/apps/rtsuper/rtsuper.html b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/apps/rtsuper/rtsuper.html
new file mode 100644
index 0000000..bee4276
--- /dev/null
+++ b/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/apps/rtsuper/rtsuper.html
@@ -0,0 +1,19 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+/libs/rtsuper
\ No newline at end of file
diff --git a/it/pom.xml b/it/pom.xml
index ac198b2..438a2b6 100644
--- a/it/pom.xml
+++ b/it/pom.xml
@@ -188,7 +188,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.servlets.resolver</artifactId>
-            <version>2.9.1-SNAPSHOT</version>
+            <version>2.9.3-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledTeleportedIT.java b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledTeleportedIT.java
index 0f18051..8a3d618 100644
--- a/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledTeleportedIT.java
+++ b/it/src/test/java/org/apache/sling/scripting/bundle/tracker/it/ExampleBundlePrecompiledTeleportedIT.java
@@ -28,6 +28,7 @@ import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.junit.Test;
 
+import static junit.framework.TestCase.assertNull;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -89,4 +90,27 @@ public class ExampleBundlePrecompiledTeleportedIT extends AbstractTeleportedTest
             }
         }
     }
+
+    /*
+     * We need to test that if we register with an absolute resource type and a relative one we are not ending up with
+     * a registration in the wrong prefix. As an example, when we register a resource type called rtsuper we end up with a capability
+     * for [rtsuper,/apps/rtsuper]. That will make it so that the resolver prepends the search path prefix (which is configurable).
+     * For a default configuration, this could end up being /apps/rtsuper or /libs/rtsuper, based on the prefix value, which is a mistake
+     * because, in that case, the resource super type would be on both and could cause a cycle.
+     *
+     * To recreate this scenario without changing the resolver config for the prefix selection this test has the script in
+     * /apps and the extends in /libs with a value for /apps/rtsuper - hence, we expect that we are not finding a super type
+     * on the script in /apps because otherwise it would have picked the wrong prefix (which we avoid by not registering
+     * relative resource types when there is an absolute one for the same resource type).
+     */
+    @Test
+    public void testRtSuper() throws LoginException {
+        final String expectedRT = "rtsuper";
+        ResourceResolverFactory resourceResolverFactory = teleporter.getService(ResourceResolverFactory.class);
+        try (ResourceResolver resolver = resourceResolverFactory.getResourceResolver(AUTH_MAP)) {
+            Resource main = resolver.resolve("/apps/" + expectedRT);
+            assertNotNull(main);
+            assertNull(main.getResourceSuperType());
+        }
+    }
 }