Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.9.0

* Verify the API's TLS certificate with the `certifi` CA bundle (the
`requests` default) instead of a CA bundle shipped with this package.
* Require `requests` 2.16.0 or newer.

## 1.8.0

* Added `tinify.Format` constants for the media types `convert` accepts.
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "tinify"))
from version import __version__

install_require = ["requests >= 2.7.0, < 3.0.0"]
install_require = ["requests >= 2.16.0, < 3.0.0"]
tests_require = ["pytest", "pytest-xdist", "requests-mock", "types-requests"]

if sys.version_info.major > 2:
Expand All @@ -33,7 +33,7 @@
packages=["tinify"],
package_data={
"": ["LICENSE", "README.md"],
"tinify": ["data/cacert.pem", "py.typed"],
"tinify": ["py.typed"],
},
install_requires=install_require,
tests_require=tests_require,
Expand Down
15 changes: 15 additions & 0 deletions test/unit/tinify_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ def test_should_update_compression_count(self, mock_requests, client):
assert tinify.compression_count == 12


class TestClientCertificateVerification:
def test_should_verify_with_default_ca_bundle(
self, mock_requests, client, monkeypatch
):
monkeypatch.delenv("REQUESTS_CA_BUNDLE", raising=False)
monkeypatch.delenv("CURL_CA_BUNDLE", raising=False)
mock_requests.get(
"https://api.tinify.com/", headers={"compression-count": "12"}
)

client.request("GET", "/")

assert mock_requests.last_request.verify is True


class TestClientRequestWhenValidWithAppId:
def test_should_issue_request_with_user_agent(self, mock_requests):
mock_requests.get(
Expand Down
2 changes: 0 additions & 2 deletions tinify/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals

import sys
import os
import platform
import requests
from requests.structures import CaseInsensitiveDict
Expand Down Expand Up @@ -35,7 +34,6 @@ def __init__(self, key, app_identifier=None, proxy=None): # type: (str, Optiona
self.session.headers = CaseInsensitiveDict({
'user-agent': self.USER_AGENT + ' ' + app_identifier if app_identifier else self.USER_AGENT,
})
self.session.verify = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data', 'cacert.pem')

def __enter__(self): # type: () -> Client
return self
Expand Down
2,754 changes: 0 additions & 2,754 deletions tinify/data/cacert.pem

This file was deleted.

2 changes: 1 addition & 1 deletion tinify/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.8.0'
__version__ = '1.9.0'
17 changes: 0 additions & 17 deletions update-cacert.sh

This file was deleted.

Loading