15

I'm looking for a way to test the new rule set efficiently. I'd like to test the rules before I make the decision to switch over to Firestore from the Realtime Database. Please provide a solution or indicate if there are any works-in-progress.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Vincent
  • 1,553
  • 1
  • 11
  • 21
  • 1
    Apparently Firebase have recently (and so far quietly) added a simulator to the security rules tab. Check it out! – blap May 25 '18 at 21:49

3 Answers3

25

2018-05-26 UPDATE

There now is simulator for Firestore security rules built right into the Firebase console.


Previous answer:

firebaser here

There currently is no simulator for the Firestore security rules. As far as I know one is in the works, but as usual: no promises and no release dates.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • 3
    The only way is to [file a bug report or feature request](https://firebase.google.com/support/contact/bugs-features/). But as said: the team is already very aware of how useful this would be. – Frank van Puffelen Nov 10 '17 at 19:29
4

As such you can not 'test' the rules but you can customize them as per your requirement. There are various resources which can help you to switch from the Realtime Database to Firestore.

Both the security rules work similarly and there is not so much difference.

Also as per the docs about Firestore Security Rules:

  • Rules don't cascade unless you use a wildcard.

  • Data validation happens automatically.

  • Rules can constrain queries: If a query's results might contain data the user doesn't have access to, the entire query fails.

So if your project is in beta you can try Firestore otherwise as of now Realtime Database is just fine.

Kartik Shandilya
  • 3,796
  • 5
  • 24
  • 42
4

There seems to be a development going one here: https://www.npmjs.com/package/firestore-security-tests

I've been using this to perform several simple tests on my rules and it seems to work well!

Peter
  • 10,910
  • 3
  • 35
  • 68
  • 1
    `Get requested doc based on path does not work when simulating rules`. Please, notice – Vlad Jan 20 '18 at 14:20