lundi 20 janvier 2020

How to get a Bearer token from Auth0 to impersonate a test user in an integration test?

Context

I am trying to write some integration tests that verify correctness of my RESTful Web API service (.NET Core-based). To make requests that mimic the user's browser requests I'd need to configure an HttpClient's headers to include Authorization: Bearer {test-user-1-bearer-token}.

Problem

My issue is that I can not find a way to programmatically retrieve the bearer token(s) for the test user(s) I created by hand.

What I tried

According to my research of the Auth0 Architecture Scenarios the only one that could work for me is called Server Application + API. That scenario relies on retrieving an access token for the testing Application (not a bearer token for a user the code is trying to impersonate). As far as I understand, this prevents me from having multiple test accounts, which I need to have to be able to test complex, multi-user interaction scenarios around my Web API.

Ugh

I suspect that my question is off-topic because I'm not providing code. Hopefully, I at least get some answers or comments that give me a clue.

Aucun commentaire:

Enregistrer un commentaire