cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Integration testing - How do I deal with authentication?

I am trying to setup some integration tests for a web API. Some of the routes in the controller I am interested in use the [Authorize] attribute, backed by JWT authentication using Identity Server 4, to prevent unauthorized from accessing certain resources.

I'd like to "disable" authorization for testing purposes: replacing Identity Server with a "fake" authorizer that always gives green light to all requests.

I am using TestServer to run the API I want to test in memory and I'd like to use ConfigureTestServices to override the authorisation method, but I can't find any easy way to stub/mock it.

Does anyone have any relevant experience with a similar problem?

himeshlem79
Member
5 REPLIES 5

There are multiple solutions available for this problem. One of the solution is API Gateway pattern .

  1. First request goes to API gateway
  2. API Gateway authenticates & authroizes the request
  3. Authentication is stored on cache database such as Redis, Memcache etc with expiry time on it
  4. Saved access token is returned to client
  5. Client can use the saved access token in the subsequent calls for the some time span (i.e. until the token is valid)
  6. Once the token is expired, the API gateway will authenticate and share the new token to client
  7. This solution will reduce the need to authenticate each request and improves the performance

API Gateway is the single entry point for all the services. So, you may not need separate cache for each service. ACES ETM

mathws
Member

Incorporation testing is extremely well known theme and author attempt to clarify generally How would I manage validation? NF Merchandise

A debt of gratitude is in order for haring this data with Us.

hofila2989
Member

Combined testing is a very popular topic and the authors always want to explain how to manage validation? NF equipment

Thanks for sharing this information.

Download Here Beetv 

sai123
Member

It is a topic that is being prepared for testing and the authors try to explain it in general. How do I handle confirmation? NF product

Thank you for sharing this information with us.

Download krnl executor

 

sai123
Member

In addition, authors always want to explain how to manage validation in combined testing, which is a very popular topic? This is very useful information. Thanks for sharing it.

farrugia34
Member