mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.2.N-AUDIT-API (5.2.2) to 5.2.N (5.2.2)
137900 eknizat: REPO-1298,REPO-2624 Enable/Disable Application Auditing - Add junit tests git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@137964 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -212,4 +212,47 @@ public class AuditAppTest extends AuditTest
|
||||
assertTrue(auditApp.getIsEnabled());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEnableDisableAuditApplication() throws Exception
|
||||
{
|
||||
AuditApp requestAuditApp = new AuditApp();
|
||||
AuditApp responseAuditApp = null;
|
||||
String appId = null;
|
||||
|
||||
setRequestContext(networkOne.getId(), networkAdmin, DEFAULT_ADMIN_PWD);
|
||||
|
||||
//Get one of the audit app ids (default tagging)
|
||||
ListResponse<AuditApp> apps = publicApiClient.auditApps().getAuditApps(null, "Getting audit apps error ", HttpServletResponse.SC_OK);
|
||||
appId = (apps.getList().size()>0) ? apps.getList().get(0).getId() : "tagging";
|
||||
|
||||
// +ve
|
||||
// Disable audit app
|
||||
requestAuditApp.setIsEnabled(false);
|
||||
responseAuditApp = publicApiClient.auditApps().updateAuditApp(appId,requestAuditApp,null, HttpServletResponse.SC_OK);
|
||||
assertFalse("Wrong response for request to disable audit app.", responseAuditApp.getIsEnabled());
|
||||
assertFalse("Disable audit app test failed.", publicApiClient.auditApps().getAuditApp(appId).getIsEnabled());
|
||||
|
||||
// Enable audit app
|
||||
requestAuditApp.setIsEnabled(true);
|
||||
responseAuditApp = publicApiClient.auditApps().updateAuditApp(appId,requestAuditApp,null, HttpServletResponse.SC_OK);
|
||||
assertTrue("Wrong response for request to enable audit app.", responseAuditApp.getIsEnabled());
|
||||
assertTrue("Enable audit app test failed.", publicApiClient.auditApps().getAuditApp(appId).getIsEnabled());
|
||||
|
||||
// -ve
|
||||
// 400
|
||||
publicApiClient.auditApps().update("audit-applications",appId,null,null,"badBody",null,"Was expecting error 400",HttpServletResponse.SC_BAD_REQUEST);
|
||||
// 401
|
||||
setRequestContext(networkOne.getId(), networkAdmin, "fakepswd");
|
||||
publicApiClient.auditApps().updateAuditApp(appId,requestAuditApp,null, HttpServletResponse.SC_UNAUTHORIZED);
|
||||
// 403
|
||||
setRequestContext(networkOne.getId(), user1, null);
|
||||
publicApiClient.auditApps().updateAuditApp(appId,requestAuditApp,null, HttpServletResponse.SC_FORBIDDEN);
|
||||
// 404
|
||||
setRequestContext(networkOne.getId(), networkAdmin, DEFAULT_ADMIN_PWD);
|
||||
publicApiClient.auditApps().updateAuditApp("fakeid",requestAuditApp,null, HttpServletResponse.SC_NOT_FOUND);
|
||||
// 501
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2477,6 +2477,22 @@ public class PublicApiClient
|
||||
return null;
|
||||
}
|
||||
|
||||
public AuditApp updateAuditApp(String applicationId, AuditApp auditApp, Map<String, String> params, int expectedStatus) throws PublicApiException
|
||||
{
|
||||
HttpResponse response = update("audit-applications", applicationId,null,null, auditApp.toJSON().toString(), params, "Eriks test failed", expectedStatus);
|
||||
|
||||
if (response != null && response.getJsonResponse() != null)
|
||||
{
|
||||
JSONObject jsonEntry = (JSONObject) response.getJsonResponse().get("entry");
|
||||
if (jsonEntry != null)
|
||||
{
|
||||
return AuditApp.parseAuditApp(jsonEntry);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user