Esempio n. 1
0
 def test_fork_with_same_name(self):
     Project.objects.create(name=u'mirror-same', author=self.request.user)
     data = {
         'username': u'whatever',
         'projectname': u'mirror-same',
         'as_private': u'checked',
     }
     form = GithubForkForm(data)
     form.request = self.request
     self.assertFalse(form.is_valid())
Esempio n. 2
0
 def test_fork(self):
     data = {
         'username': u'lukaszb',
         'projectname': u'django-guardian',
         #'as_private': u'checked',
     }
     form = GithubForkForm(data)
     form.request = self.request
     self.assertTrue(form.is_valid())
     fork = form.fork()
     fork = Project.objects.get(pk=fork.pk)
     self.assertTrue(len(fork.repository.revisions) > 5)
     changeset = fork.repository.get_changeset()
     self.assertTrue(changeset.get_node('setup.py') is not None)
     self.assertFalse(fork.is_private())
Esempio n. 3
0
 def test_valid(self):
     """
     This test checks if sane values have been passed to the form.
     Allowing external forking may be very dangerous as we may expose
     own project to be used as *proxy* for attacks on external locations.
     """
     data_list = [dict((key, val) for key, val in (
         ('foobar', '<script...'),
         ('<script', 'foobar'),
         ('foobar', '../../'),
         ('../../', 'foobar'),
     ))]
     for data in data_list:
         form = GithubForkForm(data)
         form.request = self.request
         self.assertFalse(form.is_valid())