diff --git a/assignment-v2/test-case-7.json b/assignment-v2/test-case-7.json new file mode 100644 index 00000000..33b59e41 --- /dev/null +++ b/assignment-v2/test-case-7.json @@ -0,0 +1,37 @@ +{ + "experiment": "empty_string_variations_test", + "valueType": "string", + "subjectsWithAttributes": [ + { + "subjectKey": "subject-1", + "subjectAttributes": { + "email": "test@geteppo.com" + } + }, + { + "subjectKey": "subject-2", + "subjectAttributes": { + "email": "test@example.com" + } + }, + { + "subjectKey": "subject-3", + "subjectAttributes": { + "device": "android", + "version": "1.0.0" + } + }, + { + "subjectKey": "subject-4", + "subjectAttributes": { + "country": "US" + } + } + ], + "expectedAssignments": [ + "test-value", + "", + "another-value", + "" + ] +} \ No newline at end of file diff --git a/ufc/flags-v1-obfuscated.json b/ufc/flags-v1-obfuscated.json index bb844ba9..7f3739a7 100644 --- a/ufc/flags-v1-obfuscated.json +++ b/ufc/flags-v1-obfuscated.json @@ -1284,6 +1284,77 @@ "value": "eyJhIjogIueFp+mhviIsICJiIjogIua8guS6riJ9" } } + }, + "1d23cbd300895799fda462f81ec4e135": { + "key": "1d23cbd300895799fda462f81ec4e135", + "comment": "Testing the empty string as a variation value", + "enabled": true, + "variationType": "STRING", + "variations": { + "ZW1wdHlfc3RyaW5n": { + "key": "ZW1wdHlfc3RyaW5n", + "value": "" + }, + "bm9uX2VtcHR5": { + "key": "bm9uX2VtcHR5", + "value": "bm9uX2VtcHR5" + } + }, + "allocations": [ + { + "key": "YWxsb2NhdGlvbi1lbXB0eQ==", + "rules": [ + { + "conditions": [ + { + "attribute": "e909c2d7067ea37437cf97fe11d91bd0", + "operator": "05015086bdd8402218f6aad6528bef08", + "value": "VVM=" + } + ] + } + ], + "splits": [ + { + "variationKey": "ZW1wdHlfc3RyaW5n", + "shards": [ + { + "salt": "YWxsb2NhdGlvbi1lbXB0eS1zaGFyZHM=", + "ranges": [ + { + "start": 0, + "end": 10000 + } + ] + } + ] + } + ], + "doLog": true + }, + { + "key": "YWxsb2NhdGlvbi10ZXN0", + "rules": [], + "splits": [ + { + "variationKey": "bm9uX2VtcHR5", + "shards": [ + { + "salt": "YWxsb2NhdGlvbi1lbXB0eS1zaGFyZHM=", + "ranges": [ + { + "start": 0, + "end": 10000 + } + ] + } + ] + } + ], + "doLog": true + } + ], + "totalShards": 10000 } } } diff --git a/ufc/flags-v1.json b/ufc/flags-v1.json index 060d378c..d2fa8d6b 100644 --- a/ufc/flags-v1.json +++ b/ufc/flags-v1.json @@ -410,6 +410,77 @@ ], "totalShards": 10000 }, + "empty_string_flag": { + "key": "empty_string_flag", + "enabled": true, + "comment": "Testing the empty string as a variation value", + "variationType": "STRING", + "variations": { + "empty_string": { + "key": "empty_string", + "value": "" + }, + "non_empty": { + "key": "non_empty", + "value": "non_empty" + } + }, + "allocations": [ + { + "key": "allocation-empty", + "rules": [ + { + "conditions": [ + { + "attribute": "country", + "operator": "MATCHES", + "value": "US" + } + ] + } + ], + "splits": [ + { + "variationKey": "empty_string", + "shards": [ + { + "salt": "allocation-empty-shards", + "ranges": [ + { + "start": 0, + "end": 10000 + } + ] + } + ] + } + ], + "doLog": true + }, + { + "key": "allocation-test", + "rules": [], + "splits": [ + { + "variationKey": "non_empty", + "shards": [ + { + "salt": "allocation-empty-shards", + "ranges": [ + { + "start": 0, + "end": 10000 + } + ] + } + ] + } + ], + "doLog": true + } + ], + "totalShards": 10000 + }, "kill-switch": { "key": "kill-switch", "enabled": true, diff --git a/ufc/tests/test-case-flag-with-empty-string.json b/ufc/tests/test-case-flag-with-empty-string.json new file mode 100644 index 00000000..37e103d0 --- /dev/null +++ b/ufc/tests/test-case-flag-with-empty-string.json @@ -0,0 +1,73 @@ +{ + "flag": "empty_string_flag", + "variationType": "STRING", + "defaultValue": "default", + "subjects": [ + { + "subjectKey": "alice", + "subjectAttributes": { + "country": "US" + }, + "assignment": "", + "evaluationDetails": { + "environmentName": "Test", + "flagEvaluationCode": "MATCH", + "flagEvaluationDescription": "Supplied attributes match rules defined in allocation \"allocation-empty\".", + "banditKey": null, + "banditAction": null, + "variationKey": "empty_string", + "variationValue": "", + "matchedRule": { + "conditions": [ + { + "attribute": "country", + "operator": "MATCHES", + "value": "US" + } + ] + }, + "matchedAllocation": { + "key": "allocation-empty", + "allocationEvaluationCode": "MATCH", + "orderPosition": 1 + }, + "unmatchedAllocations": [], + "unevaluatedAllocations": [ + { + "allocationEvaluationCode": "UNEVALUATED", + "key": "allocation-test", + "orderPosition": 2 + } + ] + } + }, + { + "subjectKey": "bob", + "subjectAttributes": {}, + "assignment": "non_empty", + "evaluationDetails": { + "environmentName": "Test", + "flagEvaluationCode": "MATCH", + "flagEvaluationDescription": "bob belongs to the range of traffic assigned to \"non_empty\" defined in allocation \"allocation-test\".", + "banditKey": null, + "banditAction": null, + "variationKey": "non_empty", + "variationValue": "non_empty", + "matchedRule": null, + "matchedAllocation": { + "key": "allocation-test", + "allocationEvaluationCode": "MATCH", + "orderPosition": 2 + }, + "unmatchedAllocations": [ + { + "allocationEvaluationCode": "FAILING_RULE", + "key": "allocation-empty", + "orderPosition": 1 + } + ], + "unevaluatedAllocations": [] + } + } + ] +}