@@ -146,6 +146,18 @@ def test_gitlab_post_commit_knows_default_branches(self):
146
146
rtd .default_branch = old_default
147
147
rtd .save ()
148
148
149
+ def test_gitlab_request_empty_url (self ):
150
+ """
151
+ The gitlab hook shouldn't build any project
152
+ if the url, ssh_url or ref are empty.
153
+ """
154
+ self .payload ['project' ]['http_url' ] = ''
155
+ r = self .client .post (
156
+ '/gitlab/' , data = json .dumps (self .payload ),
157
+ content_type = 'application/json'
158
+ )
159
+ self .assertEqual (r .status_code , 404 )
160
+
149
161
def test_gitlab_webhook_is_deprecated (self ):
150
162
# Project is created after feature, not included in historical allowance
151
163
url = 'https://github.com/rtfd/readthedocs-build'
@@ -265,6 +277,19 @@ def test_400_on_no_ref(self):
265
277
content_type = 'application/json' )
266
278
self .assertEqual (r .status_code , 400 )
267
279
280
+ def test_github_request_empty_url (self ):
281
+ """
282
+ The github hook shouldn't build any project
283
+ if the url, ssh_url or ref are empty.
284
+ """
285
+ self .payload ['repository' ]['url' ] = ''
286
+ self .payload ['repository' ]['ssh_url' ] = ''
287
+ r = self .client .post (
288
+ '/github/' , data = json .dumps (self .payload ),
289
+ content_type = 'application/json'
290
+ )
291
+ self .assertEqual (r .status_code , 403 )
292
+
268
293
def test_private_repo_mapping (self ):
269
294
"""
270
295
Test for private GitHub repo mapping.
@@ -534,6 +559,18 @@ def test_bitbucket_default_branch(self):
534
559
content_type = 'application/json' )
535
560
self .assertContains (r , '(URL Build) Build Started: bitbucket.org/test/project [latest]' )
536
561
562
+ def test_bitbucket_request_empty_url (self ):
563
+ """
564
+ The bitbucket hook shouldn't build any project
565
+ if the url, ssh_url or ref are empty.
566
+ """
567
+ self .git_payload ['repository' ]['absolute_url' ] = ''
568
+ r = self .client .post (
569
+ '/bitbucket/' , data = json .dumps (self .git_payload ),
570
+ content_type = 'application/json'
571
+ )
572
+ self .assertEqual (r .status_code , 400 )
573
+
537
574
def test_bitbucket_webhook_is_deprecated (self ):
538
575
# Project is created after feature, not included in historical allowance
539
576
url = 'https://bitbucket.org/rtfd/readthedocs-build'
0 commit comments