forked from open-policy-agent/opa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
topdown: Add urlquery.decode_object builtin
This builtin is the reverse of the encode_object builtin and makes it easier to use the URI query parameters in policies Fixes open-policy-agent#2647 Signed-off-by: Frederic <frederic.vanreet@icloud.com>
- Loading branch information
Showing
5 changed files
with
96 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
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
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
34 changes: 34 additions & 0 deletions
34
test/cases/testdata/urlbuiltins/test-urlbuiltins-1076.yaml
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,34 @@ | ||
cases: | ||
- modules: | ||
- | | ||
package decode_object | ||
p = x { | ||
x = urlquery.decode_object("a=value_a1&b=value_b&a=value_a2") | ||
} | ||
note: urlbuiltins/decode_object multiple | ||
query: data.decode_object.p = x | ||
want_result: | ||
- x: {"a": ["value_a1", "value_a2"], "b": ["value_b"]} | ||
- modules: | ||
- | | ||
package decode_object | ||
p = x { | ||
x = urlquery.decode_object("a=value_a1&b") | ||
} | ||
note: urlbuiltins/decode_object empty parameter | ||
query: data.decode_object.p = x | ||
want_result: | ||
- x: {"a": ["value_a1"], "b": [""]} | ||
- modules: | ||
- | | ||
package decode_object | ||
p = x { | ||
x = urlquery.decode_object("") | ||
} | ||
note: urlbuiltins/decode_object empty string | ||
query: data.decode_object.p = x | ||
want_result: | ||
- x: {} |
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