Skip to content

Commit a4f168d

Browse files
committed
Do not require the IP address input
1 parent 25b4a93 commit a4f168d

4 files changed

Lines changed: 30 additions & 11 deletions

File tree

HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
History
44
-------
55

6+
2.2.0
7+
++++++++++++++++++
8+
9+
* The device IP address is no longer a required input.
10+
611
2.1.0 (2020-09-25)
712
++++++++++++++++++
813

README.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ Each of these methods takes a dictionary representing the transaction to be sent
7272
to the web service. The structure of this dictionary should be in `the format
7373
specified in the REST API documentation
7474
<https://dev.maxmind.com/minfraud/#Request_Body>`__.
75-
The ``ip_address`` in the ``device`` sub-dictionary is required. All other
76-
fields are optional.
75+
All fields are optional.
7776

7877
Report Transactions Usage
7978
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -114,9 +113,9 @@ The possible errors are:
114113
is unable to authenticate the request, e.g., if the license key or account
115114
ID is invalid.
116115
* ``minfraud.InvalidRequestError`` - This will be raised when the server
117-
rejects the request as invalid for another reason, such as a missing or
118-
reserved IP address. It is also raised if validation of the request before
119-
it is sent to the server fails.
116+
rejects the request as invalid for another reason, such as a reserved IP
117+
address. It is also raised if validation of the request before it is sent to
118+
the server fails.
120119
* ``minfraud.HttpError`` - This will be raised when an unexpected HTTP
121120
error occurs such as a firewall interfering with the request to the server.
122121
* ``minfraud.MinFraudError`` - This will be raised when some other error

minfraud/validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ def _uri(s: str) -> str:
294294
"token": _credit_card_token,
295295
},
296296
"custom_inputs": {_custom_input_key: _custom_input_value},
297-
Required("device"): {
297+
"device": {
298298
"accept_language": str,
299-
Required("ip_address"): _ip_address,
299+
"ip_address": _ip_address,
300300
"session_age": All(_any_number, Range(min=0)),
301301
"session_id": str,
302302
"user_agent": str,

tests/test_validation.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ def check_report_str_type(self, key):
6666
self.check_invalid_report({key: 12})
6767

6868

69+
class TestTransaction(unittest.TestCase, ValidationBase):
70+
def test_transaction_without_device(self):
71+
transaction = {
72+
"account": {
73+
"user_id": "usr",
74+
}
75+
}
76+
validate_transaction(transaction)
77+
78+
6979
class TestAccount(unittest.TestCase, ValidationBase):
7080
def test_account_user_id(self):
7181
self.check_transaction({"account": {"user_id": "usr"}})
@@ -209,12 +219,17 @@ def test_ip_address(self):
209219
self.check_invalid_transaction({"device": {"ip_address": invalid}})
210220

211221
def test_missing_ip(self):
212-
with self.assertRaises(MultipleInvalid):
213-
validate_transaction({"device": {}})
222+
validate_transaction({"device": {}})
223+
validate_transaction(
224+
{
225+
"device": {
226+
"user_agent": "foo",
227+
}
228+
}
229+
)
214230

215231
def test_missing_device(self):
216-
with self.assertRaises(MultipleInvalid):
217-
validate_transaction({})
232+
validate_transaction({})
218233

219234
def test_user_agent(self):
220235
self.check_transaction_str_type("device", "user_agent")

0 commit comments

Comments
 (0)