From 64bd8832831531d77703987af8984fe2b57e4821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 17 Oct 2011 17:05:02 +0200 Subject: [PATCH] Bug #847 - #918: Add chauth method in Java OCA --- .../src/org/opennebula/client/user/User.java | 25 +++++++++++++++++++ src/oca/java/test/UserTest.java | 16 ++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/oca/java/src/org/opennebula/client/user/User.java b/src/oca/java/src/org/opennebula/client/user/User.java index f2969cfeec..f81da16fb1 100644 --- a/src/oca/java/src/org/opennebula/client/user/User.java +++ b/src/oca/java/src/org/opennebula/client/user/User.java @@ -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 // ================================= diff --git a/src/oca/java/test/UserTest.java b/src/oca/java/test/UserTest.java index eb39adc8e2..079dd7c31e 100644 --- a/src/oca/java/test/UserTest.java +++ b/src/oca/java/test/UserTest.java @@ -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() {