We have a Spring Boot microservice that use gcp Secret Manager, we've encountered issues with connection resets and timeouts. Normally we mock the entire client in our tests but here we want to keep the client and mock the gcp service to test retries and error handling.
We use googles client
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-secretmanager</artifactId>
<version>2.28.0</version>
</dependency>
Are there any good tools or examples out there that does this? It can be gcp Secret Manager or any other GCP service that has an gRPC client.
I'm not a Java developer.
This should be straightforward.
Google's (Cloud) client libraries allow you to override the service endpoint (i.e. replace secretmanager.googleapis.com:443
with your own implementation e.g. localhost:50051
).
For Secret Manager, you'd then configure the client to point to your implementation:
create(SecretManagerServiceSettings)
create(ServiceManagerStub)
The gRPC service for Secret Manager is defined here: SecretManagerService
You should be able to pick a subset of methods that you want to test and implement those. I'm unsure about Java but, in order to only implement a subset of service, protoc
should (!?) generate an UnimplementedServer
method that you can use to stub out redundant methods in your server.