-
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
139 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 0 additions & 84 deletions
84
ctera/src/test/java/ch/cyberduck/core/ctera/CteraCustomACLTest.java
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
ctera/src/test/java/ch/cyberduck/core/ctera/CteraPermissionFeatureAclToPermissionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package ch.cyberduck.core.ctera;/* | ||
* Copyright (c) 2002-2023 iterate GmbH. All rights reserved. | ||
* https://cyberduck.io/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
import ch.cyberduck.core.Acl; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameter; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import static ch.cyberduck.core.ctera.CteraCustomACL.*; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(Parameterized.class) | ||
public class CteraPermissionFeatureAclToPermissionTest { | ||
@Parameterized.Parameters(name = "{0} {1} {2} {3}") | ||
public static Collection<Object[]> data() { | ||
|
||
return Arrays.asList( | ||
new Object[][]{ | ||
{Acl.EMPTY, true, true, true}, | ||
{new Acl(new Acl.CanonicalUser(), writepermission), false, true, false}, | ||
{new Acl(new Acl.CanonicalUser(), readpermission), true, false, false}, | ||
{new Acl(new Acl.CanonicalUser(), executepermission), false, false, true}, | ||
{new Acl(new Acl.CanonicalUser(), deletepermission), false, false, false}, | ||
{new Acl(new Acl.CanonicalUser(), traversepermission), false, false, true}, | ||
{new Acl(new Acl.CanonicalUser(), Createfilepermission), false, false, false}, | ||
{new Acl(new Acl.CanonicalUser(), CreateDirectoriespermission), false, false, false} | ||
} | ||
); | ||
} | ||
|
||
@Parameter | ||
public Acl acl; | ||
|
||
@Parameter(1) | ||
public boolean r; | ||
|
||
@Parameter(2) | ||
public boolean w; | ||
|
||
@Parameter(3) | ||
public boolean x; | ||
|
||
|
||
@Test | ||
public void testAclToPermission() { | ||
assertEquals(r, aclToPermission(acl).isReadable()); | ||
assertEquals(w, aclToPermission(acl).isWritable()); | ||
assertEquals(x, aclToPermission(acl).isExecutable()); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
ctera/src/test/java/ch/cyberduck/core/ctera/CteraPermissionFeatureCustomPropsToAclTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2023 iterate GmbH. All rights reserved. | ||
*/ | ||
|
||
package ch.cyberduck.core.ctera; | ||
|
||
import ch.cyberduck.core.Acl; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameter; | ||
|
||
import java.util.AbstractMap; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
import static ch.cyberduck.core.ctera.CteraCustomACL.*; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(Parameterized.class) | ||
class CteraPermissionFeatureCustomPropsToAclTest { | ||
|
||
@Parameterized.Parameters(name = "{0} {1}") | ||
public static Collection<Object[]> data() { | ||
|
||
return Arrays.asList( | ||
new Object[][]{ | ||
{Collections.emptyMap(), Acl.EMPTY}, | ||
{ | ||
(Map<String, String>) Stream.of( | ||
new AbstractMap.SimpleEntry<>(readpermission.getName(), "false"), | ||
new AbstractMap.SimpleEntry<>(writepermission.getName(), "false"), | ||
new AbstractMap.SimpleEntry<>(executepermission.getName(), "false"), | ||
new AbstractMap.SimpleEntry<>(deletepermission.getName(), "false"), | ||
new AbstractMap.SimpleEntry<>(traversepermission.getName(), "true"), | ||
new AbstractMap.SimpleEntry<>(Createfilepermission.getName(), "false"), | ||
new AbstractMap.SimpleEntry<>(CreateDirectoriespermission.getName(), "false") | ||
).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)), | ||
new Acl(new Acl.CanonicalUser(), traversepermission) | ||
}, | ||
{ | ||
(Map<String, String>) Stream.of( | ||
new AbstractMap.SimpleEntry<>(readpermission.getName(), "false"), | ||
new AbstractMap.SimpleEntry<>(writepermission.getName(), "true"), | ||
new AbstractMap.SimpleEntry<>(executepermission.getName(), "false"), | ||
new AbstractMap.SimpleEntry<>(deletepermission.getName(), "false"), | ||
new AbstractMap.SimpleEntry<>(traversepermission.getName(), "false"), | ||
new AbstractMap.SimpleEntry<>(Createfilepermission.getName(), "false"), | ||
new AbstractMap.SimpleEntry<>(CreateDirectoriespermission.getName(), "true") | ||
).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)), | ||
new Acl(new Acl.CanonicalUser(), writepermission, CreateDirectoriespermission) | ||
} | ||
} | ||
); | ||
} | ||
|
||
@Parameter | ||
public Map<String, String> map; | ||
|
||
@Parameter(1) | ||
public Acl expected; | ||
|
||
|
||
public void testCustomPropsToAcl(final Map<String, String> map, final Acl expected) { | ||
assertEquals(expected, customPropsToAcl(map)); | ||
|
||
} | ||
} |