You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "tmaret (via GitHub)" <gi...@apache.org> on 2024/04/23 14:37:29 UTC
[PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
tmaret opened a new pull request, #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "tmaret (via GitHub)" <gi...@apache.org>.
tmaret commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1576408193
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserContentPackageIT.java:
##########
@@ -105,6 +105,15 @@ public void installUserA_Replace_PkgPath() throws RepositoryException, IOExcepti
installUserA(ImportMode.REPLACE, true, true);
}
+ @Test
+ public void installUserA_Underscores() throws RepositoryException, IOException, PackageException {
Review Comment:
Thanks for looking at this @kwin !
I suggest to add a breakpoint [here](https://github.com/apache/jackrabbit-filevault/blob/81fa88f1d7af07e77871e2c0bb03515107f18d74/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java#L1047) while running the test. You should see that the `info.path` has been transformed to `/home/users/test/6k:test-user-a` while it was `/home/users/test/_6k_test-user-a` in the package.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1576442352
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserContentPackageIT.java:
##########
@@ -105,6 +105,15 @@ public void installUserA_Replace_PkgPath() throws RepositoryException, IOExcepti
installUserA(ImportMode.REPLACE, true, true);
}
+ @Test
+ public void installUserA_Underscores() throws RepositoryException, IOException, PackageException {
Review Comment:
For me this package this IT only proofs that the escaped filename `_6k_LELiIYRQppWQpR3W` is correctly deescaped into `6k:LELiIYRQppWQpR3W`, please try to come up with a test case which shows inconsistencies with a round trip test.
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserContentPackageIT.java:
##########
@@ -105,6 +105,15 @@ public void installUserA_Replace_PkgPath() throws RepositoryException, IOExcepti
installUserA(ImportMode.REPLACE, true, true);
}
+ @Test
+ public void installUserA_Underscores() throws RepositoryException, IOException, PackageException {
Review Comment:
For me this package/this IT only proofs that the escaped filename `_6k_LELiIYRQppWQpR3W` is correctly deescaped into `6k:LELiIYRQppWQpR3W`, please try to come up with a test case which shows inconsistencies with a round trip test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#issuecomment-2085429128
Superseded by #336
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "tmaret (via GitHub)" <gi...@apache.org>.
tmaret commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1576434881
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserContentPackageIT.java:
##########
@@ -105,6 +105,15 @@ public void installUserA_Replace_PkgPath() throws RepositoryException, IOExcepti
installUserA(ImportMode.REPLACE, true, true);
}
+ @Test
+ public void installUserA_Underscores() throws RepositoryException, IOException, PackageException {
Review Comment:
Potentially, the actual path we found in the FileVault package when we observed the issue was
```
jcr_root/home/users/_/_6k_LELiIYRQppWQpR3W/
```
which has a `_` parent that may be relevant to reproduce on export.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1576382464
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserContentPackageIT.java:
##########
@@ -105,6 +105,15 @@ public void installUserA_Replace_PkgPath() throws RepositoryException, IOExcepti
installUserA(ImportMode.REPLACE, true, true);
}
+ @Test
+ public void installUserA_Underscores() throws RepositoryException, IOException, PackageException {
Review Comment:
nit: might be better to unpack the ZIP so we don't have a binary here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "tmaret (via GitHub)" <gi...@apache.org>.
tmaret commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1576904733
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserContentPackageIT.java:
##########
@@ -105,6 +105,15 @@ public void installUserA_Replace_PkgPath() throws RepositoryException, IOExcepti
installUserA(ImportMode.REPLACE, true, true);
}
+ @Test
+ public void installUserA_Underscores() throws RepositoryException, IOException, PackageException {
Review Comment:
Indeed, I could reproduce with the export. Added a test that covers that part.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin closed pull request #334: JCRVLT-751 - Add a test that demonstrates the issue
URL: https://github.com/apache/jackrabbit-filevault/pull/334
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1576439001
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserContentPackageIT.java:
##########
@@ -105,6 +105,15 @@ public void installUserA_Replace_PkgPath() throws RepositoryException, IOExcepti
installUserA(ImportMode.REPLACE, true, true);
}
+ @Test
+ public void installUserA_Underscores() throws RepositoryException, IOException, PackageException {
Review Comment:
According to https://jackrabbit.apache.org/filevault/vaultfs.html#filename-escaping this should be rather `jcr_root/home/users/__6k_LELiIYRQppWQpR3W/`. The question really is how the structure is in the original repo (before export).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1583500633
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserExportIT.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.jackrabbit.vault.packaging.integration;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.zip.Deflater;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.vault.fs.api.ImportMode;
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter;
+import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
+import org.apache.jackrabbit.vault.fs.io.Archive;
+import org.apache.jackrabbit.vault.fs.io.ImportOptions;
+import org.apache.jackrabbit.vault.fs.io.Importer;
+import org.apache.jackrabbit.vault.fs.io.ZipStreamArchive;
+import org.apache.jackrabbit.vault.packaging.ExportOptions;
+import org.apache.jackrabbit.vault.packaging.PackageException;
+import org.apache.jackrabbit.vault.packaging.PackageProperties;
+import org.apache.jackrabbit.vault.packaging.VaultPackage;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static java.util.UUID.randomUUID;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class UserExportIT extends IntegrationTestBase {
+ private static final Logger log = LoggerFactory.getLogger(UserExportIT.class);
+ private static final String TEST_USER_INTERMEDIATE_PATH = "/home/users/_";
+ private static final String TEST_USER_REP_USER_NAME = "_6k_test";
+ private static final String TEST_USER_ID = "user1";
+ private static final String TEST_USER_PATH = String.format("%s/%s", TEST_USER_INTERMEDIATE_PATH, TEST_USER_REP_USER_NAME);
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ clean(TEST_USER_PATH);
+ }
+
+ @Test
+ public void testFileNameEscaping() throws RepositoryException, ConfigurationException, IOException, PackageException {
+ assertNull(getTestUser());
+ log.info("Test user does not exist");
+ User test = ((JackrabbitSession) admin).getUserManager().createUser(TEST_USER_ID, randomUUID().toString(), new PrincipalImpl(TEST_USER_ID), TEST_USER_INTERMEDIATE_PATH);
+ admin.move(test.getPath(), TEST_USER_PATH);
+ admin.save();
+ assertNotNull(getTestUser());
+ log.info("Test user created at path {}", test.getPath());
+ byte[] serialised = export(admin, TEST_USER_PATH);
+ File tmpFile = File.createTempFile("test", ".zip");
+ try (FileOutputStream fso = new FileOutputStream(tmpFile)) {
+ fso.write(serialised);
+ }
+ log.info("Test user exported at path {}", tmpFile.getAbsolutePath());
+ clean(TEST_USER_PATH);
+ assertNull(getTestUser());
+ log.info("Test user removed from the repository");
+ importPackage(admin, new ByteArrayInputStream(serialised));
+ assertNotNull(getTestUser());
+ log.info("Test user imported");
+ }
+
+ private User getTestUser() throws RepositoryException {
+ return (User) ((JackrabbitSession) admin).getUserManager().getAuthorizable(TEST_USER_ID);
+ }
+
+ private void importPackage(Session session, InputStream is) throws IOException, ConfigurationException, RepositoryException, PackageException {
+ ImportOptions opts = new ImportOptions();
+ opts.setAccessControlHandling(AccessControlHandling.OVERWRITE);
+ opts.setCugHandling(AccessControlHandling.OVERWRITE);
+ opts.setImportMode(ImportMode.REPLACE);
+ opts.setPatchKeepInRepo(false);
+ opts.setAutoSaveThreshold(-1);
+ opts.setStrict(true);
+ Importer importer = new Importer(opts);
+ try (Archive archive = new ZipStreamArchive(is)) {
+ archive.open(false);
+ importer.run(archive, session, "/");
+ if (importer.hasErrors() && opts.isStrict(true)) {
+ throw new RuntimeException("Failed to import");
+ }
+ }
+ }
+
+
+ private byte[] export(Session session, String authorizablePath) throws IOException, RepositoryException, ConfigurationException {
+
+ PathFilterSet nodeFilters = new PathFilterSet(authorizablePath);
+ PathFilterSet propertyFilters = new PathFilterSet(authorizablePath);
+
+ DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+ filter.add(nodeFilters, propertyFilters);
+
+ DefaultMetaInf inf = new DefaultMetaInf();
+ inf.setFilter(filter);
+
+ Properties props = new Properties();
+ props.setProperty(VaultPackage.NAME_GROUP, "jackrabbit/sync");
+ props.setProperty(VaultPackage.NAME_NAME, randomUUID().toString());
+ props.setProperty(VaultPackage.NAME_VERSION, "0.0.1");
+ props.setProperty(PackageProperties.NAME_USE_BINARY_REFERENCES, String.valueOf(true));
+ inf.setProperties(props);
+
+ ExportOptions opts = new ExportOptions();
+ opts.setMetaInf(inf);
+
+ opts.setRootPath(authorizablePath);
Review Comment:
it works once you comment this and the following line. Not sure yet, in which format those are supposed to be passed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1576412490
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserContentPackageIT.java:
##########
@@ -105,6 +105,15 @@ public void installUserA_Replace_PkgPath() throws RepositoryException, IOExcepti
installUserA(ImportMode.REPLACE, true, true);
}
+ @Test
+ public void installUserA_Underscores() throws RepositoryException, IOException, PackageException {
Review Comment:
To me it seems that this is problem with the export rather than with the import according to https://jackrabbit.apache.org/filevault/vaultfs.html#filename-escaping.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1583500633
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserExportIT.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.jackrabbit.vault.packaging.integration;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.zip.Deflater;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.vault.fs.api.ImportMode;
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter;
+import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
+import org.apache.jackrabbit.vault.fs.io.Archive;
+import org.apache.jackrabbit.vault.fs.io.ImportOptions;
+import org.apache.jackrabbit.vault.fs.io.Importer;
+import org.apache.jackrabbit.vault.fs.io.ZipStreamArchive;
+import org.apache.jackrabbit.vault.packaging.ExportOptions;
+import org.apache.jackrabbit.vault.packaging.PackageException;
+import org.apache.jackrabbit.vault.packaging.PackageProperties;
+import org.apache.jackrabbit.vault.packaging.VaultPackage;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static java.util.UUID.randomUUID;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class UserExportIT extends IntegrationTestBase {
+ private static final Logger log = LoggerFactory.getLogger(UserExportIT.class);
+ private static final String TEST_USER_INTERMEDIATE_PATH = "/home/users/_";
+ private static final String TEST_USER_REP_USER_NAME = "_6k_test";
+ private static final String TEST_USER_ID = "user1";
+ private static final String TEST_USER_PATH = String.format("%s/%s", TEST_USER_INTERMEDIATE_PATH, TEST_USER_REP_USER_NAME);
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ clean(TEST_USER_PATH);
+ }
+
+ @Test
+ public void testFileNameEscaping() throws RepositoryException, ConfigurationException, IOException, PackageException {
+ assertNull(getTestUser());
+ log.info("Test user does not exist");
+ User test = ((JackrabbitSession) admin).getUserManager().createUser(TEST_USER_ID, randomUUID().toString(), new PrincipalImpl(TEST_USER_ID), TEST_USER_INTERMEDIATE_PATH);
+ admin.move(test.getPath(), TEST_USER_PATH);
+ admin.save();
+ assertNotNull(getTestUser());
+ log.info("Test user created at path {}", test.getPath());
+ byte[] serialised = export(admin, TEST_USER_PATH);
+ File tmpFile = File.createTempFile("test", ".zip");
+ try (FileOutputStream fso = new FileOutputStream(tmpFile)) {
+ fso.write(serialised);
+ }
+ log.info("Test user exported at path {}", tmpFile.getAbsolutePath());
+ clean(TEST_USER_PATH);
+ assertNull(getTestUser());
+ log.info("Test user removed from the repository");
+ importPackage(admin, new ByteArrayInputStream(serialised));
+ assertNotNull(getTestUser());
+ log.info("Test user imported");
+ }
+
+ private User getTestUser() throws RepositoryException {
+ return (User) ((JackrabbitSession) admin).getUserManager().getAuthorizable(TEST_USER_ID);
+ }
+
+ private void importPackage(Session session, InputStream is) throws IOException, ConfigurationException, RepositoryException, PackageException {
+ ImportOptions opts = new ImportOptions();
+ opts.setAccessControlHandling(AccessControlHandling.OVERWRITE);
+ opts.setCugHandling(AccessControlHandling.OVERWRITE);
+ opts.setImportMode(ImportMode.REPLACE);
+ opts.setPatchKeepInRepo(false);
+ opts.setAutoSaveThreshold(-1);
+ opts.setStrict(true);
+ Importer importer = new Importer(opts);
+ try (Archive archive = new ZipStreamArchive(is)) {
+ archive.open(false);
+ importer.run(archive, session, "/");
+ if (importer.hasErrors() && opts.isStrict(true)) {
+ throw new RuntimeException("Failed to import");
+ }
+ }
+ }
+
+
+ private byte[] export(Session session, String authorizablePath) throws IOException, RepositoryException, ConfigurationException {
+
+ PathFilterSet nodeFilters = new PathFilterSet(authorizablePath);
+ PathFilterSet propertyFilters = new PathFilterSet(authorizablePath);
+
+ DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+ filter.add(nodeFilters, propertyFilters);
+
+ DefaultMetaInf inf = new DefaultMetaInf();
+ inf.setFilter(filter);
+
+ Properties props = new Properties();
+ props.setProperty(VaultPackage.NAME_GROUP, "jackrabbit/sync");
+ props.setProperty(VaultPackage.NAME_NAME, randomUUID().toString());
+ props.setProperty(VaultPackage.NAME_VERSION, "0.0.1");
+ props.setProperty(PackageProperties.NAME_USE_BINARY_REFERENCES, String.valueOf(true));
+ inf.setProperties(props);
+
+ ExportOptions opts = new ExportOptions();
+ opts.setMetaInf(inf);
+
+ opts.setRootPath(authorizablePath);
Review Comment:
it works once you comment this and the following line. If you really need those options they should be in platform format (not in repo format I guess).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1583506297
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserExportIT.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.jackrabbit.vault.packaging.integration;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.zip.Deflater;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.vault.fs.api.ImportMode;
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter;
+import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
+import org.apache.jackrabbit.vault.fs.io.Archive;
+import org.apache.jackrabbit.vault.fs.io.ImportOptions;
+import org.apache.jackrabbit.vault.fs.io.Importer;
+import org.apache.jackrabbit.vault.fs.io.ZipStreamArchive;
+import org.apache.jackrabbit.vault.packaging.ExportOptions;
+import org.apache.jackrabbit.vault.packaging.PackageException;
+import org.apache.jackrabbit.vault.packaging.PackageProperties;
+import org.apache.jackrabbit.vault.packaging.VaultPackage;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static java.util.UUID.randomUUID;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class UserExportIT extends IntegrationTestBase {
+ private static final Logger log = LoggerFactory.getLogger(UserExportIT.class);
+ private static final String TEST_USER_INTERMEDIATE_PATH = "/home/users/_";
+ private static final String TEST_USER_REP_USER_NAME = "_6k_test";
+ private static final String TEST_USER_ID = "user1";
+ private static final String TEST_USER_PATH = String.format("%s/%s", TEST_USER_INTERMEDIATE_PATH, TEST_USER_REP_USER_NAME);
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ clean(TEST_USER_PATH);
+ }
+
+ @Test
+ public void testFileNameEscaping() throws RepositoryException, ConfigurationException, IOException, PackageException {
+ assertNull(getTestUser());
+ log.info("Test user does not exist");
+ User test = ((JackrabbitSession) admin).getUserManager().createUser(TEST_USER_ID, randomUUID().toString(), new PrincipalImpl(TEST_USER_ID), TEST_USER_INTERMEDIATE_PATH);
+ admin.move(test.getPath(), TEST_USER_PATH);
+ admin.save();
+ assertNotNull(getTestUser());
+ log.info("Test user created at path {}", test.getPath());
+ byte[] serialised = export(admin, TEST_USER_PATH);
+ File tmpFile = File.createTempFile("test", ".zip");
+ try (FileOutputStream fso = new FileOutputStream(tmpFile)) {
+ fso.write(serialised);
+ }
+ log.info("Test user exported at path {}", tmpFile.getAbsolutePath());
+ clean(TEST_USER_PATH);
+ assertNull(getTestUser());
+ log.info("Test user removed from the repository");
+ importPackage(admin, new ByteArrayInputStream(serialised));
+ assertNotNull(getTestUser());
+ log.info("Test user imported");
+ }
+
+ private User getTestUser() throws RepositoryException {
+ return (User) ((JackrabbitSession) admin).getUserManager().getAuthorizable(TEST_USER_ID);
+ }
+
+ private void importPackage(Session session, InputStream is) throws IOException, ConfigurationException, RepositoryException, PackageException {
+ ImportOptions opts = new ImportOptions();
+ opts.setAccessControlHandling(AccessControlHandling.OVERWRITE);
+ opts.setCugHandling(AccessControlHandling.OVERWRITE);
+ opts.setImportMode(ImportMode.REPLACE);
+ opts.setPatchKeepInRepo(false);
+ opts.setAutoSaveThreshold(-1);
+ opts.setStrict(true);
+ Importer importer = new Importer(opts);
+ try (Archive archive = new ZipStreamArchive(is)) {
+ archive.open(false);
+ importer.run(archive, session, "/");
+ if (importer.hasErrors() && opts.isStrict(true)) {
+ throw new RuntimeException("Failed to import");
+ }
+ }
+ }
+
+
+ private byte[] export(Session session, String authorizablePath) throws IOException, RepositoryException, ConfigurationException {
+
+ PathFilterSet nodeFilters = new PathFilterSet(authorizablePath);
+ PathFilterSet propertyFilters = new PathFilterSet(authorizablePath);
+
+ DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+ filter.add(nodeFilters, propertyFilters);
+
+ DefaultMetaInf inf = new DefaultMetaInf();
+ inf.setFilter(filter);
+
+ Properties props = new Properties();
+ props.setProperty(VaultPackage.NAME_GROUP, "jackrabbit/sync");
+ props.setProperty(VaultPackage.NAME_NAME, randomUUID().toString());
+ props.setProperty(VaultPackage.NAME_VERSION, "0.0.1");
+ props.setProperty(PackageProperties.NAME_USE_BINARY_REFERENCES, String.valueOf(true));
+ inf.setProperties(props);
+
+ ExportOptions opts = new ExportOptions();
+ opts.setMetaInf(inf);
+
+ opts.setRootPath(authorizablePath);
Review Comment:
@tripodsan Do you remember which format (repo or platform format) was supposed to be used for `ExportOptions.rootPath` and `ExportOptions.mountPath`? The javadoc is not really clear unfortunately.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1576382464
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserContentPackageIT.java:
##########
@@ -105,6 +105,15 @@ public void installUserA_Replace_PkgPath() throws RepositoryException, IOExcepti
installUserA(ImportMode.REPLACE, true, true);
}
+ @Test
+ public void installUserA_Underscores() throws RepositoryException, IOException, PackageException {
Review Comment:
nit: might be better to unpck the ZIP so we don't have a binary here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1576396863
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserContentPackageIT.java:
##########
@@ -105,6 +105,15 @@ public void installUserA_Replace_PkgPath() throws RepositoryException, IOExcepti
installUserA(ImportMode.REPLACE, true, true);
}
+ @Test
+ public void installUserA_Underscores() throws RepositoryException, IOException, PackageException {
Review Comment:
That would also help me understand the actual issue better with just looking at the PR. I am still not sure what node structure (name and type) leads to the issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] JCRVLT-751 - Add a test that demonstrates the issue [jackrabbit-filevault]
Posted by "kwin (via GitHub)" <gi...@apache.org>.
kwin commented on code in PR #334:
URL: https://github.com/apache/jackrabbit-filevault/pull/334#discussion_r1584893635
##########
vault-core-it/vault-core-integration-tests/src/main/java/org/apache/jackrabbit/vault/packaging/integration/UserExportIT.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.jackrabbit.vault.packaging.integration;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.zip.Deflater;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.vault.fs.api.ImportMode;
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter;
+import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
+import org.apache.jackrabbit.vault.fs.io.Archive;
+import org.apache.jackrabbit.vault.fs.io.ImportOptions;
+import org.apache.jackrabbit.vault.fs.io.Importer;
+import org.apache.jackrabbit.vault.fs.io.ZipStreamArchive;
+import org.apache.jackrabbit.vault.packaging.ExportOptions;
+import org.apache.jackrabbit.vault.packaging.PackageException;
+import org.apache.jackrabbit.vault.packaging.PackageProperties;
+import org.apache.jackrabbit.vault.packaging.VaultPackage;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static java.util.UUID.randomUUID;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class UserExportIT extends IntegrationTestBase {
+ private static final Logger log = LoggerFactory.getLogger(UserExportIT.class);
+ private static final String TEST_USER_INTERMEDIATE_PATH = "/home/users/_";
+ private static final String TEST_USER_REP_USER_NAME = "_6k_test";
+ private static final String TEST_USER_ID = "user1";
+ private static final String TEST_USER_PATH = String.format("%s/%s", TEST_USER_INTERMEDIATE_PATH, TEST_USER_REP_USER_NAME);
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ clean(TEST_USER_PATH);
+ }
+
+ @Test
+ public void testFileNameEscaping() throws RepositoryException, ConfigurationException, IOException, PackageException {
+ assertNull(getTestUser());
+ log.info("Test user does not exist");
+ User test = ((JackrabbitSession) admin).getUserManager().createUser(TEST_USER_ID, randomUUID().toString(), new PrincipalImpl(TEST_USER_ID), TEST_USER_INTERMEDIATE_PATH);
+ admin.move(test.getPath(), TEST_USER_PATH);
+ admin.save();
+ assertNotNull(getTestUser());
+ log.info("Test user created at path {}", test.getPath());
+ byte[] serialised = export(admin, TEST_USER_PATH);
+ File tmpFile = File.createTempFile("test", ".zip");
+ try (FileOutputStream fso = new FileOutputStream(tmpFile)) {
+ fso.write(serialised);
+ }
+ log.info("Test user exported at path {}", tmpFile.getAbsolutePath());
+ clean(TEST_USER_PATH);
+ assertNull(getTestUser());
+ log.info("Test user removed from the repository");
+ importPackage(admin, new ByteArrayInputStream(serialised));
+ assertNotNull(getTestUser());
+ log.info("Test user imported");
+ }
+
+ private User getTestUser() throws RepositoryException {
+ return (User) ((JackrabbitSession) admin).getUserManager().getAuthorizable(TEST_USER_ID);
+ }
+
+ private void importPackage(Session session, InputStream is) throws IOException, ConfigurationException, RepositoryException, PackageException {
+ ImportOptions opts = new ImportOptions();
+ opts.setAccessControlHandling(AccessControlHandling.OVERWRITE);
+ opts.setCugHandling(AccessControlHandling.OVERWRITE);
+ opts.setImportMode(ImportMode.REPLACE);
+ opts.setPatchKeepInRepo(false);
+ opts.setAutoSaveThreshold(-1);
+ opts.setStrict(true);
+ Importer importer = new Importer(opts);
+ try (Archive archive = new ZipStreamArchive(is)) {
+ archive.open(false);
+ importer.run(archive, session, "/");
+ if (importer.hasErrors() && opts.isStrict(true)) {
+ throw new RuntimeException("Failed to import");
+ }
+ }
+ }
+
+
+ private byte[] export(Session session, String authorizablePath) throws IOException, RepositoryException, ConfigurationException {
+
+ PathFilterSet nodeFilters = new PathFilterSet(authorizablePath);
+ PathFilterSet propertyFilters = new PathFilterSet(authorizablePath);
+
+ DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
+ filter.add(nodeFilters, propertyFilters);
+
+ DefaultMetaInf inf = new DefaultMetaInf();
+ inf.setFilter(filter);
+
+ Properties props = new Properties();
+ props.setProperty(VaultPackage.NAME_GROUP, "jackrabbit/sync");
+ props.setProperty(VaultPackage.NAME_NAME, randomUUID().toString());
+ props.setProperty(VaultPackage.NAME_VERSION, "0.0.1");
+ props.setProperty(PackageProperties.NAME_USE_BINARY_REFERENCES, String.valueOf(true));
+ inf.setProperties(props);
+
+ ExportOptions opts = new ExportOptions();
+ opts.setMetaInf(inf);
+
+ opts.setRootPath(authorizablePath);
Review Comment:
I proposed a fix in together with this test in #336
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org