James Moger
2013-11-26 4fcac9d2cbdafb51e3ee9ca3b3da64fd86103174
src/test/java/com/gitblit/tests/RpcTests.java
@@ -37,6 +37,7 @@
import com.gitblit.Constants.AuthorizationControl;
import com.gitblit.Constants.PermissionType;
import com.gitblit.Constants.RegistrantType;
import com.gitblit.GitBlitException.NotAllowedException;
import com.gitblit.GitBlitException.UnauthorizedException;
import com.gitblit.Keys;
import com.gitblit.RpcServlet;
@@ -53,9 +54,9 @@
/**
 * Tests all the rpc client utility methods, the rpc filter and rpc servlet.
 *
 *
 * @author James Moger
 *
 *
 */
public class RpcTests {
@@ -101,6 +102,20 @@
      list = RpcUtils.getUsers(url, "admin", "admin".toCharArray());
      assertTrue("User list is empty!", list.size() > 0);
   }
   @Test
   public void testGetUser() throws IOException {
      UserModel user = null;
      try {
         user = RpcUtils.getUser("admin", url, null, null);
      } catch (NotAllowedException e) {
      }
      assertNull("Server allows anyone to get user!", user);
      user = RpcUtils.getUser("admin", url, "admin", "admin".toCharArray());
      assertEquals("User is not the admin!", "admin", user.username);
      assertTrue("User is not an administrator!", user.canAdmin());
   }
   @Test
@@ -200,7 +215,7 @@
      assertTrue("Failed to update repository!", RpcUtils.updateRepository(retrievedRepository.name, retrievedRepository,
            url, account, password.toCharArray()));
      retrievedRepository = findRepository(retrievedRepository.name);
      // memberships
      UserModel testMember = new UserModel("justadded");
      assertTrue(RpcUtils.createUser(testMember, url, account, password.toCharArray()));
@@ -257,7 +272,7 @@
   public void testTeamAdministration() throws IOException {
      List<TeamModel> teams = RpcUtils.getTeams(url, account, password.toCharArray());
      assertEquals(1, teams.size());
      // Create the A-Team
      TeamModel aTeam = new TeamModel("A-Team");
      aTeam.users.add("admin");
@@ -287,7 +302,7 @@
         }
      }
      assertNotNull(helloworld);
      // Confirm that we have added the team
      List<String> helloworldTeams = RpcUtils.getRepositoryTeams(helloworld, url, account,
            password.toCharArray());
@@ -304,7 +319,7 @@
      helloworldTeams = RpcUtils.getRepositoryTeams(helloworld, url, account,
            password.toCharArray());
      assertEquals(0, helloworldTeams.size());
      // delete the A-Team
      assertTrue(RpcUtils.deleteTeam(aTeam, url, account, password.toCharArray()));