def test_some_user_attrs_private(): uf = UserFilter(config_with_some_attrs_private) j = uf.filter_user_props(user) assert j == user_with_some_attrs_hidden
def test_leave_anonymous_attr_as_is(): uf = UserFilter(config_with_all_attrs_private) j = uf.filter_user_props(anon_user) assert j == anon_user_with_all_attrs_hidden
def test_all_user_attrs_serialized(): uf = UserFilter(base_config) j = uf.filter_user_props(user) assert j == user
def test_unknown_top_level_attrs_stripped(): uf = UserFilter(base_config) j = uf.filter_user_props(user_with_unknown_top_level_attrs) assert j == user
def test_per_user_private_attr_plus_global_private_attrs(): uf = UserFilter(config_with_some_attrs_private) j = uf.filter_user_props(user_specifying_own_private_attr) assert j == user_with_all_attrs_hidden
def test_per_user_private_attr(): uf = UserFilter(base_config) j = uf.filter_user_props(user_specifying_own_private_attr) assert j == user_with_own_specified_attr_hidden
def __init__(self, config): self._inline_users = config.inline_users_in_events self._user_filter = UserFilter(config)
def __init__(self,sdk_key=None, user=None, use_report=False, evaluation_reasons=False, base_uri='https://app.launchdarkly.com', events_uri='https://mobile.launchdarkly.com', connect_timeout=10, read_timeout=15, events_max_pending=10000, flush_interval=5, stream_uri='https://clientstream.launchdarkly.com', stream=True, verify_ssl=True, defaults=None, send_events=None, events_enabled=True, update_processor_class=None, poll_interval=30, use_ldd=False, feature_store=None, feature_requester_class=None, event_processor_class=None, private_attribute_names=(), all_attributes_private=False, offline=False, user_keys_capacity=1000, user_keys_flush_interval=300, inline_users_in_events=False, http_proxy=None): self.__sdk_key = sdk_key if defaults is None: defaults = {} self.__base_uri = base_uri.rstrip('\\') self.__events_uri = events_uri.rstrip('\\') self.__stream_uri = stream_uri.rstrip('\\') self.__update_processor_class = update_processor_class self.__stream = stream self.__poll_interval = max(poll_interval, 30) self.__use_ldd = use_ldd self.__feature_store = InMemoryFeatureStore() if not feature_store else feature_store self.__event_processor_class = DefaultEventProcessor if not event_processor_class else event_processor_class self.__feature_requester_class = feature_requester_class self.__connect_timeout = connect_timeout self.__read_timeout = read_timeout self.__events_max_pending = events_max_pending self.__flush_interval = flush_interval self.__verify_ssl = verify_ssl self.__defaults = defaults if offline is True: send_events = False self.__send_events = events_enabled if send_events is None else send_events self.__private_attribute_names = private_attribute_names self.__all_attributes_private = all_attributes_private self.__offline = offline self.__user_keys_capacity = user_keys_capacity self.__user_keys_flush_interval = user_keys_flush_interval self.__inline_users_in_events = inline_users_in_events self.__http_proxy = http_proxy self.__use_report = use_report self.__evaluation_reasons = evaluation_reasons self.__user = user self.__user_filter = UserFilter(self) if user is not None: self.__user_filtered = self.__user_filter.filter_user_props(user) self.__user_json = json.dumps(self.__user_filtered).encode('utf-8') self.__user_b64 = urlsafe_b64encode(self.__user_json).decode('utf-8')