-
Notifications
You must be signed in to change notification settings - Fork 327
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
Use NoCredentialsProvider when firestore emulator enabled. #555
Conversation
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 the contribution. It looks pretty good. Just a couple of small comments.
...re/src/main/java/com/google/cloud/spring/autoconfigure/firestore/GcpFirestoreProperties.java
Show resolved
Hide resolved
ApplicationContextRunner contextRunner = new ApplicationContextRunner() | ||
.withPropertyValues( | ||
"spring.cloud.gcp.firestore.projectId=test-project", | ||
"spring.cloud.gcp.firestore.emulator.enabled=true", |
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.
How about also a test where the property is not set?
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.
Just one more thing on verifying the credentials provider in the tests.
"spring.cloud.gcp.firestore.host-port=localhost:8080" | ||
).run(context -> { | ||
CredentialsProvider defaultCredentialsProvider = context.getBean(CredentialsProvider.class); | ||
assertThat(defaultCredentialsProvider).isNotInstanceOf(NoCredentialsProvider.class); |
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.
I feel like we're missing the assertion on the actual Firestore credentials provider which this PR is all about.
I think you'll need to add a package-private getter for the credentialsProvider
in GcpFirestoreAutoConfiguration
.
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.
You're right, added assertion on the new commit to make sure the GcpFirestoreAutoConfiguration did change to NoCredentialsProvider when emulator enabled.
…lsProvider when emulator enabled.
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.
Looks very good, just a testing request.
(non-actionable) I checked additional-spring-configuration-metadata.json
, and we already had spring.cloud.gcp.firestore.emulator.enabled
documented there, so no changes will be needed to the metadata.
CredentialsProvider defaultCredentialsProvider = context.getBean(CredentialsProvider.class); | ||
assertThat(defaultCredentialsProvider).isNotInstanceOf(DefaultCredentialsProvider.class); |
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.
Two minor testing things:
- It would be good to validate that the mocked
CredentialsProvider
is returned. One way to do that is to use.withBean(() -> /* handle to mock */ )
instead of the current.withUserConfiguration(GcpFirestoreEmulatorAutoConfigurationTests.TestConfiguration.class)
. - Could you also test
firestoreAutoConfiguration.getCredentialsProvider()
here?
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.
@elefeint thanks for the review! pushed new commit, would you mind have a look and let me know what you think ?
…reAutoConfiguration.getCredentialsProvider() return the mocked bean.
Kudos, SonarCloud Quality Gate passed! |
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.
Thank you!
@meltsufin -- Could you take another look again when you get a chance? |
Bumps [spring-test](https://github.com/spring-projects/spring-framework) from 5.3.20 to 5.3.21. - [Release notes](https://github.com/spring-projects/spring-framework/releases) - [Commits](spring-projects/spring-framework@v5.3.20...v5.3.21) --- updated-dependencies: - dependency-name: org.springframework:spring-test dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Fix GH-501