Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map properties in custom namespace to ACLs and File ID #15468

Merged
merged 79 commits into from
Apr 3, 2024
Merged
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
d75f832
Map custom XML fields to Acl and Permission in Ctera session (CTERA-1…
chenkins Dec 14, 2023
8d9c84a
Use junit4 for parameterized tests.
chenkins Dec 20, 2023
2efe403
Move CteraCustomACL constants to CteraAclPermissionFeature.
chenkins Dec 20, 2023
2045835
Make all static fields final.
chenkins Jan 3, 2024
59e45bd
Use available API Permission.Action to build Permission from Acl.
chenkins Jan 3, 2024
a52f1f1
Extract anonymous Ctera features.
chenkins Jan 3, 2024
1c76ced
Extract checkCteraRole to CteraAclPermissionFeature.
chenkins Jan 3, 2024
461f7cf
Cleanup unused variable (CTERA-136).
chenkins Jan 8, 2024
85a751f
Add ctera:guid to custom props/path attributes (CTERA-137).
chenkins Jan 8, 2024
dc567c1
Use fileId instead of versionId for ctera:guid (CTERA-137).
chenkins Jan 11, 2024
2bfc55f
Cleanup parameter naming, duplicated parameters, formatting (CTERA-137).
chenkins Jan 11, 2024
8d5c4e0
Review exception message (CTERA-137).
chenkins Jan 11, 2024
6f11fe9
Update comments (CTERA-137).
chenkins Jan 11, 2024
a458502
Make Ctera features public (CTERA-136).
chenkins Jan 19, 2024
eff9ee5
Remove embedded webdav tweaking (CTERA-137).
chenkins Jan 19, 2024
efa406f
Post rebase fix (CTERA-136).
chenkins Mar 18, 2024
cd10ee2
Add Javadoc (CTERA-136).
chenkins Mar 18, 2024
788f050
Use Ctera features in Ctera integration tests (CTERA-136).
chenkins Mar 18, 2024
17fada9
Add Javadoc (CTERA-136).
chenkins Mar 18, 2024
5f77b36
Custom namespace and prefix for ctera permissions (CTERA-136).
chenkins Mar 18, 2024
4106da9
Custom namespace and prefix for ctera guid (CTERA-137).
chenkins Mar 18, 2024
167f7b2
Extract constant for ctera:guid (CTERA-137).
chenkins Mar 19, 2024
e0fed28
Duplicate session in CteraListService instead of making it protected …
chenkins Mar 19, 2024
40d92f3
Move CTERA_GUID constant to CteraAttributesFinderFeature (CTERA-137).
chenkins Mar 20, 2024
58a0600
Inline variables.
chenkins Mar 20, 2024
eba5363
Use setFileId when return value is not needed.
chenkins Mar 20, 2024
1288c6e
Localize exception.
chenkins Mar 20, 2024
2ea145d
Remove unused code.
chenkins Mar 20, 2024
c723ebf
Add test to show guid is same in attributes returned from touch and m…
chenkins Mar 20, 2024
c9b01e6
Add test showing guid is retained when moving file (CTERA-137).
chenkins Mar 20, 2024
099bca2
Log warning if the roles required for an operation are missing in add…
chenkins Mar 21, 2024
652f703
Add preflight test for CTERA move feature.
chenkins Mar 21, 2024
5941043
Use assertThrows.
chenkins Mar 21, 2024
fbec38a
Implement backwards compatibility by using Acl.EMPTY to skip new pref…
chenkins Mar 21, 2024
ac52577
Clean-up TODOs.
chenkins Mar 21, 2024
440fe7a
Implement preflight 3 tests for all CTERA features.
chenkins Mar 21, 2024
d8df02b
Remove commented out code.
chenkins Mar 21, 2024
878b26e
Return Acl.EMPTY when none of the ACL properties are found.
chenkins Mar 22, 2024
535c1d9
Remove role traversepermission as not supported.
chenkins Mar 22, 2024
f400d7c
Revert to no metadata feature in ctera.
chenkins Mar 22, 2024
09b8665
Drop CteraAclPermissionFeature.
chenkins Mar 22, 2024
7bdfc8a
Add override annotation.
chenkins Mar 22, 2024
14f00fb
New line.
dkocher Mar 23, 2024
90221f9
Inline.
dkocher Mar 23, 2024
6408da6
Remove super preflight.
dkocher Mar 23, 2024
ec9018c
Rename and Javadoc.
dkocher Mar 23, 2024
2b5d8c7
New line.
dkocher Mar 23, 2024
0e6226e
Formatting.
dkocher Mar 23, 2024
bc7b2d0
Rename and Javadoc.
dkocher Mar 23, 2024
b5dc666
Rename constants.
dkocher Mar 23, 2024
ced083a
Static imports.
dkocher Mar 23, 2024
943ad57
Define as set.
dkocher Mar 23, 2024
6820785
Remove unsupported roles.
dkocher Mar 23, 2024
df3d0e2
Delete failing ETag assumptions.
dkocher Mar 23, 2024
9cda7de
Fix test.
dkocher Mar 23, 2024
5958836
Delete test no longer applicable.
dkocher Mar 23, 2024
555c9d4
Fix test.
dkocher Mar 23, 2024
4f1ed7c
Disable test for LOCK not supported.
dkocher Mar 23, 2024
3992141
Delete redundant checks.
dkocher Mar 24, 2024
4442c00
Logging.
dkocher Mar 24, 2024
d56e01f
Add proper localization for errors.
dkocher Mar 24, 2024
b618e20
Add tests.
dkocher Mar 24, 2024
1bbe711
Replace with incomprehensible one-liner.
dkocher Mar 24, 2024
56293c2
Delete redundant null check.
dkocher Mar 24, 2024
4d740ff
Revert.
dkocher Mar 24, 2024
57a323d
Extract field.
dkocher Mar 24, 2024
9d09768
Add tests.
dkocher Mar 24, 2024
aae1426
Review test.
dkocher Mar 24, 2024
4c4b161
Rename permission for creating folders.
dkocher Mar 26, 2024
1a31f55
Verify acls from manually set up folders in CTERA portal.
chenkins Mar 26, 2024
d1c6507
Review tests.
dkocher Mar 27, 2024
b7c8b4e
Verify acls from manually set up folders in CTERA portal continued.
chenkins Mar 27, 2024
6b2e138
Remove TODO to be ignored.
chenkins Mar 27, 2024
7313594
Fix role name.
dkocher Mar 28, 2024
7f08a86
Fix tests.
dkocher Mar 28, 2024
63055b2
Add missing parameter.
dkocher Mar 28, 2024
2bbf7d0
Add README.md in ctera module.
chenkins Apr 2, 2024
535edc4
Remove testing on createfilespermission. Add target exists test on cp…
chenkins Apr 2, 2024
03b8b3d
Avoid long running find operation in preflight checks.
chenkins Apr 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
* GNU General Public License for more details.
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.Acl;
import ch.cyberduck.core.AlphanumericRandomStringService;
import ch.cyberduck.core.DisabledListProgressListener;
import ch.cyberduck.core.DisabledLoginCallback;
import ch.cyberduck.core.Path;
import ch.cyberduck.core.PathAttributes;
import ch.cyberduck.core.SimplePathPredicate;
import ch.cyberduck.core.dav.DAVAttributesFinderFeature;
import ch.cyberduck.core.exception.BackgroundException;
import ch.cyberduck.core.exception.NotfoundException;
import ch.cyberduck.core.features.Delete;
import ch.cyberduck.core.shared.DefaultHomeFinderService;
Expand All @@ -31,9 +34,19 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;

import java.io.IOException;
import java.util.AbstractMap;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.github.sardine.DavResource;
import com.github.sardine.impl.SardineException;

import static ch.cyberduck.core.ctera.CteraAttributesFinderFeature.*;
import static org.junit.Assert.*;

@Category(IntegrationTest.class)
Expand Down Expand Up @@ -66,9 +79,9 @@ public void testFindFile() throws Exception {
assertEquals(folderTimestamp, f.find(folder).getModificationDate());
assertEquals(folderEtag, f.find(folder).getETag());
final PathAttributes attributes = f.find(test);
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(CteraAttributesFinderFeature.READPERMISSION)));
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(CteraAttributesFinderFeature.WRITEPERMISSION)));
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(CteraAttributesFinderFeature.DELETEPERMISSION)));
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(READPERMISSION)));
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(WRITEPERMISSION)));
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(DELETEPERMISSION)));
assertEquals(0L, attributes.getSize());
assertNotEquals(-1L, attributes.getModificationDate());
assertNotNull(attributes.getETag());
Expand All @@ -95,9 +108,9 @@ public void testFindDirectory() throws Exception {
new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
final DAVAttributesFinderFeature f = new CteraAttributesFinderFeature(session);
final PathAttributes attributes = f.find(test);
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(CteraAttributesFinderFeature.READPERMISSION)));
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(CteraAttributesFinderFeature.WRITEPERMISSION)));
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(CteraAttributesFinderFeature.CREATEDIRECTORIESPERMISSION)));
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(READPERMISSION)));
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(WRITEPERMISSION)));
assertTrue(attributes.getAcl().asList().stream().anyMatch(userAndRole -> userAndRole.getRole().equals(CREATEDIRECTORIESPERMISSION)));
assertNotEquals(-1L, attributes.getModificationDate());
assertNotNull(attributes.getETag());
assertEquals(test.attributes().getFileId(), attributes.getFileId());
Expand All @@ -112,4 +125,87 @@ public void testFindDirectory() throws Exception {
// Expected
}
}

