blob: a42f48db780e243c76cab68ae2de5ba91c8b2d92 [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">
Thomas Coffee2f245372017-03-27 10:39:26 -070088 <code><a href="#test">test(name, body, 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">
Thomas Coffee2f245372017-03-27 10:39:26 -070092 <code class="details" id="test">test(name, body, 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
110 && (imageName.matches('*.png$')
111 || imageName.matches('*.jpg$'))
112 && resource.mimeType.matches('^image/')
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)
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700124 body: object, The request body. (required)
125 The object takes the form of:
126
127{ # The request for FirebaseRulesService.TestRuleset.
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700128 "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`.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700131 "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 },
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400139 "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 "resource": "", # Optional resource value as it appears in persistent storage before the
203 # request is fulfilled.
204 #
205 # The resource type depends on the `request.path` value.
206 "request": "", # Request context.
207 #
208 # The exact format of the request context is service-dependent. See the
209 # appropriate service documentation for information about the supported
210 # fields and types on the request. Minimally, all services support the
211 # following fields and types:
212 #
213 # Request field | Type
214 # ---------------|-----------------
215 # auth.uid | `string`
216 # auth.token | `map<string, string>`
217 # headers | `map<string, string>`
218 # method | `string`
219 # params | `map<string, string>`
220 # path | `string`
221 # time | `google.protobuf.Timestamp`
222 #
223 # If the request value is not well-formed for the service, the request will
224 # be rejected as an invalid argument.
225 "expectation": "A String", # Test expectation.
226 },
227 ],
228 },
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700229 }
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.
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700240 "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 "state": "A String", # State of the test.
Thomas Coffee2f245372017-03-27 10:39:26 -0700255 "errorPosition": { # Position in the `Source` content including its line, column number, and an # Position in the `Source` or `Ruleset` where the principle runtime error
256 # occurs.
257 #
258 # Evaluation of an expression may result in an error. Rules are deny by
259 # default, so a `DENY` expectation when an error is generated is valid.
260 # When there is a `DENY` with an error, the `SourcePosition` is returned.
261 #
262 # E.g. `error_position { line: 19 column: 37 }`
263 # index of the `File` in the `Source` message. Used for debug purposes.
264 "column": 42, # First column on the source line associated with the source fragment.
265 "line": 42, # Line number of the source fragment. 1-based.
266 "fileName": "A String", # Name of the `File`.
267 },
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400268 "functionCalls": [ # The set of function calls made to service-defined methods.
269 #
270 # Function calls are included in the order in which they are encountered
271 # during evaluation, are provided for both mocked and unmocked functions,
272 # and included on the response regardless of the test `state`.
273 { # Represents a service-defined function call that was invoked during test
274 # execution.
275 "function": "A String", # Name of the function invoked.
276 "args": [ # The arguments that were provided to the function.
277 "",
278 ],
279 },
280 ],
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700281 },
282 ],
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700283 "issues": [ # Syntactic and semantic `Source` issues of varying severity. Issues of
284 # `ERROR` severity will prevent tests from executing.
285 { # Issues include warnings, errors, and deprecation notices.
286 "sourcePosition": { # Position in the `Source` content including its line, column number, and an # Position of the issue in the `Source`.
287 # index of the `File` in the `Source` message. Used for debug purposes.
288 "column": 42, # First column on the source line associated with the source fragment.
289 "line": 42, # Line number of the source fragment. 1-based.
290 "fileName": "A String", # Name of the `File`.
291 },
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700292 "description": "A String", # Short error description.
Sai Cheemalapati4ba8c232017-06-06 18:46:08 -0400293 "severity": "A String", # The severity of the issue.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700294 },
295 ],
296 }</pre>
297</div>
298
299</body></html>