vectordotdev / vector

A high-performance observability data pipeline.
https://vector.dev
Mozilla Public License 2.0
17.53k stars 1.54k forks source link

chore(gcp service): create full service mock for GCP APIs with OAuth2-based authentication #12856

Open tobz opened 2 years ago

tobz commented 2 years ago

As noted in a code comment in #12755 (comment here), we have not yet added a test to the stackdriver_metrics sink as doing so would require mocking the OAuth2 endpoint that is used to generate a token for furthering interacting with the actual Stackdriver Metrics API. Doing so in a clean way was a bit too much work for the aforementioned PR.

We should extend the simple spawn_http_blackhole_server machinery with a richer set of helper methods, or potentially types, for mocking not only the service under test, but also the OAuth2 phase where credentials are used to request/refresh a token before actually calling the service.

As all GCP APIs use OAuth2, we should not only do this and use it for the stackdriver_metrics sink, but for all other GCP sinks where OAuth2 is used. This might also imply needing to unify how we parse credentials and generate tokens for GCP sinks i.e. switch exclusively to goauth or gouth, and remove the other.

spencergilbert commented 2 years ago

Existing issue around gouth vs goauth: https://github.com/vectordotdev/vector/issues/7180