@Test
public void testNoAccessAcl() throws IOException {
final Path home = new Path("/ServicesPortal/webdav/Shared With Me/ACL test (Alex Berman)", EnumSet.of(AbstractPath.Type.directory));

// list parent folder to inspect attributes
final List<DavResource> noAccess = new CteraListService(session).list(home).stream().filter(r -> r.getName().equals("NoAccess")).collect(Collectors.toList());
assertEquals(noAccess.size(), 1);
assertEquals(
Stream.of(
new AbstractMap.SimpleEntry<>("writepermission", "false"),
new AbstractMap.SimpleEntry<>("readpermission", "false"),
new AbstractMap.SimpleEntry<>("deletepermission", "false"),
new AbstractMap.SimpleEntry<>("guid", "c51c40dc-1de0-441c-a6bf-3d07c0420329:1")
).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)),
noAccess.get(0).getCustomProps());
assertEquals(new Acl(new Acl.CanonicalUser()), new CteraAttributesFinderFeature(session).toAttributes(noAccess.get(0)).getAcl());
// find fails with 403 in backend
final BackgroundException findException = assertThrows(BackgroundException.class, () -> new CteraAttributesFinderFeature(session).find(new Path(home, "NoAccess", EnumSet.of(AbstractPath.Type.directory))));
dkocher marked this conversation as resolved.
Show resolved Hide resolved
assertTrue(findException.getCause() instanceof SardineException);
assertEquals(403, ((SardineException) findException.getCause()).getStatusCode());
// listing the folder fails with 403 in the backend
final SardineException listException = assertThrows(SardineException.class, () -> new CteraListService(session).list(new Path(home, "NoAccess", EnumSet.of(AbstractPath.Type.directory))));
assertEquals(403, listException.getStatusCode());
}

