mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
F #4775: Add new argument to Java OCA
This commit is contained in:
parent
c1c61fe5c0
commit
affaf7068a
@ -77,7 +77,9 @@ public class User extends PoolElement{
|
||||
String username,
|
||||
String password)
|
||||
{
|
||||
return allocate(client, username, password, "");
|
||||
Integer[] empty = new Integer[0];
|
||||
|
||||
return allocate(client, username, password, "", empty);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,15 +89,18 @@ public class User extends PoolElement{
|
||||
* @param username Username for the new user.
|
||||
* @param password Password for the new user
|
||||
* @param auth Auth driver for the new user.
|
||||
* @param gids Group IDs. The first ID will be used as the main group. This
|
||||
* array can be empty, in which case the default group will be used.
|
||||
* @return If successful the message contains
|
||||
* the associated id (int uid) generated for this user.
|
||||
*/
|
||||
public static OneResponse allocate(Client client,
|
||||
String username,
|
||||
String password,
|
||||
String auth)
|
||||
String auth,
|
||||
Integer[] gids)
|
||||
{
|
||||
return client.call(ALLOCATE, username, password, auth);
|
||||
return client.call(ALLOCATE, username, password, auth, gids);
|
||||
}
|
||||
|
||||
/** Retrieves the information of the given user.
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
@ -29,6 +29,7 @@ import org.opennebula.client.OneResponse;
|
||||
import org.opennebula.client.OneSystem;
|
||||
import org.opennebula.client.user.User;
|
||||
import org.opennebula.client.user.UserPool;
|
||||
import org.opennebula.client.group.Group;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
public class UserTest
|
||||
@ -99,6 +100,47 @@ public class UserTest
|
||||
assertTrue( found );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allocateInGroup()
|
||||
{
|
||||
user.delete();
|
||||
|
||||
res = Group.allocate(client, "group_a");
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
int group_a_id = Integer.parseInt(res.getMessage());
|
||||
Group group_a = new Group(group_a_id, client);
|
||||
|
||||
res = Group.allocate(client, "group_b");
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
int group_b_id = Integer.parseInt(res.getMessage());
|
||||
Group group_b = new Group(group_b_id, client);
|
||||
|
||||
res = Group.allocate(client, "group_c");
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
int group_c_id = Integer.parseInt(res.getMessage());
|
||||
Group group_c = new Group(group_c_id, client);
|
||||
|
||||
Integer[] gids = {group_b_id, group_a_id};
|
||||
res = User.allocate(client, "test_user_in_group", "pass", "", gids);
|
||||
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
user = new User(Integer.parseInt(res.getMessage()), client);
|
||||
|
||||
res = user.info();
|
||||
assertTrue( res.getErrorMessage(), !res.isError() );
|
||||
|
||||
assertTrue( user.gid() == group_b_id );
|
||||
|
||||
group_a.info();
|
||||
group_b.info();
|
||||
group_c.info();
|
||||
|
||||
assertTrue( group_a.contains(user.id()) );
|
||||
assertTrue( group_b.contains(user.id()) );
|
||||
assertFalse( group_c.contains(user.id()) );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void info()
|
||||
{
|
||||
|
@ -98,6 +98,14 @@ module OpenNebula
|
||||
# +username+ Name of the new user.
|
||||
#
|
||||
# +password+ Password for the new user
|
||||
# @param username Username for the new user.
|
||||
# @param password Password for the new user
|
||||
# @param driver Auth driver for the new user.
|
||||
# @param gids Group IDs. The first ID will be used as the main group.
|
||||
# This array can be empty, in which case the default group will be used.
|
||||
#
|
||||
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
||||
# otherwise
|
||||
def allocate(username, password, driver=nil, gids=[])
|
||||
driver = CORE_AUTH if driver.nil?
|
||||
super(USER_METHODS[:allocate], username, password, driver, gids)
|
||||
|
Loading…
x
Reference in New Issue
Block a user