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