GSoC is wrapping up in another two weeks, that means it’s time to start wrapping up the module and make it in a shippable state. For that, I have started working on unit tests as well as documentation.
Unit tests help maintain a project in long term as they can help automatically detect if a change is made by someone in future doesn’t break some other part of the module, for example a change in the header library is to add some features that could result in breaking of an obscure client function that has been there since version 0.1. If the function has unit test coverage, it would get caught before the module gets released to the general public and would prevent some hassle.
My goal is to cover as many test cases as possible, accounting for general and exceptional cases. So far I have done basic Hawk Auth tests and nonce validation tests, I’ll be working on unit testing permissions, security and validation. I had to spend some time in order to figure out how Drupal does unit testing as that is something I’m not really familiar with and I haven’t done a lot of unit testing before so this was a good opportunity for me to pick up and implement some test cases to become more familiar with it.
A wall I ran into was when I was trying to use existing routes implemented by system module’s test submodule router_test in order to test whether Hawk Authentication was working. After a couple hours of tinkering it occurred to be that the route I was using was specifically mentioning basic_auth. After spending a few hours on this and realising that I was trying to get around something which was intentionally the way it is. I implemented my own custom module just for testing. The module provides a few basic routes in order to emulate controllers while the unit tests run. For example, a route simply shows the current logged in user’s username, this is to ensure Drupal is correctly identifying users via Hawk. As I implement more tests, I’ll implement more controllers to help them.
Since my blog has been accepted into Drupal Planet last week, I’ve started working on writing a few posts to recap the GSoC journey of mine as well as provide introductions to Hawk, Hawk Auth module and the project itself. Hopefully these articles will help people understand the protocol and the project better. I’m trying to get a few posts out this week and the next week.
For now that is all, I’ll continue with unit testing and documentation until the next week.