Add a test for #776 - Infinite loop on permissions check

At the moment I'm just using this for running Travis tests. Will update once bug is confirmed etc.