diff --git a/conformance/BUILD.bazel b/conformance/BUILD.bazel index 86d37cc..8c06a99 100644 --- a/conformance/BUILD.bazel +++ b/conformance/BUILD.bazel @@ -24,7 +24,10 @@ _TEST_DIRS = [ "aggregate", "aggregate_explicit_list_output", "aggregate_explicit_optional_none", + "aggregate_nested_all_rules_fall_through_to_empty", "aggregate_nested_explicit_list_double_wrapping", + "aggregate_nested_multi_branch_match", + "aggregate_nested_single_conditional_match", "aggregate_shadowed_variables", "context_pb", "first_match_nested_aggregate", diff --git a/conformance/testdata/aggregate_nested_all_rules_fall_through_to_empty/config.yaml b/conformance/testdata/aggregate_nested_all_rules_fall_through_to_empty/config.yaml new file mode 100644 index 0000000..f36fa4d --- /dev/null +++ b/conformance/testdata/aggregate_nested_all_rules_fall_through_to_empty/config.yaml @@ -0,0 +1,18 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: "aggregate_nested_all_rules_fall_through_to_empty" +variables: + - name: "x" + type_name: "int" diff --git a/conformance/testdata/aggregate_nested_all_rules_fall_through_to_empty/policy.yaml b/conformance/testdata/aggregate_nested_all_rules_fall_through_to_empty/policy.yaml new file mode 100644 index 0000000..8309f6c --- /dev/null +++ b/conformance/testdata/aggregate_nested_all_rules_fall_through_to_empty/policy.yaml @@ -0,0 +1,27 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: aggregate_nested_all_rules_fall_through_to_empty +rule: + aggregate: + - rule: + match: + - condition: "x == 1" + output: "'ONE'" + - condition: "x == 2" + output: "'TWO'" + - rule: + match: + - condition: "x == 3" + output: "'THREE'" diff --git a/conformance/testdata/aggregate_nested_all_rules_fall_through_to_empty/tests.yaml b/conformance/testdata/aggregate_nested_all_rules_fall_through_to_empty/tests.yaml new file mode 100644 index 0000000..bbff036 --- /dev/null +++ b/conformance/testdata/aggregate_nested_all_rules_fall_through_to_empty/tests.yaml @@ -0,0 +1,42 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +description: Conformance test for multiple nested match sub-rules under aggregate falling through to empty list +section: + - name: "basic" + tests: + - name: "first_rule_match_one" + input: + x: + value: 1 + output: + value: ["ONE"] + - name: "first_rule_match_two" + input: + x: + value: 2 + output: + value: ["TWO"] + - name: "second_rule_match_three" + input: + x: + value: 3 + output: + value: ["THREE"] + - name: "all_rules_fall_through_to_empty" + input: + x: + value: 99 + output: + value: [] diff --git a/conformance/testdata/aggregate_nested_multi_branch_match/config.yaml b/conformance/testdata/aggregate_nested_multi_branch_match/config.yaml new file mode 100644 index 0000000..45dc015 --- /dev/null +++ b/conformance/testdata/aggregate_nested_multi_branch_match/config.yaml @@ -0,0 +1,20 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: "aggregate_nested_multi_branch_match" +variables: + - name: "cond" + type_name: "bool" + - name: "x" + type_name: "int" diff --git a/conformance/testdata/aggregate_nested_multi_branch_match/policy.yaml b/conformance/testdata/aggregate_nested_multi_branch_match/policy.yaml new file mode 100644 index 0000000..22487db --- /dev/null +++ b/conformance/testdata/aggregate_nested_multi_branch_match/policy.yaml @@ -0,0 +1,26 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: aggregate_nested_multi_branch_match +rule: + aggregate: + - condition: "cond" + rule: + match: + - condition: "x > 10" + output: "'HIGH'" + - condition: "x > 0" + output: "'LOW'" + - condition: "true" + output: "'DEFAULT'" diff --git a/conformance/testdata/aggregate_nested_multi_branch_match/tests.yaml b/conformance/testdata/aggregate_nested_multi_branch_match/tests.yaml new file mode 100644 index 0000000..6970bdc --- /dev/null +++ b/conformance/testdata/aggregate_nested_multi_branch_match/tests.yaml @@ -0,0 +1,50 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +description: Conformance test for multi-branch nested match rule with optional fallback under aggregate +section: + - name: "basic" + tests: + - name: "first_branch_match" + input: + cond: + value: true + x: + value: 15 + output: + value: ["HIGH", "DEFAULT"] + - name: "second_branch_match" + input: + cond: + value: true + x: + value: 5 + output: + value: ["LOW", "DEFAULT"] + - name: "nested_fallback_to_empty" + input: + cond: + value: true + x: + value: -1 + output: + value: ["DEFAULT"] + - name: "outer_condition_false" + input: + cond: + value: false + x: + value: 15 + output: + value: ["DEFAULT"] diff --git a/conformance/testdata/aggregate_nested_single_conditional_match/config.yaml b/conformance/testdata/aggregate_nested_single_conditional_match/config.yaml new file mode 100644 index 0000000..1bf2b7a --- /dev/null +++ b/conformance/testdata/aggregate_nested_single_conditional_match/config.yaml @@ -0,0 +1,18 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: "aggregate_nested_single_conditional_match" +variables: + - name: "x" + type_name: "int" diff --git a/conformance/testdata/aggregate_nested_single_conditional_match/policy.yaml b/conformance/testdata/aggregate_nested_single_conditional_match/policy.yaml new file mode 100644 index 0000000..f9f1246 --- /dev/null +++ b/conformance/testdata/aggregate_nested_single_conditional_match/policy.yaml @@ -0,0 +1,22 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: aggregate_nested_single_conditional_match +rule: + aggregate: + - condition: "true" + rule: + match: + - condition: "x > 10" + output: "'GT10'" diff --git a/conformance/testdata/aggregate_nested_single_conditional_match/tests.yaml b/conformance/testdata/aggregate_nested_single_conditional_match/tests.yaml new file mode 100644 index 0000000..00acc52 --- /dev/null +++ b/conformance/testdata/aggregate_nested_single_conditional_match/tests.yaml @@ -0,0 +1,30 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +description: Conformance test for single conditional match nested inside aggregate +section: + - name: "basic" + tests: + - name: "condition_true" + input: + x: + value: 15 + output: + value: ["GT10"] + - name: "condition_false" + input: + x: + value: 5 + output: + value: []