From 7306e003ffeb59d50a0b0a2115a9deaf7197ae79 Mon Sep 17 00:00:00 2001 From: Adam Simon Date: Wed, 25 Oct 2023 17:35:27 +0200 Subject: [PATCH] Adjust model and tests to config v6 schema changes --- src/ConfigCat.Client.Tests/ModelTests.cs | 8 +++--- .../2_rules_matching_targeted_attribute.txt | 6 ++-- .../2_rules_no_targeted_attribute.txt | 8 +++--- .../2_targeting_rules/2_rules_no_user.txt | 4 +-- ..._rules_not_matching_targeted_attribute.txt | 6 ++-- .../circular_dependency_override.json | 8 +++--- .../_overrides/test_list_truncation.json | 6 ++-- .../data/sample_v5.json | 28 +++++++++---------- .../data/sample_variationid_v5.json | 14 +++++----- .../data/test_circulardependency_v6.json | 10 +++---- .../data/test_override_flagdependency_v6.json | 2 +- .../Models/ConditionContainer.cs | 8 +++--- 12 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/ConfigCat.Client.Tests/ModelTests.cs b/src/ConfigCat.Client.Tests/ModelTests.cs index 3e7df9f2..e91851a2 100644 --- a/src/ConfigCat.Client.Tests/ModelTests.cs +++ b/src/ConfigCat.Client.Tests/ModelTests.cs @@ -38,7 +38,7 @@ public void SettingValue_ToString(object? value, string expectedResult) } [DataTestMethod] - [DataRow(BasicSampleSdkKey, null, "stringIsNotInDogDefaultCat", 0, 0, new[] { "User.Email IS NOT ONE OF [<2 hashed values>]" })] + [DataRow(BasicSampleSdkKey, null, "stringIsNotInDogDefaultCat", 0, 0, new[] { "User.Email IS NOT ONE OF ['a@configcat.com', 'b@configcat.com']" })] [DataRow(SegmentsV6SampleSdkKey, null, "countrySegment", 0, 0, new[] { "User IS IN SEGMENT 'United'" })] [DataRow(FlagDependencyV6SampleSdkKey, null, "boolDependsOnBool", 0, 0, new[] { "Flag 'mainBoolFlag' EQUALS 'True'" })] public void Condition_ToString(string? sdkKey, string baseUrlOrFileName, string settingKey, int targetingRuleIndex, int conditionIndex, string[] expectedResultLines) @@ -71,7 +71,7 @@ public void PercentageOption_ToString(string? sdkKey, string baseUrlOrFileName, [DataTestMethod] [DataRow(BasicSampleSdkKey, null, "stringIsNotInDogDefaultCat", 0, new[] { - "IF User.Email IS NOT ONE OF [<2 hashed values>]", + "IF User.Email IS NOT ONE OF ['a@configcat.com', 'b@configcat.com']", "THEN 'Dog'", })] [DataRow(ComparatorsV6SampleSdkKey, null, "missingPercentageAttribute", 0, new[] @@ -102,7 +102,7 @@ public void TargetingRule_ToString(string? sdkKey, string baseUrlOrFileName, str [DataRow(null, "test_json_complex", "doubleSetting", new[] { "To all users: '3.14'" })] [DataRow(BasicSampleSdkKey, null, "stringIsNotInDogDefaultCat", new[] { - "IF User.Email IS NOT ONE OF [<2 hashed values>]", + "IF User.Email IS NOT ONE OF ['a@configcat.com', 'b@configcat.com']", "THEN 'Dog'", "To all others: 'Cat'", })] @@ -122,7 +122,7 @@ public void TargetingRule_ToString(string? sdkKey, string baseUrlOrFileName, str })] [DataRow(BasicSampleSdkKey, null, "string25Cat25Dog25Falcon25HorseAdvancedRules", new[] { - "IF User.Country IS ONE OF [<2 hashed values>]", + "IF User.Country IS ONE OF ['Hungary', 'United Kingdom']", "THEN 'Dolphin'", "ELSE IF User.Custom1 CONTAINS ANY OF ['admi']", "THEN 'Lion'", diff --git a/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_matching_targeted_attribute.txt b/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_matching_targeted_attribute.txt index a1507177..d124a4f4 100644 --- a/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_matching_targeted_attribute.txt +++ b/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_matching_targeted_attribute.txt @@ -1,7 +1,7 @@ -WARNING [3003] Cannot evaluate condition (User.Email IS ONE OF [<2 hashed values>]) for setting 'stringIsInDogDefaultCat' (the User.Email attribute is missing). You should set the User.Email attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/ +WARNING [3003] Cannot evaluate condition (User.Email IS ONE OF ['a@configcat.com', 'b@configcat.com']) for setting 'stringIsInDogDefaultCat' (the User.Email attribute is missing). You should set the User.Email attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/ INFO [5000] Evaluating 'stringIsInDogDefaultCat' for User '{"Identifier":"12345","Custom1":"admin"}' Evaluating targeting rules and applying the first match if any: - - IF User.Email IS ONE OF [<2 hashed values>] THEN 'Dog' => cannot evaluate, the User.Email attribute is missing + - IF User.Email IS ONE OF ['a@configcat.com', 'b@configcat.com'] THEN 'Dog' => cannot evaluate, the User.Email attribute is missing The current targeting rule is ignored and the evaluation continues with the next rule. - - IF User.Custom1 IS ONE OF [<1 hashed value>] THEN 'Dog' => MATCH, applying rule + - IF User.Custom1 IS ONE OF ['admin'] THEN 'Dog' => MATCH, applying rule Returning 'Dog'. diff --git a/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_no_targeted_attribute.txt b/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_no_targeted_attribute.txt index 80eb43b0..0e020769 100644 --- a/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_no_targeted_attribute.txt +++ b/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_no_targeted_attribute.txt @@ -1,9 +1,9 @@ -WARNING [3003] Cannot evaluate condition (User.Email IS ONE OF [<2 hashed values>]) for setting 'stringIsInDogDefaultCat' (the User.Email attribute is missing). You should set the User.Email attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/ -WARNING [3003] Cannot evaluate condition (User.Custom1 IS ONE OF [<1 hashed value>]) for setting 'stringIsInDogDefaultCat' (the User.Custom1 attribute is missing). You should set the User.Custom1 attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/ +WARNING [3003] Cannot evaluate condition (User.Email IS ONE OF ['a@configcat.com', 'b@configcat.com']) for setting 'stringIsInDogDefaultCat' (the User.Email attribute is missing). You should set the User.Email attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/ +WARNING [3003] Cannot evaluate condition (User.Custom1 IS ONE OF ['admin']) for setting 'stringIsInDogDefaultCat' (the User.Custom1 attribute is missing). You should set the User.Custom1 attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/ INFO [5000] Evaluating 'stringIsInDogDefaultCat' for User '{"Identifier":"12345"}' Evaluating targeting rules and applying the first match if any: - - IF User.Email IS ONE OF [<2 hashed values>] THEN 'Dog' => cannot evaluate, the User.Email attribute is missing + - IF User.Email IS ONE OF ['a@configcat.com', 'b@configcat.com'] THEN 'Dog' => cannot evaluate, the User.Email attribute is missing The current targeting rule is ignored and the evaluation continues with the next rule. - - IF User.Custom1 IS ONE OF [<1 hashed value>] THEN 'Dog' => cannot evaluate, the User.Custom1 attribute is missing + - IF User.Custom1 IS ONE OF ['admin'] THEN 'Dog' => cannot evaluate, the User.Custom1 attribute is missing The current targeting rule is ignored and the evaluation continues with the next rule. Returning 'Cat'. diff --git a/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_no_user.txt b/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_no_user.txt index 49f74903..da3e73a3 100644 --- a/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_no_user.txt +++ b/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_no_user.txt @@ -1,8 +1,8 @@ WARNING [3001] Cannot evaluate targeting rules and % options for setting 'stringIsInDogDefaultCat' (User Object is missing). You should pass a User Object to the evaluation methods like `GetValue()`/`GetValueAsync()` in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/ INFO [5000] Evaluating 'stringIsInDogDefaultCat' Evaluating targeting rules and applying the first match if any: - - IF User.Email IS ONE OF [<2 hashed values>] THEN 'Dog' => cannot evaluate, User Object is missing + - IF User.Email IS ONE OF ['a@configcat.com', 'b@configcat.com'] THEN 'Dog' => cannot evaluate, User Object is missing The current targeting rule is ignored and the evaluation continues with the next rule. - - IF User.Custom1 IS ONE OF [<1 hashed value>] THEN 'Dog' => cannot evaluate, User Object is missing + - IF User.Custom1 IS ONE OF ['admin'] THEN 'Dog' => cannot evaluate, User Object is missing The current targeting rule is ignored and the evaluation continues with the next rule. Returning 'Cat'. diff --git a/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_not_matching_targeted_attribute.txt b/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_not_matching_targeted_attribute.txt index 1564f0bc..72217b28 100644 --- a/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_not_matching_targeted_attribute.txt +++ b/src/ConfigCat.Client.Tests/data/evaluationlog/2_targeting_rules/2_rules_not_matching_targeted_attribute.txt @@ -1,7 +1,7 @@ -WARNING [3003] Cannot evaluate condition (User.Email IS ONE OF [<2 hashed values>]) for setting 'stringIsInDogDefaultCat' (the User.Email attribute is missing). You should set the User.Email attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/ +WARNING [3003] Cannot evaluate condition (User.Email IS ONE OF ['a@configcat.com', 'b@configcat.com']) for setting 'stringIsInDogDefaultCat' (the User.Email attribute is missing). You should set the User.Email attribute in order to make targeting work properly. Read more: https://configcat.com/docs/advanced/user-object/ INFO [5000] Evaluating 'stringIsInDogDefaultCat' for User '{"Identifier":"12345","Custom1":"user"}' Evaluating targeting rules and applying the first match if any: - - IF User.Email IS ONE OF [<2 hashed values>] THEN 'Dog' => cannot evaluate, the User.Email attribute is missing + - IF User.Email IS ONE OF ['a@configcat.com', 'b@configcat.com'] THEN 'Dog' => cannot evaluate, the User.Email attribute is missing The current targeting rule is ignored and the evaluation continues with the next rule. - - IF User.Custom1 IS ONE OF [<1 hashed value>] THEN 'Dog' => no match + - IF User.Custom1 IS ONE OF ['admin'] THEN 'Dog' => no match Returning 'Cat'. diff --git a/src/ConfigCat.Client.Tests/data/evaluationlog/_overrides/circular_dependency_override.json b/src/ConfigCat.Client.Tests/data/evaluationlog/_overrides/circular_dependency_override.json index 39c53c08..0e9d9d95 100644 --- a/src/ConfigCat.Client.Tests/data/evaluationlog/_overrides/circular_dependency_override.json +++ b/src/ConfigCat.Client.Tests/data/evaluationlog/_overrides/circular_dependency_override.json @@ -8,16 +8,16 @@ "t": 1, "v": { "s": "value1" }, "r": [ - {"c": [{"d": {"f": "key2", "c": 0, "v": {"s": "fourth"}}}], "s": {"v": {"s": "first"}}}, - {"c": [{"d": {"f": "key3", "c": 0, "v": {"s": "value3"}}}], "s": {"v": {"s": "second"}}} + {"c": [{"p": {"f": "key2", "c": 0, "v": {"s": "fourth"}}}], "s": {"v": {"s": "first"}}}, + {"c": [{"p": {"f": "key3", "c": 0, "v": {"s": "value3"}}}], "s": {"v": {"s": "second"}}} ] }, "key2": { "t": 1, "v": { "s": "value2" }, "r": [ - {"c": [{"d": {"f": "key1", "c": 0, "v": {"s": "value1"}}}], "s": {"v": {"s": "third"}}}, - {"c": [{"d": {"f": "key3", "c": 0, "v": {"s": "value3"}}}], "s": {"v": {"s": "fourth"}}} + {"c": [{"p": {"f": "key1", "c": 0, "v": {"s": "value1"}}}], "s": {"v": {"s": "third"}}}, + {"c": [{"p": {"f": "key3", "c": 0, "v": {"s": "value3"}}}], "s": {"v": {"s": "fourth"}}} ] }, "key3": { diff --git a/src/ConfigCat.Client.Tests/data/evaluationlog/_overrides/test_list_truncation.json b/src/ConfigCat.Client.Tests/data/evaluationlog/_overrides/test_list_truncation.json index 12cf9e5e..6fdde459 100644 --- a/src/ConfigCat.Client.Tests/data/evaluationlog/_overrides/test_list_truncation.json +++ b/src/ConfigCat.Client.Tests/data/evaluationlog/_overrides/test_list_truncation.json @@ -14,7 +14,7 @@ { "c": [ { - "t": { + "u": { "a": "Identifier", "c": 2, "l": [ @@ -32,7 +32,7 @@ } }, { - "t": { + "u": { "a": "Identifier", "c": 2, "l": [ @@ -51,7 +51,7 @@ } }, { - "t": { + "u": { "a": "Identifier", "c": 2, "l": [ diff --git a/src/ConfigCat.Client.Tests/data/sample_v5.json b/src/ConfigCat.Client.Tests/data/sample_v5.json index 89ad04a2..66407ffd 100644 --- a/src/ConfigCat.Client.Tests/data/sample_v5.json +++ b/src/ConfigCat.Client.Tests/data/sample_v5.json @@ -15,7 +15,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 16, "l": [ @@ -34,7 +34,7 @@ { "c": [ { - "t": { + "u": { "a": "Custom1", "c": 16, "l": [ @@ -60,7 +60,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 17, "l": [ @@ -87,7 +87,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 2, "l": [ @@ -113,7 +113,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 3, "l": [ @@ -203,7 +203,7 @@ { "c": [ { - "t": { + "u": { "a": "Country", "c": 16, "l": [ @@ -222,7 +222,7 @@ { "c": [ { - "t": { + "u": { "a": "Custom1", "c": 2, "l": [ @@ -240,7 +240,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 2, "l": [ @@ -304,7 +304,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 16, "l": [ @@ -323,7 +323,7 @@ { "c": [ { - "t": { + "u": { "a": "Country", "c": 2, "l": [ @@ -363,7 +363,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 2, "l": [ @@ -427,7 +427,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 2, "l": [ @@ -479,7 +479,7 @@ { "c": [ { - "t": { + "u": { "a": "Country", "c": 16, "l": [ @@ -498,7 +498,7 @@ { "c": [ { - "t": { + "u": { "a": "SubscriptionType", "c": 16, "l": [ diff --git a/src/ConfigCat.Client.Tests/data/sample_variationid_v5.json b/src/ConfigCat.Client.Tests/data/sample_variationid_v5.json index 75d883d8..32cfdc2b 100644 --- a/src/ConfigCat.Client.Tests/data/sample_variationid_v5.json +++ b/src/ConfigCat.Client.Tests/data/sample_variationid_v5.json @@ -9,7 +9,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 2, "l": [ @@ -53,7 +53,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 2, "l": [ @@ -72,7 +72,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 2, "l": [ @@ -116,7 +116,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 2, "l": [ @@ -160,7 +160,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 2, "l": [ @@ -179,7 +179,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 16, "l": [ @@ -198,7 +198,7 @@ { "c": [ { - "t": { + "u": { "a": "Email", "c": 16, "l": [ diff --git a/src/ConfigCat.Client.Tests/data/test_circulardependency_v6.json b/src/ConfigCat.Client.Tests/data/test_circulardependency_v6.json index 8ae493ee..d8a7d047 100644 --- a/src/ConfigCat.Client.Tests/data/test_circulardependency_v6.json +++ b/src/ConfigCat.Client.Tests/data/test_circulardependency_v6.json @@ -11,7 +11,7 @@ { "c": [ { - "d": { + "p": { "f": "key1", "c": 0, "v": { "s": "key1-prereq1" } @@ -23,7 +23,7 @@ { "c": [ { - "d": { + "p": { "f": "key2", "c": 0, "v": { "s": "key1-prereq2" } @@ -35,7 +35,7 @@ { "c": [ { - "d": { + "p": { "f": "key3", "c": 0, "v": { "s": "key1-prereq3" } @@ -53,7 +53,7 @@ { "c": [ { - "d": { + "p": { "f": "key1", "c": 0, "v": { "s": "key2-prereq1" } @@ -71,7 +71,7 @@ { "c": [ { - "d": { + "p": { "f": "key3", "c": 0, "v": { "s": "key3-prereq1" } diff --git a/src/ConfigCat.Client.Tests/data/test_override_flagdependency_v6.json b/src/ConfigCat.Client.Tests/data/test_override_flagdependency_v6.json index 0eead859..62e159e5 100644 --- a/src/ConfigCat.Client.Tests/data/test_override_flagdependency_v6.json +++ b/src/ConfigCat.Client.Tests/data/test_override_flagdependency_v6.json @@ -18,7 +18,7 @@ { "c": [ { - "d": { + "p": { "f": "mainIntFlag", "c": 0, "v": { diff --git a/src/ConfigCatClient/Models/ConditionContainer.cs b/src/ConfigCatClient/Models/ConditionContainer.cs index b0968994..6913cc29 100644 --- a/src/ConfigCatClient/Models/ConditionContainer.cs +++ b/src/ConfigCatClient/Models/ConditionContainer.cs @@ -14,9 +14,9 @@ internal struct ConditionContainer : IConditionProvider private object? condition; #if USE_NEWTONSOFT_JSON - [JsonProperty(PropertyName = "t")] + [JsonProperty(PropertyName = "u")] #else - [JsonPropertyName("t")] + [JsonPropertyName("u")] #endif public UserCondition? UserCondition { @@ -36,9 +36,9 @@ public SegmentCondition? SegmentCondition } #if USE_NEWTONSOFT_JSON - [JsonProperty(PropertyName = "d")] + [JsonProperty(PropertyName = "p")] #else - [JsonPropertyName("d")] + [JsonPropertyName("p")] #endif public PrerequisiteFlagCondition? PrerequisiteFlagCondition {