summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-12-21 17:35:18 -0500
committerJames Moger <james.moger@gitblit.com>2012-12-21 17:35:18 -0500
commitb2d0287b3f424c7f9ada44834365bf909db62a50 (patch)
tree8b121b27aba638a00814c9524a8ef91ccfc4985d /tests
parent7b0f3069ec3011650c9628b6e17c01d5e845ca46 (diff)
downloadgitblit-b2d0287b3f424c7f9ada44834365bf909db62a50.tar.gz
gitblit-b2d0287b3f424c7f9ada44834365bf909db62a50.zip
Fixed regression in isFrozen (issue 181)
Diffstat (limited to 'tests')
-rw-r--r--tests/com/gitblit/tests/GitServletTest.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/com/gitblit/tests/GitServletTest.java b/tests/com/gitblit/tests/GitServletTest.java
index e65c61cb..07771a20 100644
--- a/tests/com/gitblit/tests/GitServletTest.java
+++ b/tests/com/gitblit/tests/GitServletTest.java
@@ -223,6 +223,46 @@ public class GitServletTest {
}
@Test
+ public void testPushToFrozenRepo() throws Exception {
+ CloneCommand clone = Git.cloneRepository();
+ clone.setURI(MessageFormat.format("{0}/git/test/jgit.git", url));
+ clone.setDirectory(jgitFolder);
+ clone.setBare(false);
+ clone.setCloneAllBranches(true);
+ clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
+ GitBlitSuite.close(clone.call());
+ assertTrue(true);
+
+ // freeze repo
+ RepositoryModel model = GitBlit.self().getRepositoryModel("test/jgit.git");
+ model.isFrozen = true;
+ GitBlit.self().updateRepositoryModel(model.name, model, false);
+
+ Git git = Git.open(jgitFolder);
+ File file = new File(jgitFolder, "TODO");
+ OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(file, true), Constants.CHARSET);
+ BufferedWriter w = new BufferedWriter(os);
+ w.write("// " + new Date().toString() + "\n");
+ w.close();
+ git.add().addFilepattern(file.getName()).call();
+ git.commit().setMessage("test commit").call();
+
+ try {
+ git.push().setPushAll().call();
+ assertTrue(false);
+ } catch (Exception e) {
+ assertTrue(e.getCause().getMessage().contains("access forbidden"));
+ }
+
+ // unfreeze repo
+ model.isFrozen = false;
+ GitBlit.self().updateRepositoryModel(model.name, model, false);
+
+ git.push().setPushAll().call();
+ GitBlitSuite.close(git);
+ }
+
+ @Test
public void testPushToNonBareRepository() throws Exception {
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/git/working/jgit", url));