use of org.eclipse.jgit.transport.ReceiveCommand in project gitblit by gitblit.
the class GroovyScriptTest method testProtectRefsDeleteTag.
@Test
public void testProtectRefsDeleteTag() throws Exception {
MockGitblit gitblit = new MockGitblit();
MockLogger logger = new MockLogger();
MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
ReceiveCommand command = new ReceiveCommand(ObjectId.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(), "refs/tags/v1.0");
commands.add(command);
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
assertEquals(ReceiveCommand.Result.REJECTED_NODELETE, command.getResult());
assertEquals(0, logger.messages.size());
}
use of org.eclipse.jgit.transport.ReceiveCommand in project gitblit by gitblit.
the class GroovyScriptTest method testProtectRefsDeleteOtherBranch.
@Test
public void testProtectRefsDeleteOtherBranch() throws Exception {
MockGitblit gitblit = new MockGitblit();
MockLogger logger = new MockLogger();
MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), ObjectId.zeroId(), "refs/heads/other"));
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
assertEquals(0, logger.messages.size());
}
use of org.eclipse.jgit.transport.ReceiveCommand in project gitblit by gitblit.
the class GroovyScriptTest method testBlockPush.
@Test
public void testBlockPush() throws Exception {
MockGitblit gitblit = new MockGitblit();
MockLogger logger = new MockLogger();
MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId.fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
try {
test("blockpush.groovy", gitblit, logger, clientLogger, commands, repository);
assertTrue("blockpush should have failed!", false);
} catch (GitBlitException e) {
assertTrue(e.getMessage().contains("failed"));
}
}
use of org.eclipse.jgit.transport.ReceiveCommand in project gitblit by gitblit.
the class GroovyScriptTest method testProtectRefsCreateBranch.
@Test
public void testProtectRefsCreateBranch() throws Exception {
MockGitblit gitblit = new MockGitblit();
MockLogger logger = new MockLogger();
MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId.zeroId(), ObjectId.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
test("protect-refs.groovy", gitblit, logger, clientLogger, commands, repository);
}
use of org.eclipse.jgit.transport.ReceiveCommand in project gitblit by gitblit.
the class GroovyScriptTest method testClientLogging.
@Test
public void testClientLogging() throws Exception {
MockGitblit gitblit = new MockGitblit();
MockLogger logger = new MockLogger();
MockClientLogger clientLogger = new MockClientLogger();
List<ReceiveCommand> commands = new ArrayList<ReceiveCommand>();
commands.add(new ReceiveCommand(ObjectId.fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
RepositoryModel repository = new RepositoryModel("ex@mple.git", "", "admin", new Date());
File groovyDir = repositories().getHooksFolder();
File tempScript = File.createTempFile("testClientLogging", "groovy", groovyDir);
tempScript.deleteOnExit();
BufferedWriter writer = new BufferedWriter(new FileWriter(tempScript));
writer.write("clientLogger.info('this is a test message')\n");
writer.flush();
writer.close();
test(tempScript.getName(), gitblit, logger, clientLogger, commands, repository);
assertTrue("Message Missing", clientLogger.messages.contains("this is a test message"));
}
Aggregations