|
|
@@ -25,6 +25,7 @@ import java.text.MessageFormat; |
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
|
@@ -73,20 +74,40 @@ public class GroovyScriptTest { |
|
|
|
.fromString("c18877690322dfc6ae3e37bb7f7085a24e94e887"), ObjectId
|
|
|
|
.fromString("3fa7c46d11b11d61f1cbadc6888be5d0eae21969"), "refs/heads/master"));
|
|
|
|
|
|
|
|
test("sendmail.groovy", gitblit, logger, commands);
|
|
|
|
RepositoryModel repository = GitBlit.self().getRepositoryModel("helloworld.git");
|
|
|
|
repository.mailingLists.add("list@helloworld.git");
|
|
|
|
|
|
|
|
test("sendmail.groovy", gitblit, logger, commands, repository);
|
|
|
|
assertEquals(1, logger.messages.size());
|
|
|
|
assertEquals(1, gitblit.messages.size());
|
|
|
|
MockMail m = gitblit.messages.get(0);
|
|
|
|
assertEquals(5, m.toAddresses.size());
|
|
|
|
assertTrue(m.message.contains("BIT"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testBlockPush() throws Exception {
|
|
|
|
MockGitblit gitblit = new MockGitblit();
|
|
|
|
MockLogger logger = new MockLogger();
|
|
|
|
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, commands, repository);
|
|
|
|
assertTrue("blockpush should have failed!", false);
|
|
|
|
} catch (GitBlitException e) {
|
|
|
|
assertTrue(e.getMessage().contains("failed"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void test(String script, MockGitblit gitblit, MockLogger logger,
|
|
|
|
List<ReceiveCommand> commands) throws Exception {
|
|
|
|
List<ReceiveCommand> commands, RepositoryModel repository) throws Exception {
|
|
|
|
|
|
|
|
UserModel user = new UserModel("mock");
|
|
|
|
RepositoryModel repository = GitBlit.self().getRepositoryModel("helloworld.git");
|
|
|
|
repository.mailingLists.add("list@helloworld.git");
|
|
|
|
|
|
|
|
String gitblitUrl = GitBlitSuite.url;
|
|
|
|
|