-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Todd Baert <[email protected]>
- Loading branch information
Showing
2 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
{ | ||
"flags": { | ||
"fractional-flag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"clubs": "clubs", | ||
"diamonds": "diamonds", | ||
"hearts": "hearts", | ||
"spades": "spades", | ||
"wild": "wild" | ||
}, | ||
"defaultVariant": "wild", | ||
"targeting": { | ||
"fractional": [ | ||
{ "var": "user.name" }, | ||
[ "clubs", 25 ], | ||
[ "diamonds", 25 ], | ||
[ "hearts", 25 ], | ||
[ "spades", 25 ] | ||
] | ||
} | ||
}, | ||
"starts-ends-flag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"prefix": "prefix", | ||
"postfix": "postfix", | ||
"none": "none" | ||
}, | ||
"defaultVariant": "none", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"starts_with": [{"var": "id"}, "abc"] | ||
}, | ||
"prefix", { | ||
"if": [ | ||
{ | ||
"ends_with": [{"var": "id"}, "xyz"] | ||
}, | ||
"postfix", "none" | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"equal-greater-lesser-version-flag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"equal": "equal", | ||
"greater": "greater", | ||
"lesser": "lesser", | ||
"invalid": "invalid" | ||
}, | ||
"defaultVariant": "invalid", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"sem_ver": [{"var": "version"}, "=", "2.0.0"] | ||
}, | ||
"equal", { | ||
"if": [ | ||
{ | ||
"sem_ver": [{"var": "version"}, ">", "2.0.0"] | ||
}, | ||
"greater", { | ||
"if": [ | ||
{ | ||
"sem_ver": [{"var": "version"}, "<", "2.0.0"] | ||
}, | ||
"lesser", "none" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"major-minor-version-flag": { | ||
"state": "ENABLED", | ||
"variants": { | ||
"minor": "minor", | ||
"major": "major", | ||
"none": "none" | ||
}, | ||
"defaultVariant": "none", | ||
"targeting": { | ||
"if": [ | ||
{ | ||
"sem_ver": [{"var": "version"}, "~", "3.0.0"] | ||
}, | ||
"minor", { | ||
"if": [ | ||
{ | ||
"sem_ver": [{"var": "version"}, "^", "3.0.0"] | ||
}, | ||
"major", "none" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Feature: flagd providers | ||
|
||
# This test suite contains scenarios to test flagd providers (both RPC and in-process). | ||
# It's associated with the flags configured in flags/custom-ops.json and flags/zero-flags.json | ||
# It should be used in conjunection with the suites supplied by the OpenFeature specification | ||
|
||
Background: | ||
Given a flagd provider is set | ||
|
||
# events | ||
Scenario: Provider ready event | ||
When a PROVIDER_READY handler is added | ||
Then the PROVIDER_READY handler must run | ||
|
||
Scenario: Flag change event | ||
When a PROVIDER_CONFIGURATION_CHANGED handler is added | ||
And a flag with key "changing-flag" is modified | ||
Then the PROVIDER_CONFIGURATION_CHANGED handler must run | ||
And the event details must indicate "changing-flag" was altered | ||
|
||
# zero evaluation | ||
Scenario: Resolves boolean zero value | ||
When a boolean flag with key "boolean-zero" is evaluated with default value "true" | ||
Then the resolved boolean value should be "false" | ||
|
||
Scenario: Resolves string zero value | ||
When a string flag with key "string-zero" is evaluated with default value "hi" | ||
Then the resolved string value should be "" | ||
|
||
Scenario: Resolves integer zero value | ||
When an integer flag with key "integer-zero" is evaluated with default value 1 | ||
Then the resolved integer value should be 0 | ||
|
||
Scenario: Resolves float zero value | ||
When a float flag with key "float-flag" is evaluated with default value 0.1 | ||
Then the resolved float value should be 0.0 | ||
|
||
# custom operators | ||
Scenario Outline: Fractional operator | ||
When a string flag with key "fractional-flag" is evaluated with default value "fallback" | ||
And a context containing a nested property with outer key "user" and inner key "name", with value <name> | ||
Then the returned value should be <value> | ||
Examples: | ||
|name|value| | ||
|jack|clubs| | ||
|queen|diamonds| | ||
|ace|hearts| | ||
|joker|spades| | ||
|
||
Scenario Outline: Substring operators | ||
When a string flag with key "starts-ends-flag" is evaluated with default value "fallback" | ||
And a context containing a key "id", with value <id> | ||
Then the returned value should be <value> | ||
Examples: | ||
|id|value| | ||
|abcdef|prefix| | ||
|uvwxyz|postfix| | ||
|abcxyz|prefix| | ||
|lmnopq|nomatch| | ||
|
||
Scenario Outline: Semantic version operator numeric comparision | ||
When a string flag with key "equal-greater-lesser-version-flag" is evaluated with default value "fallback" | ||
And a context containing a key "version", with value <version> | ||
Then the returned value should be <value> | ||
Examples: | ||
|version|value| | ||
|2.0.0|equal| | ||
|2.1.0|greater| | ||
|1.9.0|lesser| | ||
|2.0.0-alpha|lesser| | ||
|2.0.0.0|invalid| | ||
|
||
Scenario Outline: Semantic version operator semantic comparision | ||
When a string flag with key "major-minor-version-flag" is evaluated with default value "fallback" | ||
And a context containing a key "version", with value <version> | ||
Then the returned value should be <value> | ||
Examples: | ||
|version|value| | ||
|3.0.1|minor| | ||
|3.1.0|major| | ||
|4.0.0|none| |