/
GroupControlExecute_test.java
91 lines (72 loc) · 3.23 KB
/
GroupControlExecute_test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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);
}
}