blob: 50c4f3e3c4a487f9aca1d1857f1b6f9731913d45 [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 },
139 }
140
141 x__xgafv: string, V1 error format.
142 Allowed values
143 1 - v1 error format
144 2 - v2 error format
145
146Returns:
147 An object of the form:
148
149 { # The response for FirebaseRulesService.TestRuleset.
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700150 "testResults": [ # The set of test results given the test cases in the `TestSuite`.
151 # The results will appear in the same order as the test cases appear in the
152 # `TestSuite`.
153 { # Test result message containing the state of the test as well as a
154 # description and source position for test failures.
155 "debugMessages": [ # Debug messages related to test execution issues encountered during
156 # evaluation.
157 #
158 # Debug messages may be related to too many or too few invocations of
159 # function mocks or to runtime errors that occur during evaluation.
160 #
161 # For example: ```Unable to read variable [name: "resource"]```
162 "A String",
163 ],
164 "state": "A String", # State of the test.
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700165 "functionCalls": [ # The set of function calls made to service-defined methods.
166 #
167 # Function calls are included in the order in which they are encountered
168 # during evaluation, are provided for both mocked and unmocked functions,
169 # and included on the response regardless of the test `state`.
170 { # Represents a service-defined function call that was invoked during test
171 # execution.
172 "function": "A String", # Name of the function invoked.
173 "args": [ # The arguments that were provided to the function.
174 "",
175 ],
176 },
177 ],
Thomas Coffee2f245372017-03-27 10:39:26 -0700178 "errorPosition": { # Position in the `Source` content including its line, column number, and an # Position in the `Source` or `Ruleset` where the principle runtime error
179 # occurs.
180 #
181 # Evaluation of an expression may result in an error. Rules are deny by
182 # default, so a `DENY` expectation when an error is generated is valid.
183 # When there is a `DENY` with an error, the `SourcePosition` is returned.
184 #
185 # E.g. `error_position { line: 19 column: 37 }`
186 # index of the `File` in the `Source` message. Used for debug purposes.
187 "column": 42, # First column on the source line associated with the source fragment.
188 "line": 42, # Line number of the source fragment. 1-based.
189 "fileName": "A String", # Name of the `File`.
190 },
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700191 },
192 ],
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700193 "issues": [ # Syntactic and semantic `Source` issues of varying severity. Issues of
194 # `ERROR` severity will prevent tests from executing.
195 { # Issues include warnings, errors, and deprecation notices.
196 "sourcePosition": { # Position in the `Source` content including its line, column number, and an # Position of the issue in the `Source`.
197 # index of the `File` in the `Source` message. Used for debug purposes.
198 "column": 42, # First column on the source line associated with the source fragment.
199 "line": 42, # Line number of the source fragment. 1-based.
200 "fileName": "A String", # Name of the `File`.
201 },
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700202 "severity": "A String", # The severity of the issue.
Sai Cheemalapatie833b792017-03-24 15:06:46 -0700203 "description": "A String", # Short error description.
Jon Wayne Parrott0a471d32016-05-19 10:54:38 -0700204 },
205 ],
206 }</pre>
207</div>
208
209</body></html>