mirror of
https://github.com/certbot/certbot.git
synced 2026-06-06 23:32:06 -04:00
Added openssl and responses as dependencies, added tests for Validator.{https,redirect}
This commit is contained in:
parent
93be5486a8
commit
d0125f05f3
3 changed files with 46 additions and 2 deletions
|
|
@ -36,7 +36,7 @@ In general:
|
|||
|
||||
```
|
||||
sudo apt-get install python python-setuptools python-virtualenv \
|
||||
python-dev gcc swig dialog libaugeas0 libssl-dev
|
||||
python-dev gcc swig dialog libaugeas0 libssl-dev openssl
|
||||
```
|
||||
|
||||
#### Mac OSX
|
||||
|
|
|
|||
|
|
@ -1,5 +1,48 @@
|
|||
import unittest
|
||||
|
||||
import responses
|
||||
from requests.exceptions import ConnectionError
|
||||
from letsencrypt.client.errors import LetsEncryptValidationError
|
||||
|
||||
from letsencrypt.client.validator import Validator
|
||||
|
||||
|
||||
def _add(secure=False, **kwargs):
|
||||
url = "{}://test.com".format("https" if secure else "http")
|
||||
print(url)
|
||||
return responses.add(responses.GET, url, **kwargs)
|
||||
|
||||
|
||||
class ValidatorTest(unittest.TestCase):
|
||||
pass
|
||||
@responses.activate
|
||||
def test_succesful_redirect(self):
|
||||
_add(status=301, adding_headers={"location": "https://test.com"})
|
||||
self.assertTrue(Validator().redirect("test.com"))
|
||||
|
||||
@responses.activate
|
||||
def test_redirect_missing_location(self):
|
||||
_add(status=301)
|
||||
self.assertFalse(Validator().redirect("test.com"))
|
||||
|
||||
@responses.activate
|
||||
def test_redirect_wrong_status_code(self):
|
||||
_add(status=201, adding_headers={"location": "https://test.com"})
|
||||
self.assertFalse(Validator().redirect("test.com"))
|
||||
|
||||
@responses.activate
|
||||
def test_redirect_wrong_redirect_code(self):
|
||||
_add(status=303, adding_headers={"location": "https://test.com"})
|
||||
self.assertRaises(LetsEncryptValidationError, Validator().redirect, "test.com")
|
||||
|
||||
@responses.activate
|
||||
def test_https_fail(self):
|
||||
self.assertRaises(ConnectionError, Validator().https, "test.com")
|
||||
|
||||
@responses.activate
|
||||
def test_https_success(self):
|
||||
_add(secure=True, body="blaa")
|
||||
self.assertTrue(Validator().https("test.com"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
responses==0.3.0
|
||||
M2Crypto==0.22.3
|
||||
python2-pythondialog
|
||||
jsonschema==2.4.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue