Skip to content

Commit ff2466f

Browse files
author
Inbal Tako
committed
SN-1938 Validate user id
1 parent 21fbea9 commit ff2466f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

securenative/models/event_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class EventOptions(object):
22

3-
def __init__(self, event, user_id=None, user_traits=None,
3+
def __init__(self, event, user_id, user_traits=None,
44
context=None, properties=None, timestamp=None):
55
self.event = event
66
self.user_id = user_id

tests/sdk_event_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import unittest
2+
3+
from securenative.config.securenative_options import SecureNativeOptions
4+
from securenative.enums.event_types import EventTypes
5+
from securenative.exceptions.securenative_invalid_options_exception import SecureNativeInvalidOptionsException
6+
from securenative.models.event_options import EventOptions
7+
from securenative.models.sdk_event import SDKEvent
8+
9+
10+
class SDKEventTest(unittest.TestCase):
11+
12+
def test_creating_event_without_user_id_throws(self):
13+
with self.assertRaises(SecureNativeInvalidOptionsException):
14+
event_options = EventOptions(EventTypes.LOG_IN, None)
15+
options = SecureNativeOptions()
16+
17+
SDKEvent(event_options, options)

0 commit comments

Comments
 (0)