| | |
| | | import org.eclipse.jgit.transport.RemoteRefUpdate.Status; |
| | | import org.eclipse.jgit.util.FileUtils; |
| | | import org.junit.AfterClass; |
| | | import org.junit.Assert; |
| | | import org.junit.BeforeClass; |
| | | import org.junit.Test; |
| | | |
| | | import com.gitblit.Constants.AccessRestrictionType; |
| | | import com.gitblit.Constants.AuthorizationControl; |
| | | import com.gitblit.GitBlit; |
| | | import com.gitblit.models.RepositoryModel; |
| | | |
| | | public class GitDaemonTest extends Assert { |
| | | public class GitDaemonTest extends GitblitUnitTest { |
| | | |
| | | static File ticgitFolder = new File(GitBlitSuite.REPOSITORIES, "working/ticgit"); |
| | | |
| | |
| | | } |
| | | |
| | | // set push restriction |
| | | RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git"); |
| | | RepositoryModel model = repositories().getRepositoryModel("ticgit.git"); |
| | | model.accessRestriction = AccessRestrictionType.PUSH; |
| | | model.authorizationControl = AuthorizationControl.NAMED; |
| | | GitBlit.self().updateRepositoryModel(model.name, model, false); |
| | | repositories().updateRepositoryModel(model.name, model, false); |
| | | |
| | | CloneCommand clone = Git.cloneRepository(); |
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url)); |
| | |
| | | // restore anonymous repository access |
| | | model.accessRestriction = AccessRestrictionType.NONE; |
| | | model.authorizationControl = AuthorizationControl.NAMED; |
| | | GitBlit.self().updateRepositoryModel(model.name, model, false); |
| | | repositories().updateRepositoryModel(model.name, model, false); |
| | | } |
| | | |
| | | @Test |
| | |
| | | } |
| | | |
| | | // restrict repository access |
| | | RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git"); |
| | | RepositoryModel model = repositories().getRepositoryModel("ticgit.git"); |
| | | model.accessRestriction = AccessRestrictionType.CLONE; |
| | | model.authorizationControl = AuthorizationControl.NAMED; |
| | | GitBlit.self().updateRepositoryModel(model.name, model, false); |
| | | repositories().updateRepositoryModel(model.name, model, false); |
| | | |
| | | // delete any existing working folder |
| | | boolean cloned = false; |
| | |
| | | // restore anonymous repository access |
| | | model.accessRestriction = AccessRestrictionType.NONE; |
| | | model.authorizationControl = AuthorizationControl.NAMED; |
| | | GitBlit.self().updateRepositoryModel(model.name, model, false); |
| | | repositories().updateRepositoryModel(model.name, model, false); |
| | | } |
| | | |
| | | @Test |
| | |
| | | } |
| | | |
| | | // restore anonymous repository access |
| | | RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git"); |
| | | RepositoryModel model = repositories().getRepositoryModel("ticgit.git"); |
| | | model.accessRestriction = AccessRestrictionType.NONE; |
| | | model.authorizationControl = AuthorizationControl.NAMED; |
| | | GitBlit.self().updateRepositoryModel(model.name, model, false); |
| | | repositories().updateRepositoryModel(model.name, model, false); |
| | | |
| | | CloneCommand clone = Git.cloneRepository(); |
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url)); |
| | |
| | | } |
| | | |
| | | // restore anonymous repository access |
| | | RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git"); |
| | | RepositoryModel model = repositories().getRepositoryModel("ticgit.git"); |
| | | model.accessRestriction = AccessRestrictionType.PUSH; |
| | | model.authorizationControl = AuthorizationControl.NAMED; |
| | | GitBlit.self().updateRepositoryModel(model.name, model, false); |
| | | repositories().updateRepositoryModel(model.name, model, false); |
| | | |
| | | CloneCommand clone = Git.cloneRepository(); |
| | | clone.setURI(MessageFormat.format("{0}/ticgit.git", url)); |
| | |
| | | assertTrue(true); |
| | | |
| | | // freeze repo |
| | | RepositoryModel model = GitBlit.self().getRepositoryModel("test/jgit.git"); |
| | | RepositoryModel model = repositories().getRepositoryModel("test/jgit.git"); |
| | | model.isFrozen = true; |
| | | GitBlit.self().updateRepositoryModel(model.name, model, false); |
| | | repositories().updateRepositoryModel(model.name, model, false); |
| | | |
| | | Git git = Git.open(jgitFolder); |
| | | File file = new File(jgitFolder, "TODO"); |
| | |
| | | |
| | | // unfreeze repo |
| | | model.isFrozen = false; |
| | | GitBlit.self().updateRepositoryModel(model.name, model, false); |
| | | repositories().updateRepositoryModel(model.name, model, false); |
| | | |
| | | results = git.push().setPushAll().call(); |
| | | GitBlitSuite.close(git); |