1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-12 09:17:41 +03:00

Bug #847 - #918: Add chauth method in Java OCA

This commit is contained in:
Carlos Martín 2011-10-17 17:05:02 +02:00
parent 6b43690216
commit 64bd883283
2 changed files with 41 additions and 0 deletions

View File

@ -33,6 +33,7 @@ public class User extends PoolElement{
private static final String DELETE = METHOD_PREFIX + "delete";
private static final String PASSWD = METHOD_PREFIX + "passwd";
private static final String CHGRP = METHOD_PREFIX + "chgrp";
private static final String CHAUTH = METHOD_PREFIX + "chauth";
/**
* Creates a new User representation.
@ -143,6 +144,19 @@ public class User extends PoolElement{
return client.call(CHGRP, id, gid);
}
/**
* Changes the auth driver of the given user
*
* @param client XML-RPC Client.
* @param id The user id (uid) of the target user we want to modify.
* @param auth The new auth driver.
* @return If an error occurs the error message contains the reason.
*/
public static OneResponse chauth(Client client, int id, String auth)
{
return client.call(CHAUTH, id, auth);
}
// =================================
// Instanced object XML-RPC methods
// =================================
@ -193,6 +207,17 @@ public class User extends PoolElement{
return chgrp(client, id, gid);
}
/**
* Changes the auth driver of the given user
*
* @param auth The new auth driver.
* @return If an error occurs the error message contains the reason.
*/
public OneResponse chauth(String auth)
{
return chauth(client, id, auth);
}
// =================================
// Helpers
// =================================

View File

@ -113,6 +113,22 @@ public class UserTest
assertTrue( user.xpath("ENABLED").equals("1") );
}
@Test
public void chauth()
{
res = user.info();
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( user.xpath("AUTH_DRIVER").equals("core") );
res = user.chauth("new_driver");
res = user.info();
assertTrue( res.getErrorMessage(), !res.isError() );
assertTrue( user.xpath("AUTH_DRIVER").equals("new_driver") );
}
@Test
public void delete()
{