I am testing my own auth system. I am storing jwt token in cookie.
I already made logic, it works fine… But, now I want to write automated unittests. How can I mock values of cookies? How can I create context that will have cookies inside it?
There is a topic where I explain a little about how I accomplish this, you can check it out here:
Note, I think that this testing only works if the cookies are not secure, I do this on a local server and have an if statement to determine whether the cookies should be secure in the application.
Or, if you want to maintain your flow with secure cookies, you can store your login process in order allow for yourself to be logged in. For me, I have MFA so I had to store the cookies.