| 1 | // Copyright 2024 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package policy |
| 16 | |
| 17 | // TestSuite describes a set of tests divided by section. |
| 18 | // |
| 19 | // Deprecated: Use google3/third_party/cel/go/test/suite.go instead. |
| 20 | type TestSuite struct { |
| 21 | Description string `yaml:"description"` |
| 22 | Sections []*TestSection `yaml:"section"` |
| 23 | } |
| 24 | |
| 25 | // TestSection describes a related set of tests associated with a behavior. |
| 26 | type TestSection struct { |
| 27 | Name string `yaml:"name"` |
| 28 | Tests []*TestCase `yaml:"tests"` |
| 29 | } |
| 30 | |
| 31 | // TestCase describes a named test scenario with a set of inputs and expected outputs. |
| 32 | // |
| 33 | // Note, when a test requires additional functions to be provided to execute, the test harness |
| 34 | // must supply these functions. |
| 35 | type TestCase struct { |
| 36 | Name string `yaml:"name"` |
| 37 | Input map[string]TestInput `yaml:"input"` |
| 38 | Output string `yaml:"output"` |
| 39 | } |
| 40 | |
| 41 | // TestInput represents an input literal value or expression. |
| 42 | type TestInput struct { |
| 43 | // Value is a simple literal value. |
| 44 | Value any `yaml:"value"` |
| 45 | |
| 46 | // Expr is a CEL expression based input. |
| 47 | Expr string `yaml:"expr"` |
| 48 | |
| 49 | // ContextExpr is a CEL expression which is used as cel.ContextProtoVars |
| 50 | ContextExpr string `yaml:"context_expr"` |
| 51 | } |