Skip to content

Comments

v2 versions of CreateFakeTestimony, createFakeOrg, modifyAccount and adminResolveReport#2052

Open
AstorDG wants to merge 2 commits intocodeforboston:mainfrom
AstorDG:main
Open

v2 versions of CreateFakeTestimony, createFakeOrg, modifyAccount and adminResolveReport#2052
AstorDG wants to merge 2 commits intocodeforboston:mainfrom
AstorDG:main

Conversation

@AstorDG
Copy link
Collaborator

@AstorDG AstorDG commented Feb 20, 2026

Summary

Created v2 versions of all of these functions that turn them into firebase v2 functions. I also created v2 versions of checkAuth, checkAdmin and the fail function they use for throwing errors. The failv2 uses the v2 version of the HttpsError.
The v2 version of scrape single hearing now uses the v2 versions of check auth and check admin since its a v2 firebase function.

Steps to test/reproduce

The testing is a little complicated as they all need to be tested with curl commands. The url end points stayed the same on my machine when testing so copy and pasting the url should work but if it doesn't you can get the url from the docker logs. Once firebase starts serving on a port it will list out all of the function urls. This can be found in the terminal after running yarn dev:up or in the logs tab of the firebase emulator ui. I added the -v flag in my curl commands to see the result of http output that shows success or error. Make sure that you're logged in as the test admin user on the local site. Username: testadmin@example.com, Password: password. This will make the bearer token valid.

If you need to get the bearer token because this isn't the correct one on your machine you can run:
curl -s -X POST \
'http://127.0.0.1:9099/identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=fake-api-key' \
-H 'Content-Type: application/json' \
-d '{"email":"testadmin@example.com","password":"password","returnSecureToken":true}'
This will return a couple fields but the important one is the idToken field.

createFakeTestimony:
Run this curl command: curl -v -X POST http://127.0.0.1:5001/demo-dtp/us-central1/createFakeTestimonyv2 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJuYW1lIjoiIiwicGljdHVyZSI6IiIsInJvbGUiOiJhZG1pbiIsImVtYWlsIjoidGVzdGFkbWluQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF1dGhfdGltZSI6MTc3MTAwNzA0NiwidXNlcl9pZCI6IjA1bGN5NllRclB2UFJ2VlBsWkZiQ0EwTzgxVEYiLCJmaXJlYmFzZSI6eyJpZGVudGl0aWVzIjp7ImVtYWlsIjpbInRlc3RhZG1pbkBleGFtcGxlLmNvbSJdfSwic2lnbl9pbl9wcm92aWRlciI6InBhc3N3b3JkIn0sImlhdCI6MTc3MTAwNzA0NiwiZXhwIjoxNzcxMDEwNjQ2LCJhdWQiOiJkZW1vLWR0cCIsImlzcyI6Imh0dHBzOi8vc2VjdXJldG9rZW4uZ29vZ2xlLmNvbS9kZW1vLWR0cCIsInN1YiI6IjA1bGN5NllRclB2UFJ2VlBsWkZiQ0EwTzgxVEYifQ." \
-d '{"data":{"uid":"any_id_you_want", "fullname": "test user","email":"test@testimony.com"}}'

The uid field can be any string or text. So can the fullname and test user fields. Besides getting a 200 ok from curl you can check that the function worked by going into the local firestore ui and clicking either the users or profile tab. The new user that was created should be easy to spot because the user id is the one you gave it. They'll have the id that was given in the uid field. Then you can click the id and see the testimonies for that user and see the fake testimony that was just created.

createFakeOrg:

Run this curl command: curl -v -X POST http://127.0.0.1:5001/demo-dtp/us-central1/createFakeOrgv2 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJuYW1lIjoiIiwicGljdHVyZSI6IiIsInJvbGUiOiJhZG1pbiIsImVtYWlsIjoidGVzdGFkbWluQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF1dGhfdGltZSI6MTc3MTAwNzA0NiwidXNlcl9pZCI6IjA1bGN5NllRclB2UFJ2VlBsWkZiQ0EwTzgxVEYiLCJmaXJlYmFzZSI6eyJpZGVudGl0aWVzIjp7ImVtYWlsIjpbInRlc3RhZG1pbkBleGFtcGxlLmNvbSJdfSwic2lnbl9pbl9wcm92aWRlciI6InBhc3N3b3JkIn0sImlhdCI6MTc3MTAwNzA0NiwiZXhwIjoxNzcxMDEwNjQ2LCJhdWQiOiJkZW1vLWR0cCIsImlzcyI6Imh0dHBzOi8vc2VjdXJldG9rZW4uZ29vZ2xlLmNvbS9kZW1vLWR0cCIsInN1YiI6IjA1bGN5NllRclB2UFJ2VlBsWkZiQ0EwTzgxVEYifQ." \
-d '{"data":{"uid":"any_id_you_want", "fullname": "test org","email":"test@org.com"}'

