Search code examples
tddmicroservicesidentityserver4atdd

IdentityServer4 first acceptance test


I am starting a new project to create an authentication api using IdentityServer4 following TDD. Many microservices and websites will be using this to authenticate users. But I could not figure out first 3 acceptance tests for the project. Any help will be highly appreciated.

Note: I have recently read goos


Solution

  • Well, in the book they suggest starting with the simplest success case possible. For an authentication service that would probably be a successful authentication.

    So your first acceptance test could look something like that:

    When: receiving valid user data

    Then: authentication should be successful

    That may seem awfully small for an acceptance test that is supposed to test a whole system, but your system is also very small and there aren't many user stories to handle. Basically only authentication success, fail and maybe a test that covers the case when a user has tried to log in too many times without success. Your unit tests then can go more into detail about the actual authentication mechanism, but the acceptance test should always be about the user story.

    I guess one could also argue that you don't need to write acceptance tests for your authentication service at all, since it is only a part of your system and you should rather write acceptance tests for your whole system, meaning when you have brought all the microservices together or for each individual website that will rely on that service. The main reason for this kind of argument is that acceptance testing is about testing from the outside in and your authentication service is already a rather deep component of your system.