From 0de33ca879def0010294b3a1c6bc1ecd0bf47cd4 Mon Sep 17 00:00:00 2001 From: Adam Simon Date: Wed, 26 Jul 2023 19:10:29 +0200 Subject: [PATCH] Adjust implementation and tests to the modified config v6 format --- .../data/sample_and_or_v6.json | 500 +++++----- .../data/sample_comparators_v6.json | 672 +++++++------ .../data/sample_flagdependency_v6.json | 934 +++++++++--------- .../data/sample_number_v5.json | 28 +- .../data/sample_segments_v6.json | 326 +++--- .../data/sample_semantic_2_v5.json | 2 +- .../data/sample_semantic_v5.json | 80 +- .../data/sample_sensitive_v5.json | 28 +- .../data/sample_v5.json | 328 +++--- .../data/sample_variationid_v5.json | 126 ++- .../data/test_json_complex.json | 2 +- .../Evaluation/RolloutEvaluator.cs | 70 +- src/ConfigCatClient/Models/Setting.cs | 28 +- 13 files changed, 1537 insertions(+), 1587 deletions(-) diff --git a/src/ConfigCat.Client.Tests/data/sample_and_or_v6.json b/src/ConfigCat.Client.Tests/data/sample_and_or_v6.json index f177292f..cf804920 100644 --- a/src/ConfigCat.Client.Tests/data/sample_and_or_v6.json +++ b/src/ConfigCat.Client.Tests/data/sample_and_or_v6.json @@ -1,270 +1,270 @@ { - "p": { - "u": "https://test-cdn-eu.configcat.com", - "r": 0, - "s": "az3pBWME9aWMPoIfIaANgCOGm9W38ZLOV68W/cznnak=" + "p": { + "u": "https://test-cdn-eu.configcat.com", + "r": 0, + "s": "ZLekiFJToRFzstYb2RKkFDDu9L0DFdJCosuxDmaAqUQ=" + }, + "s": [ + { + "n": "Beta Users", + "r": [ + { + "a": "Email", + "c": 16, + "l": [ + "3b10c030fb23069ef9cdd96e81b739c7127ec08d4eb87ef542e34e66ba0cb756", + "63aadd8165cfb561fb12bebd68c3d5001128150b828880d3ec917316e1f1604a" + ] + } + ] }, - "s": [ + { + "n": "Developers", + "r": [ { - "n": "Beta", - "r": [ - { - "a": "Email", - "c": 16, - "l": [ - "8ce91ec158f90ee775dd27d325df1808ac5524264d75b71503ec9e8f5a2995e5", - "45086cef4138010300e1ec6cd0c634164928be5b4922dd48c80b9442279efbd0" - ] - } - ] - }, + "a": "Email", + "c": 16, + "l": [ + "b3892c655a4c5a51bce2888f9cdc994b721244fda9fbee1151c6f7bc1bd47d16", + "026df07501bfabede2ef24324cbf02ba308ae33c0f53ba91cb6ddfc1267640ae" + ] + } + ] + } + ], + "f": { + "dependentFeature": { + "t": 1, + "r": [ { - "n": "Deve", - "r": [ - { - "a": "Email", - "c": 16, - "l": [ - "4c87c42ca527c67c915b97ee05710875f4e63b0a9ebe2883afd235ea9326edc0", - "5f7e0f5f0f7187d0a2cb0c028800571967059c15682d89d1ad0582478d517115" - ] + "c": [ + { + "d": { + "f": "mainFeature", + "c": 0, + "v": { + "s": "target" } - ] + } + } + ], + "p": [ + { + "p": 25, + "v": { + "s": "Cat" + }, + "i": "993d7ee0" + }, + { + "p": 25, + "v": { + "s": "Dog" + }, + "i": "08b8348e" + }, + { + "p": 25, + "v": { + "s": "Falcon" + }, + "i": "a6fb7a01" + }, + { + "p": 25, + "v": { + "s": "Horse" + }, + "i": "699fb4bf" + } + ] } - ], - "f": { - "dependentFeature": { - "t": 1, - "r": [ - { - "c": [ - { - "d": { - "f": "mainFeature", - "c": 0, - "v": { - "s": "target" - } - } - } - ], - "p": [ - { - "p": 25, - "v": { - "s": "Cat" - }, - "i": "993d7ee0" - }, - { - "p": 25, - "v": { - "s": "Dog" - }, - "i": "08b8348e" - }, - { - "p": 25, - "v": { - "s": "Falcon" - }, - "i": "a6fb7a01" - }, - { - "p": 25, - "v": { - "s": "Horse" - }, - "i": "699fb4bf" - } - ] - } - ], + ], + "v": { + "s": "Chicken" + }, + "i": "e6198f92" + }, + "emailAnd": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 22, + "l": [ + "4_985cf0de31fcaa9ebd67c6a3cb7feacc8dc93afff3aacb6a53a242527b193538" + ] + } + }, + { + "t": { + "a": "Email", + "c": 2, + "l": [ + "@" + ] + } + }, + { + "t": { + "a": "Email", + "c": 23, + "l": [ + "20_37bff8efb4b90dc4e7eb84b1e0880e96b65d0e24219480fd23dba89f2ac47684" + ] + } + } + ], + "s": { + "v": { + "s": "Dog" + }, + "i": "a1393561" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "bdabd589" + }, + "emailOr": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 22, + "l": [ + "5_a92c2e4e4bf2095350663418ce4ab607ed3a0cdee28974533ed447f5322a3c2a" + ] + } + } + ], + "s": { "v": { - "s": "Chicken" + "s": "Jane" }, - "i": "e6198f92" + "i": "01383bbf" + } }, - "emailAnd": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 22, - "l": [ - "4_82d1be6769aae4915132c810246f0e4e55604abc6d0745c9200a48ccb4932219" - ] - } - }, - { - "t": { - "a": "Email", - "c": 2, - "l": [ - "@" - ] - } - }, - { - "t": { - "a": "Email", - "c": 23, - "l": [ - "20_1d54924b2d446a23bb8655ee23c55f77990f952b189443afea73c77ff9332d89" - ] - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "a1393561" - } - } - ], + { + "c": [ + { + "t": { + "a": "Email", + "c": 22, + "l": [ + "5_328c4cfd2383d91b4516f4cea92bc2b0d48b5297f233b91ef2d2762561aa3be0" + ] + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "John" }, - "i": "bdabd589" + "i": "a069dc24" + } }, - "emailOr": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 22, - "l": [ - "5_4856f7f73845a5078d604543fc803e027fa4167c97dfc21f3f8e36089cc21dca" - ] - } - } - ], - "s": { - "v": { - "s": "Jane" - }, - "i": "01383bbf" - } - }, - { - "c": [ - { - "t": { - "a": "Email", - "c": 22, - "l": [ - "5_ddc6f2a92390569bd3f0d67d894eeaf986fc2c47d4162f2e415d16273d468d85" - ] - } - } - ], - "s": { - "v": { - "s": "John" - }, - "i": "a069dc24" - } - }, - { - "c": [ - { - "t": { - "a": "Email", - "c": 22, - "l": [ - "5_ea327c01fe032017d1d44abda3f5687bf3222d71696718f7f19ef3eb2ed7b0c7" - ] - } - } - ], - "s": { - "v": { - "s": "Mark" - }, - "i": "d7b02cc0" - } - } - ], + { + "c": [ + { + "t": { + "a": "Email", + "c": 22, + "l": [ + "5_8ca6756c5ec04629726258e49a8bb41e93e55d91857e0f00eb392cd7bf57d92a" + ] + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Mark" + }, + "i": "d7b02cc0" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "ab0b46ad" + }, + "mainFeature": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 23, + "l": [ + "21_afedf39f3b57256c1bb1fa8fa7c45238eb1a23b80d3fa374a63cd5831e5f0dc6" + ] + } + }, + { + "t": { + "a": "Country", + "c": 16, + "l": [ + "c36c40f8e7d00adbebc80046b2c5d654b031ab2e4572d84707ce58dc0656c6c0", + "67b6cc7cdc0c6d981e2e04dc3c1e71fb07581e99540b5fb11432b72e221aa394" + ] + } + } + ], + "s": { + "v": { + "s": "private" }, - "i": "ab0b46ad" + "i": "64f8e1a6" + } }, - "mainFeature": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 23, - "l": [ - "21_ff4f72a95f9c721f6cc70ffac896bb42fd3613e3248f5f09e672bbe52168004c" - ] - } - }, - { - "t": { - "a": "Country", - "c": 16, - "l": [ - "98ab46322c5af478279c6f22be442e193e0f399634e8e27221c1504ff061cc2b", - "fe3cfb77aa05445db8cc314e6dd1a156980756819d88a68e5188fd0ebdd4c1a1" - ] - } - } - ], - "s": { - "v": { - "s": "private" - }, - "i": "64f8e1a6" - } - }, - { - "c": [ - { - "t": { - "a": "Country", - "c": 16, - "l": [ - "391ea48edd104a06f3350666c52e82ee6bff33bce63f153cdbfa3ed5e8621e5e" - ] - } - }, - { - "s": { - "s": 0, - "c": 1 - } - }, - { - "s": { - "s": 1, - "c": 1 - } - } - ], - "s": { - "v": { - "s": "target" - }, - "i": "f570ef26" - } - } - ], + { + "c": [ + { + "t": { + "a": "Country", + "c": 16, + "l": [ + "f17aae9d1a9ead1448cf60ffa8e0353214315c49bbe51b9d634da9488994a7d0" + ] + } + }, + { + "s": { + "s": 0, + "c": 1 + } + }, + { + "s": { + "s": 1, + "c": 1 + } + } + ], + "s": { "v": { - "s": "public" + "s": "target" }, - "i": "f16ac582" + "i": "f570ef26" + } } + ], + "v": { + "s": "public" + }, + "i": "f16ac582" } + } } diff --git a/src/ConfigCat.Client.Tests/data/sample_comparators_v6.json b/src/ConfigCat.Client.Tests/data/sample_comparators_v6.json index 98e6e137..578e46fe 100644 --- a/src/ConfigCat.Client.Tests/data/sample_comparators_v6.json +++ b/src/ConfigCat.Client.Tests/data/sample_comparators_v6.json @@ -1,368 +1,360 @@ { - "p": { - "u": "https://test-cdn-eu.configcat.com", - "r": 0, - "s": "OMMRn/iOWHRK3uyhEIh2vF/h7BmRZEAeCMiX0YTnW04=" - }, - "f": { - "arrayContainsCaseCheckDogDefaultCat": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Custom1", - "c": 24, - "s": "4deba9a545c066fa278baedd9c8e26244678c9055f6d5233b11fb6b5473958e7" - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "5d80eff1" - } - } - ], + "p": { + "u": "https://test-cdn-eu.configcat.com", + "r": 0, + "s": "SNq0KXXa7lDr1mgPE0Z\u002BI29fJY21qaQRZB8YyNC8by0=" + }, + "f": { + "arrayContainsCaseCheckDogDefaultCat": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Custom1", + "c": 24, + "s": "ffc3d87acd33d31d79b2ca324564f4c178f9db8869e0246bdb08efd333f3f633" + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "ce055a38" - }, - "arrayContainsDogDefaultCat": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Custom1", - "c": 24, - "s": "14c1936a4d2a752529cdaf9cacb8448ace0624a288ddf0cfb4b95c38632d5563" - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "147fdd01" - } - } - ], + "i": "5d80eff1" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "ce055a38" + }, + "arrayContainsDogDefaultCat": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Custom1", + "c": 24, + "s": "ce0f7e7820546b27d580eeda29ee8dfe1b8392a3c34623e23fd57253cdafd27d" + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "5f573f9c" - }, - "arrayDoesNotContainCaseCheckDogDefaultCat": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Custom1", - "c": 25, - "s": "4e1ce609402cc2fcd2b445c060f1bc965cb421a5b5eef633d0e1f5bf0b75e225" - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "d4ad5730" - } - } - ], + "i": "147fdd01" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "5f573f9c" + }, + "arrayDoesNotContainCaseCheckDogDefaultCat": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Custom1", + "c": 25, + "s": "1cf9717de67f35575410dfefbdd7e427ed4dcb1ea321eb44402e12430edc7d58" + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "df4915fd" - }, - "arrayDoesNotContainDogDefaultCat": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Custom1", - "c": 25, - "s": "3d9512db57ce9ae86c995246f6d175ef67e84569b0efb8e8c89187624aa610d7" - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "c2161ac9" - } - } - ], + "i": "d4ad5730" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "df4915fd" + }, + "arrayDoesNotContainDogDefaultCat": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Custom1", + "c": 25, + "s": "178b73ada932545fd3d5cbf148973a22b8dee088131fd57befe3b8cf3f80dcfd" + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "41910880" - }, - "boolTrueIn202304": { - "t": 0, - "r": [ - { - "c": [ - { - "t": { - "a": "Custom1", - "c": 19, - "d": 1680307200 - } - }, - { - "t": { - "a": "Custom1", - "c": 18, - "d": 1682899200 - } - } - ], - "s": { - "v": { - "b": true - }, - "i": "6948d7cd" - } - } - ], - "v": { - "b": false + "i": "c2161ac9" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "41910880" + }, + "boolTrueIn202304": { + "t": 0, + "r": [ + { + "c": [ + { + "t": { + "a": "Custom1", + "c": 19, + "d": 1680307200 + } }, - "i": "ae2a09bd" - }, - "countryPercentageAttribute": { - "t": 1, - "p": "Country", - "r": [ - { - "p": [ - { - "p": 50, - "v": { - "s": "Falcon" - }, - "i": "2b05fd81" - }, - { - "p": 50, - "v": { - "s": "Horse" - }, - "i": "e28b6a82" - } - ] - } - ], + { + "t": { + "a": "Custom1", + "c": 18, + "d": 1682899200 + } + } + ], + "s": { "v": { - "s": "Chicken" + "b": true }, - "i": "29bb6bbb" + "i": "6948d7cd" + } + } + ], + "v": { + "b": false + }, + "i": "ae2a09bd" + }, + "countryPercentageAttribute": { + "t": 1, + "a": "Country", + "p": [ + { + "p": 50, + "v": { + "s": "Falcon" + }, + "i": "2b05fd81" }, - "customPercentageAttribute": { - "t": 1, - "p": "Custom1", - "r": [ - { - "p": [ - { - "p": 50, - "v": { - "s": "Falcon" - }, - "i": "3715712d" - }, - { - "p": 50, - "v": { - "s": "Horse" - }, - "i": "7b3542d5" - } - ] - } - ], - "v": { - "s": "Chicken" + { + "p": 50, + "v": { + "s": "Horse" + }, + "i": "e28b6a82" + } + ], + "v": { + "s": "Chicken" + }, + "i": "29bb6bbb" + }, + "customPercentageAttribute": { + "t": 1, + "a": "Custom1", + "p": [ + { + "p": 50, + "v": { + "s": "Falcon" + }, + "i": "3715712d" + }, + { + "p": 50, + "v": { + "s": "Horse" + }, + "i": "7b3542d5" + } + ], + "v": { + "s": "Chicken" + }, + "i": "50466fb6" + }, + "missingPercentageAttribute": { + "t": 1, + "a": "NotFound", + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 23, + "l": [ + "14_c047c343641cd3a436de1742a31683bcad94a480e9bdf1ed8f92218067bfaed9" + ] + } + } + ], + "p": [ + { + "p": 50, + "v": { + "s": "Falcon" + }, + "i": "4b7d88ba" }, - "i": "50466fb6" + { + "p": 50, + "v": { + "s": "Horse" + }, + "i": "a1c2c9a9" + } + ] }, - "missingPercentageAttribute": { - "t": 1, - "p": "NotFound", - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 23, - "l": [ - "14_65c03652573a0269ea92a552b8fbefbc77a8c802246751d1297727f94d2c274b" - ] - } - } - ], - "p": [ - { - "p": 50, - "v": { - "s": "Falcon" - }, - "i": "4b7d88ba" - }, - { - "p": 50, - "v": { - "s": "Horse" - }, - "i": "a1c2c9a9" - } - ] - }, - { - "c": [ - { - "t": { - "a": "Email", - "c": 23, - "l": [ - "14_65c03652573a0269ea92a552b8fbefbc77a8c802246751d1297727f94d2c274b" - ] - } - } - ], - "s": { - "v": { - "s": "NotFound" - }, - "i": "8aa042fe" - } - } - ], + { + "c": [ + { + "t": { + "a": "Email", + "c": 23, + "l": [ + "14_c047c343641cd3a436de1742a31683bcad94a480e9bdf1ed8f92218067bfaed9" + ] + } + } + ], + "s": { "v": { - "s": "Chicken" + "s": "NotFound" }, - "i": "e5107172" - }, - "stringDoseNotEqualDogDefaultCat": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 21, - "s": "0457803ad75fa1a5afbee1da1d514d8f33da384e73cada4ad690ac37d849eaf4" - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "8e423808" - } - } - ], + "i": "8aa042fe" + } + } + ], + "v": { + "s": "Chicken" + }, + "i": "e5107172" + }, + "stringDoseNotEqualDogDefaultCat": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 21, + "s": "cdd984e448beb5366757fe321ca05212c7a71f391563967f641bc8fbb53181b5" + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "1835a09a" - }, - "stringEndsWithDogDefaultCat": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 23, - "l": [ - "14_3b5bc40493ea5245fb31fe3499f2566181840cbe4b97156474bce37d71795be4" - ] - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "d7a00741" - } - } - ], + "i": "8e423808" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "1835a09a" + }, + "stringEndsWithDogDefaultCat": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 23, + "l": [ + "14_990f14d915dcba8151beb87309b836bcfc70c6abe64eedc8242d5be1ce73dfc9" + ] + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "45b7d922" - }, - "stringEqualsDogDefaultCat": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 20, - "s": "71ae1b93ac5e880186f38ce6f5e2102e60d1e3e9e670a5fce3704378e9610b73" - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "703c31ed" - } - } - ], + "i": "d7a00741" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "45b7d922" + }, + "stringEqualsDogDefaultCat": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 20, + "s": "9ac40540ef568377e775882572799b01a449812dd917061fb3ffbaac5fb71ee5" + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "adc0b01c" - }, - "stringStartsWithDogDefaultCat": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 22, - "l": [ - "1_fc6315e1e0fceb01fdd841361415dfe1952a8375c0d57f2dd2239846828b4bf4" - ] - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "3b409872" - } - } - ], + "i": "703c31ed" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "adc0b01c" + }, + "stringStartsWithDogDefaultCat": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 22, + "l": [ + "1_7282e383d728e8c7551e9cab4b8b49ebae70c6cafd493a8266a2f2b9285c284b" + ] + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "3659b0fe" + "i": "3b409872" + } } + ], + "v": { + "s": "Cat" + }, + "i": "3659b0fe" } + } } diff --git a/src/ConfigCat.Client.Tests/data/sample_flagdependency_v6.json b/src/ConfigCat.Client.Tests/data/sample_flagdependency_v6.json index 5c0c12d5..a4a259e7 100644 --- a/src/ConfigCat.Client.Tests/data/sample_flagdependency_v6.json +++ b/src/ConfigCat.Client.Tests/data/sample_flagdependency_v6.json @@ -1,520 +1,520 @@ { - "p": { - "u": "https://test-cdn-eu.configcat.com", - "r": 0, - "s": "aSJB3ZAYcuG\u002BpPutxgM9z/ShekLfhUjQHpKUI4j4sOU=" - }, - "f": { - "boolDependsOnBool": { - "t": 0, - "r": [ - { - "c": [ - { - "d": { - "f": "mainBoolFlag", - "c": 0, - "v": { - "b": true - } - } - } - ], - "s": { - "v": { - "b": true - }, - "i": "8dc94c1d" - } - } - ], - "v": { - "b": false - }, - "i": "d6194760" - }, - "boolDependsOnBoolDependsOnBool": { - "t": 0, - "r": [ - { - "c": [ - { - "d": { - "f": "boolDependsOnBool", - "c": 0, - "v": { - "b": true - } - } - } - ], - "s": { - "v": { - "b": false - }, - "i": "d6870486" - } + "p": { + "u": "https://test-cdn-eu.configcat.com", + "r": 0, + "s": "3NxLBU9uVBPeeOcykk44gCJJcJek/oXqDW9PmDh7L/U=" + }, + "f": { + "boolDependsOnBool": { + "t": 0, + "r": [ + { + "c": [ + { + "d": { + "f": "mainBoolFlag", + "c": 0, + "v": { + "b": true } - ], + } + } + ], + "s": { "v": { - "b": true + "b": true }, - "i": "cd4c95e7" - }, - "boolDependsOnBoolInverse": { - "t": 0, - "r": [ - { - "c": [ - { - "d": { - "f": "mainBoolFlagInverse", - "c": 1, - "v": { - "b": true - } - } - } - ], - "s": { - "v": { - "b": true - }, - "i": "3c09bff0" - } + "i": "8dc94c1d" + } + } + ], + "v": { + "b": false + }, + "i": "d6194760" + }, + "boolDependsOnBoolDependsOnBool": { + "t": 0, + "r": [ + { + "c": [ + { + "d": { + "f": "boolDependsOnBool", + "c": 0, + "v": { + "b": true } - ], + } + } + ], + "s": { "v": { - "b": false + "b": false }, - "i": "cecbc501" - }, - "doubleDependsOnBool": { - "t": 3, - "r": [ - { - "c": [ - { - "d": { - "f": "mainBoolFlag", - "c": 0, - "v": { - "b": true - } - } - } - ], - "s": { - "v": { - "d": 1.1 - }, - "i": "271fd003" - } + "i": "d6870486" + } + } + ], + "v": { + "b": true + }, + "i": "cd4c95e7" + }, + "boolDependsOnBoolInverse": { + "t": 0, + "r": [ + { + "c": [ + { + "d": { + "f": "mainBoolFlagInverse", + "c": 1, + "v": { + "b": true } - ], + } + } + ], + "s": { "v": { - "d": 3.14 + "b": true }, - "i": "718aae2b" - }, - "intDependsOnBool": { - "t": 2, - "r": [ - { - "c": [ - { - "d": { - "f": "mainBoolFlag", - "c": 0, - "v": { - "b": true - } - } - } - ], - "s": { - "v": { - "i": 1 - }, - "i": "d2dda649" - } + "i": "3c09bff0" + } + } + ], + "v": { + "b": false + }, + "i": "cecbc501" + }, + "doubleDependsOnBool": { + "t": 3, + "r": [ + { + "c": [ + { + "d": { + "f": "mainBoolFlag", + "c": 0, + "v": { + "b": true } - ], + } + } + ], + "s": { "v": { - "i": 42 + "d": 1.1 }, - "i": "43ec49a8" - }, - "mainBoolFlag": { - "t": 0, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 23, - "l": [ - "21_a6945ecaa58a2b8a1b297768511bb72acc3b77fa86a408812c47172af3db0774" - ] - } - } - ], - "s": { - "v": { - "b": false - }, - "i": "e842ea6f" - } + "i": "271fd003" + } + } + ], + "v": { + "d": 3.14 + }, + "i": "718aae2b" + }, + "intDependsOnBool": { + "t": 2, + "r": [ + { + "c": [ + { + "d": { + "f": "mainBoolFlag", + "c": 0, + "v": { + "b": true } - ], + } + } + ], + "s": { "v": { - "b": true + "i": 1 }, - "i": "8a68b064" - }, - "mainBoolFlagEmpty": { - "t": 0, + "i": "d2dda649" + } + } + ], + "v": { + "i": 42 + }, + "i": "43ec49a8" + }, + "mainBoolFlag": { + "t": 0, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 23, + "l": [ + "21_cf5734ba99c5249c8d65caacfbab8384fd3fed32f4331e011956ec33b523ad8b" + ] + } + } + ], + "s": { "v": { - "b": true + "b": false }, - "i": "f3295d43" - }, - "mainBoolFlagInverse": { - "t": 0, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 23, - "l": [ - "21_cda0e9a4455d858822ed0c0fac751ee57c79feab4612433b3afc58505698ea32" - ] - } - } - ], - "s": { - "v": { - "b": true - }, - "i": "28c65f1f" - } - } - ], + "i": "e842ea6f" + } + } + ], + "v": { + "b": true + }, + "i": "8a68b064" + }, + "mainBoolFlagEmpty": { + "t": 0, + "v": { + "b": true + }, + "i": "f3295d43" + }, + "mainBoolFlagInverse": { + "t": 0, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 23, + "l": [ + "21_0c911f659714662fc4f393cca45b36a10a508ca2bd4eefdf877ac0c17db46950" + ] + } + } + ], + "s": { "v": { - "b": false + "b": true }, - "i": "d70e47a7" - }, - "mainDoubleFlag": { - "t": 3, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 23, - "l": [ - "21_8d951d1b58f70bee3396b29537fa07f8ba6e32513451d3b1c101eb4eacb841be" - ] - } - } - ], - "s": { - "v": { - "d": 0.1 - }, - "i": "a67947ed" - } - } - ], + "i": "28c65f1f" + } + } + ], + "v": { + "b": false + }, + "i": "d70e47a7" + }, + "mainDoubleFlag": { + "t": 3, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 23, + "l": [ + "21_25f46b10ee2b54fe778f7874eb1b12237ac15c0ffd89e468ef0e5126fadce63e" + ] + } + } + ], + "s": { "v": { - "d": 3.14 + "d": 0.1 }, - "i": "beb3acc7" - }, - "mainIntFlag": { - "t": 2, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 23, - "l": [ - "21_0e9b9f9406df4f5a7daca1c0b357f4d8c74827914a56ce9d217cb8f2def7fb8c" - ] - } - } - ], - "s": { - "v": { - "i": 2 - }, - "i": "67e14078" - } - } - ], + "i": "a67947ed" + } + } + ], + "v": { + "d": 3.14 + }, + "i": "beb3acc7" + }, + "mainIntFlag": { + "t": 2, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 23, + "l": [ + "21_b04d723faf281b034e89980109541237873dd089f5f7ec646c895821af60e10b" + ] + } + } + ], + "s": { "v": { - "i": 42 + "i": 2 }, - "i": "a7490aca" - }, - "mainStringFlag": { - "t": 1, - "r": [ - { - "c": [ - { - "t": { - "a": "Email", - "c": 23, - "l": [ - "21_a7af91b860fd02dad64d2c46be08260d45eaf83014585bebf14092bad05a24e3" - ] - } - } - ], - "s": { - "v": { - "s": "private" - }, - "i": "51b57fb0" - } - } - ], + "i": "67e14078" + } + } + ], + "v": { + "i": 42 + }, + "i": "a7490aca" + }, + "mainStringFlag": { + "t": 1, + "r": [ + { + "c": [ + { + "t": { + "a": "Email", + "c": 23, + "l": [ + "21_9cd722ab794bae47d4fa1bf9f05e34fd8f60d9264e99d289f91f90c5f7a9c172" + ] + } + } + ], + "s": { "v": { - "s": "public" + "s": "private" }, - "i": "24c96275" - }, - "stringDependsOnBool": { - "t": 1, - "r": [ - { - "c": [ - { - "d": { - "f": "mainBoolFlag", - "c": 0, - "v": { - "b": true - } - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "fc8daf80" - } + "i": "51b57fb0" + } + } + ], + "v": { + "s": "public" + }, + "i": "24c96275" + }, + "stringDependsOnBool": { + "t": 1, + "r": [ + { + "c": [ + { + "d": { + "f": "mainBoolFlag", + "c": 0, + "v": { + "b": true } - ], + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "d53a2b42" - }, - "stringDependsOnDouble": { - "t": 1, - "r": [ - { - "c": [ - { - "d": { - "f": "mainDoubleFlag", - "c": 0, - "v": { - "d": 0.1 - } - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "84fc7ed9" - } + "i": "fc8daf80" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "d53a2b42" + }, + "stringDependsOnDouble": { + "t": 1, + "r": [ + { + "c": [ + { + "d": { + "f": "mainDoubleFlag", + "c": 0, + "v": { + "d": 0.1 } - ], + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "9cc8fd8f" - }, - "stringDependsOnDoubleIntValue": { - "t": 1, - "r": [ - { - "c": [ - { - "d": { - "f": "mainDoubleFlag", - "c": 0, - "v": { - "d": 0 - } - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "842c1d75" - } + "i": "84fc7ed9" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "9cc8fd8f" + }, + "stringDependsOnDoubleIntValue": { + "t": 1, + "r": [ + { + "c": [ + { + "d": { + "f": "mainDoubleFlag", + "c": 0, + "v": { + "d": 0 } - ], + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "db7f56c8" - }, - "stringDependsOnEmptyBool": { - "t": 1, - "r": [ - { - "c": [ - { - "d": { - "f": "mainBoolFlagEmpty", - "c": 0, - "v": { - "b": true - } - } - } - ], - "s": { - "v": { - "s": "EmptyOn" - }, - "i": "d5508c78" - } + "i": "842c1d75" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "db7f56c8" + }, + "stringDependsOnEmptyBool": { + "t": 1, + "r": [ + { + "c": [ + { + "d": { + "f": "mainBoolFlagEmpty", + "c": 0, + "v": { + "b": true } - ], + } + } + ], + "s": { "v": { - "s": "EmptyOff" + "s": "EmptyOn" }, - "i": "8e0dbe88" - }, - "stringDependsOnInt": { - "t": 1, - "r": [ - { - "c": [ - { - "d": { - "f": "mainIntFlag", - "c": 0, - "v": { - "i": 2 - } - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "12531eec" - } + "i": "d5508c78" + } + } + ], + "v": { + "s": "EmptyOff" + }, + "i": "8e0dbe88" + }, + "stringDependsOnInt": { + "t": 1, + "r": [ + { + "c": [ + { + "d": { + "f": "mainIntFlag", + "c": 0, + "v": { + "i": 2 } - ], + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "e227d926" - }, - "stringDependsOnString": { - "t": 1, - "r": [ - { - "c": [ - { - "d": { - "f": "mainStringFlag", - "c": 0, - "v": { - "s": "private" - } - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "426b6d4d" - } + "i": "12531eec" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "e227d926" + }, + "stringDependsOnString": { + "t": 1, + "r": [ + { + "c": [ + { + "d": { + "f": "mainStringFlag", + "c": 0, + "v": { + "s": "private" } - ], + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "d36000e1" - }, - "stringDependsOnStringCaseCheck": { - "t": 1, - "r": [ - { - "c": [ - { - "d": { - "f": "mainStringFlag", - "c": 0, - "v": { - "s": "Private" - } - } - } - ], - "s": { - "v": { - "s": "Dog" - }, - "i": "87d24aed" - } + "i": "426b6d4d" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "d36000e1" + }, + "stringDependsOnStringCaseCheck": { + "t": 1, + "r": [ + { + "c": [ + { + "d": { + "f": "mainStringFlag", + "c": 0, + "v": { + "s": "Private" } - ], + } + } + ], + "s": { "v": { - "s": "Cat" + "s": "Dog" }, - "i": "ad94f385" - }, - "stringInverseDependsOnEmptyBool": { - "t": 1, - "r": [ - { - "c": [ - { - "d": { - "f": "mainBoolFlagEmpty", - "c": 1, - "v": { - "b": true - } - } - } - ], - "s": { - "v": { - "s": "EmptyOff" - }, - "i": "b7c3efae" - } + "i": "87d24aed" + } + } + ], + "v": { + "s": "Cat" + }, + "i": "ad94f385" + }, + "stringInverseDependsOnEmptyBool": { + "t": 1, + "r": [ + { + "c": [ + { + "d": { + "f": "mainBoolFlagEmpty", + "c": 1, + "v": { + "b": true } - ], + } + } + ], + "s": { "v": { - "s": "EmptyOn" + "s": "EmptyOff" }, - "i": "f6b4b8a2" + "i": "b7c3efae" + } } + ], + "v": { + "s": "EmptyOn" + }, + "i": "f6b4b8a2" } + } } diff --git a/src/ConfigCat.Client.Tests/data/sample_number_v5.json b/src/ConfigCat.Client.Tests/data/sample_number_v5.json index 9cf5b71f..1c6f3cb0 100644 --- a/src/ConfigCat.Client.Tests/data/sample_number_v5.json +++ b/src/ConfigCat.Client.Tests/data/sample_number_v5.json @@ -1,6 +1,6 @@ { "p": { - "s": "bK4l7GU7kB9db5FTxQ3kXEQjAmW3keJsTBFrJiDvhBI=" + "s": "/Y4mJ/uSa1GBTn2Wt5y33RohDIPavEWxe0TAqr5Lwp4=" }, "f": { "numberWithPercentage": { @@ -101,22 +101,20 @@ "s": "\u003C\u003E4.2" } } + } + ], + "p": [ + { + "p": 80, + "v": { + "s": "80%" + } }, { - "p": [ - { - "p": 80, - "v": { - "s": "80%" - } - }, - { - "p": 20, - "v": { - "s": "20%" - } - } - ] + "p": 20, + "v": { + "s": "20%" + } } ], "v": { diff --git a/src/ConfigCat.Client.Tests/data/sample_segments_v6.json b/src/ConfigCat.Client.Tests/data/sample_segments_v6.json index 1293bef6..3d0d0866 100644 --- a/src/ConfigCat.Client.Tests/data/sample_segments_v6.json +++ b/src/ConfigCat.Client.Tests/data/sample_segments_v6.json @@ -1,180 +1,180 @@ { - "p": { - "u": "https://test-cdn-eu.configcat.com", - "r": 0, - "s": "xsZfkjIELRJhElvdQJJWcys0cn836z8DcClMiR1Vd/s=" - }, - "s": [ + "p": { + "u": "https://test-cdn-eu.configcat.com", + "r": 0, + "s": "B0sm1Jb9oq6EkCiw4zCmGqqfadmoZwa5tvtVjVO98Qg=" + }, + "s": [ + { + "n": "Beta Users", + "r": [ { - "n": "Beta", - "r": [ - { - "a": "Email", - "c": 16, - "l": [ - "42be0307afe6d38e8a0ba7f5ab9230104bed054149c50b6903e2514b77c5f8f4", - "82847209de6d4bfa4ba9e0902c9caf7b36ce3b52e54f019686d5dc9b9cc175d9" - ] - } - ] - }, + "a": "Email", + "c": 16, + "l": [ + "19e3869c1c82c6b818e8b7511ab1d1d857d02ed56df4b676073368e034f6a9ef", + "7180d01c87c920a79ab9ab3e73914f70f1a495a7b1d96bd79c4ceaddd0556513" + ] + } + ] + }, + { + "n": "Developers", + "r": [ { - "n": "Deve", - "r": [ - { - "a": "Email", - "c": 16, - "l": [ - "ea05dc0e0eec2f4921c3f87aba58a0bb245887399507bac129f8401443264b96", - "b399eca1657a3ba9ae5fdf20c287ec341ef06db42779cecd238c37ebafd552b4" - ] - } - ] - }, + "a": "Email", + "c": 16, + "l": [ + "344d25f0ad356f8323b8a22a587a20dd4d6da9ff9a9dc6eb199ea62ac8a9d7f0", + "86917c36d7a5a3b1ceb32441678e97890dda8094f98004ca2a09ae49607acc4c" + ] + } + ] + }, + { + "n": "Not Beta Users", + "r": [ { - "n": "Not ", - "r": [ - { - "a": "Email", - "c": 17, - "l": [ - "27ea22674ccea76dd6fbdab96f36a20b22897e88f2821f93f0ac75d76df3219d", - "334423d07640c751beb2ac0c2e247d7af6cffcc729d619ec005ae1782bf0551a" - ] - } - ] - }, + "a": "Email", + "c": 17, + "l": [ + "d4f805c0b9a7e23edda3929060a25e12e0dee89e9fa8bf0876e3f1fb1e8f8aa2", + "d7931fb70c6c8a7ce73f5bf18c75644075598730aa0e40d63228f4a7809dcf38" + ] + } + ] + }, + { + "n": "Not Developers", + "r": [ { - "n": "Not ", - "r": [ - { - "a": "Email", - "c": 17, - "l": [ - "18fef9b334075fb1e8f61edd22d88fc7ffd0dbf56bba9ab6a82c7d2f183cf6bc", - "334423d07640c751beb2ac0c2e247d7af6cffcc729d619ec005ae1782bf0551a" - ] - } - ] - }, + "a": "Email", + "c": 17, + "l": [ + "03ec9be44734ba3c76260e304ca077c3123cf1c6a0be428e6a05f0b589d3681c", + "42e07ee44f228d422722390d281fe4d3a7bc292057cac459060e64424d4278c9" + ] + } + ] + }, + { + "n": "United", + "r": [ { - "n": "Unit", - "r": [ - { - "a": "Country", - "c": 2, - "l": [ - "United" - ] - } - ] - }, + "a": "Country", + "c": 2, + "l": [ + "United" + ] + } + ] + }, + { + "n": "Not States", + "r": [ { - "n": "Not ", - "r": [ - { - "a": "Country", - "c": 3, - "l": [ - "States" - ] - } - ] + "a": "Country", + "c": 3, + "l": [ + "States" + ] } - ], - "f": { - "countrySegment": { - "t": 1, - "r": [ - { - "c": [ - { - "s": { - "s": 4, - "c": 0 - } - }, - { - "s": { - "s": 5, - "c": 0 - } - } - ], - "s": { - "v": { - "s": "A" - }, - "i": "9b7e6414" - } - } - ], + ] + } + ], + "f": { + "countrySegment": { + "t": 1, + "r": [ + { + "c": [ + { + "s": { + "s": 4, + "c": 0 + } + }, + { + "s": { + "s": 5, + "c": 0 + } + } + ], + "s": { "v": { - "s": "Z" + "s": "A" }, - "i": "f71b6d96" - }, - "developerAndBetaUserSegment": { - "t": 0, - "r": [ - { - "c": [ - { - "s": { - "s": 1, - "c": 0 - } - }, - { - "s": { - "s": 0, - "c": 1 - } - } - ], - "s": { - "v": { - "b": true - }, - "i": "ddc50638" - } - } - ], + "i": "9b7e6414" + } + } + ], + "v": { + "s": "Z" + }, + "i": "f71b6d96" + }, + "developerAndBetaUserSegment": { + "t": 0, + "r": [ + { + "c": [ + { + "s": { + "s": 1, + "c": 0 + } + }, + { + "s": { + "s": 0, + "c": 1 + } + } + ], + "s": { "v": { - "b": false + "b": true + }, + "i": "ddc50638" + } + } + ], + "v": { + "b": false + }, + "i": "6427f4b8" + }, + "notDeveloperAndNotBetaUserSegment": { + "t": 0, + "r": [ + { + "c": [ + { + "s": { + "s": 2, + "c": 0 + } }, - "i": "6427f4b8" - }, - "notDeveloperAndNotBetaUserSegment": { - "t": 0, - "r": [ - { - "c": [ - { - "s": { - "s": 2, - "c": 0 - } - }, - { - "s": { - "s": 3, - "c": 1 - } - } - ], - "s": { - "v": { - "b": true - }, - "i": "77081d42" - } - } - ], + { + "s": { + "s": 3, + "c": 1 + } + } + ], + "s": { "v": { - "b": false + "b": true }, - "i": "a14eaf13" + "i": "77081d42" + } } + ], + "v": { + "b": false + }, + "i": "a14eaf13" } + } } diff --git a/src/ConfigCat.Client.Tests/data/sample_semantic_2_v5.json b/src/ConfigCat.Client.Tests/data/sample_semantic_2_v5.json index 96724e41..c7170ef6 100644 --- a/src/ConfigCat.Client.Tests/data/sample_semantic_2_v5.json +++ b/src/ConfigCat.Client.Tests/data/sample_semantic_2_v5.json @@ -1,6 +1,6 @@ { "p": { - "s": "gV6FuoNatH9CfBEAzZKpPaG8Ifh8/FXEdw9FoclHPwc=" + "s": "a/zoGhq13j5rXWNPFrwpOHIw2qRN/iPstBxxa59fehs=" }, "f": { "precedenceTests": { diff --git a/src/ConfigCat.Client.Tests/data/sample_semantic_v5.json b/src/ConfigCat.Client.Tests/data/sample_semantic_v5.json index 0c009b16..0504ee8d 100644 --- a/src/ConfigCat.Client.Tests/data/sample_semantic_v5.json +++ b/src/ConfigCat.Client.Tests/data/sample_semantic_v5.json @@ -1,6 +1,6 @@ { "p": { - "s": "lVw3JlijkfC8bkwY4rX3Ug06u8qfgBNM2e55hJ\u002BjMPc=" + "s": "13VDn230ZoiZ0UlrxgR9P5v\u002Bvhu8/7itFsVNqtb3Mn8=" }, "f": { "isOneOf": { @@ -196,22 +196,20 @@ "s": "is one of (1.0.0)" } } + } + ], + "p": [ + { + "p": 20, + "v": { + "s": "20%" + } }, { - "p": [ - { - "p": 20, - "v": { - "s": "20%" - } - }, - { - "p": 80, - "v": { - "s": "80%" - } - } - ] + "p": 80, + "v": { + "s": "80%" + } } ], "v": { @@ -312,22 +310,20 @@ "s": "Is not one of (1.0.0, 3.0.1)" } } + } + ], + "p": [ + { + "p": 20, + "v": { + "s": "20%" + } }, { - "p": [ - { - "p": 20, - "v": { - "s": "20%" - } - }, - { - "p": 80, - "v": { - "s": "80%" - } - } - ] + "p": 80, + "v": { + "s": "80%" + } } ], "v": { @@ -352,22 +348,20 @@ "s": "\u003C 1.0.0" } } + } + ], + "p": [ + { + "p": 20, + "v": { + "s": "20%" + } }, { - "p": [ - { - "p": 20, - "v": { - "s": "20%" - } - }, - { - "p": 80, - "v": { - "s": "80%" - } - } - ] + "p": 80, + "v": { + "s": "80%" + } } ], "v": { diff --git a/src/ConfigCat.Client.Tests/data/sample_sensitive_v5.json b/src/ConfigCat.Client.Tests/data/sample_sensitive_v5.json index e889c87a..88b8eaee 100644 --- a/src/ConfigCat.Client.Tests/data/sample_sensitive_v5.json +++ b/src/ConfigCat.Client.Tests/data/sample_sensitive_v5.json @@ -1,6 +1,6 @@ { "p": { - "s": "LKQu1a62agfNnWuGwA8cZglf4x0yZSbY2En7WQn5dWw=" + "s": "PTTl5hs8rhXMOBZju\u002B30y8SsG0F4GSqhrMS\u002Bd1HGRW0=" }, "f": { "isNotOneOfSensitive": { @@ -13,8 +13,8 @@ "a": "Identifier", "c": 17, "l": [ - "61418c941ecda8031d08ab86ec821e676fde7b6a59cd16b1e7191503c2f8297d", - "2ebea0310612c4c40d183b0c123d9bd425cf54f1e101f42858e701b5077cba01" + "61338bc24f4393fb5266167100d4ab5f56f5f146fa0c1c44d0ae9dee2d2ff0e6", + "ea4669a7df3b1c9989ce11e6fe1def6b92a07412c1ed5583aed6b16cca7de03c" ] } } @@ -32,8 +32,8 @@ "a": "Email", "c": 17, "l": [ - "9946f8f58f00db77453316c9da1553bd9e30449908c0816f0dc4b08d2fca8359", - "7518d56d552d68a0b2a71631d156e21afcff9a973df94ea8b407db2d2bb2df95" + "f7995450d2d32812f13d40d8c24764d01c39685fcd9bd7cc9cb66c3288564e7a", + "a16c6e1a1e1bfc8f455b1f8c8756731cf5c6f456cc3e6c5c5a4226f427459d38" ] } } @@ -51,9 +51,9 @@ "a": "Country", "c": 17, "l": [ - "66c2eb75fa8dc9b42a8901297bd41265bafe3a0336c883e55503943af355311c", - "b4a338878cd96e0d624b54d85381210239d1940a583dbc2cb7efb74ec2713b47", - "984188303bd31c407f91e4784e10cda0abb600c437fd13f4078d284ba2a4e7fc" + "aedda83026d352c585ea7923307fb5c77859e0a68949fcb7c6c76baea517d6c1", + "53652982b82dc7b32a3681ce4f0d4a6e3643333d48e5678a31d9dd46a7bc3418", + "a69168fa5b2793618e0c62770c256ac568fc8322541634ed1d5bde7dcaf763fc" ] } } @@ -79,7 +79,7 @@ "a": "Email", "c": 16, "l": [ - "16be4b1b5975801ce19a741b11364ea09ba4de98a5d50e81081163bbd74ac69f" + "980203a2d47f455ea84562067049bfbabe43032d750eac8471f7003e2ffcf26a" ] } } @@ -97,8 +97,8 @@ "a": "Identifier", "c": 16, "l": [ - "a09ac5210f9996595f85a68bd71c7bea4ea230cbbc7526c44f6b3b3919836f28", - "3cca65ac07b230290174fdab3eddf443c70cf2ee68ab94027246a03e925f251f" + "8213c46251fb349f7c332e53a22238815cfba02bed3124b51cd3011be0dbb388", + "4e8611c778dfd8516d43a3b9d12544674aeef2726e333dcafd158b8dce029343" ] } } @@ -116,9 +116,9 @@ "a": "Country", "c": 16, "l": [ - "5aa17666db74bdbbd95890cfb8e5596b21a5124399323e48ba1dd4061806a9af", - "92324ccbbf9ec7fc76f06679fccaa9835a92d742aea4eb4e9514f3accd8ca3bf", - "e68e12c74fd3da7c9e18ca63c37a0e83988726daa210ce7e107ea9a06c2fd9a3" + "ec9d3a16c19d872cd835f8fcf7d366fb960653d41719048db325e8a0343155d3", + "a3c1959a63910936a728f72bc133e1cc42120d2458d95eb041c34213567d7dc9", + "111d1e465f7a84483de93bffbc344e98150e8a89c6a5830a7e17fa2b1bf45546" ] } } diff --git a/src/ConfigCat.Client.Tests/data/sample_v5.json b/src/ConfigCat.Client.Tests/data/sample_v5.json index e3b39d30..89ad04a2 100644 --- a/src/ConfigCat.Client.Tests/data/sample_v5.json +++ b/src/ConfigCat.Client.Tests/data/sample_v5.json @@ -1,6 +1,6 @@ { "p": { - "s": "AUG/yhZQ06MUJcjZub1rNxGTHOhLJZeAn4/4HO\u002BqQYk=" + "s": "kSBpFzVdEHN7QbjOPhKkB2FHKaSXCGo8D55r0lqxhss=" }, "f": { "stringDefaultCat": { @@ -19,8 +19,8 @@ "a": "Email", "c": 16, "l": [ - "05909594acf5d11e42efb1a5434bf022f2f6ece8f63faa218212a9712f51ea78", - "388ac6554da9426c8824222cbd0ec4bfc9cc518ff4a0dfdb540acba50ee35264" + "206b33d71717cc9d3b74834fe2e6e1b195f052b4cc614d80571eafb1ad831fd5", + "2aa6bbf5d735ca9ace441fb4641478701bd6f364122e83b3d0bf5f54fddd550c" ] } } @@ -38,7 +38,7 @@ "a": "Custom1", "c": 16, "l": [ - "81b6700c1d5678fa0307ce2ac1cc1676b493d4c8827727cebc2c182202d2c441" + "5e7d81d60e0e5b55e2ffbdfe052b02b24afdaae16626e64ae6f3d183772cf9ec" ] } } @@ -64,8 +64,8 @@ "a": "Email", "c": 17, "l": [ - "170b5a0e07494f9ff4870489ff4904d2fab0849a5cc53810a8e343c97a15c568", - "cd494ccefcabcd75a8f58d96c3546a6d0cf13219038f7cf891efca5ce847a8ec" + "f117c6948de816414d68207e8c9fe562b5c53b0e0d3af1b5abcc36f1e0955997", + "56a3573e5aa9c408bdb83878dd038e78d555aea31f98d99f0b2b8c2867463b7c" ] } } @@ -135,34 +135,30 @@ }, "string25Cat25Dog25Falcon25Horse": { "t": 1, - "r": [ + "p": [ { - "p": [ - { - "p": 25, - "v": { - "s": "Cat" - } - }, - { - "p": 25, - "v": { - "s": "Dog" - } - }, - { - "p": 25, - "v": { - "s": "Falcon" - } - }, - { - "p": 25, - "v": { - "s": "Horse" - } - } - ] + "p": 25, + "v": { + "s": "Cat" + } + }, + { + "p": 25, + "v": { + "s": "Dog" + } + }, + { + "p": 25, + "v": { + "s": "Falcon" + } + }, + { + "p": 25, + "v": { + "s": "Horse" + } } ], "v": { @@ -171,34 +167,30 @@ }, "string75Cat0Dog25Falcon0Horse": { "t": 1, - "r": [ + "p": [ { - "p": [ - { - "p": 75, - "v": { - "s": "Cat" - } - }, - { - "p": 0, - "v": { - "s": "Dog" - } - }, - { - "p": 25, - "v": { - "s": "Falcon" - } - }, - { - "p": 0, - "v": { - "s": "Horse" - } - } - ] + "p": 75, + "v": { + "s": "Cat" + } + }, + { + "p": 0, + "v": { + "s": "Dog" + } + }, + { + "p": 25, + "v": { + "s": "Falcon" + } + }, + { + "p": 0, + "v": { + "s": "Horse" + } } ], "v": { @@ -215,8 +207,8 @@ "a": "Country", "c": 16, "l": [ - "f08f90b0cf687c5bc82b2bc2d9a61c149063a6d90981590de1e9aec7341d7977", - "31a5bc9ee68eafe7d649b5fc160d1a0ab84532bcec75d823e4a5361de6981ba2" + "4af88801ac46795aac6d8e412d87eaaae27e02954464932c4d98175b3eafba9b", + "825a2eb2bdc769ad45059625349b889ee32b6a86d636b96e79de4133326d030d" ] } } @@ -262,34 +254,32 @@ "s": "Kitten" } } + } + ], + "p": [ + { + "p": 25, + "v": { + "s": "Cat" + } }, { - "p": [ - { - "p": 25, - "v": { - "s": "Cat" - } - }, - { - "p": 25, - "v": { - "s": "Dog" - } - }, - { - "p": 25, - "v": { - "s": "Falcon" - } - }, - { - "p": 25, - "v": { - "s": "Horse" - } - } - ] + "p": 25, + "v": { + "s": "Dog" + } + }, + { + "p": 25, + "v": { + "s": "Falcon" + } + }, + { + "p": 25, + "v": { + "s": "Horse" + } } ], "v": { @@ -318,8 +308,8 @@ "a": "Email", "c": 16, "l": [ - "f3ddb5dd5ffb08cd8d61dcc23e6f7bd4bed356f82a8031d4e6c50f0ad82f7cc8", - "e20b6cafb22cc4a6f73bd9d903b6447a477b098c029810bb8b18c1d155ae4f68" + "3209f667a750966e68e6f6357515b30564f5ac510d347a04cdf2f538715d3dd8", + "4632d76e9719686ebefd5ac89084019f4cd6c31e2b2d25ca2aaf566a68137d29" ] } } @@ -347,22 +337,20 @@ "b": false } } + } + ], + "p": [ + { + "p": 30, + "v": { + "b": true + } }, { - "p": [ - { - "p": 30, - "v": { - "b": true - } - }, - { - "p": 70, - "v": { - "b": false - } - } - ] + "p": 70, + "v": { + "b": false + } } ], "v": { @@ -389,34 +377,32 @@ "i": 5 } } + } + ], + "p": [ + { + "p": 25, + "v": { + "i": 1 + } }, { - "p": [ - { - "p": 25, - "v": { - "i": 1 - } - }, - { - "p": 25, - "v": { - "i": 2 - } - }, - { - "p": 25, - "v": { - "i": 3 - } - }, - { - "p": 25, - "v": { - "i": 4 - } - } - ] + "p": 25, + "v": { + "i": 2 + } + }, + { + "p": 25, + "v": { + "i": 3 + } + }, + { + "p": 25, + "v": { + "i": 4 + } } ], "v": { @@ -455,34 +441,32 @@ "d": 5.561 } } + } + ], + "p": [ + { + "p": 25, + "v": { + "d": 3.1415 + } }, { - "p": [ - { - "p": 25, - "v": { - "d": 3.1415 - } - }, - { - "p": 25, - "v": { - "d": 2.7182 - } - }, - { - "p": 25, - "v": { - "d": 1.61803 - } - }, - { - "p": 25, - "v": { - "d": 0 - } - } - ] + "p": 25, + "v": { + "d": 2.7182 + } + }, + { + "p": 25, + "v": { + "d": 1.61803 + } + }, + { + "p": 25, + "v": { + "d": 0 + } } ], "v": { @@ -499,8 +483,8 @@ "a": "Country", "c": 16, "l": [ - "7cf35b0cf2fefdbdf79d29c00f8bacf6a5eacdf7b63a0e984d97b98dc456b8d5", - "735ca4396231886e1843c4d98bd0ed5baf39dcce6d412eda35c552418950f34b" + "569d4810dfac9d6a4b4196aaddf5ba3e8ef0a653cfa15054529e0e9ed76f5f25", + "a7d55166218ec2c197cc4b14723cc96f00cfbee0d734cb57769bb33d30387c71" ] } } @@ -518,7 +502,7 @@ "a": "SubscriptionType", "c": 16, "l": [ - "177018c891c56ee81519948640bc727ef1603e17a74b6c38e53db7ab5be594c4" + "ddd689eb98271df997e28f75dbe9a134af7235b1d6d84d7d6773cb48556103a6" ] } } @@ -528,22 +512,20 @@ "s": "Lion" } } + } + ], + "p": [ + { + "p": 50, + "v": { + "s": "Falcon" + } }, { - "p": [ - { - "p": 50, - "v": { - "s": "Falcon" - } - }, - { - "p": 50, - "v": { - "s": "Horse" - } - } - ] + "p": 50, + "v": { + "s": "Horse" + } } ], "v": { diff --git a/src/ConfigCat.Client.Tests/data/sample_variationid_v5.json b/src/ConfigCat.Client.Tests/data/sample_variationid_v5.json index e2b5fd54..75d883d8 100644 --- a/src/ConfigCat.Client.Tests/data/sample_variationid_v5.json +++ b/src/ConfigCat.Client.Tests/data/sample_variationid_v5.json @@ -1,6 +1,6 @@ { "p": { - "s": "fRMLn\u002BIUb\u002B3p/lwJsE\u002BgBQdkWAhb5CWJQb1WEolDz8I=" + "s": "XNvUomOaJnfFzAfmqPLzbRgtU\u002BK\u002BPtFywkA\u002Bf/NsOhc=" }, "f": { "boolean": { @@ -24,24 +24,22 @@ }, "i": "67787ae4" } + } + ], + "p": [ + { + "p": 50, + "v": { + "b": true + }, + "i": "67787ae4" }, { - "p": [ - { - "p": 50, - "v": { - "b": true - }, - "i": "67787ae4" - }, - { - "p": 50, - "v": { - "b": false - }, - "i": "a0e56eda" - } - ] + "p": 50, + "v": { + "b": false + }, + "i": "a0e56eda" } ], "v": { @@ -89,24 +87,22 @@ }, "i": "65310deb" } + } + ], + "p": [ + { + "p": 50, + "v": { + "s": "a" + }, + "i": "30ba32b9" }, { - "p": [ - { - "p": 50, - "v": { - "s": "a" - }, - "i": "30ba32b9" - }, - { - "p": 50, - "v": { - "s": "b" - }, - "i": "cf19e913" - } - ] + "p": 50, + "v": { + "s": "b" + }, + "i": "cf19e913" } ], "v": { @@ -135,24 +131,22 @@ }, "i": "ab30533b" } + } + ], + "p": [ + { + "p": 50, + "v": { + "i": 0 + }, + "i": "ec14f6a9" }, { - "p": [ - { - "p": 50, - "v": { - "i": 0 - }, - "i": "ec14f6a9" - }, - { - "p": 50, - "v": { - "i": -1 - }, - "i": "61a5a033" - } - ] + "p": 50, + "v": { + "i": -1 + }, + "i": "61a5a033" } ], "v": { @@ -189,7 +183,7 @@ "a": "Email", "c": 16, "l": [ - "15084532704dfa49c1084d8652db0ae64c34d0ecb0fdc972bb17084481966de9" + "16c5c406a4ab19fe4924f77e61d70ea58349db2c76311e757d0acac0d76f592f" ] } } @@ -208,7 +202,7 @@ "a": "Email", "c": 16, "l": [ - "f0b9ddb002076878774c2e437c2965e9f0cf96af9d9c8a6383b744cc99393fdb" + "5bc0abba39810e3565c0d73ff143483a76c8aa620b9567f5edb312f3c5d17c81" ] } } @@ -219,24 +213,22 @@ }, "i": "d66c5781" } + } + ], + "p": [ + { + "p": 50, + "v": { + "d": 1 + }, + "i": "d0dbc27f" }, { - "p": [ - { - "p": 50, - "v": { - "d": 1 - }, - "i": "d0dbc27f" - }, - { - "p": 50, - "v": { - "d": 2 - }, - "i": "8155ad7b" - } - ] + "p": 50, + "v": { + "d": 2 + }, + "i": "8155ad7b" } ], "v": { diff --git a/src/ConfigCat.Client.Tests/data/test_json_complex.json b/src/ConfigCat.Client.Tests/data/test_json_complex.json index be38538a..4383d896 100644 --- a/src/ConfigCat.Client.Tests/data/test_json_complex.json +++ b/src/ConfigCat.Client.Tests/data/test_json_complex.json @@ -1,6 +1,6 @@ { "p": { - "s": "6q7XeGm5KnT7kByEwVRau87Q6cbQLHLZ/Hs\u002B0/A1Nkg=" + "s": "s449fLWNwiEFQ/AqfRj13pPHVdV9g3h0HAFzWtjpZgE=" }, "f": { "disabledFeature": { diff --git a/src/ConfigCatClient/Evaluation/RolloutEvaluator.cs b/src/ConfigCatClient/Evaluation/RolloutEvaluator.cs index 3575ce05..46e7089a 100644 --- a/src/ConfigCatClient/Evaluation/RolloutEvaluator.cs +++ b/src/ConfigCatClient/Evaluation/RolloutEvaluator.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using ConfigCat.Client.Utils; @@ -68,18 +67,29 @@ public EvaluateResult Evaluate(ref EvaluateContext context) private EvaluateResult EvaluateSetting(ref EvaluateContext context) { - if (!TryEvaluateTargetingRules(context.Setting.TargetingRules, ref context, out var evaluateResult)) + EvaluateResult evaluateResult; + + var targetingRules = context.Setting.TargetingRules; + if (targetingRules.Length > 0 && TryEvaluateTargetingRules(targetingRules, ref context, out evaluateResult)) { - evaluateResult = new EvaluateResult(context.Setting); + return evaluateResult; } + var percentageOptions = context.Setting.PercentageOptions; + if (percentageOptions.Length > 0 && TryEvaluatePercentageOptions(percentageOptions, targetingRule: null, ref context, out evaluateResult)) + { + return evaluateResult; + } + + evaluateResult = new EvaluateResult(context.Setting); return evaluateResult; } private bool TryEvaluateTargetingRules(TargetingRule[] targetingRules, ref EvaluateContext context, out EvaluateResult result) { var logBuilder = context.LogBuilder; - var hasConditions = false; + + logBuilder?.NewLine("Evaluating targeting rules and applying the first match if any:"); for (var i = 0; i < targetingRules.Length; i++) { @@ -91,12 +101,6 @@ private bool TryEvaluateTargetingRules(TargetingRule[] targetingRules, ref Evalu // Actual targeting rule? if (conditions.Length > 0) { - if (!hasConditions) - { - logBuilder?.NewLine("Evaluating targeting rules and applying the first match if any:"); - hasConditions = true; - } - // TODO: error handling - condition.GetCondition() - what to do when the condition is invalid (not available/multiple values specified)? if (!TryEvaluateConditions(conditions, static condition => condition.GetCondition()!, targetingRule, contextSalt: context.Key, ref context, out var isMatch)) { @@ -124,10 +128,9 @@ private bool TryEvaluateTargetingRules(TargetingRule[] targetingRules, ref Evalu } logBuilder?.IncreaseIndent(); - if (TryEvaluatePercentageOptions(percentageOptions, ref context, out var percentageOption)) + if (TryEvaluatePercentageOptions(percentageOptions, targetingRule, ref context, out result)) { logBuilder?.DecreaseIndent(); - result = new EvaluateResult(percentageOption, targetingRule, percentageOption); return true; } else @@ -138,50 +141,14 @@ private bool TryEvaluateTargetingRules(TargetingRule[] targetingRules, ref Evalu continue; } } - // % options without conditions? - else - { - if (i != targetingRules.Length - 1) - { - // TODO: error handling - % options without conditions is not the last item - throw new InvalidOperationException(); - } - - if (targetingRule.SimpleValue is not null) - { - // TODO: error handling - % options are expected but simple value is specified - throw new InvalidOperationException(); - } - - if (percentageOptions is not { Length: > 0 }) - { - // TODO: error handling - percentage options are expected but the list of percentage options are missing or both of simple value and percentage options are specified - throw new InvalidOperationException(); - } - - if (TryEvaluatePercentageOptions(percentageOptions, ref context, out var percentageOption)) - { - // TODO: return matched targeting rule even if it has no conditions? - result = new EvaluateResult(percentageOption, matchedPercentageOption: percentageOption); - return true; - } - else - { - // TODO error handling - what to do if there are additional items? - break; - } - } } result = default; return false; } - private bool TryEvaluatePercentageOptions(PercentageOption[] percentageOptions, ref EvaluateContext context, - [NotNullWhen(true)] out PercentageOption? percentageOption) + private bool TryEvaluatePercentageOptions(PercentageOption[] percentageOptions, TargetingRule? targetingRule, ref EvaluateContext context, out EvaluateResult result) { - percentageOption = null; - var logBuilder = context.LogBuilder; if (context.User is null) @@ -194,6 +161,7 @@ private bool TryEvaluatePercentageOptions(PercentageOption[] percentageOptions, context.IsMissingUserObjectLogged = true; } + result = default; return false; } @@ -216,6 +184,7 @@ private bool TryEvaluatePercentageOptions(PercentageOption[] percentageOptions, context.IsMissingUserObjectAttributeLogged = true; } + result = default; return false; } @@ -242,7 +211,7 @@ private bool TryEvaluatePercentageOptions(PercentageOption[] percentageOptions, for (var i = 0; i < percentageOptions.Length; i++) { - percentageOption = percentageOptions[i]; // TODO: error handling - what to do when item is null? + var percentageOption = percentageOptions[i]; // TODO: error handling - what to do when item is null? bucket += percentageOption.Percentage; @@ -254,6 +223,7 @@ private bool TryEvaluatePercentageOptions(PercentageOption[] percentageOptions, var percentageOptionValue = percentageOption.Value.GetValue(context.Setting.SettingType, throwIfInvalid: false); logBuilder?.NewLine().Append($"- Hash value {hashValue} selects % option {i + 1} ({percentageOption.Percentage}%), '{percentageOptionValue ?? ModelHelper.InvalidValuePlaceholder}'."); + result = new EvaluateResult(percentageOption, matchedTargetingRule: targetingRule, matchedPercentageOption: percentageOption); return true; } diff --git a/src/ConfigCatClient/Models/Setting.cs b/src/ConfigCatClient/Models/Setting.cs index 148aa6b5..abb3326a 100644 --- a/src/ConfigCatClient/Models/Setting.cs +++ b/src/ConfigCatClient/Models/Setting.cs @@ -31,7 +31,10 @@ public interface ISetting /// IReadOnlyList TargetingRules { get; } - // TODO: percentage options? + /// + /// The list of percentage options. + /// + IReadOnlyList PercentageOptions { get; } /// /// The (fallback) value of the setting. @@ -62,9 +65,9 @@ public SettingType SettingType } #if USE_NEWTONSOFT_JSON - [JsonProperty(PropertyName = "p")] + [JsonProperty(PropertyName = "a")] #else - [JsonPropertyName("p")] + [JsonPropertyName("a")] #endif [NotNull] public string? PercentageOptionsAttribute { get; set; } @@ -91,6 +94,25 @@ public TargetingRule[]? TargetingRules ? new ReadOnlyCollection(this.targetingRules) : ArrayUtils.EmptyArray(); + private PercentageOption[]? percentageOptions; + +#if USE_NEWTONSOFT_JSON + [JsonProperty(PropertyName = "p")] +#else + [JsonPropertyName("p")] +#endif + [NotNull] + public PercentageOption[]? PercentageOptions + { + get => this.percentageOptions ?? ArrayUtils.EmptyArray(); + set => this.percentageOptions = value; + } + + private IReadOnlyList? percentageOptionsReadOnly; + IReadOnlyList ISetting.PercentageOptions => this.percentageOptionsReadOnly ??= this.percentageOptions is { Length: > 0 } + ? new ReadOnlyCollection(this.percentageOptions) + : ArrayUtils.EmptyArray(); + object ISetting.Value => Value.GetValue()!; [JsonIgnore]