-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 2.5 (PR #435 from virtual-imaging-platform/develop)
- Loading branch information
Showing
40 changed files
with
576 additions
and
99 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
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
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
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
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
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
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
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
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
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
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
41 changes: 41 additions & 0 deletions
41
vip-api/src/test/java/fr/insalyon/creatis/vip/api/business/LFCPermissionBusinessTest.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,41 @@ | ||
package fr.insalyon.creatis.vip.api.business; | ||
|
||
import fr.insalyon.creatis.vip.api.data.UserTestUtils; | ||
import fr.insalyon.creatis.vip.core.client.bean.Group; | ||
import fr.insalyon.creatis.vip.core.client.view.CoreConstants; | ||
import fr.insalyon.creatis.vip.core.server.business.BusinessException; | ||
import fr.insalyon.creatis.vip.datamanager.server.business.LFCPermissionBusiness; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class LFCPermissionBusinessTest { | ||
|
||
@AfterEach | ||
protected void tearDown() { | ||
// to reset user groups | ||
UserTestUtils.reset(); | ||
} | ||
|
||
@Test | ||
public void testGroupAccess() throws BusinessException { | ||
String groupName="EGI tutorial"; | ||
String path = "/vip/EGI tutorial (group)/inputs"; | ||
Map<Group, CoreConstants.GROUP_ROLE> groups = new HashMap<>(); | ||
UserTestUtils.baseUser1.setGroups(groups); | ||
UserTestUtils.baseUser2.setGroups(groups); | ||
LFCPermissionBusiness sut = new LFCPermissionBusiness(null, null); | ||
|
||
// First, test users does not belong to the group | ||
Assertions.assertFalse(sut.isLFCPathAllowed(UserTestUtils.baseUser1, path, LFCPermissionBusiness.LFCAccessType.UPLOAD, false)); | ||
Assertions.assertFalse(sut.isLFCPathAllowed(UserTestUtils.baseUser2, path, LFCPermissionBusiness.LFCAccessType.UPLOAD, false)); | ||
|
||
// Then, they belong to the group, but baseUser1 is beginner although baseUser2 is advanced | ||
groups.put(new Group(groupName, true, true, true), CoreConstants.GROUP_ROLE.User); | ||
Assertions.assertFalse(sut.isLFCPathAllowed(UserTestUtils.baseUser1, path, LFCPermissionBusiness.LFCAccessType.UPLOAD, false)); | ||
Assertions.assertTrue(sut.isLFCPathAllowed(UserTestUtils.baseUser2, path, LFCPermissionBusiness.LFCAccessType.UPLOAD, false)); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -38,6 +38,8 @@ | |
import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors; | ||
import org.springframework.test.web.servlet.request.RequestPostProcessor; | ||
|
||
import java.util.Collections; | ||
|
||
/** | ||
* Created by abonnet on 7/26/16. | ||
*/ | ||
|
@@ -53,6 +55,10 @@ public class UserTestUtils { | |
|
||
|
||
static { | ||
reset(); | ||
} | ||
|
||
static public void reset() { | ||
baseUser1 = new User("base1", "User1", "[email protected]", null, | ||
UserLevel.Beginner, null); | ||
baseUser1.setFolder("user1"); | ||
|
@@ -61,7 +67,7 @@ public class UserTestUtils { | |
baseUser2.setFolder("user2"); | ||
|
||
restUser1 = new SignUpUserDTO("base3", "User3", "[email protected]", "test", baseUser2Password, | ||
UserLevel.Advanced, null, "test comment", "test applications"); | ||
UserLevel.Advanced, null, "test comment", Collections.singletonList("test applications")); | ||
} | ||
|
||
public static RequestPostProcessor baseUser1() { | ||
|
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
Oops, something went wrong.