Skip to content

Commit c6c151b

Browse files
authored
Adding verify event type (#6)
* SN-612 Moving the config file into the securenative package * SN-612 Moving the config file into the securenative package * SN-612 Bug fix when event.params is None the as_dict() method crashes * SN-612 Adding verify event type, reflecting the changes on docs * SN-612 Adding markdown readme support for PyPi page
1 parent 1b50fd9 commit c6c151b

6 files changed

Lines changed: 19 additions & 13 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ if __name__=='__main__':
2222
Once the SDK has been initialized, you can start sending new events with the `track` function:
2323
```python
2424
import securenative
25-
from securenative.event_types import login
2625
from securenative.event_options import Event, User
2726

2827
def my_login_function():
2928
# Many lines of code ...
3029

3130
event = Event( # Build the event from the request's context
32-
event_type=login,
31+
event_type=securenative.event_types.login,
3332
ip='35.199.23.1',
3433
remote_ip='35.199.23.2',
3534
user_agent='Mozilla/5.0 (Linux; U; Android 4.4.2; zh-cn; GT-I9500 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.0 QQ-URL-Manager Mobile Safari/537.36',
@@ -59,7 +58,7 @@ def my_change_password_function():
5958
# Many lines of code...
6059

6160
event = Event( # Build the event from the request's context
62-
event_type='',
61+
event_type=securenative.event_types.verify,
6362
ip='35.199.23.1',
6463
remote_ip='35.199.23.2',
6564
user_agent='Mozilla/5.0 (Linux; U; Android 4.4.2; zh-cn; GT-I9500 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko)Version/4.0 MQQBrowser/5.0 QQ-URL-Manager Mobile Safari/537.36',

securenative/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
sdk_version = '0.1.3'
1+
sdk_version = '0.1.5'
22
_max_allowed_params = 6

securenative/event_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
role_update = "sn.user.role.update"
1717
profile_update = "sn.user.profile.update"
1818
page_view = "sn.user.page.view"
19+
verify = "sn.verify"

securenative/integration_test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@
1111
class IntegrationTest(unittest.TestCase):
1212
def test_integration_with_server(self):
1313
api_key = os.environ.get('TEST_API_KEY')
14-
id = str(uuid.uuid4())
14+
user_id = str(uuid.uuid4())
1515

1616
options = SecureNativeOptions(auto_send=False)
1717
securenative.init(api_key, options)
1818

19-
securenative.track(self.build_event(id, '52.23.233.3'))
19+
securenative.track(self.build_event(user_id, securenative.event_types.login, '52.23.233.3'))
2020
securenative.flush()
2121
sleep(10)
22-
result = securenative.verify(self.build_event(id, '31.168.11.138'))
22+
result = securenative.verify(self.build_event(user_id, securenative.event_types.verify, '31.168.11.138'))
2323

24-
25-
def build_event(self, id, ip):
26-
return Event(event_type=securenative.event_types.login,
24+
self.assertEqual(result['riskLevel'], 'high')
25+
self.assertEqual(result['score'], 0.64)
26+
self.assertIsNotNone(result['triggers'])
27+
28+
def build_event(self, id, type, ip):
29+
return Event(event_type=type,
2730
ip=ip,
2831
user=User(user_id=id, user_email='python-sdk@securenative.com', user_name='python sdk'),
2932
params=[CustomParam('key', 'val')]

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
from distutils.core import setup
1+
from setuptools import setup, Extension
22

33
from securenative.config import sdk_version
44

5+
with open("README.md", "r") as fh:
6+
long_description = fh.read()
7+
58
setup(
69
name='securenative',
710
packages=['securenative'],
@@ -13,6 +16,8 @@
1316
url='http://www.securenative.com',
1417
download_url='https://github.com/securenative/securenative-python/archive/0.1.tar.gz',
1518
keywords=["securenative", 'cyber-security'],
19+
long_description=long_description,
20+
long_description_content_type="text/markdown",
1621
install_requires=[
1722
"requests",
1823
],

0 commit comments

Comments
 (0)