I describe the problem in this Racket Help needed with automating an API test to change password | Racket
But I’ll use text here as well.
Decreasing confidence in the account API that we use from the mobile app. There is no backend dev in my team, which really sucks. The tests in the account API seemed kinda bare bones so I figured I’d expand the tests.
A specific API call that has been giving weird responses back is the call to change your password. This is the test I have trouble with to make it reliable.
What I did and thought of
the existing API tests are made with Postman. First, I made a very ugly set of 2 tests that were depending on one another. In Test 1 I change from password A to B and in test 2, which has to run straight after, I change it back from password B to A so the account is back in the original state. BUT: that wasn’t possible because you can’t change your password back to the last-chosen password (security reasons I guess) so then I’d have to expand this to a set of 3 tests who are dependent on one another and that just is a bad solution. A test should be able to run reliably and not be depending on 2 other tests.
The way to work around this is making me run into the limitation of Postman. You can’t persistently store data in Postman as far as I know. To fix the test and remove the second/third tests I would need to store a randomly generated password somewhere so the next time the test runs it can use that again. But in Postman I don’t know how to do that. You have the Environment Variables, but as far as I know these don’t persist over sessions. I did some Googling and didn’t find an answer. Is there an option here that I’m missing?
A total different avenue would be to create a new account every time. But, a new account has to be confirmed via an email or in the admin console of SAP…I have no access to confirm account via an API (only manual action in SAP Gigya CDC) —> someone from the SAP team is going to find out if they have API’s I can use, but I don’t have an answer as of now. There could be a way to work around this by using something like mailSlurp so you can access emails with an API, but it’s a paid tool…
So, now I’m thinking I could also create my own backend service to store this damned password as a variable so I can keep using postman OR, I’ll just make a NodeJS project with the API tests because Postmans client is sometimes making me want to pull my hair out. It’s so easy to end up with code duplication because it’s not fully an IDE but not “just a GUI” either. It can get messy quickly I just want some neat helper methods and I like my code clean.
I don’t want to use mocks because the problem is in the chain so a test with only mocks wouldn’t really add value for me.
Screenshot of “the thing I need” in Postman
I’d prefer to have one variable “password” that first gets filled at passwordCurrent, THEN somehow generate a new password, store that in the variable and use it in passwordNew. I just don’t know if this is possible in Postman. In pure code project this would be trivial.