Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated alert acknowledgement integration test for enhanced Alert ACL

  • Loading branch information...
commit 7063810716b922796966397db027e41b897bc826 1 parent 6601291
pnguyen authored
View
38 src/org/hyperic/hq/hqapi1/test/AlertAck_test.java
@@ -1,12 +1,16 @@
package org.hyperic.hq.hqapi1.test;
import org.hyperic.hq.hqapi1.types.Alert;
-import org.hyperic.hq.hqapi1.types.Resource;
+import org.hyperic.hq.hqapi1.types.AlertResponse;
import org.hyperic.hq.hqapi1.types.Escalation;
+import org.hyperic.hq.hqapi1.types.Group;
+import org.hyperic.hq.hqapi1.types.Operation;
+import org.hyperic.hq.hqapi1.types.Resource;
+import org.hyperic.hq.hqapi1.types.Role;
import org.hyperic.hq.hqapi1.types.User;
-import org.hyperic.hq.hqapi1.types.AlertResponse;
import org.hyperic.hq.hqapi1.AlertApi;
+import java.util.Collections;
import java.util.List;
public class AlertAck_test extends AlertTestBase {
@@ -55,6 +59,36 @@ public void testAckAlertNoPermission() throws Exception {
deleteEscalation(e);
deleteTestUsers(users);
}
+
+ public void testAckAlertAlertingPermission() throws Exception {
+ Resource platform = getLocalPlatformResource(false, false);
+ Escalation e = createEscalation();
+ Alert a = generateAlerts(platform, e);
+ validateAlert(a);
+
+ // Create user/group/role with insufficient permissions
+ List<User> users = createTestUsers(1);
+ User unprivUser = users.get(0);
+ Role alertRole = createRole(Collections.singletonList(unprivUser),
+ Collections.singletonList(Operation.MANAGE_PLATFORM_ALERTS));
+ Group groupWithRole = createGroup(Collections.singletonList(platform),
+ Collections.singletonList(alertRole));
+
+ AlertApi apiUnpriv = getApi(unprivUser.getName(), TESTUSER_PASSWORD).getAlertApi();
+
+ // Test ack (alert will be in Escalation) with an unprivileged user.
+ // Role needs alerting and at least view resource permissions
+ // in order to ack alerts
+ AlertResponse ackResponse = apiUnpriv.ackAlert(a.getId(), "Test ACK", 60000l);
+ hqAssertFailurePermissionDenied(ackResponse);
+
+ // Cleanup
+ deleteAlertDefinitionByAlert(a);
+ deleteEscalation(e);
+ deleteTestUsers(users);
+ cleanupRole(alertRole);
+ cleanupGroup(groupWithRole);
+ }
public void testAckUnacknowledableAlert() throws Exception {
Resource platform = getLocalPlatformResource(false, false);
View
5 src/org/hyperic/hq/hqapi1/test/HQApiTestBase.java
@@ -197,9 +197,12 @@ protected Resource getLocalPlatformResource(boolean verbose,
hqAssertSuccess(resourceResponse);
Resource localPlatform = null;
+ List<String> invalidPlatforms = new ArrayList<String>();
+ invalidPlatforms.add("Network Device");
+ invalidPlatforms.add("Network Host");
for (Resource r : resourceResponse.getResource()) {
- if (!r.getResourcePrototype().getName().equals("Network Device")) {
+ if (!invalidPlatforms.contains(r.getResourcePrototype().getName())) {
localPlatform = r;
break;
}
Please sign in to comment.
Something went wrong with that request. Please try again.