Permalink
Browse files

Merge latest master

  • Loading branch information...
2 parents 163882e + fa97b00 commit edc915a462cc9151e53c08cbc7a77e5068ff3794 Jennifer Hickey committed Aug 3, 2010
View
@@ -1,6 +1,11 @@
+Changes in HQApi 3.3
+
Changes in HQApi 3.2
+ *) Add support to get and sync platform resources by FQDN.
+ No corresponding CLI command was explicitly implemented.
+
*) [HHQ-4058] Also update the agent when syncing platforms
*) [HHQ-4060] Add --groupId option to metricData list CLI command.
@@ -84,6 +89,24 @@ Changes in HQApi 3.0
*) [HHQ-3144] Add ServerConfigApi to allow manipulation of HQ server config
settings.
+
+Changes in HQApi 2.6
+
+ *) [HHQ-4151] Add new API to ResourceApi to find a platform Resource
+ based on the passed resource id. Extended support for this into the
+ CLI using the --parentPlatform flag to resource list.
+
+ *) [HHQ-4150] Make --count optional when listing alerts via the CLI.
+
+ *) [HHQ-4145] Add --addRole, --removeRole, and --clearRoles options to
+ command line group syncing. These can only be used with --name.
+
+Changes in HQApi 2.5
+
+ *) [HHQ-4133] Perform permission checking on ResourceApi.
+
+ *) Back port AlertApi to 2.x branch. As a part of this change portions of
+ the new MetricDataApi were also backported to aid in testing.
Changes in HQApi 2.4
@@ -32,7 +32,11 @@
import org.hyperic.hq.hqapi1.types.Resource;
import org.hyperic.hq.hqapi1.types.ResourcePrototype;
import org.hyperic.hq.hqapi1.types.ResourcePrototypeResponse;
+import org.hyperic.hq.hqapi1.types.ResourceResponse;
import org.hyperic.hq.hqapi1.types.ResourcesResponse;
+import org.hyperic.hq.hqapi1.types.User;
+
+import java.util.List;
public class ResourceFind_test extends ResourceTestBase {
@@ -132,4 +136,56 @@ public void testFindByDescriptionNoMatches() throws Exception {
assertTrue("Found matches for '" + DESC + "'", response.getResource().size() == 0);
}
+
+ public void testFindResourceByAgentUnauthorized() throws Exception {
+ List<User> users = createTestUsers(1);
+ User user = users.get(0);
+ ResourceApi api = getApi(user.getName(), TESTUSER_PASSWORD).getResourceApi();
+
+ // Use admin user to get local agent..
+ Agent agent = getRunningAgent();
+
+ // Test find by agent
+ ResourcesResponse response = api.getResources(agent, false, false);
+ hqAssertSuccess(response);
+
+ assertTrue("Found resources with unauthorized user", response.getResource().size() == 0);
+
+ deleteTestUsers(users);
+ }
+
+ public void testFindResourceByPrototypeUnauthorized() throws Exception {
+ List<User> users = createTestUsers(1);
+ User user = users.get(0);
+ ResourceApi api = getApi(user.getName(), TESTUSER_PASSWORD).getResourceApi();
+
+ // Use admin user to get local platform..
+ Resource localPlatform = getLocalPlatformResource(false, false);
+
+ // Test find by prototype
+ ResourcesResponse response = api.getResources(localPlatform.getResourcePrototype(), false, false);
+ hqAssertSuccess(response);
+
+ assertTrue("Found resources with unauthorized user", response.getResource().size() == 0);
+
+ deleteTestUsers(users);
+ }
+
+ public void testFindResourceByDescriptionUnauthorized() throws Exception {
+ final String DESC = "Hyperic HQ monitor Agent";
+ List<User> users = createTestUsers(1);
+ User user = users.get(0);
+ ResourceApi api = getApi(user.getName(), TESTUSER_PASSWORD).getResourceApi();
+
+ // Use admin user to get local platform..
+ Resource localPlatform = getLocalPlatformResource(false, false);
+
+ // Test find by prototype
+ ResourcesResponse response = api.getResources(DESC, false, false);
+ hqAssertSuccess(response);
+
+ assertTrue("Found resources with unauthorized user", response.getResource().size() == 0);
+
+ deleteTestUsers(users);
+ }
}
@@ -209,4 +209,97 @@ private String getFqdn(Resource r) {
}
return fqdn;
}
+
+ public void testGetResourceByIdUnauthorized() throws Exception {
+ List<User> users = createTestUsers(1);
+ User user = users.get(0);
+ ResourceApi api = getApi(user.getName(), TESTUSER_PASSWORD).getResourceApi();
+
+ // Use admin user to get local platform..
+ Resource localPlatform = getLocalPlatformResource(false, false);
+
+ // Test find by ID
+ ResourceResponse response = api.getResource(localPlatform.getId(), false, false);
+ hqAssertFailurePermissionDenied(response);
+
+ deleteTestUsers(users);
+ }
+
+ public void testGetResourceByNameUnauthorized() throws Exception {
+ List<User> users = createTestUsers(1);
+ User user = users.get(0);
+ ResourceApi api = getApi(user.getName(), TESTUSER_PASSWORD).getResourceApi();
+
+ // Use admin user to get local platform..
+ Resource localPlatform = getLocalPlatformResource(false, false);
+
+ // Test find by name
+ ResourceResponse response = api.getPlatformResource(localPlatform.getName(), false, false);
+ hqAssertFailurePermissionDenied(response);
+
+ deleteTestUsers(users);
+ }
+
+ public void testGetPlatformResourceByPlatform() throws Exception {
+
+ ResourceApi api = getApi().getResourceApi();
+ Resource localPlatform = getLocalPlatformResource(false, false);
+
+ ResourceResponse response = api.getPlatformResource(localPlatform.getId(), false, false);
+ hqAssertSuccess(response);
+
+ assertEquals("Platform ids not equal", localPlatform.getId(),
+ response.getResource().getId());
+ }
+
+ public void testGetPlatformResourceByServer() throws Exception {
+
+ ResourceApi api = getApi().getResourceApi();
+ Resource localPlatform = getLocalPlatformResource(false, true);
+
+ List<Resource> servers = localPlatform.getResource();
+ assertTrue("No servers found for " + localPlatform.getName(),
+ servers.size() > 0);
+
+ Resource server = servers.get(0);
+
+ ResourceResponse response = api.getPlatformResource(server.getId(), false, false);
+ hqAssertSuccess(response);
+
+ assertEquals("Platform ids not equal", localPlatform.getId(),
+ response.getResource().getId());
+ }
+
+ public void testGetPlatformResourceByService() throws Exception {
+
+ ResourceApi api = getApi().getResourceApi();
+ Resource localPlatform = getLocalPlatformResource(false, true);
+
+ List<Resource> servers = localPlatform.getResource();
+ assertTrue("No servers found for " + localPlatform.getName(),
+ servers.size() > 0);
+ Resource service = null;
+ for (Resource server : servers) {
+ if (server.getResource().size() > 0) {
+ service = server.getResource().get(0);
+ break;
+ }
+ }
+
+ assertNotNull("Unable to find a service for platform " + localPlatform.getName(),
+ service);
+
+ ResourceResponse response = api.getPlatformResource(service.getId(), false, false);
+ hqAssertSuccess(response);
+
+ assertEquals("Platform ids not equal", localPlatform.getId(),
+ response.getResource().getId());
+ }
+
+ public void testGetPlatformResourceInvalidId() throws Exception {
+ ResourceApi api = getApi().getResourceApi();
+
+ ResourceResponse response = api.getPlatformResource(Integer.MAX_VALUE, false, false);
+ hqAssertFailureObjectNotFound(response);
+ }
}
Oops, something went wrong.

0 comments on commit edc915a

Please sign in to comment.