incognia-python 2.1.1__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.1.1 → incognia_python-3.0.0}/.github/workflows/continuous.yaml +4 -4
- {incognia_python-2.1.1 → incognia_python-3.0.0}/PKG-INFO +13 -13
- {incognia_python-2.1.1 → incognia_python-3.0.0}/README.md +12 -12
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia/api.py +19 -25
- incognia_python-3.0.0/incognia/datetime_util.py +5 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia/feedback_events.py +8 -5
- incognia_python-3.0.0/incognia/singleton.py +8 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia_python.egg-info/PKG-INFO +13 -13
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia_python.egg-info/SOURCES.txt +1 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/tests/test_api.py +60 -86
- incognia_python-2.1.1/incognia/datetime_util.py +0 -9
- {incognia_python-2.1.1 → incognia_python-3.0.0}/.github/dependabot.yml +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/.github/workflows/codeql.yaml +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/.gitignore +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/CODEOWNERS +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/LICENSE.txt +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/MANIFEST.in +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia/__init__.py +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia/base_request.py +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia/endpoints.py +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia/exceptions.py +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia/json_util.py +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia/models.py +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia/token_manager.py +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia_python.egg-info/dependency_links.txt +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia_python.egg-info/not-zip-safe +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia_python.egg-info/requires.txt +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/incognia_python.egg-info/top_level.txt +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/pyproject.toml +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/requirements.txt +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/setup.cfg +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/tests/__init__.py +0 -0
- {incognia_python-2.1.1 → incognia_python-3.0.0}/tests/test_base_request.py +0 -0
- {incognia_python-2.1.1 → 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,21 +21,21 @@ 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
30
|
account_id: Optional[str] = None) -> dict:
|
|
30
|
-
if not
|
|
31
|
-
raise IncogniaError('
|
|
31
|
+
if not request_token:
|
|
32
|
+
raise IncogniaError('request_token is required.')
|
|
32
33
|
|
|
33
34
|
try:
|
|
34
35
|
headers = self.__get_authorization_header()
|
|
35
36
|
headers.update(JSON_CONTENT_HEADER)
|
|
36
37
|
body = {
|
|
37
|
-
'
|
|
38
|
+
'request_token': request_token,
|
|
38
39
|
'address_line': address_line,
|
|
39
40
|
'structured_address': structured_address,
|
|
40
41
|
'address_coordinates': address_coordinates,
|
|
@@ -50,21 +51,17 @@ class IncogniaAPI:
|
|
|
50
51
|
|
|
51
52
|
def register_feedback(self,
|
|
52
53
|
event: str,
|
|
53
|
-
timestamp: dt.datetime = None,
|
|
54
54
|
external_id: Optional[str] = None,
|
|
55
55
|
login_id: Optional[str] = None,
|
|
56
56
|
payment_id: Optional[str] = None,
|
|
57
57
|
signup_id: Optional[str] = None,
|
|
58
58
|
account_id: Optional[str] = None,
|
|
59
59
|
installation_id: Optional[str] = None,
|
|
60
|
-
session_token: Optional[str] = None,
|
|
61
60
|
request_token: Optional[str] = None,
|
|
62
61
|
occurred_at: dt.datetime = None,
|
|
63
62
|
expires_at: dt.datetime = None) -> None:
|
|
64
63
|
if not event:
|
|
65
64
|
raise IncogniaError('event is required.')
|
|
66
|
-
if timestamp is not None and not has_timezone(timestamp):
|
|
67
|
-
raise IncogniaError('timestamp must have timezone')
|
|
68
65
|
if occurred_at is not None and not has_timezone(occurred_at):
|
|
69
66
|
raise IncogniaError('occurred_at must have timezone')
|
|
70
67
|
if expires_at is not None and not has_timezone(expires_at):
|
|
@@ -81,11 +78,8 @@ class IncogniaAPI:
|
|
|
81
78
|
'signup_id': signup_id,
|
|
82
79
|
'account_id': account_id,
|
|
83
80
|
'installation_id': installation_id,
|
|
84
|
-
'session_token': session_token,
|
|
85
81
|
'request_token': request_token
|
|
86
82
|
}
|
|
87
|
-
if timestamp is not None:
|
|
88
|
-
body['timestamp'] = total_milliseconds_since_epoch(timestamp)
|
|
89
83
|
if occurred_at is not None:
|
|
90
84
|
body['occurred_at'] = occurred_at.isoformat()
|
|
91
85
|
if expires_at is not None:
|
|
@@ -97,7 +91,7 @@ class IncogniaAPI:
|
|
|
97
91
|
raise IncogniaHTTPError(e) from None
|
|
98
92
|
|
|
99
93
|
def register_payment(self,
|
|
100
|
-
|
|
94
|
+
request_token: str,
|
|
101
95
|
account_id: str,
|
|
102
96
|
external_id: Optional[str] = None,
|
|
103
97
|
addresses: Optional[List[TransactionAddress]] = None,
|
|
@@ -105,8 +99,8 @@ class IncogniaAPI:
|
|
|
105
99
|
payment_methods: Optional[List[PaymentMethod]] = None,
|
|
106
100
|
evaluate: Optional[bool] = None,
|
|
107
101
|
policy_id: Optional[str] = None) -> dict:
|
|
108
|
-
if not
|
|
109
|
-
raise IncogniaError('
|
|
102
|
+
if not request_token:
|
|
103
|
+
raise IncogniaError('request_token is required.')
|
|
110
104
|
if not account_id:
|
|
111
105
|
raise IncogniaError('account_id is required.')
|
|
112
106
|
|
|
@@ -116,7 +110,7 @@ class IncogniaAPI:
|
|
|
116
110
|
params = None if evaluate is None else {'eval': evaluate}
|
|
117
111
|
body = {
|
|
118
112
|
'type': 'payment',
|
|
119
|
-
'
|
|
113
|
+
'request_token': request_token,
|
|
120
114
|
'account_id': account_id,
|
|
121
115
|
'external_id': external_id,
|
|
122
116
|
'addresses': addresses,
|
|
@@ -132,13 +126,13 @@ class IncogniaAPI:
|
|
|
132
126
|
raise IncogniaHTTPError(e) from None
|
|
133
127
|
|
|
134
128
|
def register_login(self,
|
|
135
|
-
|
|
129
|
+
request_token: str,
|
|
136
130
|
account_id: str,
|
|
137
131
|
external_id: Optional[str] = None,
|
|
138
132
|
evaluate: Optional[bool] = None,
|
|
139
133
|
policy_id: Optional[str] = None) -> dict:
|
|
140
|
-
if not
|
|
141
|
-
raise IncogniaError('
|
|
134
|
+
if not request_token:
|
|
135
|
+
raise IncogniaError('request_token is required.')
|
|
142
136
|
if not account_id:
|
|
143
137
|
raise IncogniaError('account_id is required.')
|
|
144
138
|
|
|
@@ -148,7 +142,7 @@ class IncogniaAPI:
|
|
|
148
142
|
params = None if evaluate is None else {'eval': evaluate}
|
|
149
143
|
body = {
|
|
150
144
|
'type': 'login',
|
|
151
|
-
'
|
|
145
|
+
'request_token': request_token,
|
|
152
146
|
'account_id': account_id,
|
|
153
147
|
'external_id': external_id,
|
|
154
148
|
'policy_id': policy_id
|
|
@@ -161,13 +155,13 @@ class IncogniaAPI:
|
|
|
161
155
|
raise IncogniaHTTPError(e) from None
|
|
162
156
|
|
|
163
157
|
def register_web_login(self,
|
|
164
|
-
|
|
158
|
+
request_token: str,
|
|
165
159
|
account_id: str,
|
|
166
160
|
external_id: Optional[str] = None,
|
|
167
161
|
evaluate: Optional[bool] = None,
|
|
168
162
|
policy_id: Optional[str] = None) -> dict:
|
|
169
|
-
if not
|
|
170
|
-
raise IncogniaError('
|
|
163
|
+
if not request_token:
|
|
164
|
+
raise IncogniaError('request_token is required.')
|
|
171
165
|
if not account_id:
|
|
172
166
|
raise IncogniaError('account_id is required.')
|
|
173
167
|
|
|
@@ -177,7 +171,7 @@ class IncogniaAPI:
|
|
|
177
171
|
params = None if evaluate is None else {'eval': evaluate}
|
|
178
172
|
body = {
|
|
179
173
|
'type': 'login',
|
|
180
|
-
'
|
|
174
|
+
'request_token': request_token,
|
|
181
175
|
'account_id': account_id,
|
|
182
176
|
'external_id': external_id,
|
|
183
177
|
'policy_id': policy_id
|
|
@@ -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,10 +55,13 @@ 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,
|
|
@@ -71,7 +72,6 @@ class TestIncogniaAPI(TestCase):
|
|
|
71
72
|
OK_STATUS_CODE: Final[int] = 200
|
|
72
73
|
CLIENT_ERROR_CODE: Final[int] = 400
|
|
73
74
|
VALID_EVENT_FEEDBACK_TYPE: Final[str] = 'valid_event_feedback_type'
|
|
74
|
-
INVALID_EVENT_FEEDBACK_TYPE: Final[str] = 'invalid_event_feedback_type'
|
|
75
75
|
TIMESTAMP: Final[dt.datetime] = dt.datetime.now(dt.timezone.utc)
|
|
76
76
|
TIMESTAMP_WITHOUT_TIMEZONE: Final[dt.datetime] = dt.datetime.now()
|
|
77
77
|
LOGIN_ID: Final[str] = 'ANY_LOGIN_ID'
|
|
@@ -87,59 +87,59 @@ class TestIncogniaAPI(TestCase):
|
|
|
87
87
|
'signup_id': f'{SIGNUP_ID}',
|
|
88
88
|
'account_id': f'{ACCOUNT_ID}',
|
|
89
89
|
'installation_id': f'{INSTALLATION_ID}',
|
|
90
|
-
'session_token': f'{SESSION_TOKEN}',
|
|
91
90
|
'request_token': f'{REQUEST_TOKEN}',
|
|
92
|
-
'timestamp': int((
|
|
93
|
-
TIMESTAMP - dt.datetime.fromtimestamp(0, dt.timezone.utc)).total_seconds() * 1000.0),
|
|
94
91
|
'occurred_at': TIMESTAMP.isoformat(),
|
|
95
92
|
'expires_at': TIMESTAMP.isoformat(),
|
|
96
93
|
})
|
|
97
|
-
REGISTER_INVALID_FEEDBACK_DATA: Final[bytes] = encode({
|
|
98
|
-
'event': f'{INVALID_EVENT_FEEDBACK_TYPE}'
|
|
99
|
-
})
|
|
100
94
|
REGISTER_VALID_PAYMENT_DATA: Final[bytes] = encode({
|
|
101
95
|
'type': 'payment',
|
|
102
|
-
'
|
|
96
|
+
'request_token': f'{REQUEST_TOKEN}',
|
|
103
97
|
'account_id': f'{ACCOUNT_ID}',
|
|
104
|
-
'policy_id': f'{POLICY_ID}'
|
|
98
|
+
'policy_id': f'{POLICY_ID}',
|
|
105
99
|
})
|
|
106
100
|
REGISTER_INVALID_PAYMENT_DATA: Final[bytes] = encode({
|
|
107
101
|
'type': 'payment',
|
|
108
|
-
'
|
|
102
|
+
'request_token': f'{INVALID_REQUEST_TOKEN}',
|
|
109
103
|
'account_id': f'{INVALID_ACCOUNT_ID}'
|
|
110
104
|
})
|
|
111
105
|
REGISTER_VALID_LOGIN_DATA: Final[bytes] = encode({
|
|
112
106
|
'type': 'login',
|
|
113
|
-
'
|
|
107
|
+
'request_token': f'{REQUEST_TOKEN}',
|
|
114
108
|
'account_id': f'{ACCOUNT_ID}',
|
|
115
109
|
'policy_id': f'{POLICY_ID}'
|
|
116
110
|
})
|
|
117
111
|
REGISTER_VALID_WEB_LOGIN_DATA: Final[bytes] = encode({
|
|
118
112
|
'type': 'login',
|
|
119
|
-
'
|
|
113
|
+
'request_token': f'{REQUEST_TOKEN}',
|
|
120
114
|
'account_id': f'{ACCOUNT_ID}',
|
|
121
115
|
'policy_id': f'{POLICY_ID}'
|
|
122
116
|
})
|
|
123
117
|
REGISTER_INVALID_LOGIN_DATA: Final[bytes] = encode({
|
|
124
118
|
'type': 'login',
|
|
125
|
-
'
|
|
119
|
+
'request_token': f'{INVALID_REQUEST_TOKEN}',
|
|
126
120
|
'account_id': f'{INVALID_ACCOUNT_ID}'
|
|
127
121
|
})
|
|
128
122
|
REGISTER_INVALID_WEB_LOGIN_DATA: Final[bytes] = encode({
|
|
129
123
|
'type': 'login',
|
|
130
|
-
'
|
|
124
|
+
'request_token': f'{INVALID_REQUEST_TOKEN}',
|
|
131
125
|
'account_id': f'{INVALID_ACCOUNT_ID}'
|
|
132
126
|
})
|
|
133
127
|
DEFAULT_PARAMS: Final[None] = None
|
|
134
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
|
+
|
|
135
135
|
@patch.object(BaseRequest, 'post')
|
|
136
136
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
137
|
-
def
|
|
137
|
+
def test_register_new_signup_when_request_token_is_valid_should_return_a_valid_dict(
|
|
138
138
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
139
139
|
mock_base_request_post.configure_mock(return_value=self.JSON_RESPONSE)
|
|
140
140
|
|
|
141
141
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
142
|
-
response = api.register_new_signup(
|
|
142
|
+
response = api.register_new_signup(request_token=self.REQUEST_TOKEN)
|
|
143
143
|
|
|
144
144
|
mock_token_manager_get.assert_called()
|
|
145
145
|
mock_base_request_post.assert_called_with(Endpoints.SIGNUPS,
|
|
@@ -150,18 +150,18 @@ class TestIncogniaAPI(TestCase):
|
|
|
150
150
|
|
|
151
151
|
@patch.object(BaseRequest, 'post')
|
|
152
152
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
153
|
-
def
|
|
153
|
+
def test_register_new_signup_when_request_token_is_valid_should_return_full_valid_dict_(
|
|
154
154
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
155
155
|
mock_base_request_post.configure_mock(return_value=self.JSON_RESPONSE)
|
|
156
156
|
|
|
157
157
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
158
|
-
response = api.register_new_signup(
|
|
159
|
-
address_line=self.ADDRESS_LINE,
|
|
158
|
+
response = api.register_new_signup(address_line=self.ADDRESS_LINE,
|
|
160
159
|
structured_address=self.STRUCTURED_ADDRESS,
|
|
161
160
|
address_coordinates=self.ADDRESS_COORDINATES,
|
|
162
161
|
external_id=self.EXTERNAL_ID,
|
|
163
162
|
policy_id=self.POLICY_ID,
|
|
164
|
-
account_id=self.ACCOUNT_ID
|
|
163
|
+
account_id=self.ACCOUNT_ID,
|
|
164
|
+
request_token=self.REQUEST_TOKEN)
|
|
165
165
|
|
|
166
166
|
mock_token_manager_get.assert_called()
|
|
167
167
|
mock_base_request_post.assert_called_with(Endpoints.SIGNUPS,
|
|
@@ -172,29 +172,29 @@ class TestIncogniaAPI(TestCase):
|
|
|
172
172
|
|
|
173
173
|
@patch.object(BaseRequest, 'post')
|
|
174
174
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
175
|
-
def
|
|
175
|
+
def test_register_new_signup_when_request_token_is_empty_should_raise_an_IncogniaError(
|
|
176
176
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
177
|
-
mock_base_request_post.configure_mock(side_effect=IncogniaHTTPError)
|
|
178
|
-
|
|
179
177
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
180
178
|
|
|
181
|
-
self.assertRaises(
|
|
179
|
+
self.assertRaises(IncogniaError, api.register_new_signup, request_token='')
|
|
182
180
|
|
|
183
|
-
mock_token_manager_get.
|
|
184
|
-
mock_base_request_post.
|
|
185
|
-
headers=self.AUTH_AND_JSON_CONTENT_HEADERS,
|
|
186
|
-
data=self.REGISTER_SIGNUP_DATA)
|
|
181
|
+
mock_token_manager_get.assert_not_called()
|
|
182
|
+
mock_base_request_post.assert_not_called()
|
|
187
183
|
|
|
188
184
|
@patch.object(BaseRequest, 'post')
|
|
189
|
-
@patch.object(TokenManager, 'get')
|
|
190
|
-
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(
|
|
191
187
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
188
|
+
mock_base_request_post.configure_mock(side_effect=IncogniaHTTPError)
|
|
189
|
+
|
|
192
190
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
193
191
|
|
|
194
|
-
self.assertRaises(
|
|
192
|
+
self.assertRaises(IncogniaHTTPError, api.register_new_signup, self.INVALID_REQUEST_TOKEN)
|
|
195
193
|
|
|
196
|
-
mock_token_manager_get.
|
|
197
|
-
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)
|
|
198
198
|
|
|
199
199
|
@patch.object(BaseRequest, 'post')
|
|
200
200
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
@@ -216,7 +216,6 @@ class TestIncogniaAPI(TestCase):
|
|
|
216
216
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
217
217
|
|
|
218
218
|
api.register_feedback(self.VALID_EVENT_FEEDBACK_TYPE,
|
|
219
|
-
timestamp=self.TIMESTAMP,
|
|
220
219
|
occurred_at=self.TIMESTAMP,
|
|
221
220
|
expires_at=self.TIMESTAMP,
|
|
222
221
|
external_id=self.EXTERNAL_ID,
|
|
@@ -225,7 +224,6 @@ class TestIncogniaAPI(TestCase):
|
|
|
225
224
|
signup_id=self.SIGNUP_ID,
|
|
226
225
|
account_id=self.ACCOUNT_ID,
|
|
227
226
|
installation_id=self.INSTALLATION_ID,
|
|
228
|
-
session_token=self.SESSION_TOKEN,
|
|
229
227
|
request_token=self.REQUEST_TOKEN)
|
|
230
228
|
|
|
231
229
|
mock_token_manager_get.assert_called()
|
|
@@ -244,20 +242,6 @@ class TestIncogniaAPI(TestCase):
|
|
|
244
242
|
mock_token_manager_get.assert_not_called()
|
|
245
243
|
mock_base_request_post.assert_not_called()
|
|
246
244
|
|
|
247
|
-
@patch.object(BaseRequest, 'post')
|
|
248
|
-
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
249
|
-
def test_register_feedback_when_timestamp_does_not_have_timezone_should_raise_IncogniaError(
|
|
250
|
-
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
251
|
-
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
252
|
-
|
|
253
|
-
self.assertRaises(IncogniaError,
|
|
254
|
-
api.register_feedback,
|
|
255
|
-
event=self.VALID_EVENT_FEEDBACK_TYPE,
|
|
256
|
-
timestamp=self.TIMESTAMP_WITHOUT_TIMEZONE)
|
|
257
|
-
|
|
258
|
-
mock_token_manager_get.assert_not_called()
|
|
259
|
-
mock_base_request_post.assert_not_called()
|
|
260
|
-
|
|
261
245
|
@patch.object(BaseRequest, 'post')
|
|
262
246
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
263
247
|
def test_register_feedback_when_occurred_at_does_not_have_timezone_should_raise_IncogniaError(
|
|
@@ -286,22 +270,6 @@ class TestIncogniaAPI(TestCase):
|
|
|
286
270
|
mock_token_manager_get.assert_not_called()
|
|
287
271
|
mock_base_request_post.assert_not_called()
|
|
288
272
|
|
|
289
|
-
@patch.object(BaseRequest, 'post')
|
|
290
|
-
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
291
|
-
def test_register_feedback_when_required_fields_are_invalid_should_raise_an_IncogniaHTTPError(
|
|
292
|
-
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
293
|
-
mock_base_request_post.configure_mock(side_effect=IncogniaHTTPError)
|
|
294
|
-
|
|
295
|
-
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
296
|
-
|
|
297
|
-
self.assertRaises(IncogniaHTTPError, api.register_feedback,
|
|
298
|
-
event=self.INVALID_EVENT_FEEDBACK_TYPE)
|
|
299
|
-
|
|
300
|
-
mock_token_manager_get.assert_called()
|
|
301
|
-
mock_base_request_post.assert_called_with(Endpoints.FEEDBACKS,
|
|
302
|
-
headers=self.AUTH_AND_JSON_CONTENT_HEADERS,
|
|
303
|
-
data=self.REGISTER_INVALID_FEEDBACK_DATA)
|
|
304
|
-
|
|
305
273
|
@patch.object(BaseRequest, 'post')
|
|
306
274
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
307
275
|
def test_register_payment_when_required_fields_are_valid_should_work(
|
|
@@ -310,7 +278,7 @@ class TestIncogniaAPI(TestCase):
|
|
|
310
278
|
|
|
311
279
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
312
280
|
|
|
313
|
-
request_response = api.register_payment(self.
|
|
281
|
+
request_response = api.register_payment(self.REQUEST_TOKEN,
|
|
314
282
|
self.ACCOUNT_ID,
|
|
315
283
|
policy_id=self.POLICY_ID)
|
|
316
284
|
|
|
@@ -324,11 +292,12 @@ class TestIncogniaAPI(TestCase):
|
|
|
324
292
|
|
|
325
293
|
@patch.object(BaseRequest, 'post')
|
|
326
294
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
327
|
-
def
|
|
295
|
+
def test_register_payment_when_request_token_is_empty_should_raise_an_IncogniaError(
|
|
328
296
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
329
297
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
330
298
|
|
|
331
|
-
self.assertRaises(IncogniaError, api.register_payment,
|
|
299
|
+
self.assertRaises(IncogniaError, api.register_payment,
|
|
300
|
+
request_token='',
|
|
332
301
|
account_id=self.ACCOUNT_ID)
|
|
333
302
|
|
|
334
303
|
mock_token_manager_get.assert_not_called()
|
|
@@ -340,7 +309,8 @@ class TestIncogniaAPI(TestCase):
|
|
|
340
309
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
341
310
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
342
311
|
|
|
343
|
-
self.assertRaises(IncogniaError, api.register_payment,
|
|
312
|
+
self.assertRaises(IncogniaError, api.register_payment,
|
|
313
|
+
request_token=self.REQUEST_TOKEN,
|
|
344
314
|
account_id='')
|
|
345
315
|
|
|
346
316
|
mock_token_manager_get.assert_not_called()
|
|
@@ -355,7 +325,7 @@ class TestIncogniaAPI(TestCase):
|
|
|
355
325
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
356
326
|
|
|
357
327
|
self.assertRaises(IncogniaHTTPError, api.register_payment,
|
|
358
|
-
|
|
328
|
+
request_token=self.INVALID_REQUEST_TOKEN,
|
|
359
329
|
account_id=self.INVALID_ACCOUNT_ID)
|
|
360
330
|
|
|
361
331
|
mock_token_manager_get.assert_called()
|
|
@@ -372,7 +342,7 @@ class TestIncogniaAPI(TestCase):
|
|
|
372
342
|
|
|
373
343
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
374
344
|
|
|
375
|
-
request_response = api.register_login(self.
|
|
345
|
+
request_response = api.register_login(self.REQUEST_TOKEN,
|
|
376
346
|
self.ACCOUNT_ID,
|
|
377
347
|
policy_id=self.POLICY_ID)
|
|
378
348
|
|
|
@@ -386,11 +356,12 @@ class TestIncogniaAPI(TestCase):
|
|
|
386
356
|
|
|
387
357
|
@patch.object(BaseRequest, 'post')
|
|
388
358
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
389
|
-
def
|
|
359
|
+
def test_register_login_when_request_token_is_empty_should_raise_an_IncogniaError(
|
|
390
360
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
391
361
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
392
362
|
|
|
393
|
-
self.assertRaises(IncogniaError, api.register_login,
|
|
363
|
+
self.assertRaises(IncogniaError, api.register_login,
|
|
364
|
+
request_token='',
|
|
394
365
|
account_id=self.ACCOUNT_ID)
|
|
395
366
|
|
|
396
367
|
mock_token_manager_get.assert_not_called()
|
|
@@ -402,7 +373,8 @@ class TestIncogniaAPI(TestCase):
|
|
|
402
373
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
403
374
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
404
375
|
|
|
405
|
-
self.assertRaises(IncogniaError, api.register_login,
|
|
376
|
+
self.assertRaises(IncogniaError, api.register_login,
|
|
377
|
+
request_token=self.REQUEST_TOKEN,
|
|
406
378
|
account_id='')
|
|
407
379
|
|
|
408
380
|
mock_token_manager_get.assert_not_called()
|
|
@@ -417,7 +389,7 @@ class TestIncogniaAPI(TestCase):
|
|
|
417
389
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
418
390
|
|
|
419
391
|
self.assertRaises(IncogniaHTTPError, api.register_login,
|
|
420
|
-
|
|
392
|
+
request_token=self.INVALID_REQUEST_TOKEN,
|
|
421
393
|
account_id=self.INVALID_ACCOUNT_ID)
|
|
422
394
|
|
|
423
395
|
mock_token_manager_get.assert_called()
|
|
@@ -434,7 +406,7 @@ class TestIncogniaAPI(TestCase):
|
|
|
434
406
|
|
|
435
407
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
436
408
|
|
|
437
|
-
request_response = api.register_web_login(self.
|
|
409
|
+
request_response = api.register_web_login(self.REQUEST_TOKEN,
|
|
438
410
|
self.ACCOUNT_ID,
|
|
439
411
|
policy_id=self.POLICY_ID)
|
|
440
412
|
|
|
@@ -448,11 +420,12 @@ class TestIncogniaAPI(TestCase):
|
|
|
448
420
|
|
|
449
421
|
@patch.object(BaseRequest, 'post')
|
|
450
422
|
@patch.object(TokenManager, 'get', return_value=TOKEN_VALUES)
|
|
451
|
-
def
|
|
423
|
+
def test_register_web_login_when_request_token_is_empty_should_raise_an_IncogniaError(
|
|
452
424
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
453
425
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
454
426
|
|
|
455
|
-
self.assertRaises(IncogniaError, api.register_web_login,
|
|
427
|
+
self.assertRaises(IncogniaError, api.register_web_login,
|
|
428
|
+
request_token='',
|
|
456
429
|
account_id=self.ACCOUNT_ID)
|
|
457
430
|
|
|
458
431
|
mock_token_manager_get.assert_not_called()
|
|
@@ -464,7 +437,8 @@ class TestIncogniaAPI(TestCase):
|
|
|
464
437
|
self, mock_token_manager_get: Mock, mock_base_request_post: Mock):
|
|
465
438
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
466
439
|
|
|
467
|
-
self.assertRaises(IncogniaError, api.register_web_login,
|
|
440
|
+
self.assertRaises(IncogniaError, api.register_web_login,
|
|
441
|
+
request_token=self.REQUEST_TOKEN,
|
|
468
442
|
account_id='')
|
|
469
443
|
|
|
470
444
|
mock_token_manager_get.assert_not_called()
|
|
@@ -479,8 +453,8 @@ class TestIncogniaAPI(TestCase):
|
|
|
479
453
|
api = IncogniaAPI(self.CLIENT_ID, self.CLIENT_SECRET)
|
|
480
454
|
|
|
481
455
|
self.assertRaises(IncogniaHTTPError, api.register_web_login,
|
|
482
|
-
|
|
483
|
-
|
|
456
|
+
account_id=self.INVALID_ACCOUNT_ID,
|
|
457
|
+
request_token=self.INVALID_REQUEST_TOKEN)
|
|
484
458
|
|
|
485
459
|
mock_token_manager_get.assert_called()
|
|
486
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.1.1 → 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
|