From c9a6a81a8a5499c8131969acce36573969ba07bf Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 18 Nov 2021 10:45:18 -0800 Subject: [PATCH 1/3] Remove Snyk config --- setup.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/setup.py b/setup.py index 8b7b437..6eb8983 100644 --- a/setup.py +++ b/setup.py @@ -25,12 +25,6 @@ "voluptuous", ] -# Write requirements.txt needed for snyk testing, only for latest release python. -if os.environ.get("SNYK_TOKEN") and os.environ.get("RUN_SNYK"): - with open("requirements.txt", "w") as f: - for r in requirements: - f.write(r + "\n") - setup( name="minfraud", version=_version, From 5f18c3b51c913d5a8b38428ff23f476d511903a5 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 18 Nov 2021 10:47:41 -0800 Subject: [PATCH 2/3] Test on Python 3.10 --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 2 +- setup.cfg | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ae500ea..36247cb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: "3.10" - name: Install dependencies run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ba7f37f..16b16fb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: # We don't test on Windows currently as it appears mocket may not # work there. platform: [ubuntu-latest, macos-latest] - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.6, 3.7, 3.8, 3.9, "3.10"] name: Python ${{ matrix.python-version }} on ${{ matrix.platform }} runs-on: ${{ matrix.platform }} diff --git a/setup.cfg b/setup.cfg index 9d48adc..bffd5eb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,14 +9,15 @@ max-line-length = 88 universal = 1 [tox:tox] -envlist = py36, py37, py38, py39, mypy +envlist = py36, py37, py38, py39, py310, mypy [gh-actions] python = 3.6: py36 3.7: py37 3.8: py38 - 3.9: py39, mypy + 3.9: py39 + "3.10": py310, mypy [testenv] deps = From 0e979822d17b380896343322a40dbe232f777632 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 18 Nov 2021 10:54:36 -0800 Subject: [PATCH 3/3] Upgrade geoip2 to 4.5.0 and add MCC/MNC tests --- HISTORY.rst | 5 +++++ setup.py | 2 +- tests/data/factors-response.json | 2 ++ tests/data/insights-response.json | 2 ++ tests/test_models.py | 4 ++++ tests/test_webservice.py | 2 ++ 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 6e764f5..36ccbc1 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -6,6 +6,11 @@ History 2.6.0 ++++++++++++++++++ +* Upgraded ``geoip2`` to 4.5.0. This adds mobile country code (MCC) and mobile + network code (MNC) to minFraud Insights and Factors responses. These are + available at ``response.ip_address.traits.mobile_country_code`` and + ``response.ip_address.traits.mobile_network_code``. We expect this data to be + available by late January, 2022. * Added the following new values to the ``/payment/processor`` validation: * ``boacompra`` * ``boku`` diff --git a/setup.py b/setup.py index 6eb8983..ecf0b56 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ requirements = [ "aiohttp>=3.6.2,<4.0.0", "email_validator>=1.1.1,<2.0.0", - "geoip2>=4.3.0,<5.0.0", + "geoip2>=4.5.0,<5.0.0", "requests>=2.24.0,<3.0.0", "urllib3>=1.25.2,<2.0.0", "voluptuous", diff --git a/tests/data/factors-response.json b/tests/data/factors-response.json index 8397286..26a7bba 100644 --- a/tests/data/factors-response.json +++ b/tests/data/factors-response.json @@ -108,6 +108,8 @@ "is_satellite_provider": true, "is_tor_exit_node": true, "isp": "Andrews & Arnold Ltd", + "mobile_country_code" : "310", + "mobile_network_code" : "004", "organization": "STONEHOUSE office network", "user_type": "government" } diff --git a/tests/data/insights-response.json b/tests/data/insights-response.json index 9e6e7e6..d2ad035 100644 --- a/tests/data/insights-response.json +++ b/tests/data/insights-response.json @@ -108,6 +108,8 @@ "is_satellite_provider": true, "is_tor_exit_node": true, "isp": "Andrews & Arnold Ltd", + "mobile_country_code" : "310", + "mobile_network_code" : "004", "organization": "STONEHOUSE office network", "user_type": "government" } diff --git a/tests/test_models.py b/tests/test_models.py index 162aef8..5859387 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -175,6 +175,8 @@ def test_ip_address(self): "is_residential_proxy": True, "is_satellite_provider": True, "is_tor_exit_node": True, + "mobile_country_code": "310", + "mobile_network_code": "004", }, } ) @@ -191,6 +193,8 @@ def test_ip_address(self): self.assertEqual(True, address.traits.is_residential_proxy) self.assertEqual(True, address.traits.is_satellite_provider) self.assertEqual(True, address.traits.is_tor_exit_node) + self.assertEqual("310", address.traits.mobile_country_code) + self.assertEqual("004", address.traits.mobile_network_code) self.assertEqual(True, address.country.is_high_risk) self.assertEqual("ANONYMOUS_IP", address.risk_reasons[0].code) diff --git a/tests/test_webservice.py b/tests/test_webservice.py index b68538a..21c439a 100644 --- a/tests/test_webservice.py +++ b/tests/test_webservice.py @@ -193,6 +193,8 @@ def test_200(self): if self.has_ip_location(): self.assertEqual("United Kingdom", model.ip_address.country.name) self.assertEqual(True, model.ip_address.traits.is_residential_proxy) + self.assertEqual("310", model.ip_address.traits.mobile_country_code) + self.assertEqual("004", model.ip_address.traits.mobile_network_code) self.assertEqual("ANONYMOUS_IP", model.ip_address.risk_reasons[0].code) @httprettified