@Test
public void testNoDeleteAcl() throws BackgroundException {
final Path home = new Path("/ServicesPortal/webdav/Shared With Me/ACL test (Alex Berman)", EnumSet.of(AbstractPath.Type.directory));
final Path folder = new Path(home, "NoDelete", EnumSet.of(AbstractPath.Type.directory));
final Acl folderAcl = new CteraAttributesFinderFeature(session).find(folder).getAcl();
assertEquals(new Acl(new Acl.UserAndRole(new Acl.CanonicalUser(), READPERMISSION)), folderAcl);

// TODO CTERA-136 file is named RW but returns only R?
chenkins marked this conversation as resolved.
Show resolved Hide resolved
final Path file = new Path(folder, "RW no delete.txt", EnumSet.of(AbstractPath.Type.file));
final Acl fileAcl = new CteraAttributesFinderFeature(session).find(file).getAcl();
assertEquals(new Acl(new Acl.UserAndRole(new Acl.CanonicalUser(), READPERMISSION)), fileAcl);
}

@Test
public void testReadOnlyAcl() throws BackgroundException {
final Path home = new Path("/ServicesPortal/webdav/Shared With Me/ACL test (Alex Berman)", EnumSet.of(AbstractPath.Type.directory));
final Path folder = new Path(home, "ReadOnly", EnumSet.of(AbstractPath.Type.directory));
final Acl folderAcl = new CteraAttributesFinderFeature(session).find(folder).getAcl();
assertEquals(new Acl(new Acl.UserAndRole(new Acl.CanonicalUser(), READPERMISSION)), folderAcl);

final Path file = new Path(folder, "ReadOnly.txt", EnumSet.of(AbstractPath.Type.file));
final Acl fileAcl = new CteraAttributesFinderFeature(session).find(file).getAcl();
assertEquals(new Acl(new Acl.UserAndRole(new Acl.CanonicalUser(), READPERMISSION)), fileAcl);
}

@Test
public void testReadWriteAcl() throws BackgroundException {
final Path home = new Path("/ServicesPortal/webdav/Shared With Me/ACL test (Alex Berman)", EnumSet.of(AbstractPath.Type.directory));
final Path folder = new Path(home, "ReadWrite", EnumSet.of(AbstractPath.Type.directory));
final Acl folderAcl = new CteraAttributesFinderFeature(session).find(folder).getAcl();
assertEquals(new Acl(
new Acl.UserAndRole(new Acl.CanonicalUser(), READPERMISSION),
new Acl.UserAndRole(new Acl.CanonicalUser(), WRITEPERMISSION),
new Acl.UserAndRole(new Acl.CanonicalUser(), DELETEPERMISSION)
), folderAcl);

final Path file = new Path(folder, "Free Access.txt", EnumSet.of(AbstractPath.Type.file));
final Acl fileAcl = new CteraAttributesFinderFeature(session).find(file).getAcl();
assertEquals(new Acl(
new Acl.UserAndRole(new Acl.CanonicalUser(), READPERMISSION),
new Acl.UserAndRole(new Acl.CanonicalUser(), WRITEPERMISSION),
new Acl.UserAndRole(new Acl.CanonicalUser(), DELETEPERMISSION)
), fileAcl);

final Path subfolderNoAccess = new Path(folder, "NoAccess", EnumSet.of(AbstractPath.Type.directory));

final BackgroundException noAccessException = assertThrows(BackgroundException.class, () -> new CteraAttributesFinderFeature(session).find(subfolderNoAccess));
assertTrue(noAccessException.getCause() instanceof SardineException);

final Path subfolderReadOnly = new Path(folder, "subfolder-readonly", EnumSet.of(AbstractPath.Type.directory));
final Acl subfolderReadOnlyAcl = new CteraAttributesFinderFeature(session).find(subfolderReadOnly).getAcl();
assertEquals(new Acl(new Acl.UserAndRole(new Acl.CanonicalUser(), READPERMISSION)), subfolderReadOnlyAcl);

final Path readOnlyFile = new Path(subfolderReadOnly, "readonly.txt", EnumSet.of(AbstractPath.Type.file));
final Acl readOnlyFileAcl = new CteraAttributesFinderFeature(session).find(readOnlyFile).getAcl();
assertEquals(new Acl(new Acl.UserAndRole(new Acl.CanonicalUser(), READPERMISSION)), readOnlyFileAcl);
}
}
Loading