1<html><body> 2<style> 3 4body, h1, h2, h3, div, span, p, pre, a { 5 margin: 0; 6 padding: 0; 7 border: 0; 8 font-weight: inherit; 9 font-style: inherit; 10 font-size: 100%; 11 font-family: inherit; 12 vertical-align: baseline; 13} 14 15body { 16 font-size: 13px; 17 padding: 1em; 18} 19 20h1 { 21 font-size: 26px; 22 margin-bottom: 1em; 23} 24 25h2 { 26 font-size: 24px; 27 margin-bottom: 1em; 28} 29 30h3 { 31 font-size: 20px; 32 margin-bottom: 1em; 33 margin-top: 1em; 34} 35 36pre, code { 37 line-height: 1.5; 38 font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; 39} 40 41pre { 42 margin-top: 0.5em; 43} 44 45h1, h2, h3, p { 46 font-family: Arial, sans serif; 47} 48 49h1, h2, h3 { 50 border-bottom: solid #CCC 1px; 51} 52 53.toc_element { 54 margin-top: 0.5em; 55} 56 57.firstline { 58 margin-left: 2 em; 59} 60 61.method { 62 margin-top: 1em; 63 border: solid 1px #CCC; 64 padding: 1em; 65 background: #EEE; 66} 67 68.details { 69 font-weight: bold; 70 font-size: 14px; 71} 72 73</style> 74 75<h1><a href="firebaserules_v1.html">Firebase Rules API</a> . <a href="firebaserules_v1.projects.html">projects</a></h1> 76<h2>Instance Methods</h2> 77<p class="toc_element"> 78 <code><a href="firebaserules_v1.projects.releases.html">releases()</a></code> 79</p> 80<p class="firstline">Returns the releases Resource.</p> 81 82<p class="toc_element"> 83 <code><a href="firebaserules_v1.projects.rulesets.html">rulesets()</a></code> 84</p> 85<p class="firstline">Returns the rulesets Resource.</p> 86 87<p class="toc_element"> 88 <code><a href="#test">test(name, body, x__xgafv=None)</a></code></p> 89<p class="firstline">Test `Source` for syntactic and semantic correctness. Issues present, if</p> 90<h3>Method Details</h3> 91<div class="method"> 92 <code class="details" id="test">test(name, body, x__xgafv=None)</code> 93 <pre>Test `Source` for syntactic and semantic correctness. Issues present, if 94any, will be returned to the caller with a description, severity, and 95source location. 96 97The test method may be executed with `Source` or a `Ruleset` name. 98Passing `Source` is useful for unit testing new rules. Passing a `Ruleset` 99name is useful for regression testing an existing rule. 100 101The following is an example of `Source` that permits users to upload images 102to a bucket bearing their user id and matching the correct metadata: 103 104_*Example*_ 105 106 // Users are allowed to subscribe and unsubscribe to the blog. 107 service firebase.storage { 108 match /users/{userId}/images/{imageName} { 109 allow write: if userId == request.auth.uid 110 && (imageName.matches('*.png$') 111 || imageName.matches('*.jpg$')) 112 && resource.mimeType.matches('^image/') 113 } 114 } 115 116Args: 117 name: string, Tests may either provide `source` or a `Ruleset` resource name. 118 119For tests against `source`, the resource name must refer to the project: 120Format: `projects/{project_id}` 121 122For tests against a `Ruleset`, this must be the `Ruleset` resource name: 123Format: `projects/{project_id}/rulesets/{ruleset_id}` (required) 124 body: object, The request body. (required) 125 The object takes the form of: 126 127{ # The request for FirebaseRulesService.TestRuleset. 128 "source": { # `Source` is one or more `File` messages comprising a logical set of rules. # Optional `Source` to be checked for correctness. 129 # 130 # This field must not be set when the resource name refers to a `Ruleset`. 131 "files": [ # `File` set constituting the `Source` bundle. 132 { # `File` containing source content. 133 "content": "A String", # Textual Content. 134 "name": "A String", # File name. 135 "fingerprint": "A String", # Fingerprint (e.g. github sha) associated with the `File`. 136 }, 137 ], 138 }, 139 "testSuite": { # `TestSuite` is a collection of `TestCase` instances that validate the logical # Inline `TestSuite` to run. 140 # correctness of a `Ruleset`. The `TestSuite` may be referenced in-line within 141 # a `TestRuleset` invocation or as part of a `Release` object as a pre-release 142 # check. 143 "testCases": [ # Collection of test cases associated with the `TestSuite`. 144 { # `TestCase` messages provide the request context and an expectation as to 145 # whether the given context will be allowed or denied. Test cases may specify 146 # the `request`, `resource`, and `function_mocks` to mock a function call to 147 # a service-provided function. 148 # 149 # The `request` object represents context present at request-time. 150 # 151 # The `resource` is the value of the target resource as it appears in 152 # persistent storage before the request is executed. 153 "functionMocks": [ # Optional function mocks for service-defined functions. If not set, any 154 # service defined function is expected to return an error, which may or may 155 # not influence the test outcome. 156 { # Mock function definition. 157 # 158 # Mocks must refer to a function declared by the target service. The type of 159 # the function args and result will be inferred at test time. If either the 160 # arg or result values are not compatible with function type declaration, the 161 # request will be considered invalid. 162 # 163 # More than one `FunctionMock` may be provided for a given function name so 164 # long as the `Arg` matchers are distinct. There may be only one function 165 # for a given overload where all `Arg` values are `Arg.any_value`. 166 "function": "A String", # The name of the function. 167 # 168 # The function name must match one provided by a service declaration. 169 "args": [ # The list of `Arg` values to match. The order in which the arguments are 170 # provided is the order in which they must appear in the function 171 # invocation. 172 { # Arg matchers for the mock function. 173 "anyValue": { # A generic empty message that you can re-use to avoid defining duplicated # Argument matches any value provided. 174 # empty messages in your APIs. A typical example is to use it as the request 175 # or the response type of an API method. For instance: 176 # 177 # service Foo { 178 # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); 179 # } 180 # 181 # The JSON representation for `Empty` is empty JSON object `{}`. 182 }, 183 "exactValue": "", # Argument exactly matches value provided. 184 }, 185 ], 186 "result": { # Possible result values from the function mock invocation. # The mock result of the function call. 187 "undefined": { # A generic empty message that you can re-use to avoid defining duplicated # The result is undefined, meaning the result could not be computed. 188 # empty messages in your APIs. A typical example is to use it as the request 189 # or the response type of an API method. For instance: 190 # 191 # service Foo { 192 # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); 193 # } 194 # 195 # The JSON representation for `Empty` is empty JSON object `{}`. 196 }, 197 "value": "", # The result is an actual value. The type of the value must match that 198 # of the type declared by the service. 199 }, 200 }, 201 ], 202 "request": "", # Request context. 203 # 204 # The exact format of the request context is service-dependent. See the 205 # appropriate service documentation for information about the supported 206 # fields and types on the request. Minimally, all services support the 207 # following fields and types: 208 # 209 # Request field | Type 210 # ---------------|----------------- 211 # auth.uid | `string` 212 # auth.token | `map<string, string>` 213 # headers | `map<string, string>` 214 # method | `string` 215 # params | `map<string, string>` 216 # path | `string` 217 # time | `google.protobuf.Timestamp` 218 # 219 # If the request value is not well-formed for the service, the request will 220 # be rejected as an invalid argument. 221 "resource": "", # Optional resource value as it appears in persistent storage before the 222 # request is fulfilled. 223 # 224 # The resource type depends on the `request.path` value. 225 "expectation": "A String", # Test expectation. 226 }, 227 ], 228 }, 229 } 230 231 x__xgafv: string, V1 error format. 232 Allowed values 233 1 - v1 error format 234 2 - v2 error format 235 236Returns: 237 An object of the form: 238 239 { # The response for FirebaseRulesService.TestRuleset. 240 "testResults": [ # The set of test results given the test cases in the `TestSuite`. 241 # The results will appear in the same order as the test cases appear in the 242 # `TestSuite`. 243 { # Test result message containing the state of the test as well as a 244 # description and source position for test failures. 245 "debugMessages": [ # Debug messages related to test execution issues encountered during 246 # evaluation. 247 # 248 # Debug messages may be related to too many or too few invocations of 249 # function mocks or to runtime errors that occur during evaluation. 250 # 251 # For example: ```Unable to read variable [name: "resource"]``` 252 "A String", 253 ], 254 "visitedExpressions": [ # The set of visited permission expressions for a given test. This returns 255 # the positions and evaluation results of all visited permission 256 # expressions which were relevant to the test case, e.g. 257 # ``` 258 # match /path { 259 # allow read if: <expr> 260 # } 261 # ``` 262 # For a detailed report of the intermediate evaluation states, see the 263 # `expression_reports` field 264 { # Store the position and access outcome for an expression visited in rules. 265 "sourcePosition": { # Position in the `Source` content including its line, column number, and an # Position in the `Source` or `Ruleset` where an expression was visited. 266 # index of the `File` in the `Source` message. Used for debug purposes. 267 "column": 42, # First column on the source line associated with the source fragment. 268 "line": 42, # Line number of the source fragment. 1-based. 269 "fileName": "A String", # Name of the `File`. 270 }, 271 "value": "", # The evaluated value for the visited expression, e.g. true/false 272 }, 273 ], 274 "state": "A String", # State of the test. 275 "functionCalls": [ # The set of function calls made to service-defined methods. 276 # 277 # Function calls are included in the order in which they are encountered 278 # during evaluation, are provided for both mocked and unmocked functions, 279 # and included on the response regardless of the test `state`. 280 { # Represents a service-defined function call that was invoked during test 281 # execution. 282 "function": "A String", # Name of the function invoked. 283 "args": [ # The arguments that were provided to the function. 284 "", 285 ], 286 }, 287 ], 288 "errorPosition": { # Position in the `Source` content including its line, column number, and an # Position in the `Source` or `Ruleset` where the principle runtime error 289 # occurs. 290 # 291 # Evaluation of an expression may result in an error. Rules are deny by 292 # default, so a `DENY` expectation when an error is generated is valid. 293 # When there is a `DENY` with an error, the `SourcePosition` is returned. 294 # 295 # E.g. `error_position { line: 19 column: 37 }` 296 # index of the `File` in the `Source` message. Used for debug purposes. 297 "column": 42, # First column on the source line associated with the source fragment. 298 "line": 42, # Line number of the source fragment. 1-based. 299 "fileName": "A String", # Name of the `File`. 300 }, 301 }, 302 ], 303 "issues": [ # Syntactic and semantic `Source` issues of varying severity. Issues of 304 # `ERROR` severity will prevent tests from executing. 305 { # Issues include warnings, errors, and deprecation notices. 306 "sourcePosition": { # Position in the `Source` content including its line, column number, and an # Position of the issue in the `Source`. 307 # index of the `File` in the `Source` message. Used for debug purposes. 308 "column": 42, # First column on the source line associated with the source fragment. 309 "line": 42, # Line number of the source fragment. 1-based. 310 "fileName": "A String", # Name of the `File`. 311 }, 312 "severity": "A String", # The severity of the issue. 313 "description": "A String", # Short error description. 314 }, 315 ], 316 }</pre> 317</div> 318 319</body></html>