From ac7f1753d3f742e0af8dd5e142b4eac9d9d2fbba Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 28 Oct 2011 21:41:31 -0400
Subject: [PATCH] Preserve feed selections when not saving passwords

---
 tests/com/gitblit/tests/RpcTests.java |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/tests/com/gitblit/tests/RpcTests.java b/tests/com/gitblit/tests/RpcTests.java
index a20b918..637d488 100644
--- a/tests/com/gitblit/tests/RpcTests.java
+++ b/tests/com/gitblit/tests/RpcTests.java
@@ -16,6 +16,8 @@
 package com.gitblit.tests;
 
 import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -23,10 +25,13 @@
 
 import com.gitblit.Constants.AccessRestrictionType;
 import com.gitblit.GitBlitException.UnauthorizedException;
+import com.gitblit.Keys;
 import com.gitblit.models.FederationModel;
 import com.gitblit.models.FederationProposal;
 import com.gitblit.models.FederationSet;
 import com.gitblit.models.RepositoryModel;
+import com.gitblit.models.ServerSettings;
+import com.gitblit.models.ServerStatus;
 import com.gitblit.models.UserModel;
 import com.gitblit.utils.RpcUtils;
 
@@ -203,4 +208,45 @@
 		List<FederationSet> sets = RpcUtils.getFederationSets(url, account, password.toCharArray());
 		assertTrue("No federation sets were retrieved!", sets.size() > 0);
 	}
+
+	public void testSettings() throws Exception {
+		ServerSettings settings = RpcUtils.getSettings(url, account, password.toCharArray());
+		assertTrue("No settings were retrieved!", settings != null);
+	}
+
+	public void testServerStatus() throws Exception {
+		ServerStatus status = RpcUtils.getStatus(url, account, password.toCharArray());
+		assertTrue("No status was retrieved!", status != null);
+	}
+
+	public void testUpdateSettings() throws Exception {
+		Map<String, String> updated = new HashMap<String, String>();
+
+		// grab current setting
+		ServerSettings settings = RpcUtils.getSettings(url, account, password.toCharArray());
+		boolean showSizes = settings.get(Keys.web.showRepositorySizes).getBoolean(true);
+		showSizes = !showSizes;
+
+		// update setting
+		updated.put(Keys.web.showRepositorySizes, String.valueOf(showSizes));
+		boolean success = RpcUtils.updateSettings(updated, "http://localhost:8080/gb", account,
+				password.toCharArray());
+		assertTrue("Failed to update server settings", success);
+
+		// confirm setting change
+		settings = RpcUtils.getSettings(url, account, password.toCharArray());
+		boolean newValue = settings.get(Keys.web.showRepositorySizes).getBoolean(false);
+		assertEquals(newValue, showSizes);
+
+		// restore setting
+		newValue = !newValue;
+		updated.put(Keys.web.showRepositorySizes, String.valueOf(newValue));
+	}
+
+	public void testBranches() throws Exception {
+		Map<String, Collection<String>> branches = RpcUtils.getAllBranches(url, account,
+				password.toCharArray());
+		assertTrue(branches != null);
+		assertTrue(branches.size() > 0);
+	}
 }

--
Gitblit v1.9.1