From 5ce4f3f9f998bbcc15aef9fbfd12ca97d4a398f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:24:19 +0000 Subject: [PATCH 1/2] chore(deps): bump dd-smoke-tests/openfeature/src/test/resources/ffe-system-test-data Bumps [dd-smoke-tests/openfeature/src/test/resources/ffe-system-test-data](https://github.com/DataDog/ffe-system-test-data) from `8c4d241` to `6df74e6`. - [Commits](https://github.com/DataDog/ffe-system-test-data/compare/8c4d2410aa643aa6b97c8547ae5fe358c46b7f6f...6df74e605f7c1eed8b397dc9aa4c002691475939) --- updated-dependencies: - dependency-name: dd-smoke-tests/openfeature/src/test/resources/ffe-system-test-data dependency-version: 6df74e605f7c1eed8b397dc9aa4c002691475939 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .../openfeature/src/test/resources/ffe-system-test-data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dd-smoke-tests/openfeature/src/test/resources/ffe-system-test-data b/dd-smoke-tests/openfeature/src/test/resources/ffe-system-test-data index 8c4d2410aa6..6df74e605f7 160000 --- a/dd-smoke-tests/openfeature/src/test/resources/ffe-system-test-data +++ b/dd-smoke-tests/openfeature/src/test/resources/ffe-system-test-data @@ -1 +1 @@ -Subproject commit 8c4d2410aa643aa6b97c8547ae5fe358c46b7f6f +Subproject commit 6df74e605f7c1eed8b397dc9aa4c002691475939 From 81484981f698acc9c506676dd5291eeb07fcf726 Mon Sep 17 00:00:00 2001 From: Leo Romanovsky Date: Thu, 12 Nov 2026 19:38:41 +0000 Subject: [PATCH 2/2] Test canonical feature maps and reject unhandled expectations --- .../openfeature/CanonicalFixtureTest.java | 93 ++++++++++++++++++- 1 file changed, 91 insertions(+), 2 deletions(-) diff --git a/dd-openfeature/src/test/java/com/datadog/openfeature/CanonicalFixtureTest.java b/dd-openfeature/src/test/java/com/datadog/openfeature/CanonicalFixtureTest.java index c89e1e4ab0d..787fefa1c11 100644 --- a/dd-openfeature/src/test/java/com/datadog/openfeature/CanonicalFixtureTest.java +++ b/dd-openfeature/src/test/java/com/datadog/openfeature/CanonicalFixtureTest.java @@ -1,12 +1,18 @@ package com.datadog.openfeature; +import static com.datadog.openfeature.internal.evaluation.MetadataKeys.EVALUATION_FEATURE_PREFIX; +import static com.datadog.openfeature.internal.evaluation.MetadataKeys.EXPOSURE_FEATURE_PREFIX; +import static com.datadog.openfeature.internal.evaluation.MetadataKeys.FEATURE_PREFIX; import static java.util.Collections.emptyMap; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import com.datadog.openfeature.internal.JsonReading; @@ -24,13 +30,17 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Stream; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import org.junit.jupiter.params.provider.ValueSource; /** * Evaluates the cross-SDK canonical fixtures from the {@code ffe-system-test-data} submodule, @@ -45,6 +55,24 @@ void canonicalFixturesArePresent() throws IOException { assertThat(canonicalTestCases().size(), greaterThan(0)); } + @ValueSource(strings = {"result", "features", "flagMetadata"}) + @ParameterizedTest + void rejectsUnhandledExpectations(final String location) { + final Map result = new java.util.LinkedHashMap<>(); + result.put("value", false); + result.put("reason", "STATIC"); + if ("result".equals(location)) { + result.put("unhandledExpectation", true); + } else { + result.put(location, Map.of("unhandledExpectation", true)); + } + final AssertionError error = + assertThrows( + AssertionError.class, + () -> new FixtureCase("unsupported.json", 0, Map.of("result", result))); + assertTrue(error.getMessage().contains("unhandledExpectation")); + } + @MethodSource("canonicalTestCases") @ParameterizedTest(name = "{0}") void evaluateCanonicalFixture(final FixtureCase testCase) throws IOException { @@ -114,7 +142,7 @@ private void evaluateCanonicalFixture( assertThat(details.getValue(), equalTo(expectedValue)); assertThat(details.getReason(), equalTo(testCase.resultReason)); - if (testCase.resultVariant != null) { + if (testCase.checksVariant) { assertThat(details.getVariant(), equalTo(testCase.resultVariant)); } if (testCase.resultErrorCode != null) { @@ -136,11 +164,27 @@ private void evaluateCanonicalFixture( if (testCase.resultDoLog != null) { assertEquals(testCase.resultDoLog, metadata.get("__dd_do_log")); } - if (testCase.resultAllocationKey != null) { + if (testCase.checksAllocationKey) { assertThat( details.getFlagMetadata().getString("allocationKey"), equalTo(testCase.resultAllocationKey)); } + if (testCase.resultFeatures != null) { + assertEquals( + testCase.resultFeatures.get("HOOK"), + SplitFeatureMetadata.featuresWithPrefix(details.getFlagMetadata(), FEATURE_PREFIX), + "HOOK features for " + testCase); + assertEquals( + testCase.resultFeatures.get("EXPOSURE"), + SplitFeatureMetadata.featuresWithPrefix( + details.getFlagMetadata(), EXPOSURE_FEATURE_PREFIX), + "EXPOSURE features for " + testCase); + assertEquals( + testCase.resultFeatures.get("EVALUATION"), + SplitFeatureMetadata.featuresWithPrefix( + details.getFlagMetadata(), EVALUATION_FEATURE_PREFIX), + "EVALUATION features for " + testCase); + } } private static Object fixtureValue(final Class type, final Object value) { @@ -275,10 +319,13 @@ static final class FixtureCase { final String resultReason; final String resultErrorCode; final String resultVariant; + final boolean checksVariant; final String resultAllocationKey; + final boolean checksAllocationKey; final boolean checksSerialId; final Number resultSerialId; final Boolean resultDoLog; + final Map> resultFeatures; @SuppressWarnings("unchecked") FixtureCase(final String fileName, final int index, final Map json) { @@ -292,16 +339,58 @@ static final class FixtureCase { this.targetingKey = (String) json.get("targetingKey"); this.variationType = (String) json.get("variationType"); final Map result = (Map) json.get("result"); + requireSupportedKeys( + result, + fileName + "[" + index + "].result", + "value", + "reason", + "errorCode", + "variant", + "flagMetadata", + "serialId", + "doLog", + "features"); this.checksSerialId = result.containsKey("serialId"); this.resultSerialId = (Number) result.get("serialId"); this.resultDoLog = (Boolean) result.get("doLog"); + if (result.containsKey("doLog")) { + assertNotNull(this.resultDoLog, "A doLog expectation must be a boolean"); + } this.resultValue = normalize(result.get("value")); this.resultReason = (String) result.get("reason"); this.resultErrorCode = (String) result.get("errorCode"); + if (result.containsKey("errorCode")) { + assertNotNull(this.resultErrorCode, "An errorCode expectation must be a string"); + } + this.checksVariant = result.containsKey("variant"); this.resultVariant = (String) result.get("variant"); final Map metadata = (Map) result.get("flagMetadata"); + if (result.containsKey("flagMetadata")) { + assertNotNull(metadata, "A flagMetadata expectation must be an object"); + requireSupportedKeys(metadata, "result.flagMetadata", "allocationKey"); + } + this.checksAllocationKey = metadata != null && metadata.containsKey("allocationKey"); final Object allocationKey = metadata == null ? null : metadata.get("allocationKey"); this.resultAllocationKey = allocationKey == null ? null : String.valueOf(allocationKey); + this.resultFeatures = (Map>) normalize(result.get("features")); + if (result.containsKey("features")) { + assertNotNull(this.resultFeatures, "A features expectation must be an object"); + assertEquals( + Set.of("HOOK", "EXPOSURE", "EVALUATION"), + this.resultFeatures.keySet(), + "Feature expectations must specify all three destinations"); + for (final Map features : this.resultFeatures.values()) { + assertNotNull(features, "Each feature destination expectation must be an object"); + } + } + } + + private static void requireSupportedKeys( + final Map values, final String location, final String... supportedKeys) { + final Set unhandled = new TreeSet<>(values.keySet()); + unhandled.removeAll(Arrays.asList(supportedKeys)); + assertTrue( + unhandled.isEmpty(), () -> "Unhandled expectations in " + location + ": " + unhandled); } @Override