Automated testing of a Web App that requires Google OIDC AuthN

Viewed 64

I'm writing a Python-based Web App that requires users to authenticate themselves against the app using their Organization Google account (Google Workspace account). I'm successfully using Python google-auth library and I've implemented the workflow described in the sign-in with Google personalized button guide. Works like a charm.

I'm wondering, what would be the best approach to writing automated tests for it. Because if I won't be able to somehow automatically log in, I won't be able to test the app.

I've tried googling if there is maybe a way to securely obtain JWT credential using e.g. gcloud CLI? Would it be possible to obtain a valid JWT credential of a (dummy? Test?) user?

Another option would be implementing a user/password authentication in addition to oicd and enable it only in tests? But that means that the app -- especially around the critical AuthN related processes -- will behave very differently than the one in prod. And I'd need to test the prod flavor. Any kind of tampering with AuthN process in test version of the app would result in me testing something significantly different that I'm running in production.

Does anyone know if there's a way to obtain any -- even dummy -- but valid JWT credential using Sign-in with Google? I would really appreciate any pointers and/or advice. :)

0 Answers
Related