James Moger
2012-12-21 b2d0287b3f424c7f9ada44834365bf909db62a50
Fixed regression in isFrozen (issue-181)
3 files modified
45 ■■■■■ changed files
docs/04_releases.mkd 1 ●●●● patch | view | raw | blame | history
src/com/gitblit/GitServlet.java 4 ●●●● patch | view | raw | blame | history
tests/com/gitblit/tests/GitServletTest.java 40 ●●●●● patch | view | raw | blame | history
docs/04_releases.mkd
@@ -12,6 +12,7 @@
#### fixes
- Fixed regression in *isFrozen* (issue 181)
- Author metrics can be broken by newlines in email addresses from converted repositories (issue 176)
- Set subjectAlternativeName on generated SSL cert if CN is an ip address (issue 170)
- Fixed incorrect links on history page for files not in the current/active commit (issue 166)
src/com/gitblit/GitServlet.java
@@ -124,6 +124,10 @@
                rp.setAllowDeletes(user.canDeleteRef(repository));
                rp.setAllowNonFastForwards(user.canRewindRef(repository));
                
                if (repository.isFrozen) {
                    throw new ServiceNotEnabledException();
                }
                return rp;
            }
        });
tests/com/gitblit/tests/GitServletTest.java
@@ -223,6 +223,46 @@
    }
    
    @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));