Trapped in the Matrix

Posted 2018-03-25 21:20:11 UTC

Series: libmatrix-client

Part 1

I finally pushed my recent changes in libmatrix-client to git after having made sure they didn't suck too badly. After that, I began working on implementing the logout endpoint. This ended up being both simpler and more difficult than I expected at the same time.

It turns out that the logout endpoint returns 200 OK and {} (success) no matter what the URL parameters were, including the case where the access_token field was absent. This made handling things in the code easier since there isn't really any way to fail on this call. In fact, the only way I managed to get an error out of this endpoint was by trying to use an HTTP method other than POST on it.

Unfortunately, this also led me to spend a long time fussing with cURL since I wasn't able to determine whether I was POSTing things correctly. Eventually, I found enough cURL documentation to determine that I was doing it right and that it was time to call this function finished.

Now that it was done, I decided it was time to write a unit test for it. About to create the new test, I realized that I would need the token to persist across the login and logout unit tests which then launched me into a thirty minute internal debate on how to make the data persist. My final decision was that the logout function was so simple and effectively couldn't fail, so it should just be part of the login test. This way, I wouldn't have to implement sane test interactivity (yet?) and the access token would still get invalidated after the login test had run.