-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #44 from IABTechLab/mkc-UID2-3626-requests
Replace urllib with requests
- Loading branch information
Showing
8 changed files
with
51 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "uid2_client" | ||
version = "2.4.6" | ||
version = "3.0.0a1" | ||
authors = [ | ||
{ name = "UID2 team", email = "[email protected]" } | ||
] | ||
|
@@ -18,9 +18,9 @@ classifiers = [ | |
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
] | ||
requires-python = ">=3.6" | ||
requires-python = ">=3.8" | ||
dependencies = [ | ||
"setuptools", | ||
"requests", | ||
"pycryptodome", | ||
"bitarray" | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import os | ||
import unittest | ||
from urllib.error import URLError, HTTPError | ||
|
||
import requests | ||
|
||
from uid2_client import IdentityMapClient, IdentityMapInput, normalize_and_hash_email, normalize_and_hash_phone | ||
|
||
|
@@ -134,19 +135,19 @@ def test_identity_map_bad_url(self): | |
identity_map_input = IdentityMapInput.from_emails( | ||
["[email protected]", "[email protected]", "[email protected]"]) | ||
client = IdentityMapClient("https://operator-bad-url.uidapi.com", os.getenv("UID2_API_KEY"), os.getenv("UID2_SECRET_KEY")) | ||
self.assertRaises(URLError, client.generate_identity_map, identity_map_input) | ||
self.assertRaises(requests.exceptions.ConnectionError, client.generate_identity_map, identity_map_input) | ||
|
||
def test_identity_map_bad_api_key(self): | ||
identity_map_input = IdentityMapInput.from_emails( | ||
["[email protected]", "[email protected]", "[email protected]"]) | ||
client = IdentityMapClient(os.getenv("UID2_BASE_URL"), "bad-api-key", os.getenv("UID2_SECRET_KEY")) | ||
self.assertRaises(HTTPError, client.generate_identity_map,identity_map_input) | ||
self.assertRaises(requests.exceptions.HTTPError, client.generate_identity_map,identity_map_input) | ||
|
||
def test_identity_map_bad_secret(self): | ||
identity_map_input = IdentityMapInput.from_emails( | ||
["[email protected]", "[email protected]", "[email protected]"]) | ||
client = IdentityMapClient(os.getenv("UID2_BASE_URL"), os.getenv("UID2_API_KEY"), "wJ0hP19QU4hmpB64Y3fV2dAed8t/mupw3sjN5jNRFzg=") | ||
self.assertRaises(HTTPError, client.generate_identity_map, | ||
self.assertRaises(requests.exceptions.HTTPError, client.generate_identity_map, | ||
identity_map_input) | ||
|
||
def assert_mapped(self, response, dii): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import os | ||
import unittest | ||
|
||
import requests | ||
|
||
from uid2_client import Uid2PublisherClient | ||
from uid2_client import TokenGenerateInput | ||
from uid2_client import TokenGenerateResponse | ||
from uid2_client.identity_tokens import IdentityTokens | ||
from urllib.request import HTTPError | ||
|
||
|
||
class PublisherEuidIntegrationTests(unittest.TestCase): | ||
|
@@ -175,7 +175,7 @@ def test_integration_bad_requests(self): | |
|
||
expired_respose = "{\"advertising_token\":\"AgAAAAN6QZRCFTau+sfOlMMUY2ftElFMq2TCrcu1EAaD9WmEfoT2BWm2ZKz1tumbT00tWLffRDQ/9POXfA0O/Ljszn7FLtG5EzTBM3HYs4f5irkqeEvu38DhVCxUEpI+gZZZkynRap1oYx6AmC/ip3rk+7pmqa3r3saDs1mPRSSTm+Nh6A==\",\"user_token\":\"AgAAAAL6aleYI4BubI5ZXMBshqmMEfCkbCJF4fLeg1sdI0BTLzj9sXsSISjkG0lMC743diC2NVy3ElkbO1lLysd+Lm6alkqevPrcuWDisQ1939YdoH6LqpwBH3FNSE4/xa3Q+94=\",\"refresh_token\":\"AAAAAARomrP3NjjH+8mt5djfTHbmRZXjOMnAN8WpjJoe30AhUCvYksO/xoDSj77GzWv4M99DhnPl2cVco8CZFTcE10nauXI4Barr890ILnH0IIacOei5Zjwh6DycFkoXkAAuHY1zjmxb7niGLfSP2RctWkZdRVGWQv/UW/grw6+paU9bnKEWPzVvLwwdW2NgjDKu+szE6A+b5hkY+I3voKoaz8/kLDmX8ddJGLy/YOh/LIveBspSAvEg+v89OuUCwAqm8L3Rt8PxDzDnt0U4Na+AUawvvfsIhmsn/zMpRRks6GHhIAB/EQUHID8TedU8Hv1WFRsiraG9Dfn1Kc5/uYnDJhEagWc+7RgTGT+U5GqI6+afrAl5091eBLbmvXnXn9ts\",\"identity_expires\":1668059799628,\"refresh_expires\":1668142599628,\"refresh_from\":1668056202628,\"refresh_response_key\":\"P941vVeuyjaDRVnFQ8DPd0AZnW4bPeiJPXER2K9QXcU=\"}" | ||
current_identity = IdentityTokens.from_json_string(expired_respose) | ||
with self.assertRaises(HTTPError): | ||
with self.assertRaises(requests.exceptions.HTTPError): | ||
self.publisher_client.refresh_token(current_identity) | ||
|
||
with self.assertRaises(TypeError): | ||
|
@@ -185,15 +185,15 @@ def test_integration_bad_requests(self): | |
self.publisher_client.refresh_token(None) | ||
|
||
bad_url_client = Uid2PublisherClient("https://www.something.com", self.UID2_API_KEY, self.UID2_SECRET_KEY) | ||
with self.assertRaises(HTTPError): | ||
with self.assertRaises(requests.exceptions.HTTPError): | ||
bad_url_client.generate_token(TokenGenerateInput.from_email("[email protected]")) | ||
|
||
bad_secret_client = Uid2PublisherClient(self.UID2_BASE_URL, self.UID2_API_KEY, "badSecretKeypB64Y3fV2dAed8t/mupw3sjN5jNRFzg=") | ||
with self.assertRaises(HTTPError): | ||
with self.assertRaises(requests.exceptions.HTTPError): | ||
bad_secret_client.generate_token(TokenGenerateInput.from_email("[email protected]")) | ||
|
||
bad_api_client = Uid2PublisherClient(self.UID2_BASE_URL, "not-real-key", self.UID2_SECRET_KEY) | ||
with self.assertRaises(HTTPError): | ||
with self.assertRaises(requests.exceptions.HTTPError): | ||
bad_secret_client.generate_token(TokenGenerateInput.from_email("[email protected]")) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters