diff --git a/README.md b/README.md index f2e97be..d7e0344 100644 --- a/README.md +++ b/README.md @@ -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', @@ -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', diff --git a/securenative/config.py b/securenative/config.py index 2aa2793..88c8519 100644 --- a/securenative/config.py +++ b/securenative/config.py @@ -1,2 +1,2 @@ -sdk_version = '0.1.3' +sdk_version = '0.1.5' _max_allowed_params = 6 diff --git a/securenative/event_types.py b/securenative/event_types.py index 2ac34a2..3c3b6fc 100644 --- a/securenative/event_types.py +++ b/securenative/event_types.py @@ -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" diff --git a/securenative/integration_test.py b/securenative/integration_test.py index 4541d33..1af0445 100644 --- a/securenative/integration_test.py +++ b/securenative/integration_test.py @@ -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')] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 224a779..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = README.md \ No newline at end of file diff --git a/setup.py b/setup.py index 8d84903..9e9090e 100644 --- a/setup.py +++ b/setup.py @@ -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'], @@ -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", ],