Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions evaluator/flags/testkit-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,50 @@
"targeting": {
"sem_ver": [{"var": "version"}, "="]
}
},
"disabled-boolean-flag": {
"state": "DISABLED",
"variants": {
"on": true,
"off": false
},
"defaultVariant": "on"
},
"disabled-string-flag": {
"state": "DISABLED",
"variants": {
"greeting": "hi",
"parting": "bye"
},
"defaultVariant": "greeting"
},
"disabled-integer-flag": {
"state": "DISABLED",
"variants": {
"one": 1,
"ten": 10
},
"defaultVariant": "ten"
},
"disabled-float-flag": {
"state": "DISABLED",
"variants": {
"tenth": 0.1,
"half": 0.5
},
"defaultVariant": "half"
},
"disabled-object-flag": {
"state": "DISABLED",
"variants": {
"empty": {},
"template": {
"showImages": true,
"title": "Check out these pics!",
"imagesPerPage": 100
}
},
"defaultVariant": "template"
}
},
"$evaluators": {
Expand Down
22 changes: 22 additions & 0 deletions evaluator/gherkin/disabled.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@disabled
Feature: Evaluator disabled flag evaluation

# Validates that disabled flags resolve with reason=DISABLED. The evaluator
# substitutes the caller-provided default value and omits the variant.
# Flags are configured in evaluator/flags/testkit-flags.json.
# Relates to: https://github.com/open-feature/flagd/issues/1965

Scenario Outline: Resolve disabled flag returns reason DISABLED with the default value
Given an evaluator
And a <type>-flag with key "<key>" and a fallback value "<default>"
When the flag was evaluated with details
Then the resolved details value should be "<default>"
And the reason should be "DISABLED"

Examples:
| key | type | default |
| disabled-boolean-flag | Boolean | false |
| disabled-string-flag | String | bye |
| disabled-integer-flag | Integer | 1 |
| disabled-float-flag | Float | 0.1 |
| disabled-object-flag | Object | {} |
2 changes: 1 addition & 1 deletion flagd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG FLAGD_BASE_IMAGE=ghcr.io/open-feature/flagd:v0.15.5
ARG FLAGD_BASE_IMAGE=ghcr.io/open-feature/flagd:v0.16.0
ARG TARGETARCH

FROM ${FLAGD_BASE_IMAGE} AS flagd
Expand Down
56 changes: 56 additions & 0 deletions flags/disabled-flags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"flags": {
"disabled-boolean-flag": {
"state": "DISABLED",
"variants": {
"on": true,
"off": false
},
"defaultVariant": "on"
},
"disabled-string-flag": {
"state": "DISABLED",
"variants": {
"greeting": "hi",
"parting": "bye"
},
"defaultVariant": "greeting"
},
"disabled-integer-flag": {
"state": "DISABLED",
"variants": {
"one": 1,
"ten": 10
},
"defaultVariant": "ten"
},
"disabled-float-flag": {
"state": "DISABLED",
"variants": {
"tenth": 0.1,
"half": 0.5
},
"defaultVariant": "half"
},
"disabled-object-flag": {
"state": "DISABLED",
"variants": {
"empty": {},
"template": {
"showImages": true,
"title": "Check out these pics!",
"imagesPerPage": 100
}
},
"defaultVariant": "template"
},
"cross-flagset-flag": {
"state": "DISABLED",
"variants": {
"on": true,
"off": false
},
"defaultVariant": "on"
}
}
Comment thread
jonathannorris marked this conversation as resolved.
}
11 changes: 11 additions & 0 deletions flags/selector-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
"bar": "bar"
},
"defaultVariant": "foo"
},
"cross-flagset-flag": {
"state": "ENABLED",
"variants": {
"on": true,
"off": false
},
"defaultVariant": "on"
}
},
"metadata": {
"flagSetId": "selector-set"
}
}
37 changes: 37 additions & 0 deletions gherkin/disabled.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@disabled @in-process @rpc
Feature: Disabled flag evaluation
Comment thread
jonathannorris marked this conversation as resolved.

# Test coverage for disabled flag behavior. A flag with state=DISABLED resolves
# successfully with reason=DISABLED; the evaluator substitutes the caller-provided
# default value and omits the variant.
# Relates to: https://github.com/open-feature/flagd/issues/1965

Scenario Outline: Evaluating a disabled flag returns reason DISABLED and code default
Given an option "cache" of type "CacheType" with value "disabled"
And a stable flagd provider
Comment thread
jonathannorris marked this conversation as resolved.
And a <type>-flag with key "<key>" and a default value "<default>"
When the flag was evaluated with details
Then the resolved details value should be "<default>"
And the reason should be "DISABLED"

Examples:
| key | type | default |
| disabled-boolean-flag | Boolean | false |
| disabled-string-flag | String | bye |
| disabled-integer-flag | Integer | 1 |
| disabled-float-flag | Float | 0.1 |
Comment thread
jonathannorris marked this conversation as resolved.
Comment thread
jonathannorris marked this conversation as resolved.
| disabled-object-flag | Object | {} |

Scenario Outline: Flag disabled in one flag set, enabled in another
Given an option "cache" of type "CacheType" with value "disabled"
And an option "selector" of type "String" with value "<selector>"
And a stable flagd provider
And a Boolean-flag with key "cross-flagset-flag" and a default value "false"
When the flag was evaluated with details
Then the resolved details value should be "<resolved_value>"
And the reason should be "<reason>"

Examples:
| selector | resolved_value | reason |
| flags/allFlags.json | false | DISABLED |
| rawflags/selector-flags.json | true | STATIC |
Loading