Archive for July, 2013

The django.test.client.Client

July 19, 2013

I like django and the more I work with it, the more I like it 🙂

For a unittest I needed to simulate requests coming from different remote addresses. And the django.test.client.Client makes this pretty easy:

class DistributedTestClient(Client):
    def request(self, **request):
        request["REMOTE_ADDR"] = "192.168.%i.%i" % (random.randint(1,254), random.randint(1,254))
        return super(DistributedTestClient, self).request(**request)

class DistributedClientkTestCase(TestCase):
    client_class = DistributedTestClient
    def test_distributed_meep(self):

Thanks django!

sha512crypt for node

July 7, 2013

I implemented sha512crypt in nodejs here.

$ ./demo.js pass salt

$ python -c 'import crypt; crypt.crypt("pass", "$6$salt")

With that, I plan to extend the PassHash firefox plugin to use that as the default algorithm for the password generation.