2

I have a scenario where I need to set up integration testing against our micrososervice architected application. This will mean creating some tests using Postman to hit our API, and running them with Newman. We also use oAuth with Identity Server, so we need to initially authenticate, then receive a token back which is passed into all of the requests.

The problem is, when we make the initial call to authenticate the user, how do we know that the user exists in the environment that we are running the tests?

2 possible solutions that I can think of are:

  • In the test script, create the User at the beginning (and possibly delete them again at the end). This would be problematic for us, because that part of the API is not public (we don't want external users to be able to create new users)
  • Deploy a dummy identity service that will return an authenticated token. This doesn't feel like it would be a proper integration test to me.

I was wondering how others would approach this sort of problem?

  • Why don't you set up the test user in your test env so that you will 100% sure the user exists and you will be using that user for all your tests? – Alexey R. Oct 12 '17 at 10:16
  • What is it that you are trying to test? Your service or the Identity server? If it is the first, mocking the identity seems a valid solution to me. I don't fully get the problem with creating users and it being private? What is it that you want to prevent? Are the Postman scripts being made available to outside parties?? If the Identity is under full control of your company, why not extract users first that you know exist for instance? – Ray Oei Oct 12 '17 at 16:00
  • Hmmm, perhaps you are right and I have overthought this. The simplest solution might be to always have the user created upfront. Thanks – jazza1000 Oct 13 '17 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.