Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add group control action tests to support HHQ-3411
- Loading branch information
pnguyen
committed
Sep 23, 2009
1 parent
e3d8e5b
commit 774f994
Showing
3 changed files
with
282 additions
and
0 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
src/org/hyperic/hq/hqapi1/test/GroupControlAction_test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* | ||
* NOTE: This copyright does *not* cover user programs that use HQ | ||
* program services by normal system calls through the application | ||
* program interfaces provided as part of the Hyperic Plug-in Development | ||
* Kit or the Hyperic Client Development Kit - this is merely considered | ||
* normal use of the program, and does *not* fall under the heading of | ||
* "derived work". | ||
* | ||
* Copyright (C) [2008, 2009], Hyperic, Inc. | ||
* This file is part of HQ. | ||
* | ||
* HQ is free software; you can redistribute it and/or modify | ||
* it under the terms version 2 of the GNU General Public License as | ||
* published by the Free Software Foundation. This program is distributed | ||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
* USA. | ||
* | ||
*/ | ||
|
||
package org.hyperic.hq.hqapi1.test; | ||
|
||
import org.hyperic.hq.hqapi1.ControlApi; | ||
import org.hyperic.hq.hqapi1.HQApi; | ||
import org.hyperic.hq.hqapi1.types.ControlActionResponse; | ||
import org.hyperic.hq.hqapi1.types.Group; | ||
import org.hyperic.hq.hqapi1.types.User; | ||
|
||
import java.util.List; | ||
|
||
public class GroupControlAction_test extends ControlTestBase { | ||
|
||
public GroupControlAction_test(String name) { | ||
super(name); | ||
} | ||
|
||
public void testControlActionInvalidGroup() throws Exception { | ||
ControlApi api = getApi().getControlApi(); | ||
|
||
Group g = new Group(); | ||
g.setResourceId(Integer.MAX_VALUE); | ||
|
||
ControlActionResponse response = api.getActions(g); | ||
hqAssertFailureObjectNotFound(response); | ||
} | ||
|
||
public void testControlActionValidGroup() throws Exception { | ||
HQApi api = getApi(); | ||
|
||
Group controlGroup = createControllableGroup(api); | ||
|
||
ControlApi cApi = api.getControlApi(); | ||
ControlActionResponse response = cApi.getActions(controlGroup); | ||
hqAssertSuccess(response); | ||
|
||
assertTrue("Should have found 1 control action for group " + | ||
controlGroup.getName(), response.getAction().size() == 1); | ||
|
||
assertEquals("run", response.getAction().get(0)); | ||
|
||
cleanupControllableGroup(api, controlGroup); | ||
} | ||
|
||
public void testControlActionNoPermission() throws Exception { | ||
HQApi api = getApi(); | ||
|
||
Group controlGroup = createControllableGroup(api); | ||
List<User> users = createTestUsers(1); | ||
User user = users.get(0); | ||
|
||
HQApi apiUnpriv = getApi(user.getName(), TESTUSER_PASSWORD); | ||
ControlApi cApiUnpriv = apiUnpriv.getControlApi(); | ||
|
||
ControlActionResponse response = cApiUnpriv.getActions(controlGroup); | ||
hqAssertFailurePermissionDenied(response); | ||
|
||
deleteTestUsers(users); | ||
cleanupControllableGroup(api, controlGroup); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/org/hyperic/hq/hqapi1/test/GroupControlExecute_test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* | ||
* NOTE: This copyright does *not* cover user programs that use HQ | ||
* program services by normal system calls through the application | ||
* program interfaces provided as part of the Hyperic Plug-in Development | ||
* Kit or the Hyperic Client Development Kit - this is merely considered | ||
* normal use of the program, and does *not* fall under the heading of | ||
* "derived work". | ||
* | ||
* Copyright (C) [2008, 2009], Hyperic, Inc. | ||
* This file is part of HQ. | ||
* | ||
* HQ is free software; you can redistribute it and/or modify | ||
* it under the terms version 2 of the GNU General Public License as | ||
* published by the Free Software Foundation. This program is distributed | ||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
* USA. | ||
* | ||
*/ | ||
|
||
package org.hyperic.hq.hqapi1.test; | ||
|
||
import org.hyperic.hq.hqapi1.ControlApi; | ||
import org.hyperic.hq.hqapi1.HQApi; | ||
import org.hyperic.hq.hqapi1.types.Group; | ||
import org.hyperic.hq.hqapi1.types.StatusResponse; | ||
import org.hyperic.hq.hqapi1.types.User; | ||
|
||
import java.util.List; | ||
|
||
public class GroupControlExecute_test extends ControlTestBase { | ||
|
||
public GroupControlExecute_test(String name) { | ||
super(name); | ||
} | ||
|
||
public void testExecuteInvalidGroup() throws Exception { | ||
ControlApi api = getApi().getControlApi(); | ||
|
||
Group g = new Group(); | ||
g.setResourceId(Integer.MAX_VALUE); | ||
|
||
StatusResponse response = api.executeAction(g, "none", new String[] {}); | ||
hqAssertFailureObjectNotFound(response); | ||
} | ||
|
||
public void testExecuteValidGroup() throws Exception { | ||
HQApi api = getApi(); | ||
|
||
Group controlGroup = createControllableGroup(api); | ||
String[] arguments = new String[0]; | ||
|
||
ControlApi cApi = api.getControlApi(); | ||
StatusResponse executeResponse = cApi.executeAction(controlGroup, | ||
"run", arguments); | ||
|
||
// TODO Update this when group control action execution is supported | ||
//hqAssertSuccess(executeResponse); | ||
hqAssertFailureNotSupported(executeResponse); | ||
|
||
cleanupControllableGroup(api, controlGroup); | ||
} | ||
|
||
public void testExecuteNoPermission() throws Exception { | ||
HQApi api = getApi(); | ||
|
||
Group controlGroup = createControllableGroup(api); | ||
List<User> users = createTestUsers(1); | ||
User user = users.get(0); | ||
|
||
HQApi apiUnpriv = getApi(user.getName(), TESTUSER_PASSWORD); | ||
ControlApi cApiUnpriv = apiUnpriv.getControlApi(); | ||
|
||
StatusResponse executeResponse = cApiUnpriv.executeAction(controlGroup, | ||
"run", new String[0]); | ||
|
||
// TODO Update this when group control action execution is supported | ||
//hqAssertFailurePermissionDenied(executeResponse); | ||
hqAssertFailureNotSupported(executeResponse); | ||
|
||
deleteTestUsers(users); | ||
cleanupControllableGroup(api, controlGroup); | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
src/org/hyperic/hq/hqapi1/test/GroupControlHistory_test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* | ||
* NOTE: This copyright does *not* cover user programs that use HQ | ||
* program services by normal system calls through the application | ||
* program interfaces provided as part of the Hyperic Plug-in Development | ||
* Kit or the Hyperic Client Development Kit - this is merely considered | ||
* normal use of the program, and does *not* fall under the heading of | ||
* "derived work". | ||
* | ||
* Copyright (C) [2008, 2009], Hyperic, Inc. | ||
* This file is part of HQ. | ||
* | ||
* HQ is free software; you can redistribute it and/or modify | ||
* it under the terms version 2 of the GNU General Public License as | ||
* published by the Free Software Foundation. This program is distributed | ||
* in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more | ||
* details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
* USA. | ||
* | ||
*/ | ||
|
||
package org.hyperic.hq.hqapi1.test; | ||
|
||
import org.hyperic.hq.hqapi1.ControlApi; | ||
import org.hyperic.hq.hqapi1.HQApi; | ||
import org.hyperic.hq.hqapi1.types.ControlHistoryResponse; | ||
import org.hyperic.hq.hqapi1.types.Group; | ||
import org.hyperic.hq.hqapi1.types.StatusResponse; | ||
import org.hyperic.hq.hqapi1.types.User; | ||
|
||
import java.util.List; | ||
|
||
public class GroupControlHistory_test extends ControlTestBase { | ||
|
||
public GroupControlHistory_test(String name) { | ||
super(name); | ||
} | ||
|
||
public void testControlHistoryInvalidGroup() throws Exception { | ||
ControlApi api = getApi().getControlApi(); | ||
|
||
Group g = new Group(); | ||
g.setResourceId(Integer.MAX_VALUE); | ||
|
||
ControlHistoryResponse response = api.getHistory(g); | ||
hqAssertFailureObjectNotFound(response); | ||
} | ||
|
||
public void testControlHistoryValidGroupWithHistory() throws Exception { | ||
HQApi api = getApi(); | ||
|
||
Group controlGroup = createControllableGroup(api); | ||
|
||
ControlApi cApi = getApi().getControlApi(); | ||
StatusResponse executeResponse = cApi.executeAction(controlGroup, | ||
"run", new String[0]); | ||
|
||
// TODO Update this when group control action execution is supported | ||
//hqAssertSuccess(executeResponse); | ||
hqAssertFailureNotSupported(executeResponse); | ||
|
||
// TODO Add control history test when group control action execution is supported | ||
|
||
cleanupControllableGroup(api, controlGroup); | ||
} | ||
|
||
public void testControlHistoryValidGroupWithoutHistory() throws Exception { | ||
HQApi api = getApi(); | ||
|
||
Group controlGroup = createControllableGroup(api); | ||
|
||
ControlApi cApi = getApi().getControlApi(); | ||
ControlHistoryResponse response = cApi.getHistory(controlGroup); | ||
hqAssertSuccess(response); | ||
|
||
assertTrue("Should have no control history for group " + controlGroup.getName(), | ||
response.getControlHistory().isEmpty()); | ||
|
||
cleanupControllableGroup(api, controlGroup); | ||
} | ||
|
||
public void testControlHistoryNoPermission() throws Exception { | ||
HQApi api = getApi(); | ||
|
||
Group controlGroup = createControllableGroup(api); | ||
List<User> users = createTestUsers(1); | ||
User user = users.get(0); | ||
|
||
HQApi apiUnpriv = getApi(user.getName(), TESTUSER_PASSWORD); | ||
ControlApi cApiUnpriv = apiUnpriv.getControlApi(); | ||
|
||
ControlHistoryResponse response = cApiUnpriv.getHistory(controlGroup); | ||
hqAssertFailurePermissionDenied(response); | ||
|
||
deleteTestUsers(users); | ||
cleanupControllableGroup(api, controlGroup); | ||
} | ||
} |