Howdy, I'm trying to verify our `refreshTokens { ...
# ktor
s
Howdy, I'm trying to verify our
refreshTokens { ... }
block but I'm having trouble triggering expired tokens since our server has a very long expiration time. Is there any way to intercept calls to simulate a server's 401 response in a way that triggers
refreshTokens
?
a
Can you describe how you are testing the
refreshTokens
block at the moment?
s
I'm waiting 1hr+ for the server to respond with a 401 due to token expiration, then getting a single shot at running the
refreshTokens
block
a
Can you try using the testApplication to control the server's behavior in returning the 401 status code at the right time?
s
I don't understand how testApplication would help. I'm trying to test my ktor client's behavior against a non-ktor server.
a
Then you can try using the MockEngine to mock the server's behavior.
s
Is there any way to implement MockEngine for only certain calls? The server's whole behavior is too complicated to mock just for this case
a
Unfortunately, the MockEngine can do only mocked calls.
👍 1
s
Thanks for the help here, nonetheless. I ended up getting my issue fixed by queueing up multiple phones and emulators for expiration so I could get more shots at testing the issue.