You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2016/02/01 15:51:29 UTC
svn commit: r1727946 - in /sling/trunk/launchpad:
builder/src/main/provisioning/
integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/repository/
test-bundles/src/main/provisioning/ test-services/
test-services/src/main/jav...
Author: bdelacretaz
Date: Mon Feb 1 14:51:29 2016
New Revision: 1727946
URL: http://svn.apache.org/viewvc?rev=1727946&view=rev
Log:
SLING-5449 - RepositoryInitializer integration test, creates a system user
Added:
sling/trunk/launchpad/builder/src/main/provisioning/repoinit.txt
sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/repository/SystemUsersTest.java
sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/repository/SystemUsersInitializer.java
sling/trunk/launchpad/test-services/src/main/resources/repoinit.txt
Modified:
sling/trunk/launchpad/test-bundles/src/main/provisioning/bundles.txt
sling/trunk/launchpad/test-services/pom.xml
Added: sling/trunk/launchpad/builder/src/main/provisioning/repoinit.txt
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/src/main/provisioning/repoinit.txt?rev=1727946&view=auto
==============================================================================
--- sling/trunk/launchpad/builder/src/main/provisioning/repoinit.txt (added)
+++ sling/trunk/launchpad/builder/src/main/provisioning/repoinit.txt Mon Feb 1 14:51:29 2016
@@ -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
Added: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/repository/SystemUsersTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/repository/SystemUsersTest.java?rev=1727946&view=auto
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/repository/SystemUsersTest.java (added)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/repository/SystemUsersTest.java Mon Feb 1 14:51:29 2016
@@ -0,0 +1,57 @@
+/*
+ * 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.launchpad.webapp.integrationtest.repository;
+
+import static org.junit.Assert.fail;
+import javax.jcr.Credentials;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.junit.Rule;
+import org.junit.Test;
+
+/** Verify that required system users have been created */
+public class SystemUsersTest {
+
+ @Rule
+ public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "Launchpad");
+
+ private void assertSystemUser(String name) throws RepositoryException {
+ final SlingRepository repo = teleporter.getService(SlingRepository.class);
+ final Session s = repo.loginAdministrative(null);
+ try {
+ final Credentials creds = new SimpleCredentials(name, new char[] {});
+ try {
+ s.impersonate(creds);
+ } catch(RepositoryException rex) {
+ fail("Impersonation as " + name + " failed: " + rex.toString());
+ }
+ } finally {
+ s.logout();
+ }
+ }
+
+ @Test
+ public void launchpadTestingUser() throws RepositoryException {
+ // This user is created by a RepositoryInitalizer in our
+ // test-services bundle
+ assertSystemUser("launchpad_testing");
+ }
+}
\ No newline at end of file
Modified: sling/trunk/launchpad/test-bundles/src/main/provisioning/bundles.txt
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-bundles/src/main/provisioning/bundles.txt?rev=1727946&r1=1727945&r2=1727946&view=diff
==============================================================================
--- sling/trunk/launchpad/test-bundles/src/main/provisioning/bundles.txt (original)
+++ sling/trunk/launchpad/test-bundles/src/main/provisioning/bundles.txt Mon Feb 1 14:51:29 2016
@@ -27,6 +27,8 @@
org.apache.sling/org.apache.sling.junit.remote/1.0.11-SNAPSHOT
org.apache.sling/org.apache.sling.junit.scriptable/1.0.11-SNAPSHOT
org.apache.sling/org.apache.sling.launchpad.test-fragment/2.0.9-SNAPSHOT
+
+[artifacts startLevel=5]
org.apache.sling/org.apache.sling.launchpad.test-services-war/2.0.8/war
org.apache.sling/org.apache.sling.launchpad.test-services/2.0.8
Modified: sling/trunk/launchpad/test-services/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/pom.xml?rev=1727946&r1=1727945&r2=1727946&view=diff
==============================================================================
--- sling/trunk/launchpad/test-services/pom.xml (original)
+++ sling/trunk/launchpad/test-services/pom.xml Mon Feb 1 14:51:29 2016
@@ -190,6 +190,18 @@
<version>2.1.2</version>
</dependency>
<dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.repoinit.parser</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.repoinit.oak-jcr</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
Added: sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/repository/SystemUsersInitializer.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/repository/SystemUsersInitializer.java?rev=1727946&view=auto
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/repository/SystemUsersInitializer.java (added)
+++ sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/repository/SystemUsersInitializer.java Mon Feb 1 14:51:29 2016
@@ -0,0 +1,75 @@
+/*
+ * 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.launchpad.testservices.repository;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import javax.jcr.Session;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.api.SlingRepositoryInitializer;
+import org.apache.sling.repoinit.jcr.JcrRepoInitOpVisitor;
+import org.apache.sling.repoinit.parser.RepoInitParser;
+import org.apache.sling.repoinit.parser.operations.Operation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * SlingRepositoryInitializer that creates system users and sets their ACLs.
+ * Meant to be used for our integration tests until we can create those from
+ * the provisioning model.
+ */
+@Component
+@Service(SlingRepositoryInitializer.class)
+public class SystemUsersInitializer implements SlingRepositoryInitializer {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ public static final String REPOINIT_FILE = "/repoinit.txt";
+
+ @Reference
+ private RepoInitParser parser;
+
+ @Override
+ public void processRepository(SlingRepository repo) throws Exception {
+ final Session s = repo.loginAdministrative(null);
+ final InputStream is = getClass().getResourceAsStream(REPOINIT_FILE);
+ try {
+ if(is == null) {
+ throw new IOException("Class Resource not found:" + REPOINIT_FILE);
+ }
+ final Reader r = new InputStreamReader(is, "UTF-8");
+ JcrRepoInitOpVisitor v = new JcrRepoInitOpVisitor(s);
+ int count = 0;
+ for(Operation op : parser.parse(r)) {
+ op.accept(v);
+ count++;
+ }
+ s.save();
+ log.info("{} repoinit Operations executed", count);
+ } finally {
+ s.logout();
+ is.close();
+ }
+ }
+}
Added: sling/trunk/launchpad/test-services/src/main/resources/repoinit.txt
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/resources/repoinit.txt?rev=1727946&view=auto
==============================================================================
--- sling/trunk/launchpad/test-services/src/main/resources/repoinit.txt (added)
+++ sling/trunk/launchpad/test-services/src/main/resources/repoinit.txt Mon Feb 1 14:51:29 2016
@@ -0,0 +1,22 @@
+#
+# 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.
+#
+
+#Â No tests rely on this so far but we can add
+# more repoinit statements here as needed.
+create service user launchpad_testing
\ No newline at end of file