Jon Wayne Parrott | 0a471d3 | 2016-05-19 10:54:38 -0700 | [diff] [blame] | 1 | <html><body> |
| 2 | <style> |
| 3 | |
| 4 | body, 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 | |
| 15 | body { |
| 16 | font-size: 13px; |
| 17 | padding: 1em; |
| 18 | } |
| 19 | |
| 20 | h1 { |
| 21 | font-size: 26px; |
| 22 | margin-bottom: 1em; |
| 23 | } |
| 24 | |
| 25 | h2 { |
| 26 | font-size: 24px; |
| 27 | margin-bottom: 1em; |
| 28 | } |
| 29 | |
| 30 | h3 { |
| 31 | font-size: 20px; |
| 32 | margin-bottom: 1em; |
| 33 | margin-top: 1em; |
| 34 | } |
| 35 | |
| 36 | pre, code { |
| 37 | line-height: 1.5; |
| 38 | font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace; |
| 39 | } |
| 40 | |
| 41 | pre { |
| 42 | margin-top: 0.5em; |
| 43 | } |
| 44 | |
| 45 | h1, h2, h3, p { |
| 46 | font-family: Arial, sans serif; |
| 47 | } |
| 48 | |
| 49 | h1, 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 Coffee | 2f24537 | 2017-03-27 10:39:26 -0700 | [diff] [blame^] | 88 | <code><a href="#test">test(name, body, x__xgafv=None)</a></code></p> |
Sai Cheemalapati | e833b79 | 2017-03-24 15:06:46 -0700 | [diff] [blame] | 89 | <p class="firstline">Test `Source` for syntactic and semantic correctness. Issues present, if</p> |
Jon Wayne Parrott | 0a471d3 | 2016-05-19 10:54:38 -0700 | [diff] [blame] | 90 | <h3>Method Details</h3> |
| 91 | <div class="method"> |
Thomas Coffee | 2f24537 | 2017-03-27 10:39:26 -0700 | [diff] [blame^] | 92 | <code class="details" id="test">test(name, body, x__xgafv=None)</code> |
Sai Cheemalapati | e833b79 | 2017-03-24 15:06:46 -0700 | [diff] [blame] | 93 | <pre>Test `Source` for syntactic and semantic correctness. Issues present, if |
| 94 | any, will be returned to the caller with a description, severity, and |
| 95 | source location. |
Jon Wayne Parrott | 0a471d3 | 2016-05-19 10:54:38 -0700 | [diff] [blame] | 96 | |
Sai Cheemalapati | e833b79 | 2017-03-24 15:06:46 -0700 | [diff] [blame] | 97 | The test method may be executed with `Source` or a `Ruleset` name. |
| 98 | Passing `Source` is useful for unit testing new rules. Passing a `Ruleset` |
| 99 | name is useful for regression testing an existing rule. |
Jon Wayne Parrott | 0a471d3 | 2016-05-19 10:54:38 -0700 | [diff] [blame] | 100 | |
| 101 | The following is an example of `Source` that permits users to upload images |
| 102 | to 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 Cheemalapati | e833b79 | 2017-03-24 15:06:46 -0700 | [diff] [blame] | 109 | allow write: if userId == request.auth.uid |
| 110 | && (imageName.matches('*.png$') |
| 111 | || imageName.matches('*.jpg$')) |
| 112 | && resource.mimeType.matches('^image/') |
Jon Wayne Parrott | 0a471d3 | 2016-05-19 10:54:38 -0700 | [diff] [blame] | 113 | } |
| 114 | } |
| 115 | |
| 116 | Args: |
Sai Cheemalapati | e833b79 | 2017-03-24 15:06:46 -0700 | [diff] [blame] | 117 | name: string, Tests may either provide `source` or a `Ruleset` resource name. |
Jon Wayne Parrott | 0a471d3 | 2016-05-19 10:54:38 -0700 | [diff] [blame] | 118 | |
Sai Cheemalapati | e833b79 | 2017-03-24 15:06:46 -0700 | [diff] [blame] | 119 | For tests against `source`, the resource name must refer to the project: |
| 120 | Format: `projects/{project_id}` |
| 121 | |
| 122 | For tests against a `Ruleset`, this must be the `Ruleset` resource name: |
| 123 | Format: `projects/{project_id}/rulesets/{ruleset_id}` (required) |
Jon Wayne Parrott | 0a471d3 | 2016-05-19 10:54:38 -0700 | [diff] [blame] | 124 | body: object, The request body. (required) |
| 125 | The object takes the form of: |
| 126 | |
| 127 | { # The request for FirebaseRulesService.TestRuleset. |
Sai Cheemalapati | e833b79 | 2017-03-24 15:06:46 -0700 | [diff] [blame] | 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`. |
Jon Wayne Parrott | 0a471d3 | 2016-05-19 10:54:38 -0700 | [diff] [blame] | 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 | } |
| 140 | |
| 141 | x__xgafv: string, V1 error format. |
| 142 | Allowed values |
| 143 | 1 - v1 error format |
| 144 | 2 - v2 error format |
| 145 | |
| 146 | Returns: |
| 147 | An object of the form: |
| 148 | |
| 149 | { # The response for FirebaseRulesService.TestRuleset. |
Sai Cheemalapati | e833b79 | 2017-03-24 15:06:46 -0700 | [diff] [blame] | 150 | "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 Cheemalapati | e833b79 | 2017-03-24 15:06:46 -0700 | [diff] [blame] | 165 | "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 Coffee | 2f24537 | 2017-03-27 10:39:26 -0700 | [diff] [blame^] | 178 | "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 Cheemalapati | e833b79 | 2017-03-24 15:06:46 -0700 | [diff] [blame] | 191 | }, |
| 192 | ], |
Jon Wayne Parrott | 0a471d3 | 2016-05-19 10:54:38 -0700 | [diff] [blame] | 193 | "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 Parrott | 0a471d3 | 2016-05-19 10:54:38 -0700 | [diff] [blame] | 202 | "severity": "A String", # The severity of the issue. |
Sai Cheemalapati | e833b79 | 2017-03-24 15:06:46 -0700 | [diff] [blame] | 203 | "description": "A String", # Short error description. |
Jon Wayne Parrott | 0a471d3 | 2016-05-19 10:54:38 -0700 | [diff] [blame] | 204 | }, |
| 205 | ], |
| 206 | }</pre> |
| 207 | </div> |
| 208 | |
| 209 | </body></html> |