Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ if __name__=='__main__':
Once the SDK has been initialized, you can start sending new events with the `track` function:
```python
import securenative
from securenative.event_types import login
from securenative.event_options import Event, User

def my_login_function():
# Many lines of code ...

event = Event( # Build the event from the request's context
event_type=login,
event_type=securenative.event_types.login,
ip='35.199.23.1',
remote_ip='35.199.23.2',
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',
Expand Down Expand Up @@ -59,7 +58,7 @@ def my_change_password_function():
# Many lines of code...

event = Event( # Build the event from the request's context
event_type='',
event_type=securenative.event_types.verify,
ip='35.199.23.1',
remote_ip='35.199.23.2',
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',
Expand Down
2 changes: 1 addition & 1 deletion securenative/config.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sdk_version = '0.1.3'
sdk_version = '0.1.5'
_max_allowed_params = 6
1 change: 1 addition & 0 deletions securenative/event_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
role_update = "sn.user.role.update"
profile_update = "sn.user.profile.update"
page_view = "sn.user.page.view"
verify = "sn.verify"
15 changes: 9 additions & 6 deletions securenative/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@
class IntegrationTest(unittest.TestCase):
def test_integration_with_server(self):
api_key = os.environ.get('TEST_API_KEY')
id = str(uuid.uuid4())
user_id = str(uuid.uuid4())

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

securenative.track(self.build_event(id, '52.23.233.3'))
securenative.track(self.build_event(user_id, securenative.event_types.login, '52.23.233.3'))
securenative.flush()
sleep(10)
result = securenative.verify(self.build_event(id, '31.168.11.138'))
result = securenative.verify(self.build_event(user_id, securenative.event_types.verify, '31.168.11.138'))


def build_event(self, id, ip):
return Event(event_type=securenative.event_types.login,
self.assertEqual(result['riskLevel'], 'high')
self.assertEqual(result['score'], 0.64)
self.assertIsNotNone(result['triggers'])

def build_event(self, id, type, ip):
return Event(event_type=type,
ip=ip,
user=User(user_id=id, user_email='python-sdk@securenative.com', user_name='python sdk'),
params=[CustomParam('key', 'val')]
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from distutils.core import setup
from setuptools import setup, Extension

from securenative.config import sdk_version

with open("README.md", "r") as fh:
long_description = fh.read()

setup(
name='securenative',
packages=['securenative'],
Expand All @@ -13,6 +16,8 @@
url='http://www.securenative.com',
download_url='https://github.com/securenative/securenative-python/archive/0.1.tar.gz',
keywords=["securenative", 'cyber-security'],
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=[
"requests",
],
Expand Down