test method

Future<TestRulesetResponse> test(
  1. TestRulesetRequest request,
  2. String name, {
  3. String? $fields,
})

Test Source for syntactic and semantic correctness.

Issues present, if any, will be returned to the caller with a description, severity, and source location. The test method may be executed with Source or a Ruleset name. Passing Source is useful for unit testing new rules. Passing a Ruleset name is useful for regression testing an existing rule. The following is an example of Source that permits users to upload images to a bucket bearing their user id and matching the correct metadata: Example // Users are allowed to subscribe and unsubscribe to the blog. service firebase.storage { match /users/{userId}/images/{imageName} { allow write: if userId == request.auth.uid && (imageName.matches('.png$') || imageName.matches('.jpg$')) && resource.mimeType.matches('^image/') } }

request - The metadata request object.

Request parameters:

name - Required. Tests may either provide source or a Ruleset resource name. For tests against source, the resource name must refer to the project: Format: projects/{project_id} For tests against a Ruleset, this must be the Ruleset resource name: Format: projects/{project_id}/rulesets/{ruleset_id} Value must have pattern ^projects/.*$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a TestRulesetResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<TestRulesetResponse> test(
  TestRulesetRequest request,
  core.String name, {
  core.String? $fields,
}) async {
  final _body = convert.json.encode(request);
  final _queryParams = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final _url = 'v1/' + core.Uri.encodeFull('$name') + ':test';

  final _response = await _requester.request(
    _url,
    'POST',
    body: _body,
    queryParams: _queryParams,
  );
  return TestRulesetResponse.fromJson(
      _response as core.Map<core.String, core.dynamic>);
}