blob: 2d11062e6506d4a023ede19975a49a831142f5b6 [file] [log] [blame]
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -07001<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">
Dan O'Mearadd494642020-05-01 07:42:23 -070088 <code><a href="#test">test(name, body=None, x__xgafv=None)</a></code></p>
Sai Cheemalapatie833b792017-03-24 15:06:46 -070089<p class="firstline">Test `Source` for syntactic and semantic correctness. Issues present, if</p>
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -070090<h3>Method Details</h3>
91<div class="method">
Dan O'Mearadd494642020-05-01 07:42:23 -070092 <code class="details" id="test">test(name, body=None, x__xgafv=None)</code>
Sai Cheemalapatie833b792017-03-24 15:06:46 -070093 <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.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -070096
Sai Cheemalapatie833b792017-03-24 15:06:46 -070097The 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.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700100
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} {
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700109 allow write: if userId == request.auth.uid
Bu Sun Kim65020912020-05-20 12:08:20 -0700110 &amp;&amp; (imageName.matches(&#x27;*.png$&#x27;)
111 || imageName.matches(&#x27;*.jpg$&#x27;))
112 &amp;&amp; resource.mimeType.matches(&#x27;^image/&#x27;)
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700113 }
114 }
115
116Args:
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700117 name: string, Tests may either provide `source` or a `Ruleset` resource name.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700118
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700119For 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)
Dan O'Mearadd494642020-05-01 07:42:23 -0700124 body: object, The request body.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700125 The object takes the form of:
126
127{ # The request for FirebaseRulesService.TestRuleset.
Bu Sun Kim65020912020-05-20 12:08:20 -0700128 &quot;source&quot;: { # `Source` is one or more `File` messages comprising a logical set of rules. # Optional `Source` to be checked for correctness.
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700129 #
130 # This field must not be set when the resource name refers to a `Ruleset`.
Bu Sun Kim65020912020-05-20 12:08:20 -0700131 &quot;files&quot;: [ # `File` set constituting the `Source` bundle.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700132 { # `File` containing source content.
Bu Sun Kim65020912020-05-20 12:08:20 -0700133 &quot;content&quot;: &quot;A String&quot;, # Textual Content.
134 &quot;fingerprint&quot;: &quot;A String&quot;, # Fingerprint (e.g. github sha) associated with the `File`.
135 &quot;name&quot;: &quot;A String&quot;, # File name.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700136 },
137 ],
138 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700139 &quot;testSuite&quot;: { # `TestSuite` is a collection of `TestCase` instances that validate the logical # Inline `TestSuite` to run.
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400140 # 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.
Bu Sun Kim65020912020-05-20 12:08:20 -0700143 &quot;testCases&quot;: [ # Collection of test cases associated with the `TestSuite`.
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400144 { # `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.
Bu Sun Kim4ed7d3f2020-05-27 12:20:54 -0700153 &quot;resource&quot;: &quot;&quot;, # Optional resource value as it appears in persistent storage before the
154 # request is fulfilled.
155 #
156 # The resource type depends on the `request.path` value.
157 &quot;expectation&quot;: &quot;A String&quot;, # Test expectation.
Bu Sun Kim65020912020-05-20 12:08:20 -0700158 &quot;functionMocks&quot;: [ # Optional function mocks for service-defined functions. If not set, any
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400159 # service defined function is expected to return an error, which may or may
160 # not influence the test outcome.
161 { # Mock function definition.
162 #
163 # Mocks must refer to a function declared by the target service. The type of
164 # the function args and result will be inferred at test time. If either the
165 # arg or result values are not compatible with function type declaration, the
166 # request will be considered invalid.
167 #
168 # More than one `FunctionMock` may be provided for a given function name so
169 # long as the `Arg` matchers are distinct. There may be only one function
170 # for a given overload where all `Arg` values are `Arg.any_value`.
Bu Sun Kim4ed7d3f2020-05-27 12:20:54 -0700171 &quot;result&quot;: { # Possible result values from the function mock invocation. # The mock result of the function call.
172 &quot;value&quot;: &quot;&quot;, # The result is an actual value. The type of the value must match that
173 # of the type declared by the service.
174 &quot;undefined&quot;: { # A generic empty message that you can re-use to avoid defining duplicated # The result is undefined, meaning the result could not be computed.
175 # empty messages in your APIs. A typical example is to use it as the request
176 # or the response type of an API method. For instance:
177 #
178 # service Foo {
179 # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
180 # }
181 #
182 # The JSON representation for `Empty` is empty JSON object `{}`.
183 },
184 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700185 &quot;args&quot;: [ # The list of `Arg` values to match. The order in which the arguments are
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400186 # provided is the order in which they must appear in the function
187 # invocation.
188 { # Arg matchers for the mock function.
Bu Sun Kim65020912020-05-20 12:08:20 -0700189 &quot;exactValue&quot;: &quot;&quot;, # Argument exactly matches value provided.
190 &quot;anyValue&quot;: { # A generic empty message that you can re-use to avoid defining duplicated # Argument matches any value provided.
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400191 # empty messages in your APIs. A typical example is to use it as the request
192 # or the response type of an API method. For instance:
193 #
194 # service Foo {
195 # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
196 # }
197 #
198 # The JSON representation for `Empty` is empty JSON object `{}`.
199 },
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400200 },
201 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700202 &quot;function&quot;: &quot;A String&quot;, # The name of the function.
203 #
204 # The function name must match one provided by a service declaration.
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400205 },
206 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700207 &quot;pathEncoding&quot;: &quot;A String&quot;, # Specifies whether paths (such as request.path) are encoded and how.
208 &quot;request&quot;: &quot;&quot;, # Request context.
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400209 #
210 # The exact format of the request context is service-dependent. See the
211 # appropriate service documentation for information about the supported
212 # fields and types on the request. Minimally, all services support the
213 # following fields and types:
214 #
215 # Request field | Type
216 # ---------------|-----------------
217 # auth.uid | `string`
Dan O'Mearadd494642020-05-01 07:42:23 -0700218 # auth.token | `map&lt;string, string&gt;`
219 # headers | `map&lt;string, string&gt;`
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400220 # method | `string`
Dan O'Mearadd494642020-05-01 07:42:23 -0700221 # params | `map&lt;string, string&gt;`
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400222 # path | `string`
223 # time | `google.protobuf.Timestamp`
224 #
225 # If the request value is not well-formed for the service, the request will
226 # be rejected as an invalid argument.
Bu Sun Kim65020912020-05-20 12:08:20 -0700227 &quot;expressionReportLevel&quot;: &quot;A String&quot;, # Specifies what should be included in the response.
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400228 },
229 ],
230 },
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700231 }
232
233 x__xgafv: string, V1 error format.
234 Allowed values
235 1 - v1 error format
236 2 - v2 error format
237
238Returns:
239 An object of the form:
240
241 { # The response for FirebaseRulesService.TestRuleset.
Bu Sun Kim65020912020-05-20 12:08:20 -0700242 &quot;testResults&quot;: [ # The set of test results given the test cases in the `TestSuite`.
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700243 # The results will appear in the same order as the test cases appear in the
244 # `TestSuite`.
245 { # Test result message containing the state of the test as well as a
246 # description and source position for test failures.
Bu Sun Kim65020912020-05-20 12:08:20 -0700247 &quot;expressionReports&quot;: [ # The mapping from expression in the ruleset AST to the values they were
248 # evaluated to. Partially-nested to mirror AST structure. Note that this
249 # field is actually tracking expressions and not permission statements in
250 # contrast to the &quot;visited_expressions&quot; field above. Literal expressions
251 # are omitted.
252 { # Describes where in a file an expression is found and what it was
253 # evaluated to over the course of its use.
254 &quot;sourcePosition&quot;: { # Position in the `Source` content including its line, column number, and an # Position of expression in original rules source.
255 # index of the `File` in the `Source` message. Used for debug purposes.
Bu Sun Kim65020912020-05-20 12:08:20 -0700256 &quot;column&quot;: 42, # First column on the source line associated with the source fragment.
257 &quot;fileName&quot;: &quot;A String&quot;, # Name of the `File`.
258 &quot;currentOffset&quot;: 42, # Start position relative to the beginning of the file.
259 &quot;endOffset&quot;: 42, # End position relative to the beginning of the file.
Bu Sun Kim4ed7d3f2020-05-27 12:20:54 -0700260 &quot;line&quot;: 42, # Line number of the source fragment. 1-based.
Bu Sun Kim65020912020-05-20 12:08:20 -0700261 },
262 &quot;children&quot;: [ # Subexpressions
263 # Object with schema name: ExpressionReport
264 ],
265 &quot;values&quot;: [ # Values that this expression evaluated to when encountered.
266 { # Tuple for how many times an Expression was evaluated to a particular
267 # ExpressionValue.
268 &quot;count&quot;: 42, # The amount of times that expression returned.
269 &quot;value&quot;: &quot;&quot;, # The return value of the expression
270 },
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400271 ],
272 },
273 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700274 &quot;debugMessages&quot;: [ # Debug messages related to test execution issues encountered during
Dan O'Mearadd494642020-05-01 07:42:23 -0700275 # evaluation.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700276 #
Dan O'Mearadd494642020-05-01 07:42:23 -0700277 # Debug messages may be related to too many or too few invocations of
278 # function mocks or to runtime errors that occur during evaluation.
Bu Sun Kim715bd7f2019-06-14 16:50:42 -0700279 #
Bu Sun Kim65020912020-05-20 12:08:20 -0700280 # For example: ```Unable to read variable [name: &quot;resource&quot;]```
281 &quot;A String&quot;,
Dan O'Mearadd494642020-05-01 07:42:23 -0700282 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700283 &quot;errorPosition&quot;: { # Position in the `Source` content including its line, column number, and an # Position in the `Source` or `Ruleset` where the principle runtime error
284 # occurs.
285 #
286 # Evaluation of an expression may result in an error. Rules are deny by
287 # default, so a `DENY` expectation when an error is generated is valid.
288 # When there is a `DENY` with an error, the `SourcePosition` is returned.
289 #
290 # E.g. `error_position { line: 19 column: 37 }`
291 # index of the `File` in the `Source` message. Used for debug purposes.
Bu Sun Kim65020912020-05-20 12:08:20 -0700292 &quot;column&quot;: 42, # First column on the source line associated with the source fragment.
293 &quot;fileName&quot;: &quot;A String&quot;, # Name of the `File`.
294 &quot;currentOffset&quot;: 42, # Start position relative to the beginning of the file.
295 &quot;endOffset&quot;: 42, # End position relative to the beginning of the file.
Bu Sun Kim4ed7d3f2020-05-27 12:20:54 -0700296 &quot;line&quot;: 42, # Line number of the source fragment. 1-based.
Bu Sun Kim65020912020-05-20 12:08:20 -0700297 },
Bu Sun Kim4ed7d3f2020-05-27 12:20:54 -0700298 &quot;functionCalls&quot;: [ # The set of function calls made to service-defined methods.
299 #
300 # Function calls are included in the order in which they are encountered
301 # during evaluation, are provided for both mocked and unmocked functions,
302 # and included on the response regardless of the test `state`.
303 { # Represents a service-defined function call that was invoked during test
304 # execution.
305 &quot;function&quot;: &quot;A String&quot;, # Name of the function invoked.
306 &quot;args&quot;: [ # The arguments that were provided to the function.
307 &quot;&quot;,
308 ],
309 },
310 ],
311 &quot;visitedExpressions&quot;: [ # The set of visited permission expressions for a given test. This returns
312 # the positions and evaluation results of all visited permission
313 # expressions which were relevant to the test case, e.g.
314 # ```
315 # match /path {
316 # allow read if: &lt;expr&gt;
317 # }
318 # ```
319 # For a detailed report of the intermediate evaluation states, see the
320 # `expression_reports` field
321 { # Store the position and access outcome for an expression visited in rules.
322 &quot;value&quot;: &quot;&quot;, # The evaluated value for the visited expression, e.g. true/false
323 &quot;sourcePosition&quot;: { # Position in the `Source` content including its line, column number, and an # Position in the `Source` or `Ruleset` where an expression was visited.
324 # index of the `File` in the `Source` message. Used for debug purposes.
325 &quot;column&quot;: 42, # First column on the source line associated with the source fragment.
326 &quot;fileName&quot;: &quot;A String&quot;, # Name of the `File`.
327 &quot;currentOffset&quot;: 42, # Start position relative to the beginning of the file.
328 &quot;endOffset&quot;: 42, # End position relative to the beginning of the file.
329 &quot;line&quot;: 42, # Line number of the source fragment. 1-based.
330 },
331 },
332 ],
333 &quot;state&quot;: &quot;A String&quot;, # State of the test.
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700334 },
335 ],
Bu Sun Kim65020912020-05-20 12:08:20 -0700336 &quot;issues&quot;: [ # Syntactic and semantic `Source` issues of varying severity. Issues of
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700337 # `ERROR` severity will prevent tests from executing.
338 { # Issues include warnings, errors, and deprecation notices.
Bu Sun Kim4ed7d3f2020-05-27 12:20:54 -0700339 &quot;description&quot;: &quot;A String&quot;, # Short error description.
Bu Sun Kim65020912020-05-20 12:08:20 -0700340 &quot;sourcePosition&quot;: { # Position in the `Source` content including its line, column number, and an # Position of the issue in the `Source`.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700341 # index of the `File` in the `Source` message. Used for debug purposes.
Bu Sun Kim65020912020-05-20 12:08:20 -0700342 &quot;column&quot;: 42, # First column on the source line associated with the source fragment.
343 &quot;fileName&quot;: &quot;A String&quot;, # Name of the `File`.
344 &quot;currentOffset&quot;: 42, # Start position relative to the beginning of the file.
345 &quot;endOffset&quot;: 42, # End position relative to the beginning of the file.
Bu Sun Kim4ed7d3f2020-05-27 12:20:54 -0700346 &quot;line&quot;: 42, # Line number of the source fragment. 1-based.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700347 },
Bu Sun Kim65020912020-05-20 12:08:20 -0700348 &quot;severity&quot;: &quot;A String&quot;, # The severity of the issue.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700349 },
350 ],
351 }</pre>
352</div>
353
354</body></html>