You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Firestore emulator doesn't recognise rules flag #1303
The emulator supports an optional --rules CLI flag. It expects the name of a local file containing your Cloud Firestore Security Rules and applies those rules to all projects. If you don't provide the local file path or use the loadFirestoreRules method as described below, the emulator treats all projects as having open rules.
That's a good point and it's a documentation error. The firestore emulator
automatically uses the rules file specified in your firebase.json , are you
trying to use a different file?
On Thu, May 16, 2019, 8:22 AM Yuri ***@***.***> wrote:
[REQUIRED] Environment info
*firebase-tools: 6.9.2*
*Platform: macOS*
[REQUIRED] Test case
According to docs
The emulator supports an optional --rules CLI flag. It expects the name of
a local file containing your Cloud Firestore Security Rules and applies
those rules to all projects. If you don't provide the local file path or
use the loadFirestoreRules method as described below, the emulator treats
all projects as having open rules.
[REQUIRED] Steps to reproduce
firestore (master) $ firebase emulators:start --only firestore --rules
firestore.stable.rules
[REQUIRED] Expected behavior
--rules flag to be recognised as per Documentation
[REQUIRED] Actual behavior
error: unknown option --rules'`
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1303?email_source=notifications&email_token=ACATB2VTKNWV6JWVGUE2IKTPVV33VA5CNFSM4HNNVHKKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GUGOD4A>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACATB2RWZQBJLLQ5WRRA2TTPVV33VANCNFSM4HNNVHKA>
.
This is definitely a documentation error, I believe we're having some conversations about docs today so I'll make sure to bring this up as a point of confusion!
@samtstern I guess it's not a big deal, just for few days we had multiple generated rules as we were testing some security rules and didn't want to deploy them straight away but wanted to use them in our jest tests
@ryanpbrewster Indeed while I was creating a reproducible repository this morning it worked using loadFirestoreRules, must be some other issue why it didn't work for me before which I will investigate. Thanks for going through it with me 🤷♂
Activity
samtstern commentedon May 16, 2019
abeisgoat commentedon May 16, 2019
This is definitely a documentation error, I believe we're having some conversations about docs today so I'll make sure to bring this up as a point of confusion!
Yuripetusko commentedon May 16, 2019
Yes I tried 3 different ways:
1
--rulesflag as above2
await firebase.loadFirestoreRules(projectId: 'test', rules: fs.readFileSync('firestore.rules', 'utf8'))- doesn't work3
in firebase.json which also doesn't work
It always just use default one from this
Yuripetusko commentedon May 16, 2019
So I guess it now turned into a feature request
samtstern commentedon May 16, 2019
@Yuripetusko yeah this is a FR not a bug since right now we only look for what's in
firestore.rulesnotemulators.firestore.rules.Could you explain your use case a bit more? What is the meaning of
.stable.rulesfor your project?Yuripetusko commentedon May 16, 2019
@samtstern I guess it's not a big deal, just for few days we had multiple generated rules as we were testing some security rules and didn't want to deploy them straight away but wanted to use them in our jest tests
samtstern commentedon May 16, 2019
@Yuripetusko FYI we provide a way to load rules files from inside your tests using the
@firebase/testinglibrary:https://github.com/firebase/quickstart-nodejs/blob/master/firestore-emulator/javascript-quickstart/test/test.js#L37
That's probably your best bet if you want to use a different rule set only in tests.
Yuripetusko commentedon May 16, 2019
@samtstern I actually already do this, but it doesn't work, looks like emulator still overwrites rules that it finds in firebase.json
ryanpbrewster commentedon May 16, 2019
That's surprising, could you provide a snippet showing how you're using the
loadFirestoreRulesfunction from@firebase/testing?Yuripetusko commentedon May 17, 2019
this is how I do it
And I am sure that file is loaded as if I change path it complains that fs cannot find a file
And I am sure that setup is called as auth user is set exactly as in setup function
Yuripetusko commentedon May 17, 2019
The only thing I do differently is I don't use firebase/testing asserts, and use jest instead, but setup is using firebase/test..
ryanpbrewster commentedon May 17, 2019
That code looks correct, and when I try it it works.
Can you provide a short repro of the issue you're running into (i.e., your rules, a test script, and the command you use to execute them)?
Yuripetusko commentedon May 20, 2019
@ryanpbrewster Indeed while I was creating a reproducible repository this morning it worked using
loadFirestoreRules, must be some other issue why it didn't work for me before which I will investigate. Thanks for going through it with me 🤷♂samtstern commentedon May 20, 2019
@Yuripetusko thanks for following up!
therefromhere commentedon Jun 13, 2019
@abeisgoat Could this be reopened since the documentation is still incorrect?
https://firebase.google.com/docs/firestore/security/test-rules-emulator#before_you_run_the_emulator
samtstern commentedon Jun 13, 2019
@therefromhere good call, I will have to get those docs fixed.
matheo commentedon Jun 15, 2019
@samtstern It would be good to add a configuration schema for the
firebase.jsonso we know which options are supported and the IDE can autocomplete too, one like this one, but complete:https://github.com/SirWindfield/vscode-firebase-configuration-schema-plugin/blob/master/schemas/firebase.schema.json
samtstern commentedon Jun 17, 2019
@therefromhere I have submitted a docs change, it will go live probably tomorrow.
@matheo that's a great idea, let me file a new issue for that.