incognia-python 2.2.0__tar.gz → 3.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {incognia_python-2.2.0 → incognia_python-3.0.0}/.github/workflows/continuous.yaml +4 -4
- {incognia_python-2.2.0 → incognia_python-3.0.0}/PKG-INFO +13 -13
- {incognia_python-2.2.0 → incognia_python-3.0.0}/README.md +12 -12
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia/api.py +27 -41
- incognia_python-3.0.0/incognia/datetime_util.py +5 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia/feedback_events.py +8 -5
- incognia_python-3.0.0/incognia/singleton.py +8 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia_python.egg-info/PKG-INFO +13 -13
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia_python.egg-info/SOURCES.txt +1 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/tests/test_api.py +63 -97
- incognia_python-2.2.0/incognia/datetime_util.py +0 -9
- {incognia_python-2.2.0 → incognia_python-3.0.0}/.github/dependabot.yml +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/.github/workflows/codeql.yaml +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/.gitignore +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/CODEOWNERS +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/LICENSE.txt +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/MANIFEST.in +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia/__init__.py +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia/base_request.py +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia/endpoints.py +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia/exceptions.py +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia/json_util.py +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia/models.py +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia/token_manager.py +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia_python.egg-info/dependency_links.txt +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia_python.egg-info/not-zip-safe +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia_python.egg-info/requires.txt +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/incognia_python.egg-info/top_level.txt +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/pyproject.toml +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/requirements.txt +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/setup.cfg +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/tests/__init__.py +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/tests/test_base_request.py +0 -0
- {incognia_python-2.2.0 → incognia_python-3.0.0}/tests/test_token_manager.py +0 -0
|
@@ -52,15 +52,15 @@ jobs:
|
|
|
52
52
|
- name: Publish Python distribution to Test PyPI
|
|
53
53
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
54
54
|
with:
|
|
55
|
-
|
|
55
|
+
repository-url: https://test.pypi.org/legacy/
|
|
56
56
|
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
skip-existing: true
|
|
58
|
+
print-hash: true
|
|
59
59
|
verbose: true
|
|
60
60
|
- name: Publish Python distribution to PyPI
|
|
61
61
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
62
62
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
63
63
|
with:
|
|
64
64
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
65
|
-
|
|
65
|
+
print-hash: true
|
|
66
66
|
verbose: true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: incognia-python
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: Python lightweight client library for Incognia APIs
|
|
5
5
|
Home-page: https://github.com/inloco/incognia-python
|
|
6
6
|
Author: Incognia
|
|
@@ -49,7 +49,7 @@ Authentication is done transparently, so you don't need to worry about it.
|
|
|
49
49
|
|
|
50
50
|
#### Registering New Signup
|
|
51
51
|
|
|
52
|
-
This method registers a new signup for the given
|
|
52
|
+
This method registers a new signup for the given request token and a structured address, an address
|
|
53
53
|
line or coordinates, returning a `dict`, containing the risk assessment and supporting evidence:
|
|
54
54
|
|
|
55
55
|
```python3
|
|
@@ -72,30 +72,30 @@ structured_address: StructuredAddress = {
|
|
|
72
72
|
'complements': 'Floor 2',
|
|
73
73
|
'postal_code': '10001'
|
|
74
74
|
}
|
|
75
|
-
assessment: dict = api.register_new_signup('
|
|
75
|
+
assessment: dict = api.register_new_signup('request-token', structured_address=structured_address)
|
|
76
76
|
|
|
77
77
|
# with address line:
|
|
78
78
|
address_line: str = '350 Fifth Avenue, Manhattan, New York 10118'
|
|
79
|
-
assessment: dict = api.register_new_signup('
|
|
79
|
+
assessment: dict = api.register_new_signup('request-token', address_line=address_line)
|
|
80
80
|
|
|
81
81
|
# with coordinates, a dict:
|
|
82
82
|
coordinates: Coordinates = {
|
|
83
83
|
'lat': 40.74836007062138,
|
|
84
84
|
'lng': -73.98509720487937
|
|
85
85
|
}
|
|
86
|
-
assessment: dict = api.register_new_signup('
|
|
86
|
+
assessment: dict = api.register_new_signup('request-token', address_coordinates=coordinates)
|
|
87
87
|
|
|
88
88
|
# with external_id:
|
|
89
89
|
external_id: str = 'external-id'
|
|
90
|
-
assessment: dict = api.register_new_signup('
|
|
90
|
+
assessment: dict = api.register_new_signup('request-token', external_id=external_id)
|
|
91
91
|
|
|
92
92
|
# with policy_id:
|
|
93
93
|
policy_id: str = 'policy-id'
|
|
94
|
-
assessment: dict = api.register_new_signup('
|
|
94
|
+
assessment: dict = api.register_new_signup('request-token', policy_id=policy_id)
|
|
95
95
|
|
|
96
96
|
# with account_id:
|
|
97
97
|
account_id: str = 'account-id'
|
|
98
|
-
assessment: dict = api.register_new_signup('
|
|
98
|
+
assessment: dict = api.register_new_signup('request-token', account_id=account_id)
|
|
99
99
|
|
|
100
100
|
```
|
|
101
101
|
|
|
@@ -113,13 +113,13 @@ api = IncogniaAPI('client-id', 'client-secret')
|
|
|
113
113
|
|
|
114
114
|
api.register_feedback(FeedbackEvents.ACCOUNT_TAKEOVER,
|
|
115
115
|
occurred_at=dt.datetime(2024, 7, 22, 15, 20, 0, tzinfo=dt.timezone.utc),
|
|
116
|
-
|
|
116
|
+
request_token='request-token',
|
|
117
117
|
account_id='account-id')
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
#### Registering Payment
|
|
121
121
|
|
|
122
|
-
This method registers a new payment for the given
|
|
122
|
+
This method registers a new payment for the given request token and account, returning a `dict`,
|
|
123
123
|
containing the risk assessment and supporting evidence.
|
|
124
124
|
|
|
125
125
|
```python3
|
|
@@ -180,7 +180,7 @@ payment_methods: List[PaymentMethod] = [
|
|
|
180
180
|
|
|
181
181
|
policy_id: str = 'policy-id'
|
|
182
182
|
|
|
183
|
-
assessment: dict = api.register_payment('
|
|
183
|
+
assessment: dict = api.register_payment('request-token',
|
|
184
184
|
'account-id',
|
|
185
185
|
'external-id',
|
|
186
186
|
addresses=addresses,
|
|
@@ -191,7 +191,7 @@ assessment: dict = api.register_payment('installation-id',
|
|
|
191
191
|
|
|
192
192
|
#### Registering Login
|
|
193
193
|
|
|
194
|
-
This method registers a new login for the given
|
|
194
|
+
This method registers a new login for the given request token and account, returning a `dict`,
|
|
195
195
|
containing the risk assessment and supporting evidence.
|
|
196
196
|
|
|
197
197
|
```python3
|
|
@@ -201,7 +201,7 @@ api = IncogniaAPI('client-id', 'client-secret')
|
|
|
201
201
|
|
|
202
202
|
policy_id: str = 'policy-id'
|
|
203
203
|
|
|
204
|
-
assessment: dict = api.register_login('
|
|
204
|
+
assessment: dict = api.register_login('request-token',
|
|
205
205
|
'account-id',
|
|
206
206
|
'external-id',
|
|
207
207
|
policy_id='policy_id')
|
|
@@ -33,7 +33,7 @@ Authentication is done transparently, so you don't need to worry about it.
|
|
|
33
33
|
|
|
34
34
|
#### Registering New Signup
|
|
35
35
|
|
|
36
|
-
This method registers a new signup for the given
|
|
36
|
+
This method registers a new signup for the given request token and a structured address, an address
|
|
37
37
|
line or coordinates, returning a `dict`, containing the risk assessment and supporting evidence:
|
|
38
38
|
|
|
39
39
|
```python3
|
|
@@ -56,30 +56,30 @@ structured_address: StructuredAddress = {
|
|
|
56
56
|
'complements': 'Floor 2',
|
|
57
57
|
'postal_code': '10001'
|
|
58
58
|
}
|
|
59
|
-
assessment: dict = api.register_new_signup('
|
|
59
|
+
assessment: dict = api.register_new_signup('request-token', structured_address=structured_address)
|
|
60
60
|
|
|
61
61
|
# with address line:
|
|
62
62
|
address_line: str = '350 Fifth Avenue, Manhattan, New York 10118'
|
|
63
|
-
assessment: dict = api.register_new_signup('
|
|
63
|
+
assessment: dict = api.register_new_signup('request-token', address_line=address_line)
|
|
64
64
|
|
|
65
65
|
# with coordinates, a dict:
|
|
66
66
|
coordinates: Coordinates = {
|
|
67
67
|
'lat': 40.74836007062138,
|
|
68
68
|
'lng': -73.98509720487937
|
|
69
69
|
}
|
|
70
|
-
assessment: dict = api.register_new_signup('
|
|
70
|
+
assessment: dict = api.register_new_signup('request-token', address_coordinates=coordinates)
|
|
71
71
|
|
|
72
72
|
# with external_id:
|
|
73
73
|
external_id: str = 'external-id'
|
|
74
|
-
assessment: dict = api.register_new_signup('
|
|
74
|
+
assessment: dict = api.register_new_signup('request-token', external_id=external_id)
|
|
75
75
|
|
|
76
76
|
# with policy_id:
|
|
77
77
|
policy_id: str = 'policy-id'
|
|
78
|
-
assessment: dict = api.register_new_signup('
|
|
78
|
+
assessment: dict = api.register_new_signup('request-token', policy_id=policy_id)
|
|
79
79
|
|
|
80
80
|
# with account_id:
|
|
81
81
|
account_id: str = 'account-id'
|
|
82
|
-
assessment: dict = api.register_new_signup('
|
|
82
|
+
assessment: dict = api.register_new_signup('request-token', account_id=account_id)
|
|
83
83
|
|
|
84
84
|
```
|
|
85
85
|
|
|
@@ -97,13 +97,13 @@ api = IncogniaAPI('client-id', 'client-secret')
|
|
|
97
97
|
|
|
98
98
|
api.register_feedback(FeedbackEvents.ACCOUNT_TAKEOVER,
|
|
99
99
|
occurred_at=dt.datetime(2024, 7, 22, 15, 20, 0, tzinfo=dt.timezone.utc),
|
|
100
|
-
|
|
100
|
+
request_token='request-token',
|
|
101
101
|
account_id='account-id')
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
#### Registering Payment
|
|
105
105
|
|
|
106
|
-
This method registers a new payment for the given
|
|
106
|
+
This method registers a new payment for the given request token and account, returning a `dict`,
|
|
107
107
|
containing the risk assessment and supporting evidence.
|
|
108
108
|
|
|
109
109
|
```python3
|
|
@@ -164,7 +164,7 @@ payment_methods: List[PaymentMethod] = [
|
|
|
164
164
|
|
|
165
165
|
policy_id: str = 'policy-id'
|
|
166
166
|
|
|
167
|
-
assessment: dict = api.register_payment('
|
|
167
|
+
assessment: dict = api.register_payment('request-token',
|
|
168
168
|
'account-id',
|
|
169
169
|
'external-id',
|
|
170
170
|
addresses=addresses,
|
|
@@ -175,7 +175,7 @@ assessment: dict = api.register_payment('installation-id',
|
|
|
175
175
|
|
|
176
176
|
#### Registering Login
|
|
177
177
|
|
|
178
|
-
This method registers a new login for the given
|
|
178
|
+
This method registers a new login for the given request token and account, returning a `dict`,
|
|
179
179
|
containing the risk assessment and supporting evidence.
|
|
180
180
|
|
|
181
181
|
```python3
|
|
@@ -185,7 +185,7 @@ api = IncogniaAPI('client-id', 'client-secret')
|
|
|
185
185
|
|
|
186
186
|
policy_id: str = 'policy-id'
|
|
187
187
|
|
|
188
|
-
assessment: dict = api.register_login('
|
|
188
|
+
assessment: dict = api.register_login('request-token',
|
|
189
189
|
'account-id',
|
|
190
190
|
'external-id',
|
|
191
191
|
policy_id='policy_id')
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
2
|
from typing import Optional, List
|
|
3
3
|
|
|
4
|
-
from .datetime_util import
|
|
4
|
+
from .datetime_util import has_timezone
|
|
5
5
|
from .endpoints import Endpoints
|
|
6
6
|
from .exceptions import IncogniaHTTPError, IncogniaError
|
|
7
7
|
from .json_util import encode
|
|
8
8
|
from .models import Coordinates, StructuredAddress, TransactionAddress, PaymentValue, PaymentMethod
|
|
9
|
+
from .singleton import Singleton
|
|
9
10
|
from .token_manager import TokenManager
|
|
10
11
|
from .base_request import BaseRequest, JSON_CONTENT_HEADER
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
class IncogniaAPI:
|
|
14
|
+
class IncogniaAPI(metaclass=Singleton):
|
|
14
15
|
def __init__(self, client_id: str, client_secret: str):
|
|
15
16
|
self.__token_manager = TokenManager(client_id, client_secret)
|
|
16
17
|
self.__request = BaseRequest()
|
|
@@ -20,29 +21,27 @@ class IncogniaAPI:
|
|
|
20
21
|
return {'Authorization': f'{token_type} {access_token}'}
|
|
21
22
|
|
|
22
23
|
def register_new_signup(self,
|
|
23
|
-
|
|
24
|
+
request_token: Optional[str],
|
|
24
25
|
address_line: Optional[str] = None,
|
|
25
26
|
structured_address: Optional[StructuredAddress] = None,
|
|
26
27
|
address_coordinates: Optional[Coordinates] = None,
|
|
27
28
|
external_id: Optional[str] = None,
|
|
28
29
|
policy_id: Optional[str] = None,
|
|
29
|
-
account_id: Optional[str] = None
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
raise IncogniaError('installation_id is required.')
|
|
30
|
+
account_id: Optional[str] = None) -> dict:
|
|
31
|
+
if not request_token:
|
|
32
|
+
raise IncogniaError('request_token is required.')
|
|
33
33
|
|
|
34
34
|
try:
|
|
35
35
|
headers = self.__get_authorization_header()
|
|
36
36
|
headers.update(JSON_CONTENT_HEADER)
|
|
37
37
|
body = {
|
|
38
|
-
'
|
|
38
|
+
'request_token': request_token,
|
|
39
39
|
'address_line': address_line,
|
|
40
40
|
'structured_address': structured_address,
|
|
41
41
|
'address_coordinates': address_coordinates,
|
|
42
42
|
'external_id': external_id,
|
|
43
43
|
'policy_id': policy_id,
|
|
44
|
-
'account_id': account_id
|
|
45
|
-
'request_token': request_token
|
|
44
|
+
'account_id': account_id
|
|
46
45
|
}
|
|
47
46
|
data = encode(body)
|
|
48
47
|
return self.__request.post(Endpoints.SIGNUPS, headers=headers, data=data)
|
|
@@ -52,21 +51,17 @@ class IncogniaAPI:
|
|
|
52
51
|
|
|
53
52
|
def register_feedback(self,
|
|
54
53
|
event: str,
|
|
55
|
-
timestamp: dt.datetime = None,
|
|
56
54
|
external_id: Optional[str] = None,
|
|
57
55
|
login_id: Optional[str] = None,
|
|
58
56
|
payment_id: Optional[str] = None,
|
|
59
57
|
signup_id: Optional[str] = None,
|
|
60
58
|
account_id: Optional[str] = None,
|
|
61
59
|
installation_id: Optional[str] = None,
|
|
62
|
-
session_token: Optional[str] = None,
|
|
63
60
|
request_token: Optional[str] = None,
|
|
64
61
|
occurred_at: dt.datetime = None,
|
|
65
62
|
expires_at: dt.datetime = None) -> None:
|
|
66
63
|
if not event:
|
|
67
64
|
raise IncogniaError('event is required.')
|
|
68
|
-
if timestamp is not None and not has_timezone(timestamp):
|
|
69
|
-
raise IncogniaError('timestamp must have timezone')
|
|
70
65
|
if occurred_at is not None and not has_timezone(occurred_at):
|
|
71
66
|
raise IncogniaError('occurred_at must have timezone')
|
|
72
67
|
if expires_at is not None and not has_timezone(expires_at):
|
|
@@ -83,11 +78,8 @@ class IncogniaAPI:
|
|
|
83
78
|
'signup_id': signup_id,
|
|
84
79
|
'account_id': account_id,
|
|
85
80
|
'installation_id': installation_id,
|
|
86
|
-
'session_token': session_token,
|
|
87
81
|
'request_token': request_token
|
|
88
82
|
}
|
|
89
|
-
if timestamp is not None:
|
|
90
|
-
body['timestamp'] = total_milliseconds_since_epoch(timestamp)
|
|
91
83
|
if occurred_at is not None:
|
|
92
84
|
body['occurred_at'] = occurred_at.isoformat()
|
|
93
85
|
if expires_at is not None:
|
|
@@ -99,17 +91,16 @@ class IncogniaAPI:
|
|
|
99
91
|
raise IncogniaHTTPError(e) from None
|
|
100
92
|
|
|
101
93
|
def register_payment(self,
|
|
102
|
-
|
|
94
|
+
request_token: str,
|
|
103
95
|
account_id: str,
|
|
104
96
|
external_id: Optional[str] = None,
|
|
105
97
|
addresses: Optional[List[TransactionAddress]] = None,
|
|
106
98
|
payment_value: Optional[PaymentValue] = None,
|
|
107
99
|
payment_methods: Optional[List[PaymentMethod]] = None,
|
|
108
100
|
evaluate: Optional[bool] = None,
|
|
109
|
-
policy_id: Optional[str] = None
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
raise IncogniaError('installation_id is required.')
|
|
101
|
+
policy_id: Optional[str] = None) -> dict:
|
|
102
|
+
if not request_token:
|
|
103
|
+
raise IncogniaError('request_token is required.')
|
|
113
104
|
if not account_id:
|
|
114
105
|
raise IncogniaError('account_id is required.')
|
|
115
106
|
|
|
@@ -119,14 +110,13 @@ class IncogniaAPI:
|
|
|
119
110
|
params = None if evaluate is None else {'eval': evaluate}
|
|
120
111
|
body = {
|
|
121
112
|
'type': 'payment',
|
|
122
|
-
'
|
|
113
|
+
'request_token': request_token,
|
|
123
114
|
'account_id': account_id,
|
|
124
115
|
'external_id': external_id,
|
|
125
116
|
'addresses': addresses,
|
|
126
117
|
'payment_value': payment_value,
|
|
127
118
|
'payment_methods': payment_methods,
|
|
128
|
-
'policy_id': policy_id
|
|
129
|
-
'request_token': request_token
|
|
119
|
+
'policy_id': policy_id
|
|
130
120
|
}
|
|
131
121
|
data = encode(body)
|
|
132
122
|
return self.__request.post(Endpoints.TRANSACTIONS, headers=headers, params=params,
|
|
@@ -136,14 +126,13 @@ class IncogniaAPI:
|
|
|
136
126
|
raise IncogniaHTTPError(e) from None
|
|
137
127
|
|
|
138
128
|
def register_login(self,
|
|
139
|
-
|
|
129
|
+
request_token: str,
|
|
140
130
|
account_id: str,
|
|
141
131
|
external_id: Optional[str] = None,
|
|
142
132
|
evaluate: Optional[bool] = None,
|
|
143
|
-
policy_id: Optional[str] = None
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
raise IncogniaError('installation_id is required.')
|
|
133
|
+
policy_id: Optional[str] = None) -> dict:
|
|
134
|
+
if not request_token:
|
|
135
|
+
raise IncogniaError('request_token is required.')
|
|
147
136
|
if not account_id:
|
|
148
137
|
raise IncogniaError('account_id is required.')
|
|
149
138
|
|
|
@@ -153,11 +142,10 @@ class IncogniaAPI:
|
|
|
153
142
|
params = None if evaluate is None else {'eval': evaluate}
|
|
154
143
|
body = {
|
|
155
144
|
'type': 'login',
|
|
156
|
-
'
|
|
145
|
+
'request_token': request_token,
|
|
157
146
|
'account_id': account_id,
|
|
158
147
|
'external_id': external_id,
|
|
159
|
-
'policy_id': policy_id
|
|
160
|
-
'request_token': request_token
|
|
148
|
+
'policy_id': policy_id
|
|
161
149
|
}
|
|
162
150
|
data = encode(body)
|
|
163
151
|
return self.__request.post(Endpoints.TRANSACTIONS, headers=headers, params=params,
|
|
@@ -167,14 +155,13 @@ class IncogniaAPI:
|
|
|
167
155
|
raise IncogniaHTTPError(e) from None
|
|
168
156
|
|
|
169
157
|
def register_web_login(self,
|
|
170
|
-
|
|
158
|
+
request_token: str,
|
|
171
159
|
account_id: str,
|
|
172
160
|
external_id: Optional[str] = None,
|
|
173
161
|
evaluate: Optional[bool] = None,
|
|
174
|
-
policy_id: Optional[str] = None
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
raise IncogniaError('session_token is required.')
|
|
162
|
+
policy_id: Optional[str] = None) -> dict:
|
|
163
|
+
if not request_token:
|
|
164
|
+
raise IncogniaError('request_token is required.')
|
|
178
165
|
if not account_id:
|
|
179
166
|
raise IncogniaError('account_id is required.')
|
|
180
167
|
|
|
@@ -184,11 +171,10 @@ class IncogniaAPI:
|
|
|
184
171
|
params = None if evaluate is None else {'eval': evaluate}
|
|
185
172
|
body = {
|
|
186
173
|
'type': 'login',
|
|
187
|
-
'
|
|
174
|
+
'request_token': request_token,
|
|
188
175
|
'account_id': account_id,
|
|
189
176
|
'external_id': external_id,
|
|
190
|
-
'policy_id': policy_id
|
|
191
|
-
'request_token': request_token
|
|
177
|
+
'policy_id': policy_id
|
|
192
178
|
}
|
|
193
179
|
data = encode(body)
|
|
194
180
|
return self.__request.post(Endpoints.TRANSACTIONS, headers=headers, params=params,
|
|
@@ -15,15 +15,18 @@ class FeedbackEvents:
|
|
|
15
15
|
PAYMENT_DECLINED_BY_BUSINESS: Final[str] = 'payment_declined_by_business'
|
|
16
16
|
PAYMENT_DECLINED_BY_ACQUIRER: Final[str] = 'payment_declined_by_acquirer'
|
|
17
17
|
LOGIN_ACCEPTED: Final[str] = 'login_accepted'
|
|
18
|
+
LOGIN_ACCEPTED_BY_DEVICE_VERIFICATION: Final[str] = 'login_accepted_by_device_verification'
|
|
19
|
+
LOGIN_ACCEPTED_BY_FACIAL_BIOMETRICS: Final[str] = 'login_accepted_by_facial_biometrics'
|
|
20
|
+
LOGIN_ACCEPTED_BY_MANUAL_REVIEW: Final[str] = 'login_accepted_by_manual_review'
|
|
18
21
|
LOGIN_DECLINED: Final[str] = 'login_declined'
|
|
22
|
+
ACCOUNT_ALLOWED: Final[str] = 'account_allowed'
|
|
23
|
+
LOGIN_DECLINED_BY_FACIAL_BIOMETRICS: Final[str] = 'login_declined_by_facial_biometrics'
|
|
24
|
+
LOGIN_DECLINED_BY_MANUAL_REVIEW: Final[str] = 'login_declined_by_manual_review'
|
|
25
|
+
DEVICE_ALLOWED: Final[str] = 'device_allowed'
|
|
19
26
|
VERIFIED: Final[str] = 'verified'
|
|
20
27
|
IDENTITY_FRAUD: Final[str] = 'identity_fraud'
|
|
21
28
|
ACCOUNT_TAKEOVER: Final[str] = 'account_takeover'
|
|
22
29
|
CHARGEBACK_NOTIFICATION: Final[str] = 'chargeback_notification'
|
|
23
30
|
CHARGEBACK: Final[str] = 'chargeback'
|
|
24
|
-
MPOS_FRAUD: Final[str] = 'mpos_fraud'
|
|
25
|
-
CHALLENGE_PASSED: Final[str] = 'challenge_passed'
|
|
26
|
-
CHALLENGE_FAILED: Final[str] = 'challenge_failed'
|
|
27
|
-
PASSWORD_CHANGED_SUCCESSFULLY: Final[str] = 'password_changed_successfully'
|
|
28
|
-
PASSWORD_CHANGE_FAILED: Final[str] = 'password_change_failed'
|
|
29
31
|
PROMOTION_ABUSE: Final[str] = 'promotion_abuse'
|
|
32
|
+
RESET: Final[str] = 'reset'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: incognia-python
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: Python lightweight client library for Incognia APIs
|
|
5
5
|
Home-page: https://github.com/inloco/incognia-python
|
|
6
6
|
Author: Incognia
|
|
@@ -49,7 +49,7 @@ Authentication is done transparently, so you don't need to worry about it.
|
|
|
49
49
|
|
|
50
50
|
#### Registering New Signup
|
|
51
51
|
|
|
52
|
-
This method registers a new signup for the given
|
|
52
|
+
This method registers a new signup for the given request token and a structured address, an address
|
|
53
53
|
line or coordinates, returning a `dict`, containing the risk assessment and supporting evidence:
|
|
54
54
|
|
|
55
55
|
```python3
|
|
@@ -72,30 +72,30 @@ structured_address: StructuredAddress = {
|
|
|
72
72
|
'complements': 'Floor 2',
|
|
73
73
|
'postal_code': '10001'
|
|
74
74
|
}
|
|
75
|
-
assessment: dict = api.register_new_signup('
|
|
75
|
+
assessment: dict = api.register_new_signup('request-token', structured_address=structured_address)
|
|
76
76
|
|
|
77
77
|
# with address line:
|
|
78
78
|
address_line: str = '350 Fifth Avenue, Manhattan, New York 10118'
|
|
79
|
-
assessment: dict = api.register_new_signup('
|
|
79
|
+
assessment: dict = api.register_new_signup('request-token', address_line=address_line)
|
|
80
80
|
|
|
81
81
|
# with coordinates, a dict:
|
|
82
82
|
coordinates: Coordinates = {
|
|
83
83
|
'lat': 40.74836007062138,
|
|
84
84
|
'lng': -73.98509720487937
|
|
85
85
|
}
|
|
86
|
-
assessment: dict = api.register_new_signup('
|
|
86
|
+
assessment: dict = api.register_new_signup('request-token', address_coordinates=coordinates)
|
|
87
87
|
|
|
88
88
|
# with external_id:
|
|
89
89
|
external_id: str = 'external-id'
|
|
90
|
-
assessment: dict = api.register_new_signup('
|
|
90
|
+
assessment: dict = api.register_new_signup('request-token', external_id=external_id)
|
|
91
91
|
|
|
92
92
|
# with policy_id:
|
|
93
93
|
policy_id: str = 'policy-id'
|
|
94
|
-
assessment: dict = api.register_new_signup('
|
|
94
|
+
assessment: dict = api.register_new_signup('request-token', policy_id=policy_id)
|
|
95
95
|
|
|
96
96
|
# with account_id:
|
|
97
97
|
account_id: str = 'account-id'
|
|
98
|
-
assessment: dict = api.register_new_signup('
|
|
98
|
+
assessment: dict = api.register_new_signup('request-token', account_id=account_id)
|
|
99
99
|
|
|
100
100
|
```
|
|
101
101
|
|
|
@@ -113,13 +113,13 @@ api = IncogniaAPI('client-id', 'client-secret')
|
|
|
113
113
|
|
|
114
114
|
api.register_feedback(FeedbackEvents.ACCOUNT_TAKEOVER,
|
|
115
115
|
occurred_at=dt.datetime(2024, 7, 22, 15, 20, 0, tzinfo=dt.timezone.utc),
|
|
116
|
-
|
|
116
|
+
request_token='request-token',
|
|
117
117
|
account_id='account-id')
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
#### Registering Payment
|
|
121
121
|
|
|
122
|
-
This method registers a new payment for the given
|
|
122
|
+
This method registers a new payment for the given request token and account, returning a `dict`,
|
|
123
123
|
containing the risk assessment and supporting evidence.
|
|
124
124
|
|
|
125
125
|
```python3
|
|
@@ -180,7 +180,7 @@ payment_methods: List[PaymentMethod] = [
|
|
|
180
180
|
|
|
181
181
|
policy_id: str = 'policy-id'
|
|
182
182
|
|
|
183
|
-
assessment: dict = api.register_payment('
|
|
183
|
+
assessment: dict = api.register_payment('request-token',
|
|
184
184
|
'account-id',
|
|
185
185
|
'external-id',
|
|
186
186
|
addresses=addresses,
|
|
@@ -191,7 +191,7 @@ assessment: dict = api.register_payment('installation-id',
|
|
|
191
191
|
|
|
192
192
|
#### Registering Login
|
|
193
193
|
|
|
194
|
-
This method registers a new login for the given
|
|
194
|
+
This method registers a new login for the given request token and account, returning a `dict`,
|
|
195
195
|
containing the risk assessment and supporting evidence.
|
|
196
196
|
|
|
197
197
|
```python3
|
|
@@ -201,7 +201,7 @@ api = IncogniaAPI('client-id', 'client-secret')
|
|
|
201
201
|
|
|
202
202
|
policy_id: str = 'policy-id'
|
|
203
203
|
|
|
204
|
-
assessment: dict = api.register_login('
|
|
204
|
+
assessment: dict = api.register_login('request-token',
|
|
205
205
|
'account-id',
|
|
206
206
|
'external-id',
|
|
207
207
|
policy_id='policy_id')
|
|
@@ -15,10 +15,8 @@ class TestIncogniaAPI(TestCase):
|
|
|
15
15
|
CLIENT_ID: Final[str] = 'ANY_ID'
|
|
16
16
|
CLIENT_SECRET: Final[str] = 'ANY_SECRET'
|
|
17
17
|
INSTALLATION_ID: Final[str] = 'ANY_INSTALLATION_ID'
|
|
18
|
-
SESSION_TOKEN: Final[str] = 'ANY_SESSION_TOKEN'
|
|
19
18
|
REQUEST_TOKEN: Final[str] = 'ANY_REQUEST_TOKEN'
|
|
20
|
-
|
|
21
|
-
INVALID_SESSION_TOKEN: Final[str] = 'INVALID_SESSION_TOKEN'
|
|
19
|
+
INVALID_REQUEST_TOKEN: Final[str] = 'INVALID_REQUEST_TOKEN'
|
|
22
20
|
ACCOUNT_ID: Final[str] = 'ANY_ACCOUNT_ID'
|
|
23
21
|
INVALID_ACCOUNT_ID: Final[str] = 'INVALID_ACCOUNT_ID'
|
|
24
22
|
ADDRESS_LINE: Final[str] = 'ANY_ADDRESS_LINE'
|
|
@@ -57,22 +55,23 @@ class TestIncogniaAPI(TestCase):
|
|
|
57
55
|
'Content-Type': 'application/json'
|
|
58
56
|
}
|
|
59
57
|
REGISTER_SIGNUP_DATA: Final[bytes] = encode({
|
|
60
|
-
'
|
|
58
|
+
'request_token': f'{REQUEST_TOKEN}'
|
|
59
|
+
})
|
|
60
|
+
REGISTER_INVALID_SIGNUP_DATA: Final[bytes] = encode({
|
|
61
|
+
'request_token': f'{INVALID_REQUEST_TOKEN}'
|
|
61
62
|
})
|
|
62
63
|
FULL_REGISTER_SIGNUP_DATA: Final[bytes] = encode({
|
|
63
|
-
'
|
|
64
|
+
'request_token': f'{REQUEST_TOKEN}',
|
|
64
65
|
'address_line': f'{ADDRESS_LINE}',
|
|
65
66
|
'structured_address': STRUCTURED_ADDRESS,
|
|
66
67
|
'address_coordinates': ADDRESS_COORDINATES,
|
|
67
68
|
'external_id': f'{EXTERNAL_ID}',
|
|
68
69
|
'policy_id': f'{POLICY_ID}',
|
|
69
|
-
'account_id': f'{ACCOUNT_ID}'
|
|
70
|
-
'request_token': f'{REQUEST_TOKEN}'
|
|
70
|
+
'account_id': f'{ACCOUNT_ID}'
|
|
71
71
|
})
|
|
72
72
|
OK_STATUS_CODE: Final[int] = 200
|
|
73
73
|
CLIENT_ERROR_CODE: Final[int] = 400
|
|
74
74
|
VALID_EVENT_FEEDBACK_TYPE: Final[str] = 'valid_event_feedback_type'
|
|
75
|
-
INVALID_EVENT_FEEDBACK_TYPE: Final[str] = 'invalid_event_feedback_type'
|
|
76
75
|
TIMESTAMP: Final[dt.datetime] = dt.datetime.now(dt.timezone.utc)
|
|
77
76
|
TIMESTAMP_WITHOUT_TIMEZONE: Final[dt.datetime] = dt.datetime.now()
|
|
78
77
|
LOGIN_ID: Final[str] = 'ANY_LOGIN_ID'
|
|
@@ -88,62 +87,59 @@ class TestIncogniaAPI(TestCase):
|
|
|
88
87
|
'signup_id': f'{SIGNUP_ID}',
|
|
89
88
|
'account_id': f'{ACCOUNT_ID}',
|
|
90
89
|
'installation_id': f'{INSTALLATION_ID}',
|
|
91
|
-
'session_token': f'{SESSION_TOKEN}',
|
|
92
90
|
'request_token': f'{REQUEST_TOKEN}',
|
|
93
|
-
'timestamp': int((
|
|
94
|
-
TIMESTAMP - dt.datetime.fromtimestamp(0, dt.timezone.utc)).total_seconds() * 1000.0),
|
|
95
91
|
'occurred_at': TIMESTAMP.isoformat(),
|
|
96
92
|
'expires_at': TIMESTAMP.isoformat(),
|
|
97
93
|
})
|
|
98
|
-
REGISTER_INVALID_FEEDBACK_DATA: Final[bytes] = encode({
|
|
99
|
-
'event': f'{INVALID_EVENT_FEEDBACK_TYPE}'
|
|
100
|
-
})
|
|
101
94
|
REGISTER_VALID_PAYMENT_DATA: Final[bytes] = encode({
|
|
102
95
|
'type': 'payment',
|
|
103
|
-
'
|
|
96
|
+
'request_token': f'{REQUEST_TOKEN}',
|
|
104
97
|
'account_id': f'{ACCOUNT_ID}',
|
|
105
98
|
'policy_id': f'{POLICY_ID}',
|
|
106
|
-
'request_token': f'{REQUEST_TOKEN}',
|
|
107
99
|
})
|
|
108
100
|
REGISTER_INVALID_PAYMENT_DATA: Final[bytes] = encode({
|
|
109
101
|
'type': 'payment',
|
|
110
|
-
'
|
|
102
|
+
'request_token': f'{INVALID_REQUEST_TOKEN}',
|
|
111
103
|
'account_id': f'{INVALID_ACCOUNT_ID}'
|
|
112
104
|
})
|
|
113
105
|
REGISTER_VALID_LOGIN_DATA: Final[bytes] = encode({
|
|
114
106
|
'type': 'login',
|
|
115
|
-
'
|
|
107
|
+
'request_token': f'{REQUEST_TOKEN}',
|
|
116
108
|
'account_id': f'{ACCOUNT_ID}',
|
|
117
|
-
'policy_id': f'{POLICY_ID}'
|
|
118
|
-
'request_token': f'{REQUEST_TOKEN}'
|
|
109
|
+
'policy_id': f'{POLICY_ID}'
|
|
119
110
|
})
|
|
120
111
|
REGISTER_VALID_WEB_LOGIN_DATA: Final[bytes] = encode({
|
|
121
112
|
'type': 'login',
|
|
122
|
-
'
|
|
113
|
+
'request_token': f'{REQUEST_TOKEN}',
|
|
123
114
|
'account_id': f'{ACCOUNT_ID}',
|
|
124
|
-
'policy_id': f'{POLICY_ID}'
|
|
125
|
-
'request_token': f'{REQUEST_TOKEN}'
|
|
115
|
+
'policy_id': f'{POLICY_ID}'
|
|
126
116
|
})
|
|
127
117
|
REGISTER_INVALID_LOGIN_DATA: Final[bytes] = encode({
|
|
128
118
|
'type': 'login',
|
|
129
|
-
'
|
|
119
|
+
'request_token': f'{INVALID_REQUEST_TOKEN}',
|
|
130
120
|
'account_id': f'{INVALID_ACCOUNT_ID}'
|
|
131
121
|
})
|
|
132
122
|
REGISTER_INVALID_WEB_LOGIN_DATA: Final[bytes] = encode({
|
|
133
123
|
'type': 'login',
|
|
134
|
-
'
|
|
124
|
+
'request_token': f'{INVALID_REQUEST_TOKEN}',
|
|
135
125
|
'account_id': f'{INVALID_ACCOUNT_ID}'
|
|
136
126
|
})
|
|
137
127
|
DEFAULT_PARAMS: Final[None] = None
|
|
138
128
|
|
|
129
|
+
def test_metaclass_singleton_should_always_return_the_same_instance(self):
|
|
130
|
+
api1 = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
131
|
+
api2 = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
132
|
+
|
|
133
|
+
self.assertEqual(api1, api2)
|
|
134
|
+
|
|
139
135
|
@patch.object(BaseRequest, 'post')
|
|
140
136
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
141
|
-
def
|
|
137
|
+
def test_register_new_signup_when_request_token_is_valid_should_return_a_valid_dict(
|
|
142
138
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
143
139
|
mock_base_request_post.configure_mock(return_value=self.JSON_RESPONSE)
|
|
144
140
|
|
|
145
141
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
146
|
-
response = api.register_new_signup(
|
|
142
|
+
response = api.register_new_signup(request_token=self.REQUEST_TOKEN)
|
|
147
143
|
|
|
148
144
|
mock_token_manager_get.assert_called()
|
|
149
145
|
mock_base_request_post.assert_called_with(Endpoints.SIGNUPS,
|
|
@@ -154,13 +150,12 @@ class TestIncogniaAPI(TestCase):
|
|
|
154
150
|
|
|
155
151
|
@patch.object(BaseRequest, 'post')
|
|
156
152
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
157
|
-
def
|
|
153
|
+
def test_register_new_signup_when_request_token_is_valid_should_return_full_valid_dict_(
|
|
158
154
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
159
155
|
mock_base_request_post.configure_mock(return_value=self.JSON_RESPONSE)
|
|
160
156
|
|
|
161
157
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
162
|
-
response = api.register_new_signup(
|
|
163
|
-
address_line=self.ADDRESS_LINE,
|
|
158
|
+
response = api.register_new_signup(address_line=self.ADDRESS_LINE,
|
|
164
159
|
structured_address=self.STRUCTURED_ADDRESS,
|
|
165
160
|
address_coordinates=self.ADDRESS_COORDINATES,
|
|
166
161
|
external_id=self.EXTERNAL_ID,
|
|
@@ -177,29 +172,29 @@ class TestIncogniaAPI(TestCase):
|
|
|
177
172
|
|
|
178
173
|
@patch.object(BaseRequest, 'post')
|
|
179
174
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
180
|
-
def
|
|
175
|
+
def test_register_new_signup_when_request_token_is_empty_should_raise_an_IncogniaError(
|
|
181
176
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
182
|
-
mock_base_request_post.configure_mock(side_effect=IncogniaHTTPError)
|
|
183
|
-
|
|
184
177
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
185
178
|
|
|
186
|
-
self.assertRaises(
|
|
179
|
+
self.assertRaises(IncogniaError, api.register_new_signup, request_token='')
|
|
187
180
|
|
|
188
|
-
mock_token_manager_get.
|
|
189
|
-
mock_base_request_post.
|
|
190
|
-
headers=self.AUTH_AND_JSON_CONTENT_HEADERS,
|
|
191
|
-
data=self.REGISTER_SIGNUP_DATA)
|
|
181
|
+
mock_token_manager_get.assert_not_called()
|
|
182
|
+
mock_base_request_post.assert_not_called()
|
|
192
183
|
|
|
193
184
|
@patch.object(BaseRequest, 'post')
|
|
194
|
-
@patch.object(TokenManager, 'get')
|
|
195
|
-
def
|
|
185
|
+
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
186
|
+
def test_register_new_signup_when_request_token_is_invalid_should_raise_an_IncogniaHTTPError(
|
|
196
187
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
188
|
+
mock_base_request_post.configure_mock(side_effect=IncogniaHTTPError)
|
|
189
|
+
|
|
197
190
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
198
191
|
|
|
199
|
-
self.assertRaises(
|
|
192
|
+
self.assertRaises(IncogniaHTTPError, api.register_new_signup, self.INVALID_REQUEST_TOKEN)
|
|
200
193
|
|
|
201
|
-
mock_token_manager_get.
|
|
202
|
-
mock_base_request_post.
|
|
194
|
+
mock_token_manager_get.assert_called()
|
|
195
|
+
mock_base_request_post.assert_called_with(Endpoints.SIGNUPS,
|
|
196
|
+
headers=self.AUTH_AND_JSON_CONTENT_HEADERS,
|
|
197
|
+
data=self.REGISTER_INVALID_SIGNUP_DATA)
|
|
203
198
|
|
|
204
199
|
@patch.object(BaseRequest, 'post')
|
|
205
200
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
@@ -221,7 +216,6 @@ class TestIncogniaAPI(TestCase):
|
|
|
221
216
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
222
217
|
|
|
223
218
|
api.register_feedback(self.VALID_EVENT_FEEDBACK_TYPE,
|
|
224
|
-
timestamp=self.TIMESTAMP,
|
|
225
219
|
occurred_at=self.TIMESTAMP,
|
|
226
220
|
expires_at=self.TIMESTAMP,
|
|
227
221
|
external_id=self.EXTERNAL_ID,
|
|
@@ -230,7 +224,6 @@ class TestIncogniaAPI(TestCase):
|
|
|
230
224
|
signup_id=self.SIGNUP_ID,
|
|
231
225
|
account_id=self.ACCOUNT_ID,
|
|
232
226
|
installation_id=self.INSTALLATION_ID,
|
|
233
|
-
session_token=self.SESSION_TOKEN,
|
|
234
227
|
request_token=self.REQUEST_TOKEN)
|
|
235
228
|
|
|
236
229
|
mock_token_manager_get.assert_called()
|
|
@@ -249,20 +242,6 @@ class TestIncogniaAPI(TestCase):
|
|
|
249
242
|
mock_token_manager_get.assert_not_called()
|
|
250
243
|
mock_base_request_post.assert_not_called()
|
|
251
244
|
|
|
252
|
-
@patch.object(BaseRequest, 'post')
|
|
253
|
-
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
254
|
-
def test_register_feedback_when_timestamp_does_not_have_timezone_should_raise_IncogniaError(
|
|
255
|
-
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
256
|
-
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
257
|
-
|
|
258
|
-
self.assertRaises(IncogniaError,
|
|
259
|
-
api.register_feedback,
|
|
260
|
-
event=self.VALID_EVENT_FEEDBACK_TYPE,
|
|
261
|
-
timestamp=self.TIMESTAMP_WITHOUT_TIMEZONE)
|
|
262
|
-
|
|
263
|
-
mock_token_manager_get.assert_not_called()
|
|
264
|
-
mock_base_request_post.assert_not_called()
|
|
265
|
-
|
|
266
245
|
@patch.object(BaseRequest, 'post')
|
|
267
246
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
268
247
|
def test_register_feedback_when_occurred_at_does_not_have_timezone_should_raise_IncogniaError(
|
|
@@ -291,22 +270,6 @@ class TestIncogniaAPI(TestCase):
|
|
|
291
270
|
mock_token_manager_get.assert_not_called()
|
|
292
271
|
mock_base_request_post.assert_not_called()
|
|
293
272
|
|
|
294
|
-
@patch.object(BaseRequest, 'post')
|
|
295
|
-
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
296
|
-
def test_register_feedback_when_required_fields_are_invalid_should_raise_an_IncogniaHTTPError(
|
|
297
|
-
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
298
|
-
mock_base_request_post.configure_mock(side_effect=IncogniaHTTPError)
|
|
299
|
-
|
|
300
|
-
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
301
|
-
|
|
302
|
-
self.assertRaises(IncogniaHTTPError, api.register_feedback,
|
|
303
|
-
event=self.INVALID_EVENT_FEEDBACK_TYPE)
|
|
304
|
-
|
|
305
|
-
mock_token_manager_get.assert_called()
|
|
306
|
-
mock_base_request_post.assert_called_with(Endpoints.FEEDBACKS,
|
|
307
|
-
headers=self.AUTH_AND_JSON_CONTENT_HEADERS,
|
|
308
|
-
data=self.REGISTER_INVALID_FEEDBACK_DATA)
|
|
309
|
-
|
|
310
273
|
@patch.object(BaseRequest, 'post')
|
|
311
274
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
312
275
|
def test_register_payment_when_required_fields_are_valid_should_work(
|
|
@@ -315,10 +278,9 @@ class TestIncogniaAPI(TestCase):
|
|
|
315
278
|
|
|
316
279
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
317
280
|
|
|
318
|
-
request_response = api.register_payment(self.
|
|
281
|
+
request_response = api.register_payment(self.REQUEST_TOKEN,
|
|
319
282
|
self.ACCOUNT_ID,
|
|
320
|
-
policy_id=self.POLICY_ID
|
|
321
|
-
request_token=self.REQUEST_TOKEN)
|
|
283
|
+
policy_id=self.POLICY_ID)
|
|
322
284
|
|
|
323
285
|
mock_token_manager_get.assert_called()
|
|
324
286
|
mock_base_request_post.assert_called_with(Endpoints.TRANSACTIONS,
|
|
@@ -330,11 +292,12 @@ class TestIncogniaAPI(TestCase):
|
|
|
330
292
|
|
|
331
293
|
@patch.object(BaseRequest, 'post')
|
|
332
294
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
333
|
-
def
|
|
295
|
+
def test_register_payment_when_request_token_is_empty_should_raise_an_IncogniaError(
|
|
334
296
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
335
297
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
336
298
|
|
|
337
|
-
self.assertRaises(IncogniaError, api.register_payment,
|
|
299
|
+
self.assertRaises(IncogniaError, api.register_payment,
|
|
300
|
+
request_token='',
|
|
338
301
|
account_id=self.ACCOUNT_ID)
|
|
339
302
|
|
|
340
303
|
mock_token_manager_get.assert_not_called()
|
|
@@ -346,7 +309,8 @@ class TestIncogniaAPI(TestCase):
|
|
|
346
309
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
347
310
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
348
311
|
|
|
349
|
-
self.assertRaises(IncogniaError, api.register_payment,
|
|
312
|
+
self.assertRaises(IncogniaError, api.register_payment,
|
|
313
|
+
request_token=self.REQUEST_TOKEN,
|
|
350
314
|
account_id='')
|
|
351
315
|
|
|
352
316
|
mock_token_manager_get.assert_not_called()
|
|
@@ -361,7 +325,7 @@ class TestIncogniaAPI(TestCase):
|
|
|
361
325
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
362
326
|
|
|
363
327
|
self.assertRaises(IncogniaHTTPError, api.register_payment,
|
|
364
|
-
|
|
328
|
+
request_token=self.INVALID_REQUEST_TOKEN,
|
|
365
329
|
account_id=self.INVALID_ACCOUNT_ID)
|
|
366
330
|
|
|
367
331
|
mock_token_manager_get.assert_called()
|
|
@@ -378,10 +342,9 @@ class TestIncogniaAPI(TestCase):
|
|
|
378
342
|
|
|
379
343
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
380
344
|
|
|
381
|
-
request_response = api.register_login(self.
|
|
345
|
+
request_response = api.register_login(self.REQUEST_TOKEN,
|
|
382
346
|
self.ACCOUNT_ID,
|
|
383
|
-
policy_id=self.POLICY_ID
|
|
384
|
-
request_token=self.REQUEST_TOKEN)
|
|
347
|
+
policy_id=self.POLICY_ID)
|
|
385
348
|
|
|
386
349
|
mock_token_manager_get.assert_called()
|
|
387
350
|
mock_base_request_post.assert_called_with(Endpoints.TRANSACTIONS,
|
|
@@ -393,11 +356,12 @@ class TestIncogniaAPI(TestCase):
|
|
|
393
356
|
|
|
394
357
|
@patch.object(BaseRequest, 'post')
|
|
395
358
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
396
|
-
def
|
|
359
|
+
def test_register_login_when_request_token_is_empty_should_raise_an_IncogniaError(
|
|
397
360
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
398
361
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
399
362
|
|
|
400
|
-
self.assertRaises(IncogniaError, api.register_login,
|
|
363
|
+
self.assertRaises(IncogniaError, api.register_login,
|
|
364
|
+
request_token='',
|
|
401
365
|
account_id=self.ACCOUNT_ID)
|
|
402
366
|
|
|
403
367
|
mock_token_manager_get.assert_not_called()
|
|
@@ -409,7 +373,8 @@ class TestIncogniaAPI(TestCase):
|
|
|
409
373
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
410
374
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
411
375
|
|
|
412
|
-
self.assertRaises(IncogniaError, api.register_login,
|
|
376
|
+
self.assertRaises(IncogniaError, api.register_login,
|
|
377
|
+
request_token=self.REQUEST_TOKEN,
|
|
413
378
|
account_id='')
|
|
414
379
|
|
|
415
380
|
mock_token_manager_get.assert_not_called()
|
|
@@ -424,7 +389,7 @@ class TestIncogniaAPI(TestCase):
|
|
|
424
389
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
425
390
|
|
|
426
391
|
self.assertRaises(IncogniaHTTPError, api.register_login,
|
|
427
|
-
|
|
392
|
+
request_token=self.INVALID_REQUEST_TOKEN,
|
|
428
393
|
account_id=self.INVALID_ACCOUNT_ID)
|
|
429
394
|
|
|
430
395
|
mock_token_manager_get.assert_called()
|
|
@@ -441,10 +406,9 @@ class TestIncogniaAPI(TestCase):
|
|
|
441
406
|
|
|
442
407
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
443
408
|
|
|
444
|
-
request_response = api.register_web_login(self.
|
|
409
|
+
request_response = api.register_web_login(self.REQUEST_TOKEN,
|
|
445
410
|
self.ACCOUNT_ID,
|
|
446
|
-
policy_id=self.POLICY_ID
|
|
447
|
-
request_token=self.REQUEST_TOKEN)
|
|
411
|
+
policy_id=self.POLICY_ID)
|
|
448
412
|
|
|
449
413
|
mock_token_manager_get.assert_called()
|
|
450
414
|
mock_base_request_post.assert_called_with(Endpoints.TRANSACTIONS,
|
|
@@ -456,11 +420,12 @@ class TestIncogniaAPI(TestCase):
|
|
|
456
420
|
|
|
457
421
|
@patch.object(BaseRequest, 'post')
|
|
458
422
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
459
|
-
def
|
|
423
|
+
def test_register_web_login_when_request_token_is_empty_should_raise_an_IncogniaError(
|
|
460
424
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
461
425
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
462
426
|
|
|
463
|
-
self.assertRaises(IncogniaError, api.register_web_login,
|
|
427
|
+
self.assertRaises(IncogniaError, api.register_web_login,
|
|
428
|
+
request_token='',
|
|
464
429
|
account_id=self.ACCOUNT_ID)
|
|
465
430
|
|
|
466
431
|
mock_token_manager_get.assert_not_called()
|
|
@@ -472,7 +437,8 @@ class TestIncogniaAPI(TestCase):
|
|
|
472
437
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
473
438
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
474
439
|
|
|
475
|
-
self.assertRaises(IncogniaError, api.register_web_login,
|
|
440
|
+
self.assertRaises(IncogniaError, api.register_web_login,
|
|
441
|
+
request_token=self.REQUEST_TOKEN,
|
|
476
442
|
account_id='')
|
|
477
443
|
|
|
478
444
|
mock_token_manager_get.assert_not_called()
|
|
@@ -487,8 +453,8 @@ class TestIncogniaAPI(TestCase):
|
|
|
487
453
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
488
454
|
|
|
489
455
|
self.assertRaises(IncogniaHTTPError, api.register_web_login,
|
|
490
|
-
|
|
491
|
-
|
|
456
|
+
account_id=self.INVALID_ACCOUNT_ID,
|
|
457
|
+
request_token=self.INVALID_REQUEST_TOKEN)
|
|
492
458
|
|
|
493
459
|
mock_token_manager_get.assert_called()
|
|
494
460
|
mock_base_request_post.assert_called_with(Endpoints.TRANSACTIONS,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import datetime as dt
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def total_milliseconds_since_epoch(t: dt.datetime) -> int:
|
|
5
|
-
return int((t - dt.datetime.fromtimestamp(0, dt.timezone.utc)).total_seconds() * 1000.0)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def has_timezone(d: dt.datetime) -> bool:
|
|
9
|
-
return d.tzinfo is not None and d.tzinfo.utcoffset(d) is not None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{incognia_python-2.2.0 → incognia_python-3.0.0}/incognia_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|