-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Where exactly is the quickstart #71
Comments
This example shows how to do unit testing with the emulator: We are working on new docs / samples to show how to do more end-to-end emulator testing. |
Okay, I appreciate the help. |
@stot3 what sort of tutorials would you like to see? |
I think most of this can be solved, if I learn to test the functions, but atm, I'm building a file converter (png to webp), I want to just pass a file to the emulator, or perhaps a mocked up http call, then see the results. |
Noting this:
I'm lost in the quickstart at this point:
I used
What should I try next?
ownsId looks like this:
Everything worked before I added the 3 lines of additional conditions (the lines beginning with ampersands) to the write rule (which I will eventually change to a create rule). There is a Firebase Function that monitors create operations that triggers |
Could you try removing the line about "size" and see if it works then?
I'm on my phone so I can't type out the full instructions to get the
emulator working but happy to help with that next time I'm at my computer.
…On Fri, Sep 6, 2019, 5:33 PM ChrisChiasson ***@***.***> wrote:
Noting this:
To use this, some people may clone the entire quickstart-nodejs directory.
When starting the quickstart, cd to the specific quickstart related to your
project (i.e. cd firestore-emulator/javascript-quickstart).
I'm lost in the quickstart at this point:
Add your project to the emulator (use firebase init if no project setup)
firebase use --add your-project-name
I used firebase init and made up a project name, but it failed.
***@***.***:~/quickstart-nodejs/firestore-emulator/javascript-quickstart$ firebase init
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/home/chrischiasson/quickstart-nodejs/firestore-emulator/javascript-quickstart
Before we get started, keep in mind:
* You are initializing in an existing Firebase project directory
? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then
Enter to confirm your choices. Firestore: Deploy rules and create indexes for Firestore
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
? Please select an option: Create a new project
i If you want to create a project in a Google Cloud organization or folder, please use "firebase projects:create" instead, and return to this command when you've created the project.
? Please specify a unique project id (warning: cannot be modified afterward) [6-30 characters]:
testingproject
? What would you like to call your project? (defaults to your project ID)
✖ Creating Google Cloud Platform project
Error: Failed to create Google Cloud project. See firebase-debug.log for more info.
What should I try next?
I'm trying to debug some rules like this:
match /recaptcha/{userId}{
allow read: if ownsId(userId);
allow write: if ownsId(userId)
&& request.resource.data.size() == 1
&& request.resource.data.hasAll(['response'])
&& request.resource.data.response is string;
allow delete: if ownsId(userId);
}
ownsId looks like this:
function ownsId(userId){
return request.auth.uid== userId;
}
Everything worked before I added the 3 lines of additional conditions (the
lines beginning with ampersands) to the write rule (which I will eventually
change to a create rule). There is a Firebase Function that monitors create
operations that triggers onCreate. The normal flow is that the user calls
delete, followed by set to send the recaptcha token response, then the
Firebase Function updates the document with the server-side validation json
from Google. The 3 new rules are there to prevent the client from faking
Google's server-side json. I realize I could structure it differently to
avoid this situation, but it is important for me to learn how the rules
work. With the new rules, the set operation never finishes, much like this
stack-overflow question & self-answer, except nothing else is going on in
the background. The only change is these three new rules, and there are no
errors to report.
https://stackoverflow.com/questions/57339474/firestore-set-suddenly-not-returning-in-then-statement-and-not-adding-docs
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#71?email_source=notifications&email_token=ACATB2S3YBARSCB5DHINMHTQILZHBA5CNFSM4HQGN3F2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6ELXUI#issuecomment-529054673>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACATB2XKHDBNWYYRXHOAUCLQILZHBANCNFSM4HQGN3FQ>
.
|
Thanks! Your question led me to do some searching, and I am going to attempt to rewrite the rule using the function mentioned in this answer (the hasOnly function): https://stackoverflow.com/questions/52245118/how-does-resource-data-size-work-in-firestore-rules-what-is-being-counted |
It works using
|
@ChrisChiasson so if you're still interested I'm happy to debug your situation and get the Firestore emulator working for you! A few notes:
So if I was debugging your original problem I might have done:
|
Thanks! I'll almost certainly need the emulator again in the coming weeks, so I will be checking back and re-reading multiple times. The reason I didn't use |
@ChrisChiasson if properly configured the quickstart will not write to production. That said if you forget to point things at the emulator (or change the config) it certainly can write to production so better safe than sorry! I wouldn't point this at your most valuable projects. It's normally better to have a "dev" project as a sandbox. |
Duly noted |
I thought there would be an example showing the capabilities of the firebase emulator, perhaps it is not in the file I was looking for.
The text was updated successfully, but these errors were encountered: