-
Notifications
You must be signed in to change notification settings - Fork 269
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
Get FCM Root Url from Environment variable #912
base: master
Are you sure you want to change the base?
Conversation
@kroikie @lahirumaramba Could you please review the PR? Looks like others are also looking for the same feature. Please take a look on comment in this PR |
@kroikie @lahirumaramba, these changes will increase the testability of applications that use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for raising this PR @yashjain12yj ! this is much needed for our use case as well, grateful for your contribution. can we merge this @kroikie @lahirumaramba ?
@kroikie @lahirumaramba any updates on this? |
This change will significantly improve the testability of the application. By using the admin SDK, we avoid the need to implement the HTTP v1 client and manage FCM-specific errors ourselves. @kroikie @lahirumaramba, could you please review and merge this? It will be beneficial for everyone. Thanks @yashjain12yj for the contribution. |
Thanks for the contribution. Any update on this PR? This is also something we need for testing purposes. |
Summary
Added functionality to override FCM root URL via Env Variable so that before constructing the FirebaseApp object we can set the Fcm root url in the environment variable. This will help in changing the base URL to localhost while writing FTs(Functional Tests)/Integration Tests.
Global Variable:
GOOGLE_FCM_HOST
Open Issue: #802
How setting the base url to localhost help with your functional tests?
While writing functional tests/Integration tests, we do mock all the external services and create mock servers which behaves the same as external service. So here in case of sending push notifications, we are using Firebase admin SDK and to write tests for this use-case, we would need to mock the FCM server with a mock server created in tests.
For example
Here, Suppose we are writing tests for Service 1. It exposes a GET API to get some data. The data contains multiple attributes few attributes from DB, a few from the cache, and a few from Service 2(HTTP API).
While setting up the tests we will create a DB, cache server, and a mock HTTP server. Once the server is up, we want Service 1 to point to these servers instead of actual hosts. Since the DB, cache, and mock HTTP server are running in the same machine on different ports. We would want to set the Host to localhost with respective ports.
Now in the case of Firebase admin SDK, the host is hardcoded in the library. Hence, we are not able to override the Host to localhost.