Besides getting a 200 ok from curl you can check that it worked by seeing the new org in the profiles tab of the firestore emulator ui. There will be a new profile with the the name and uid that was given in the curl command.

modifyAccount:

Run this curl command: curl -v -X POST http://127.0.0.1:5001/demo-dtp/us-central1/modifyAccountv2 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJuYW1lIjoiIiwicGljdHVyZSI6IiIsInJvbGUiOiJhZG1pbiIsImVtYWlsIjoidGVzdGFkbWluQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF1dGhfdGltZSI6MTc3MTAwNzA0NiwidXNlcl9pZCI6IjA1bGN5NllRclB2UFJ2VlBsWkZiQ0EwTzgxVEYiLCJmaXJlYmFzZSI6eyJpZGVudGl0aWVzIjp7ImVtYWlsIjpbInRlc3RhZG1pbkBleGFtcGxlLmNvbSJdfSwic2lnbl9pbl9wcm92aWRlciI6InBhc3N3b3JkIn0sImlhdCI6MTc3MTAwNzA0NiwiZXhwIjoxNzcxMDEwNjQ2LCJhdWQiOiJkZW1vLWR0cCIsImlzcyI6Imh0dHBzOi8vc2VjdXJldG9rZW4uZ29vZ2xlLmNvbS9kZW1vLWR0cCIsInN1YiI6IjA1bGN5NllRclB2UFJ2VlBsWkZiQ0EwTzgxVEYifQ." \
-d '{"data":{"uid":"any_id_field_from_local_firestore_user","role":"admin"}'
This can be run with any type of role. Valid roles are: user, admin, legislator, pendingUpgrade, organization.
For this function you have to put in a valid uid from a user that already exists. These can be found in the users tab of the firestore emulator ui.

Besides get a 200 okay from curl you can check that it worked by checking the role field of the user who's id was passed in the data section of the command. Then seeing if it aligned with the role you ran the command with.

adminResolveReport:

This one is kind of a hassle because you have to do some set up before you can run the curl command.
Once you have the docker image up from yarn dev:up navigate to the local site and make sure you're logged in as an admin. Then find a testimony and report it. I just reported it as spam and put "test" in the text section.
You can then navigate to the firestore emulator ui and go to the reports tab to get the report id. This tab doesn't exist by default so you may have to reload the page or click into another tab and then click back into the firestore tab. The report has the id of the testimony that you reported. You then need to use this id to find that testimony because it doesn't have all of the fields by default needed for the function to work properly. You have to add public, updatedAt and fullName fields. public is a boolean, updatedAt is a timestamp and fullName is a string. It doesn't matter what you put in these fields they just need to exist and have valid data.

Then run this curl command: curl -v -X POST http://127.0.0.1:5001/demo-dtp/us-central1/adminResolveReportv2 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJuYW1lIjoiIiwicGljdHVyZSI6IiIsInJvbGUiOiJhZG1pbiIsImVtYWlsIjoidGVzdGFkbWluQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF1dGhfdGltZSI6MTc3MTAwNzA0NiwidXNlcl9pZCI6IjA1bGN5NllRclB2UFJ2VlBsWkZiQ0EwTzgxVEYiLCJmaXJlYmFzZSI6eyJpZGVudGl0aWVzIjp7ImVtYWlsIjpbInRlc3RhZG1pbkBleGFtcGxlLmNvbSJdfSwic2lnbl9pbl9wcm92aWRlciI6InBhc3N3b3JkIn0sImlhdCI6MTc3MTAwNzA0NiwiZXhwIjoxNzcxMDEwNjQ2LCJhdWQiOiJkZW1vLWR0cCIsImlzcyI6Imh0dHBzOi8vc2VjdXJldG9rZW4uZ29vZ2xlLmNvbS9kZW1vLWR0cCIsInN1YiI6IjA1bGN5NllRclB2UFJ2VlBsWkZiQ0EwTzgxVEYifQ." \
-d '{"data":{"reportId":"2u-g3Rc0Smvb0LM5B5on7","resolution":"remove-testimony","reason":"important reason"}}'

Make sure the reportId is the if the report gotten from the firestore emulator. It needs to be correct. after getting a 200 from curl you should also see that the report has been updated to being resolved in firestore.

…inResolveReport

Created v2 versions of all of these functions that are firebase v2
versions. I also created v2 versions of checkAuth and checkAdmin and the
fail function they use for throwing errors that use the v2 error type.
@vercel
Copy link

vercel bot commented Feb 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
maple-dev Ready Ready Preview, Comment Feb 20, 2026 2:27am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant