import org.unitils.spring.annotation.SpringBeanByType;\r
\r
import eu.etaxonomy.cdm.database.PermissionDeniedException;\r
-import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;\r
-import eu.etaxonomy.cdm.model.common.Group;\r
-import eu.etaxonomy.cdm.model.common.User;\r
-import eu.etaxonomy.cdm.persistence.hibernate.permission.Role;\r
+import eu.etaxonomy.cdm.model.permission.GrantedAuthorityImpl;\r
+import eu.etaxonomy.cdm.model.permission.Group;\r
+import eu.etaxonomy.cdm.model.permission.User;\r
+import eu.etaxonomy.cdm.persistence.permission.Role;\r
\r
\r
/**\r
* @author a.kohlbecker\r
- * @date Feb 4, 2014\r
- *\r
+ * @since Feb 4, 2014\r
*/\r
@DataSet(value="SecurityTest.xml")\r
public class UserAndGroupServiceImplTest extends AbstractSecurityTestBase {\r
@SpringBeanByType\r
private ITaxonService taxonService;\r
\r
-\r
private Authentication authentication;\r
\r
-\r
@Test\r
public void testCreateUser() {\r
\r
-\r
authentication = authenticationManager.authenticate(tokenForAdmin);\r
SecurityContext context = SecurityContextHolder.getContext();\r
context.setAuthentication(authentication);\r
\r
-\r
try{\r
- userService.createUser(User.NewInstance("new user 1", "00000"));\r
+ userService.createUser(User.NewInstance("new_user_1", "00000"));\r
}catch(Exception e){\r
Assert.fail();\r
}\r
context.setAuthentication(authentication);\r
\r
try{\r
- userService.createUser(User.NewInstance("new user 2", "00000"));\r
+ userService.createUser(User.NewInstance("new_user_2", "00000"));\r
Assert.fail();\r
}catch(Exception e){\r
Assert.assertEquals("Access is denied", e.getMessage());\r
}\r
}\r
\r
-\r
@Test\r
public void testUpdateUser(){\r
\r
}catch (Exception e){\r
Assert.assertEquals("Access is denied", e.getMessage());\r
}\r
-\r
}\r
\r
@Test\r
userService.changePasswordForUser(tokenForAdmin.getName(), "newPassword");\r
}\r
\r
-\r
@Test\r
public void testCreateGroup(){\r
\r
SecurityContext context = SecurityContextHolder.getContext();\r
context.setAuthentication(authentication);\r
\r
+ List<GrantedAuthority> authorityList = new ArrayList<>();\r
+ GrantedAuthorityImpl roleRemotingAuthority = GrantedAuthorityImpl.NewInstance(null);\r
+ roleRemotingAuthority.setAuthority(Role.ROLE_REMOTING.toString()); // testing if creating a Role from string is working\r
+ authorityList.add(roleRemotingAuthority);\r
\r
- List<GrantedAuthority> authorityList = new ArrayList<GrantedAuthority>();\r
- GrantedAuthorityImpl rolePublishAthotrity = GrantedAuthorityImpl.NewInstance();\r
- rolePublishAthotrity.setAuthority(Role.ROLE_PUBLISH.toString()); // testing if creating a Role from string is working\r
- authorityList.add(rolePublishAthotrity);\r
+ String remotingGroupName = "publishers";\r
\r
- String publishersGroupName = "publishers";\r
-\r
- groupService.createGroup(publishersGroupName, authorityList);\r
+ groupService.createGroup(remotingGroupName, authorityList);\r
\r
commitAndStartNewTransaction(null);\r
\r
- List<GrantedAuthority> groupAuthorities = groupService.findGroupAuthorities(publishersGroupName);\r
-\r
- Assert.assertEquals(Role.ROLE_PUBLISH.toString(), groupAuthorities.get(0).getAuthority());\r
+ List<GrantedAuthority> groupAuthorities = groupService.findGroupAuthorities(remotingGroupName);\r
\r
+ Assert.assertEquals(Role.ROLE_REMOTING.toString(), groupAuthorities.get(0).getAuthority());\r
}\r
\r
@Test\r
context.setAuthentication(authentication);\r
\r
// create an entity of ROLE_PUBLISH and save it to the database\r
- grantedAuthorityService.save(Role.ROLE_PUBLISH.asNewGrantedAuthority());\r
commitAndStartNewTransaction(null);\r
GrantedAuthorityImpl rolePublish = grantedAuthorityService.load(Role.ROLE_PUBLISH.getUuid());\r
\r
if(group.getName().equals(groupSpecialEditor_Name)){\r
Assert.fail("The user TaxonEditor should no longer be member of this group");\r
}\r
-\r
}\r
-\r
}\r
\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()\r
- */\r
@Override\r
- public void createTestDataSet() throws FileNotFoundException {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
+ public void createTestDataSet() throws FileNotFoundException {}\r
\r
}