SLING-5355 - RepositoryInitializer created, reads from provisioning model, WIP:ProvisioningModelIT fails for now
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1744594 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index e5527eb..8a89025 100644
--- a/pom.xml
+++ b/pom.xml
@@ -112,7 +112,7 @@
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>slingstart-maven-plugin</artifactId>
- <version>1.3.6</version>
+ <version>1.4.2</version>
<extensions>true</extensions>
<executions>
<execution>
diff --git a/src/main/provisioning/boot.txt b/src/main/provisioning/boot.txt
new file mode 100644
index 0000000..e598b24
--- /dev/null
+++ b/src/main/provisioning/boot.txt
@@ -0,0 +1,55 @@
+#
+# 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.
+#
+# The :boot feature contains all things to bootstrap the installation.
+#
+[feature name=:boot]
+
+# additional entries for sling.properties
+# ---------------------------------------
+# oak_tar and oak_mongo run modes are mutually exclusive,
+# and cannot be changed after the first startup
+[settings]
+ sling.run.mode.install.options=oak_tar,oak_mongo
+
+[artifacts]
+ org.slf4j/slf4j-api/1.7.6
+ org.apache.sling/org.apache.sling.commons.log/4.0.6
+ org.apache.sling/org.apache.sling.commons.logservice/1.0.6
+ org.slf4j/jcl-over-slf4j/1.7.6
+ org.slf4j/log4j-over-slf4j/1.7.6
+ org.apache.sling/org.apache.sling.settings/1.3.8
+ org.apache.sling/org.apache.sling.fragment.xml/1.0.2
+ org.apache.sling/org.apache.sling.fragment.transaction/1.0.0
+ org.apache.sling/org.apache.sling.javax.activation/0.1.0
+ org.apache.sling/org.apache.sling.fragment.ws/1.0.2
+ org.apache.sling/org.apache.sling.launchpad.installer/1.2.2
+ org.apache.sling/org.apache.sling.installer.core/3.6.8
+ org.apache.sling/org.apache.sling.installer.provider.file/1.1.0
+ org.apache.sling/org.apache.sling.installer.factory.configuration/1.1.2
+ org.apache.sling/org.apache.sling.installer.factory.subsystems/1.0.0
+ org.apache.sling/org.apache.sling.installer.factory.subsystems-base/1.0.0-SNAPSHOT
+ org.apache.felix/org.apache.felix.configadmin/1.8.8
+ org.apache.felix/org.apache.felix.eventadmin/1.4.4
+ org.apache.aries/org.apache.aries.util/1.1.1
+ org.apache.felix/org.apache.felix.coordinator/1.0.2
+ org.eclipse.equinox/org.eclipse.equinox.region/1.2.101.v20150831-1342
+ org.apache.aries.subsystem/org.apache.aries.subsystem.api/2.0.6
+ org.apache.aries.subsystem/org.apache.aries.subsystem.core/2.0.6
+ # dependency with javax.inject - required for Sling Models (SLING-4710)
+ org.apache.geronimo.specs/geronimo-atinject_1.0_spec/1.0
diff --git a/src/main/provisioning/launchpad.txt b/src/main/provisioning/launchpad.txt
new file mode 100644
index 0000000..eeb0713
--- /dev/null
+++ b/src/main/provisioning/launchpad.txt
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+# The :launchpad feature defines Sling's launchpad version
+# Only a single artifact is allowed within this feature.
+#
+[feature name=:launchpad]
+ org.apache.sling/org.apache.sling.launchpad.base/5.4.0-2.6.11-SNAPSHOT
diff --git a/src/main/provisioning/model.txt b/src/main/provisioning/model.txt
index 01ad176..7c55e46 100644
--- a/src/main/provisioning/model.txt
+++ b/src/main/provisioning/model.txt
@@ -16,15 +16,28 @@
# specific language governing permissions and limitations
# under the License.
#
-[feature name=sling]
+[feature name=repoinit-tests]
-[artifacts]
- org.apache.sling/org.apache.sling.launchpad/8/slingstart
- org.apache.sling/org.apache.sling.junit.core/1.0.14
- org.apache.sling/org.apache.sling.testing.tools/1.0.10
-
+[artifacts startLevel=2]
org.apache.sling/org.apache.sling.repoinit.oak-jcr/0.0.1-SNAPSHOT
org.apache.sling/org.apache.sling.repoinit.parser/0.0.1-SNAPSHOT
+ org.apache.sling/org.apache.sling.provisioning.model/1.4.2
+[artifacts]
+ org.apache.sling/org.apache.sling.junit.core/1.0.14
+ org.apache.sling/org.apache.sling.testing.tools/1.0.10
+ org.apache.sling/org.apache.sling.jcr.api/2.3.1-SNAPSHOT
+
[settings]
- org.apache.sling.commons.log.julenabled=true
\ No newline at end of file
+ org.apache.sling.commons.log.julenabled=true
+
+[:repoinit]
+# Test the RepositoryInitializer which reads such sections
+create path /repoinit/fromProvisioningModel
+
+create service user userFromProvisioningModel
+
+set ACL for userFromProvisioningModel
+ allow jcr:read on /repoinit/fromProvisioningModel
+ deny jcr:write on /repoinit/fromProvisioningModel
+end
\ No newline at end of file
diff --git a/src/main/provisioning/oak.txt b/src/main/provisioning/oak.txt
new file mode 100644
index 0000000..31627b7
--- /dev/null
+++ b/src/main/provisioning/oak.txt
@@ -0,0 +1,90 @@
+#
+# 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.
+#
+# This is the OAK feature.
+[feature name=oak]
+
+[variables]
+ oak.version=1.4.0
+
+# The segment node store is used via a configuration
+[artifacts startLevel=10]
+ org.apache.felix/org.apache.felix.jaas/0.0.4
+
+[artifacts startLevel=15]
+ org.apache.jackrabbit/oak-core/${oak.version}
+ org.apache.jackrabbit/oak-commons/${oak.version}
+ org.apache.jackrabbit/oak-lucene/${oak.version}
+ org.apache.jackrabbit/oak-blob/${oak.version}
+
+[artifacts startLevel=15 runModes=oak_tar]
+ org.apache.jackrabbit/oak-segment/${oak.version}
+
+[artifacts startLevel=15 runModes=oak_mongo]
+ org.mongodb/mongo-java-driver/2.14.0
+
+# start the Oak server instance after all components have been configured
+# and started to avoid restarting that component ( see SLING-4556 )
+[artifacts startLevel=16]
+ org.apache.sling/org.apache.sling.jcr.oak.server/1.0.1-SNAPSHOT
+
+[configurations]
+ org.apache.felix.jaas.Configuration.factory-GuestLoginModule
+ jaas.controlFlag="optional"
+ jaas.classname="org.apache.jackrabbit.oak.spi.security.authentication.GuestLoginModule"
+ jaas.ranking=I"300"
+
+ org.apache.felix.jaas.Configuration.factory-LoginModuleImpl
+ jaas.controlFlag="required"
+ jaas.classname="org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl"
+
+ org.apache.felix.jaas.Configuration.factory-TokenLoginModule
+ jaas.controlFlag="sufficient"
+ jaas.classname="org.apache.jackrabbit.oak.security.authentication.token.TokenLoginModule"
+ jaas.ranking=I"200"
+
+ org.apache.felix.jaas.ConfigurationSpi
+ jaas.defaultRealmName="jackrabbit.oak"
+ jaas.configProviderName="FelixJaasProvider"
+
+ org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl
+ org.apache.jackrabbit.oak.authentication.configSpiName="FelixJaasProvider"
+
+ org.apache.jackrabbit.oak.security.user.UserConfigurationImpl
+ groupsPath="/home/groups"
+ usersPath="/home/users"
+ defaultDepth="1"
+ importBehavior="besteffort"
+
+ org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider
+ enabledActions=["org.apache.jackrabbit.oak.spi.security.user.action.AccessControlAction"]
+ userPrivilegeNames=["jcr:all"]
+ groupPrivilegeNames=["jcr:read"]
+
+ org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProviderService
+ localIndexDir="sling/repository/index"
+
+[configurations runModes=oak_tar]
+ org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService
+ name="Default\ NodeStore"
+ repository.home="sling/repository"
+
+[configurations runModes=oak_mongo]
+ org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService
+ mongouri="mongodb://localhost:27017"
+ db="sling"
diff --git a/src/main/provisioning/repoinit.txt b/src/main/provisioning/repoinit.txt
new file mode 100644
index 0000000..e300bce
--- /dev/null
+++ b/src/main/provisioning/repoinit.txt
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+[feature name=repoinit]
+
+[artifacts]
+ org.apache.sling/org.apache.sling.repoinit.parser/0.0.1-SNAPSHOT
+ org.apache.sling/org.apache.sling.repoinit.oak-jcr/0.0.1-SNAPSHOT
+
\ No newline at end of file
diff --git a/src/main/provisioning/sling.txt b/src/main/provisioning/sling.txt
new file mode 100644
index 0000000..4908aad
--- /dev/null
+++ b/src/main/provisioning/sling.txt
@@ -0,0 +1,176 @@
+#
+# 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.
+#
+# The feature for Apache Sling
+[feature name=sling]
+
+[variables]
+ jackrabbit.version=2.12.1
+
+[artifacts]
+ commons-collections/commons-collections/3.2.2
+ org.apache.commons/commons-collections4/4.1
+ commons-codec/commons-codec/1.9
+ commons-lang/commons-lang/2.6
+ org.apache.commons/commons-lang3/3.4
+ org.apache.commons/commons-math/2.2
+ org.apache.geronimo.bundles/commons-httpclient/3.1_1
+ org.apache.httpcomponents/httpcore-osgi/4.4.1
+ org.apache.httpcomponents/httpclient-osgi/4.4.1
+ com.google.guava/guava/15.0
+ org.apache.sling/org.apache.sling.adapter/2.1.6
+ org.apache.sling/org.apache.sling.api/2.11.1-SNAPSHOT
+ org.apache.sling/org.apache.sling.auth.core/1.3.14
+ org.apache.sling/org.apache.sling.auth.form/1.0.8
+ org.apache.sling/org.apache.sling.bundleresource.impl/2.2.0
+ org.apache.sling/org.apache.sling.commons.classloader/1.3.2
+ org.apache.sling/org.apache.sling.commons.compiler/2.3.0
+ org.apache.sling/org.apache.sling.commons.fsclassloader/1.0.3-SNAPSHOT
+ org.apache.sling/org.apache.sling.commons.mime/2.1.9-SNAPSHOT
+ org.apache.sling/org.apache.sling.commons.osgi/2.4.0
+ org.apache.sling/org.apache.sling.commons.scheduler/2.4.14
+ org.apache.sling/org.apache.sling.commons.threads/3.2.5-SNAPSHOT
+ org.apache.sling/org.apache.sling.discovery.api/1.0.2
+ org.apache.sling/org.apache.sling.discovery.support/1.0.0
+ org.apache.sling/org.apache.sling.discovery.commons/1.0.10
+ org.apache.sling/org.apache.sling.discovery.base/1.1.2
+ org.apache.sling/org.apache.sling.discovery.oak/1.2.6
+ org.apache.sling/org.apache.sling.engine/2.4.7-SNAPSHOT
+ org.apache.sling/org.apache.sling.event/4.0.0
+ org.apache.sling/org.apache.sling.event.dea/1.0.4
+ org.apache.sling/org.apache.sling.fsresource/1.1.5-SNAPSHOT
+ org.apache.sling/org.apache.sling.hc.core/1.2.2
+ org.apache.sling/org.apache.sling.hc.webconsole/1.1.2
+ org.apache.sling/org.apache.sling.i18n/2.4.6
+ org.apache.sling/org.apache.sling.installer.console/1.0.1-SNAPSHOT
+ org.apache.sling/org.apache.sling.installer.provider.jcr/3.1.17-SNAPSHOT
+ org.apache.sling/org.apache.sling.jcr.contentloader/2.1.11-SNAPSHOT
+ org.apache.sling/org.apache.sling.jcr.resource/2.7.4
+ org.apache.sling/org.apache.sling.launchpad.content/2.0.8
+ org.apache.sling/org.apache.sling.models.api/1.2.2
+ org.apache.sling/org.apache.sling.models.impl/1.2.6
+ org.apache.sling/org.apache.sling.resourceresolver/1.4.12
+ org.apache.sling/org.apache.sling.scripting.api/2.1.8
+ org.apache.sling/org.apache.sling.scripting.core/2.0.37-SNAPSHOT
+ org.apache.sling/org.apache.sling.scripting.javascript/2.0.28
+ org.apache.sling/org.apache.sling.scripting.jsp/2.1.8
+ org.apache.sling/org.apache.sling.scripting.jsp.taglib/2.2.5-SNAPSHOT
+ org.apache.sling/org.apache.sling.scripting.sightly/1.0.16
+ org.apache.sling/org.apache.sling.scripting.sightly.js.provider/1.0.10
+ org.apache.sling/org.apache.sling.scripting.sightly.models.provider/1.0.0
+ org.apache.sling/org.apache.sling.scripting.sightly.repl/1.0.2
+ org.apache.sling/org.apache.sling.serviceusermapper/1.2.2
+ org.apache.sling/org.apache.sling.servlets.get/2.1.14
+ org.apache.sling/org.apache.sling.servlets.post/2.3.10
+ org.apache.sling/org.apache.sling.servlets.resolver/2.4.3-SNAPSHOT
+ org.apache.sling/org.apache.sling.xss/1.0.8
+ javax.mail/mail/1.4.7
+ org.apache.geronimo.bundles/jstl/1.2_1
+ org.apache.felix/org.apache.felix.http.whiteboard/3.0.0
+
+[artifacts startLevel=5]
+ org.apache.sling/org.apache.sling.extensions.webconsolebranding/1.0.0
+ org.apache.sling/org.apache.sling.extensions.webconsolesecurityprovider/1.0.0
+ org.apache.felix/org.apache.felix.inventory/1.0.4
+ org.apache.felix/org.apache.felix.prefs/1.0.6
+ org.apache.felix/org.apache.felix.webconsole/4.2.14
+ org.apache.geronimo.bundles/json/20090211_1
+ org.apache.felix/org.apache.felix.webconsole.plugins.ds/2.0.2
+ org.apache.felix/org.apache.felix.webconsole.plugins.obr/1.0.2
+ org.apache.felix/org.apache.felix.webconsole.plugins.packageadmin/1.0.2
+ org.apache.felix/org.apache.felix.webconsole.plugins.event/1.1.4
+ org.apache.felix/org.apache.felix.webconsole.plugins.memoryusage/1.0.6
+ org.apache.sling/org.apache.sling.commons.json/2.0.16
+ org.apache.felix/org.apache.felix.bundlerepository/1.6.4
+ org.apache.sling/org.apache.sling.extensions.threaddump/0.2.2
+ org.apache.aries.jmx/org.apache.aries.jmx.api/1.1.0
+ org.apache.aries.jmx/org.apache.aries.jmx.core/1.1.1
+ org.apache.aries.jmx/org.apache.aries.jmx.whiteboard/1.0.0
+ commons-io/commons-io/2.4
+ commons-fileupload/commons-fileupload/1.3.1
+
+[artifacts startLevel=10]
+ org.apache.felix/org.apache.felix.http.sslfilter/1.0.4
+ org.apache.felix/org.apache.felix.scr/2.0.2
+ org.apache.felix/org.apache.felix.metatype/1.1.2
+ org.apache.tika/tika-core/1.11
+ org.apache.tika/tika-bundle/1.11
+
+[artifacts startLevel=15]
+ org.apache.sling/org.apache.sling.jcr.jcr-wrapper/2.0.0
+ org.apache.sling/org.apache.sling.jcr.api/2.3.1-SNAPSHOT
+ org.apache.sling/org.apache.sling.jcr.base/2.3.3-SNAPSHOT
+ org.apache.sling/org.apache.sling.jcr.registration/1.0.2
+ org.apache.jackrabbit/jackrabbit-api/${jackrabbit.version}
+ org.apache.jackrabbit/jackrabbit-jcr-commons/${jackrabbit.version}
+ org.apache.jackrabbit/jackrabbit-spi/${jackrabbit.version}
+ org.apache.jackrabbit/jackrabbit-spi-commons/${jackrabbit.version}
+ org.apache.jackrabbit/jackrabbit-webdav/${jackrabbit.version}
+ org.apache.jackrabbit/jackrabbit-jcr-rmi/${jackrabbit.version}
+ org.apache.jackrabbit/jackrabbit-data/${jackrabbit.version}
+ org.apache.sling/org.apache.sling.jcr.webdav/2.3.5-SNAPSHOT
+ org.apache.sling/org.apache.sling.jcr.davex/1.3.3-SNAPSHOT
+ org.apache.sling/org.apache.sling.jcr.jackrabbit.usermanager/2.2.4
+ org.apache.sling/org.apache.sling.jcr.jackrabbit.accessmanager/2.1.2
+ org.apache.sling/org.apache.sling.jcr.webconsole/1.0.2
+ org.apache.sling/org.apache.sling.extensions.explorer/1.0.4
+ io.dropwizard.metrics/metrics-core/3.1.0
+ org.apache.sling/org.apache.sling.commons.metrics/1.0.1-SNAPSHOT
+
+[configurations]
+ org.apache.sling.engine.impl.log.RequestLogger
+ access.log.enabled=B"true"
+ request.log.outputtype=I"0"
+ access.log.output="log.access"
+ request.log.output="log.request"
+ request.log.enabled=B"true"
+ access.log.outputtype=I"0"
+
+ org.apache.sling.commons.log.LogManager
+ org.apache.sling.commons.log.pattern="%d{dd.MM.yyyy HH:mm:ss.SSS}\ *%level*\ [%thread]\ %logger\ %msg%n"
+ org.apache.sling.commons.log.file="logs/error.log"
+ org.apache.sling.commons.log.level="info"
+ org.apache.sling.commons.log.file.size="'.'yyyy-MM-dd"
+ org.apache.sling.commons.log.file.number=I"7"
+
+ org.apache.sling.commons.log.LogManager.factory.config-access.log
+ org.apache.sling.commons.log.pattern="%msg%n"
+ org.apache.sling.commons.log.names=["log.access"]
+ org.apache.sling.commons.log.file="logs/access.log"
+ org.apache.sling.commons.log.level="info"
+
+ org.apache.sling.commons.log.LogManager.factory.config-request.log
+ org.apache.sling.commons.log.pattern="%msg%n"
+ org.apache.sling.commons.log.names=["log.request"]
+ org.apache.sling.commons.log.file="logs/request.log"
+ org.apache.sling.commons.log.level="info"
+
+ # configure the ScriptCache for scripts used by org.apache.sling.scripting.sightly.js.provider
+ org.apache.sling.scripting.core.impl.ScriptCacheImpl
+ org.apache.sling.scripting.cache.additional_extensions=["js"]
+
+ # WebDAV servlet requires config now
+ org.apache.sling.jcr.webdav.impl.servlets.SimpleWebDavServlet
+ dav.root="/dav"
+
+ # DavEx servlet requires config now
+ org.apache.sling.jcr.davex.impl.servlets.SlingDavExServlet
+ alias="/server"
+
+ org.apache.sling.resourceresolver.impl.observation.OsgiObservationBridge
+ enabled=B"true"
diff --git a/src/main/provisioning/standalone.txt b/src/main/provisioning/standalone.txt
new file mode 100644
index 0000000..06aace4
--- /dev/null
+++ b/src/main/provisioning/standalone.txt
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+# The :standalone feature contains artifacts for the standalone jar
+#
+[feature name=standalone]
+
+# Add a servlet implementation for the standalone case
+[artifacts startLevel=5 runModes=:standalone]
+ org.apache.felix/org.apache.felix.http.servlet-api/1.1.2
+ org.apache.felix/org.apache.felix.http.jetty/3.1.4
diff --git a/src/test/java/org/apache/sling/repoinit/it/ProvisioningModelIT.java b/src/test/java/org/apache/sling/repoinit/it/ProvisioningModelIT.java
new file mode 100644
index 0000000..df00cb3
--- /dev/null
+++ b/src/test/java/org/apache/sling/repoinit/it/ProvisioningModelIT.java
@@ -0,0 +1,67 @@
+/*
+ * 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.repoinit.it;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import javax.jcr.Session;
+
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.apache.sling.repoinit.parser.RepoInitParser;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+@Ignore("Fails for now - initializer not executed?")
+/** Test repoinit statements supplied by our provisioning model */
+public class ProvisioningModelIT {
+
+ private Session session;
+ private static final String TEST_PATH = "/repoinit/fromProvisioningModel";
+ private static final String TEST_USER = "fromProvisioningModel";
+
+ @Rule
+ public TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "IT");
+
+ @Before
+ public void setup() throws Exception {
+ WaitFor.services(teleporter, SlingRepository.class, RepoInitParser.class);
+ session = teleporter.getService(SlingRepository.class).loginAdministrative(null);
+ }
+
+ @After
+ public void cleanup() {
+ if(session != null) {
+ session.logout();
+ }
+ }
+
+ @Test
+ public void provisioningModelUserExists() throws Exception {
+ assertTrue("Expecting user " + TEST_USER, U.userExists(session, TEST_USER));
+ }
+
+ @Test
+ public void provisioningModelUserAcl() throws Exception {
+ assertTrue("Expecting read access", U.canRead(session, TEST_USER, TEST_PATH));
+ assertFalse("Expecting no write access", U.canWrite(session, TEST_USER, TEST_PATH));
+ }
+}
diff --git a/src/test/java/org/apache/sling/repoinit/it/RepoInitIT.java b/src/test/java/org/apache/sling/repoinit/it/RepoInitIT.java
index b40742f..6c188fe 100644
--- a/src/test/java/org/apache/sling/repoinit/it/RepoInitIT.java
+++ b/src/test/java/org/apache/sling/repoinit/it/RepoInitIT.java
@@ -22,18 +22,9 @@
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.UUID;
-import javax.jcr.AccessDeniedException;
-import javax.jcr.LoginException;
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import org.apache.jackrabbit.api.JackrabbitSession;
-import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.sling.jcr.api.SlingRepository;
import org.apache.sling.junit.rules.TeleporterRule;
import org.apache.sling.repoinit.jcr.JcrRepoInitOpVisitor;
@@ -89,41 +80,12 @@
}
}
- private boolean userExists(String id) throws LoginException, RepositoryException, InterruptedException {
- final Authorizable a = ((JackrabbitSession)session).getUserManager().getAuthorizable(id);
- return a != null;
- }
-
- private Session getServiceSession(String serviceId) throws LoginException, RepositoryException {
- return session.impersonate(new SimpleCredentials(serviceId, new char[0]));
- }
-
- /** True if user can write to specified path.
- * @throws PathNotFoundException if the path doesn't exist */
- private boolean canWrite(String userId, String path) throws PathNotFoundException,RepositoryException {
- if(!session.itemExists(path)) {
- throw new PathNotFoundException(path);
- }
-
- final Session serviceSession = getServiceSession(userId);
- final String testNodeName = "test_" + UUID.randomUUID().toString();
- try {
- ((Node)serviceSession.getItem(path)).addNode(testNodeName);
- serviceSession.save();
- } catch(AccessDeniedException ade) {
- return false;
- } finally {
- serviceSession.logout();
- }
- return true;
- }
-
@Test
public void serviceUserCreated() throws Exception {
new Retry() {
@Override
public Void call() throws Exception {
- assertTrue("Expecting user " + FRED_WILMA, userExists(FRED_WILMA));
+ assertTrue("Expecting user " + FRED_WILMA, U.userExists(session, FRED_WILMA));
return null;
}
};
@@ -134,8 +96,8 @@
new Retry() {
@Override
public Void call() throws Exception {
- assertFalse("Expecting no write access to A", canWrite(FRED_WILMA, "/acltest/A"));
- assertTrue("Expecting write access to A/B", canWrite(FRED_WILMA, "/acltest/A/B"));
+ assertFalse("Expecting no write access to A", U.canWrite(session, FRED_WILMA, "/acltest/A"));
+ assertTrue("Expecting write access to A/B", U.canWrite(session, FRED_WILMA, "/acltest/A/B"));
return null;
}
};
@@ -146,8 +108,8 @@
new Retry() {
@Override
public Void call() throws Exception {
- assertTrue("Expecting write access to A", canWrite(ANOTHER, "/acltest/A"));
- assertFalse("Expecting no write access to B", canWrite(ANOTHER, "/acltest/A/B"));
+ assertTrue("Expecting write access to A", U.canWrite(session, ANOTHER, "/acltest/A"));
+ assertFalse("Expecting no write access to B", U.canWrite(session, ANOTHER, "/acltest/A/B"));
return null;
}
};
diff --git a/src/test/java/org/apache/sling/repoinit/it/U.java b/src/test/java/org/apache/sling/repoinit/it/U.java
new file mode 100644
index 0000000..918597d
--- /dev/null
+++ b/src/test/java/org/apache/sling/repoinit/it/U.java
@@ -0,0 +1,80 @@
+/*
+ * 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.repoinit.it;
+
+import java.util.UUID;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.LoginException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.Authorizable;
+
+/** Test utilities */
+public class U {
+ public static boolean userExists(Session session, String id) throws LoginException, RepositoryException, InterruptedException {
+ final Authorizable a = ((JackrabbitSession)session).getUserManager().getAuthorizable(id);
+ return a != null;
+ }
+
+ public static Session getServiceSession(Session session, String serviceId) throws LoginException, RepositoryException {
+ return session.impersonate(new SimpleCredentials(serviceId, new char[0]));
+ }
+
+ /** True if user can write to specified path.
+ * @throws PathNotFoundException if the path doesn't exist */
+ public static boolean canWrite(Session session, String userId, String path) throws PathNotFoundException,RepositoryException {
+ if(!session.itemExists(path)) {
+ throw new PathNotFoundException(path);
+ }
+
+ final Session serviceSession = getServiceSession(session, userId);
+ final String testNodeName = "test_" + UUID.randomUUID().toString();
+ try {
+ ((Node)serviceSession.getItem(path)).addNode(testNodeName);
+ serviceSession.save();
+ } catch(AccessDeniedException ade) {
+ return false;
+ } finally {
+ serviceSession.logout();
+ }
+ return true;
+ }
+
+ /** True if user can read specified path.
+ * @throws PathNotFoundException if the path doesn't exist */
+ public static boolean canRead(Session session, String userId, String path) throws PathNotFoundException,RepositoryException {
+ if(!session.itemExists(path)) {
+ throw new PathNotFoundException(path);
+ }
+
+ final Session serviceSession = getServiceSession(session, userId);
+ try {
+ serviceSession.getItem(path);
+ } catch(AccessDeniedException ade) {
+ return false;
+ } finally {
+ serviceSession.logout();
+ }
+ return true;
+ }
+}
\ No newline at end of file