Skip to content

Commit

Permalink
HTTP Checks : add a check box to control whether Cabot should follow …
Browse files Browse the repository at this point in the history
…redirects

fix arachnys#20

- The setting is per-check
- default is 'checked' which means Cabot does follow redirects (as before this change)

- [x] db migration
- [x] views
- [x] REST api
  • Loading branch information
tleveil-mvg committed Jun 11, 2019
1 parent 56cfed4 commit a941731
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
20 changes: 20 additions & 0 deletions cabot/cabotapp/migrations/0008_statuscheck_follow_redirects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2019-06-11 10:26
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cabotapp', '0007_statuscheckresult_consecutive_failures'),
]

operations = [
migrations.AddField(
model_name='statuscheck',
name='follow_redirects',
field=models.BooleanField(default=True, help_text=b'Uncheck to prevent Cabot from following HTTP redirections (default True)'),
),
]
5 changes: 5 additions & 0 deletions cabot/cabotapp/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ class StatusCheck(PolymorphicModel):
default=True,
help_text='Set to false to allow not try to verify ssl certificates (default True)',
)
follow_redirects = models.BooleanField(
default=True,
help_text='Uncheck to prevent Cabot from following HTTP redirections (default True)',
)

# Jenkins checks
max_queued_build_time = models.IntegerField(
Expand Down Expand Up @@ -769,6 +773,7 @@ def _run(self):
timeout=self.timeout,
verify=self.verify_ssl_certificate,
auth=auth,
allow_redirects=self.follow_redirects,
headers={
"User-Agent": settings.HTTP_USER_AGENT,
},
Expand Down
2 changes: 2 additions & 0 deletions cabot/cabotapp/tests/tests_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ def setUp(self):
'name': u'HTTP Check',
'active': True,
'importance': u'CRITICAL',
'follow_redirects': True,
'frequency': 5,
'debounce': 0,
'endpoint': u'http://arachnys.com',
Expand Down Expand Up @@ -875,6 +876,7 @@ def setUp(self):
'name': u'posted http check',
'active': True,
'importance': u'ERROR',
'follow_redirects': True,
'frequency': 5,
'debounce': 0,
'endpoint': u'http://arachnys.com/post_tests',
Expand Down
1 change: 1 addition & 0 deletions cabot/cabotapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class Meta:
'password',
'text_match',
'status_code',
'follow_redirects',
'timeout',
'verify_ssl_certificate',
'frequency',
Expand Down
3 changes: 2 additions & 1 deletion cabot/rest_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ class ViewSet(viewset_class):
'password',
'text_match',
'status_code',
'follow_redirects',
'timeout',
'verify_ssl_certificate',
'verify_ssl_certificate'
),
))

Expand Down

0 comments on commit a941731

Please sign in to comment.