Esempio n. 1
0
 def mock_resolve(self):
     self._url = healthchecks.HealthcheckUrl(
         path='/path/to',
         querystring={}
     )
     self._defaultName = self._create_name()
     self.key = self.key if self.key else self._create_key()
Esempio n. 2
0
def test_https_disabled_healthcheck_settings():
    test_hostname = 'cronitor.io'
    healthchecks.settings = MockSettings(HEALTHCHECKS={
        'HOSTNAME': test_hostname,
        'HTTPS': False
    })
    HcUrl = healthchecks.HealthcheckUrl('/path/to/endpoint', None)
    assert test_hostname in HcUrl.url, "URL does not contain expected hostname"
    assert 'http://' in HcUrl.url, "URL does not contains http://"
Esempio n. 3
0
def test_raise_exception_when_hostname_cannot_be_detected():
    healthchecks.settings = MockSettings()
    raised = False
    try:
        HcUrl = healthchecks.HealthcheckUrl('/path/to/endpoint', None)
    except healthchecks.HealthcheckError:
        raised = True
    finally:
        assert raised, "Expected HealthcheckError exception not raised"
Esempio n. 4
0
def test_querystring_in_url_not_display_url():
    test_hostname = 'cronitor.io'
    test_path = '/path/to/endpoint'
    test_querystring = {'foo': 'bar', 'bar': 'foo'}
    healthchecks.settings = MockSettings(HEALTHCHECKS={
        'HOSTNAME': test_hostname,
        'HTTPS': False
    })
    HcUrl = healthchecks.HealthcheckUrl(test_path, test_querystring)
    assert 'foo=bar' in HcUrl.url, "URL does not contains querystring"
    assert 'bar=foo' in HcUrl.url, "URL does not contains querystring"
    assert 'foo=bar' not in HcUrl.display, "Display URL unexpectedly containss querystring"
    assert 'bar=foo' not in HcUrl.display, "Display URL unexpectedly containss querystring"
Esempio n. 5
0
def test_url_contains_all_expected_parts():
    test_hostname = 'cronitor.io'
    test_path = '/path/to/endpoint'
    test_querystring = {'foo': 'bar', 'bar': 'foo'}
    healthchecks.settings = MockSettings(HEALTHCHECKS={
        'HOSTNAME': test_hostname,
        'HTTPS': False
    })
    HcUrl = healthchecks.HealthcheckUrl(test_path, test_querystring)
    assert 'foo=bar' in HcUrl.url, "URL does not expected contain querystring part"
    assert 'bar=foo' in HcUrl.url, "URL does not expected contain querystring part"
    assert 'http' in HcUrl.url, "URL does not contain scheme"
    assert test_hostname in HcUrl.url, "URL does not contain hostname"
    assert test_path in HcUrl.url, "URL does not contain path"
Esempio n. 6
0
def test_https_disabled_by_default():
    test_hostname = 'cronitor.io'
    healthchecks.settings = MockSettings(
        HEALTHCHECKS={'HOSTNAME': test_hostname})
    HcUrl = healthchecks.HealthcheckUrl('/path/to/endpoint', None)
    assert 'http://' in HcUrl.url, "URL does not contains http://"
Esempio n. 7
0
def test_hostname_detection_fallback_to_allowed_hosts():
    test_hostname = 'cronitor.io'
    healthchecks.settings = MockSettings(ALLOWED_HOSTS=(test_hostname, ))
    HcUrl = healthchecks.HealthcheckUrl('/path/to/endpoint', None)
    assert test_hostname in HcUrl.url, "URL does not contain expected hostname"
Esempio n. 8
0
def test_hostname_detection_fallback_to_settings_hostname():
    test_hostname = 'cronitor.io'
    healthchecks.settings = MockSettings(HOSTNAME=test_hostname)
    HcUrl = healthchecks.HealthcheckUrl('/path/to/endpoint', None)
    assert test_hostname in HcUrl.url, "URL does not contain expected hostname"
Esempio n. 9
0
def test_hostname_from_healthcheck_settings():
    test_hostname = 'cronitor.io'
    healthchecks.settings = MockSettings(
        HEALTHCHECKS={'HOSTNAME': test_hostname})
    HcUrl = healthchecks.HealthcheckUrl('/path/to/endpoint', None)
    assert test_hostname in HcUrl.url, "URL does not contain expected hostname"