Skip to content

Commit 246b209

Browse files
committed
added prefix validation
1 parent 1abfc22 commit 246b209

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

splitio/client/input_validator.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,11 @@ def validate_pluggable_adapter(config):
536536
_LOGGER.error("Expecting custom storage `wrapper` in options, but no valid wrapper instance was provided.")
537537
return False
538538

539+
if config.get('storagePrefix') is not None:
540+
if not isinstance(config.get('storagePrefix'), str):
541+
_LOGGER.error("Custom storage prefix should be string type only")
542+
return False
543+
539544
pluggable_adapter = config.get('storageWrapper')
540545
if not isinstance(pluggable_adapter, object):
541546
_LOGGER.error("Custom storage instance is not inherted from object class")

tests/client/test_input_validator.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,3 +1259,9 @@ def test_validate_pluggable_adapter(self):
12591259

12601260
# expected mock adapter should pass
12611261
assert(input_validator.validate_pluggable_adapter({'storageType': 'PLUGGABLE', 'storageWrapper': self.mock_adapter4()}))
1262+
1263+
# using string type prefix should pass
1264+
assert(input_validator.validate_pluggable_adapter({'storageType': 'PLUGGABLE', 'storagePrefix': 'myprefix', 'storageWrapper': self.mock_adapter4()}))
1265+
1266+
# using non-string type prefix should not pass
1267+
assert(not input_validator.validate_pluggable_adapter({'storageType': 'PLUGGABLE', 'storagePrefix': 'myprefix', 123: self.mock_adapter4()}))

0 commit comments

Comments
 (0)