mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Activating disabled tests
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@50279 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,12 +28,13 @@ import org.alfresco.module.org_alfresco_module_rm.test.webscript.EventRestApiTes
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.RMCaveatConfigScriptTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.webscript.RMCaveatConfigScriptTest;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.RMConstraintScriptTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.webscript.RMConstraintScriptTest;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.RmChildrenRestApiTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.webscript.RmChildrenRestApiTest;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.webscript.RmClassesRestApiTest;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.webscript.RmPropertiesRestApiTest;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.webscript.RoleRestApiTest;
|
import org.alfresco.module.org_alfresco_module_rm.test.webscript.RoleRestApiTest;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
import org.junit.runners.Suite.SuiteClasses;
|
import org.junit.runners.Suite.SuiteClasses;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RM WebScript test suite
|
* RM WebScript test suite
|
||||||
*
|
*
|
||||||
@@ -53,8 +54,8 @@ import org.junit.runners.Suite.SuiteClasses;
|
|||||||
EmailMapKeysRestApiTest.class,
|
EmailMapKeysRestApiTest.class,
|
||||||
CapabilitiesRestApiTest.class,
|
CapabilitiesRestApiTest.class,
|
||||||
ActionDefinitionsRestApiTest.class,
|
ActionDefinitionsRestApiTest.class,
|
||||||
//RmClassesRestApiTest.class,
|
RmClassesRestApiTest.class,
|
||||||
//RmPropertiesRestApiTest.class,
|
RmPropertiesRestApiTest.class,
|
||||||
RmChildrenRestApiTest.class
|
RmChildrenRestApiTest.class
|
||||||
})
|
})
|
||||||
public class WebScriptTestSuite
|
public class WebScriptTestSuite
|
||||||
|
@@ -39,168 +39,168 @@ import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class tests the Rest API for disposition related operations
|
* This class tests the Rest API for disposition related operations
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
||||||
implements RecordsManagementModel
|
implements RecordsManagementModel
|
||||||
{
|
{
|
||||||
protected static final String GET_ROLES_URL_BY_SITE = "/api/rma/admin/{0}/rmroles";
|
protected static final String GET_ROLES_URL_BY_SITE = "/api/rma/admin/{0}/rmroles";
|
||||||
protected static final String GET_ROLES_URL_BY_FILEPLAN = "/api/rma/admin/{0}/{1}/{2}/rmroles";
|
protected static final String GET_ROLES_URL_BY_FILEPLAN = "/api/rma/admin/{0}/{1}/{2}/rmroles";
|
||||||
protected static final String SERVICE_URL_PREFIX = "/alfresco/service";
|
protected static final String SERVICE_URL_PREFIX = "/alfresco/service";
|
||||||
protected static final String APPLICATION_JSON = "application/json";
|
protected static final String APPLICATION_JSON = "application/json";
|
||||||
|
|
||||||
private String getRolesUrlBySite()
|
private String getRolesUrlBySite()
|
||||||
{
|
{
|
||||||
return MessageFormat.format(GET_ROLES_URL_BY_SITE, SITE_ID);
|
return MessageFormat.format(GET_ROLES_URL_BY_SITE, SITE_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getRoleUrlByFilePlan()
|
private String getRoleUrlByFilePlan()
|
||||||
{
|
{
|
||||||
return MessageFormat.format(GET_ROLES_URL_BY_FILEPLAN, filePlan.getStoreRef().getProtocol(), filePlan.getStoreRef().getIdentifier(), filePlan.getId());
|
return MessageFormat.format(GET_ROLES_URL_BY_FILEPLAN, filePlan.getStoreRef().getProtocol(), filePlan.getStoreRef().getIdentifier(), filePlan.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetRoles() throws Exception
|
public void testGetRoles() throws Exception
|
||||||
{
|
{
|
||||||
String role1 = GUID.generate();
|
String role1 = GUID.generate();
|
||||||
String role2 = GUID.generate();
|
String role2 = GUID.generate();
|
||||||
|
|
||||||
// Create a couple or roles by hand
|
// Create a couple or roles by hand
|
||||||
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
||||||
filePlanRoleService.createRole(filePlan, role2, "My Test Role Too", getListOfCapabilities(5));
|
filePlanRoleService.createRole(filePlan, role2, "My Test Role Too", getListOfCapabilities(5));
|
||||||
|
|
||||||
// create test group
|
// create test group
|
||||||
String groupName = GUID.generate();
|
String groupName = GUID.generate();
|
||||||
String group = authorityService.createAuthority(AuthorityType.GROUP, groupName, "monkey", null);
|
String group = authorityService.createAuthority(AuthorityType.GROUP, groupName, "monkey", null);
|
||||||
|
|
||||||
// Add the admin user to one of the roles
|
// Add the admin user to one of the roles
|
||||||
filePlanRoleService.assignRoleToAuthority(filePlan, role1, "admin");
|
filePlanRoleService.assignRoleToAuthority(filePlan, role1, "admin");
|
||||||
filePlanRoleService.assignRoleToAuthority(filePlan, role1, group);
|
filePlanRoleService.assignRoleToAuthority(filePlan, role1, group);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get the roles (for the default file plan)
|
// Get the roles (for the default file plan)
|
||||||
Response rsp = sendRequest(new GetRequest(getRolesUrlBySite()),200);
|
Response rsp = sendRequest(new GetRequest(getRolesUrlBySite()),200);
|
||||||
String rspContent = rsp.getContentAsString();
|
String rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
JSONObject obj = new JSONObject(rspContent);
|
JSONObject obj = new JSONObject(rspContent);
|
||||||
JSONObject roles = obj.getJSONObject("data");
|
JSONObject roles = obj.getJSONObject("data");
|
||||||
assertNotNull(roles);
|
assertNotNull(roles);
|
||||||
|
|
||||||
JSONObject roleObj = roles.getJSONObject(role1);
|
JSONObject roleObj = roles.getJSONObject(role1);
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role1, roleObj.get("name"));
|
assertEquals(role1, roleObj.get("name"));
|
||||||
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
||||||
checkCapabilities(roleObj, 5);
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
roleObj = roles.getJSONObject(role2);
|
roleObj = roles.getJSONObject(role2);
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role2, roleObj.get("name"));
|
assertEquals(role2, roleObj.get("name"));
|
||||||
assertEquals("My Test Role Too", roleObj.get("displayLabel"));
|
assertEquals("My Test Role Too", roleObj.get("displayLabel"));
|
||||||
checkCapabilities(roleObj, 5);
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
// Get the roles, specifying the file plan
|
// Get the roles, specifying the file plan
|
||||||
rsp = sendRequest(new GetRequest(getRoleUrlByFilePlan()),200);
|
rsp = sendRequest(new GetRequest(getRoleUrlByFilePlan()),200);
|
||||||
rspContent = rsp.getContentAsString();
|
rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
obj = new JSONObject(rspContent);
|
obj = new JSONObject(rspContent);
|
||||||
roles = obj.getJSONObject("data");
|
roles = obj.getJSONObject("data");
|
||||||
assertNotNull(roles);
|
assertNotNull(roles);
|
||||||
|
|
||||||
roleObj = roles.getJSONObject(role1);
|
roleObj = roles.getJSONObject(role1);
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role1, roleObj.get("name"));
|
assertEquals(role1, roleObj.get("name"));
|
||||||
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
||||||
checkCapabilities(roleObj, 5);
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
roleObj = roles.getJSONObject(role2);
|
roleObj = roles.getJSONObject(role2);
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role2, roleObj.get("name"));
|
assertEquals(role2, roleObj.get("name"));
|
||||||
assertEquals("My Test Role Too", roleObj.get("displayLabel"));
|
assertEquals("My Test Role Too", roleObj.get("displayLabel"));
|
||||||
checkCapabilities(roleObj, 5);
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
// Get the roles for "admin"
|
// Get the roles for "admin"
|
||||||
rsp = sendRequest(new GetRequest(getRolesUrlBySite() + "?user=admin"),200);
|
rsp = sendRequest(new GetRequest(getRolesUrlBySite() + "?user=admin"),200);
|
||||||
rspContent = rsp.getContentAsString();
|
rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
obj = new JSONObject(rspContent);
|
obj = new JSONObject(rspContent);
|
||||||
roles = obj.getJSONObject("data");
|
roles = obj.getJSONObject("data");
|
||||||
assertNotNull(roles);
|
assertNotNull(roles);
|
||||||
|
|
||||||
roleObj = roles.getJSONObject(role1);
|
roleObj = roles.getJSONObject(role1);
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role1, roleObj.get("name"));
|
assertEquals(role1, roleObj.get("name"));
|
||||||
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
||||||
checkCapabilities(roleObj, 5);
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
assertFalse(roles.has(role2));
|
assertFalse(roles.has(role2));
|
||||||
|
|
||||||
// Get the roles including assigned authorities
|
// Get the roles including assigned authorities
|
||||||
rsp = sendRequest(new GetRequest(getRoleUrlByFilePlan() + "?auths=true"),200);
|
rsp = sendRequest(new GetRequest(getRoleUrlByFilePlan() + "?auths=true"),200);
|
||||||
rspContent = rsp.getContentAsString();
|
rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
System.out.println(rspContent);
|
System.out.println(rspContent);
|
||||||
|
|
||||||
obj = new JSONObject(rspContent);
|
obj = new JSONObject(rspContent);
|
||||||
roles = obj.getJSONObject("data");
|
roles = obj.getJSONObject("data");
|
||||||
assertNotNull(roles);
|
assertNotNull(roles);
|
||||||
|
|
||||||
roleObj = roles.getJSONObject(role1);
|
roleObj = roles.getJSONObject(role1);
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role1, roleObj.get("name"));
|
assertEquals(role1, roleObj.get("name"));
|
||||||
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
||||||
checkCapabilities(roleObj, 5);
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
JSONArray users = roleObj.getJSONArray("assignedUsers");
|
JSONArray users = roleObj.getJSONArray("assignedUsers");
|
||||||
assertNotNull(users);
|
assertNotNull(users);
|
||||||
assertEquals(1, users.length());
|
assertEquals(1, users.length());
|
||||||
|
|
||||||
JSONArray groups = roleObj.getJSONArray("assignedGroups");
|
JSONArray groups = roleObj.getJSONArray("assignedGroups");
|
||||||
assertNotNull(groups);
|
assertNotNull(groups);
|
||||||
assertEquals(1, groups.length());
|
assertEquals(1, groups.length());
|
||||||
|
|
||||||
roleObj = roles.getJSONObject(role2);
|
roleObj = roles.getJSONObject(role2);
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role2, roleObj.get("name"));
|
assertEquals(role2, roleObj.get("name"));
|
||||||
assertEquals("My Test Role Too", roleObj.get("displayLabel"));
|
assertEquals("My Test Role Too", roleObj.get("displayLabel"));
|
||||||
checkCapabilities(roleObj, 5);
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
users = roleObj.getJSONArray("assignedUsers");
|
users = roleObj.getJSONArray("assignedUsers");
|
||||||
assertNotNull(users);
|
assertNotNull(users);
|
||||||
assertEquals(0, users.length());
|
assertEquals(0, users.length());
|
||||||
|
|
||||||
groups = roleObj.getJSONArray("assignedGroups");
|
groups = roleObj.getJSONArray("assignedGroups");
|
||||||
assertNotNull(groups);
|
assertNotNull(groups);
|
||||||
assertEquals(0, groups.length());
|
assertEquals(0, groups.length());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// Clean up
|
// Clean up
|
||||||
filePlanRoleService.deleteRole(filePlan, role1);
|
filePlanRoleService.deleteRole(filePlan, role1);
|
||||||
filePlanRoleService.deleteRole(filePlan, role2);
|
filePlanRoleService.deleteRole(filePlan, role2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void checkCapabilities(JSONObject role, int expectedCount) throws JSONException
|
private void checkCapabilities(JSONObject role, int expectedCount) throws JSONException
|
||||||
{
|
{
|
||||||
JSONObject capabilities = role.getJSONObject("capabilities");
|
JSONObject capabilities = role.getJSONObject("capabilities");
|
||||||
assertNotNull(capabilities);
|
assertNotNull(capabilities);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
Iterator it = capabilities.keys();
|
Iterator<String> it = capabilities.keys();
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
String key = (String)it.next();
|
String key = it.next();
|
||||||
assertNotNull(key);
|
assertNotNull(key);
|
||||||
assertNotNull(capabilities.getString(key));
|
assertNotNull(capabilities.getString(key));
|
||||||
count ++;
|
count ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(expectedCount, count);
|
assertEquals(expectedCount, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPostRoles() throws Exception
|
public void testPostRoles() throws Exception
|
||||||
{
|
{
|
||||||
Set<Capability> caps = getListOfCapabilities(5);
|
Set<Capability> caps = getListOfCapabilities(5);
|
||||||
@@ -209,23 +209,23 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
{
|
{
|
||||||
arrCaps.put(cap.getName());
|
arrCaps.put(cap.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
String roleName = GUID.generate();
|
String roleName = GUID.generate();
|
||||||
|
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
obj.put("name", roleName);
|
obj.put("name", roleName);
|
||||||
obj.put("displayLabel", "Display Label");
|
obj.put("displayLabel", "Display Label");
|
||||||
obj.put("capabilities", arrCaps);
|
obj.put("capabilities", arrCaps);
|
||||||
|
|
||||||
Response rsp = sendRequest(new PostRequest(getRolesUrlBySite(), obj.toString(), APPLICATION_JSON),200);
|
Response rsp = sendRequest(new PostRequest(getRolesUrlBySite(), obj.toString(), APPLICATION_JSON),200);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String rspContent = rsp.getContentAsString();
|
String rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
JSONObject resultObj = new JSONObject(rspContent);
|
JSONObject resultObj = new JSONObject(rspContent);
|
||||||
JSONObject roleObj = resultObj.getJSONObject("data");
|
JSONObject roleObj = resultObj.getJSONObject("data");
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
|
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(roleName, roleObj.get("name"));
|
assertEquals(roleName, roleObj.get("name"));
|
||||||
assertEquals("Display Label", roleObj.get("displayLabel"));
|
assertEquals("Display Label", roleObj.get("displayLabel"));
|
||||||
@@ -235,14 +235,14 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
{
|
{
|
||||||
filePlanRoleService.deleteRole(filePlan, roleName);
|
filePlanRoleService.deleteRole(filePlan, roleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPutRole() throws Exception
|
public void testPutRole() throws Exception
|
||||||
{
|
{
|
||||||
String role1 = GUID.generate();
|
String role1 = GUID.generate();
|
||||||
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Set<Capability> caps = getListOfCapabilities(4,8);
|
Set<Capability> caps = getListOfCapabilities(4,8);
|
||||||
@@ -252,85 +252,85 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
System.out.println(cap.getName());
|
System.out.println(cap.getName());
|
||||||
arrCaps.put(cap.getName());
|
arrCaps.put(cap.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
obj.put("name", role1);
|
obj.put("name", role1);
|
||||||
obj.put("displayLabel", "Changed");
|
obj.put("displayLabel", "Changed");
|
||||||
obj.put("capabilities", arrCaps);
|
obj.put("capabilities", arrCaps);
|
||||||
|
|
||||||
// Get the roles
|
// Get the roles
|
||||||
Response rsp = sendRequest(new PutRequest(getRolesUrlBySite() + "/" + role1, obj.toString(), APPLICATION_JSON),200);
|
Response rsp = sendRequest(new PutRequest(getRolesUrlBySite() + "/" + role1, obj.toString(), APPLICATION_JSON),200);
|
||||||
String rspContent = rsp.getContentAsString();
|
String rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
JSONObject result = new JSONObject(rspContent);
|
JSONObject result = new JSONObject(rspContent);
|
||||||
JSONObject roleObj = result.getJSONObject("data");
|
JSONObject roleObj = result.getJSONObject("data");
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
|
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role1, roleObj.get("name"));
|
assertEquals(role1, roleObj.get("name"));
|
||||||
assertEquals("Changed", roleObj.get("displayLabel"));
|
assertEquals("Changed", roleObj.get("displayLabel"));
|
||||||
checkCapabilities(roleObj, 4);
|
checkCapabilities(roleObj, 4);
|
||||||
|
|
||||||
// Bad requests
|
// Bad requests
|
||||||
sendRequest(new PutRequest(getRolesUrlBySite() + "/cheese", obj.toString(), APPLICATION_JSON), 404);
|
sendRequest(new PutRequest(getRolesUrlBySite() + "/cheese", obj.toString(), APPLICATION_JSON), 404);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// Clean up
|
// Clean up
|
||||||
filePlanRoleService.deleteRole(filePlan, role1);
|
filePlanRoleService.deleteRole(filePlan, role1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetRole() throws Exception
|
public void testGetRole() throws Exception
|
||||||
{
|
{
|
||||||
String role1 = GUID.generate();
|
String role1 = GUID.generate();
|
||||||
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get the roles
|
// Get the roles
|
||||||
Response rsp = sendRequest(new GetRequest(getRolesUrlBySite() + "/" + role1),200);
|
Response rsp = sendRequest(new GetRequest(getRolesUrlBySite() + "/" + role1),200);
|
||||||
String rspContent = rsp.getContentAsString();
|
String rspContent = rsp.getContentAsString();
|
||||||
|
|
||||||
JSONObject obj = new JSONObject(rspContent);
|
JSONObject obj = new JSONObject(rspContent);
|
||||||
JSONObject roleObj = obj.getJSONObject("data");
|
JSONObject roleObj = obj.getJSONObject("data");
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
|
|
||||||
assertNotNull(roleObj);
|
assertNotNull(roleObj);
|
||||||
assertEquals(role1, roleObj.get("name"));
|
assertEquals(role1, roleObj.get("name"));
|
||||||
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
assertEquals("My Test Role", roleObj.get("displayLabel"));
|
||||||
checkCapabilities(roleObj, 5);
|
checkCapabilities(roleObj, 5);
|
||||||
|
|
||||||
// Bad requests
|
// Bad requests
|
||||||
sendRequest(new GetRequest(getRolesUrlBySite() + "/cheese"), 404);
|
sendRequest(new GetRequest(getRolesUrlBySite() + "/cheese"), 404);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// Clean up
|
// Clean up
|
||||||
filePlanRoleService.deleteRole(filePlan, role1);
|
filePlanRoleService.deleteRole(filePlan, role1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteRole() throws Exception
|
public void testDeleteRole() throws Exception
|
||||||
{
|
{
|
||||||
String role1 = GUID.generate();
|
String role1 = GUID.generate();
|
||||||
assertFalse(filePlanRoleService.existsRole(filePlan, role1));
|
assertFalse(filePlanRoleService.existsRole(filePlan, role1));
|
||||||
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
|
||||||
assertTrue(filePlanRoleService.existsRole(filePlan, role1));
|
assertTrue(filePlanRoleService.existsRole(filePlan, role1));
|
||||||
sendRequest(new DeleteRequest(getRolesUrlBySite() + "/" + role1),200);
|
sendRequest(new DeleteRequest(getRolesUrlBySite() + "/" + role1),200);
|
||||||
assertFalse(filePlanRoleService.existsRole(filePlan, role1));
|
assertFalse(filePlanRoleService.existsRole(filePlan, role1));
|
||||||
|
|
||||||
// Bad request
|
// Bad request
|
||||||
sendRequest(new DeleteRequest(getRolesUrlBySite() + "/cheese"), 404);
|
sendRequest(new DeleteRequest(getRolesUrlBySite() + "/cheese"), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Capability> getListOfCapabilities(int size)
|
private Set<Capability> getListOfCapabilities(int size)
|
||||||
{
|
{
|
||||||
return getListOfCapabilities(size, 0);
|
return getListOfCapabilities(size, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Capability> getListOfCapabilities(int size, int offset)
|
private Set<Capability> getListOfCapabilities(int size, int offset)
|
||||||
{
|
{
|
||||||
Set<Capability> result = new HashSet<Capability>(size);
|
Set<Capability> result = new HashSet<Capability>(size);
|
||||||
@@ -353,5 +353,5 @@ public class RoleRestApiTest extends BaseRMWebScriptTestCase
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user