Skip to content
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

Added FCM Root URL in FirebaseOptions #803

Closed

Conversation

yashjain12yj
Copy link

Summary

Added FCM root URL in FirebaseOptions so that while constructing the FirebaseApp object, fcmRootUrl can be passed. This will help in changing the base URL to localhost while writing FTs(Functional Tests).

Open Issue: #802

@yashjain12yj
Copy link
Author

@lahirumaramba @dwyfrequency @kroikie Can anyone please review?

@yashjain12yj
Copy link
Author

yashjain12yj commented Jun 1, 2023

@wu-hui Can you please review the PR or add the respective reviewer?

@lahirumaramba lahirumaramba self-requested a review June 5, 2023 18:15
@lahirumaramba lahirumaramba self-assigned this Jun 5, 2023
@lahirumaramba
Copy link
Member

Hi @yashjain12yj, thank you for the FR and the PR!
I would like to better understand your use case here. Could you explain how setting the base url to localhost help with your functional tests?

@yashjain12yj
Copy link
Author

Hi @yashjain12yj, thank you for the FR and the PR! I would like to better understand your use case here. Could you explain how setting the base url to localhost help with your functional tests?

Hey @lahirumaramba, Thanks for responding

Could you explain how setting the base URL to localhost help with your functional tests?

While writing functional tests/Service level 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 FTs for this use-case, we would need to mock the FCM server with a mock server created in FTs.

Let me explain this with the help of an example.

image

Here, Suppose we are writing FTs 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 FT 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.

I hope this gives clarity. Let me know if you need to understand this more in detail.

Also, please do suggest if there is any alternate way of achieving this :)

@yashjain12yj
Copy link
Author

@lahirumaramba Could you please check this?

@yashjain12yj
Copy link
Author

Hi @yashjain12yj, thank you for the FR and the PR! I would like to better understand your use case here. Could you explain how setting the base url to localhost help with your functional tests?

Hey @lahirumaramba, Thanks for responding

Could you explain how setting the base URL to localhost help with your functional tests?

While writing functional tests/Service level 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 FTs for this use-case, we would need to mock the FCM server with a mock server created in FTs.

Let me explain this with the help of an example.

image

Here, Suppose we are writing FTs 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 FT 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.

I hope this gives clarity. Let me know if you need to understand this more in detail.

Also, please do suggest if there is any alternate way of achieving this :)

@lahirumaramba Could you please check this? It's been open from a long time.

@klindziukp
Copy link

@ lahirumaramba
Could you please check this? My team is also need this option to perform integration tests.

@bashbers
Copy link

bashbers commented Nov 7, 2023

I've ran into this issue aswell and implemented a solution using reflection as this won't be implemented any time soon it seems. Please look here on how I fixed it: #802 (comment)

@ajax-semenov-y
Copy link

Hello @lahirumaramba, I wanted to kindly request if you could take a look at this PR, as it is crucial for our integration tests. Our team is currently blocked. Thank you for considering this request.

@yashjain12yj
Copy link
Author

Closing this PR. As discussed with @kroikie, instead of expositing fcm base URL in FcmOptions we can override by environment variable.
I have raised another PR where we can override the fcm base host via Env vars.

#912

@yashjain12yj yashjain12yj deleted the fcm_root_url_from_option branch February 13, 2024 14:28
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.

5 participants