Skip to content

Commit

Permalink
Finish oldest tests (certbot#4857)
Browse files Browse the repository at this point in the history
* Pin oldest version of packaged python deps

* Install security extras in oldest tests

* Revert "bump requests requirement to >=2.10 (certbot#4248)"

This reverts commit 402ad8b.

* Use create=True when patching open on module
  • Loading branch information
bmw authored Jun 23, 2017
1 parent 03f6c6d commit f4094e4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
6 changes: 1 addition & 5 deletions acme/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
'PyOpenSSL>=0.13',
'pyrfc3339',
'pytz',
# requests>=2.10 is required to fix
# https://github.com/shazow/urllib3/issues/556. This requirement can be
# relaxed to 'requests[security]>=2.4.1', however, less useful errors
# will be raised for some network/SSL errors.
'requests[security]>=2.10',
'requests[security]>=2.4.1', # security extras added in 2.4.1
# For pkg_resources. >=1.0 so pip resolves it to a version cryptography
# will tolerate; see #2599:
'setuptools>=1.0',
Expand Down
18 changes: 9 additions & 9 deletions certbot-dns-google/certbot_dns_google/dns_google_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _setUp_client_with_mock(self, zone_request_side_effect):

@mock.patch('oauth2client.service_account.ServiceAccountCredentials.from_json_keyfile_name')
@mock.patch('certbot_dns_google.dns_google.open',
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'))
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'), create=True)
def test_add_txt_record(self, unused_credential_mock):
client, changes = self._setUp_client_with_mock([{'managedZones': [{'id': self.zone}]}])

Expand All @@ -101,7 +101,7 @@ def test_add_txt_record(self, unused_credential_mock):

@mock.patch('oauth2client.service_account.ServiceAccountCredentials.from_json_keyfile_name')
@mock.patch('certbot_dns_google.dns_google.open',
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'))
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'), create=True)
def test_add_txt_record_and_poll(self, unused_credential_mock):
client, changes = self._setUp_client_with_mock([{'managedZones': [{'id': self.zone}]}])
changes.create.return_value.execute.return_value = {'status': 'pending', 'id': self.change}
Expand All @@ -119,7 +119,7 @@ def test_add_txt_record_and_poll(self, unused_credential_mock):

@mock.patch('oauth2client.service_account.ServiceAccountCredentials.from_json_keyfile_name')
@mock.patch('certbot_dns_google.dns_google.open',
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'))
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'), create=True)
def test_add_txt_record_error_during_zone_lookup(self, unused_credential_mock):
client, unused_changes = self._setUp_client_with_mock(API_ERROR)

Expand All @@ -128,7 +128,7 @@ def test_add_txt_record_error_during_zone_lookup(self, unused_credential_mock):

@mock.patch('oauth2client.service_account.ServiceAccountCredentials.from_json_keyfile_name')
@mock.patch('certbot_dns_google.dns_google.open',
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'))
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'), create=True)
def test_add_txt_record_zone_not_found(self, unused_credential_mock):
client, unused_changes = self._setUp_client_with_mock([{'managedZones': []},
{'managedZones': []}])
Expand All @@ -138,7 +138,7 @@ def test_add_txt_record_zone_not_found(self, unused_credential_mock):

@mock.patch('oauth2client.service_account.ServiceAccountCredentials.from_json_keyfile_name')
@mock.patch('certbot_dns_google.dns_google.open',
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'))
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'), create=True)
def test_add_txt_record_error_during_add(self, unused_credential_mock):
client, changes = self._setUp_client_with_mock([{'managedZones': [{'id': self.zone}]}])
changes.create.side_effect = API_ERROR
Expand All @@ -148,7 +148,7 @@ def test_add_txt_record_error_during_add(self, unused_credential_mock):

@mock.patch('oauth2client.service_account.ServiceAccountCredentials.from_json_keyfile_name')
@mock.patch('certbot_dns_google.dns_google.open',
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'))
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'), create=True)
def test_del_txt_record(self, unused_credential_mock):
client, changes = self._setUp_client_with_mock([{'managedZones': [{'id': self.zone}]}])

Expand All @@ -173,15 +173,15 @@ def test_del_txt_record(self, unused_credential_mock):

@mock.patch('oauth2client.service_account.ServiceAccountCredentials.from_json_keyfile_name')
@mock.patch('certbot_dns_google.dns_google.open',
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'))
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'), create=True)
def test_del_txt_record_error_during_zone_lookup(self, unused_credential_mock):
client, unused_changes = self._setUp_client_with_mock(API_ERROR)

client.del_txt_record(DOMAIN, self.record_name, self.record_content, self.record_ttl)

@mock.patch('oauth2client.service_account.ServiceAccountCredentials.from_json_keyfile_name')
@mock.patch('certbot_dns_google.dns_google.open',
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'))
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'), create=True)
def test_del_txt_record_zone_not_found(self, unused_credential_mock):
client, unused_changes = self._setUp_client_with_mock([{'managedZones': []},
{'managedZones': []}])
Expand All @@ -190,7 +190,7 @@ def test_del_txt_record_zone_not_found(self, unused_credential_mock):

@mock.patch('oauth2client.service_account.ServiceAccountCredentials.from_json_keyfile_name')
@mock.patch('certbot_dns_google.dns_google.open',
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'))
mock.mock_open(read_data='{"project_id": "' + PROJECT_ID + '"}'), create=True)
def test_del_txt_record_error_during_delete(self, unused_credential_mock):
client, changes = self._setUp_client_with_mock([{'managedZones': [{'id': self.zone}]}])
changes.create.side_effect = API_ERROR
Expand Down
29 changes: 21 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,30 @@ commands =
setenv =
{[testenv]setenv}
CERTBOT_NO_PIN=1
# cffi<=1.7 is required for oldest tests due to
# https://bitbucket.org/cffi/cffi/commits/18cdf37d6b2691301a15b0e54f49757ebd4ed0f2?at=default
# requests<=2.11.1 required for oldest tests due to
# https://github.com/shazow/urllib3/pull/930
deps =
cffi<=1.7
cryptography==1.2
configargparse==0.10.0
PyOpenSSL==0.13
requests<=2.11.1
cffi==1.5.2
configargparse==0.10.0
configargparse==0.10.0
configobj==4.7.2
cryptography==1.2.3
enum34==0.9.23
idna==2.0
ipaddress==1.0.16
mock==1.0.1
ndg-httpsclient==0.3.2
parsedatetime==1.4
pyasn1==0.1.9
pyparsing==1.5.6
pyrfc3339==1.0
python-augeas==0.4.1
pytz==2012c
requests[security]==2.6.0
setuptools==0.9.8
six==1.9.0
urllib3==1.10
zope.component==4.0.2
zope.event==4.0.1
zope.interface==4.0.5

[testenv:py27_install]
Expand Down

0 comments on commit f4094e4

Please sign in to comment.