You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
759 B

  1. from django.conf import settings
  2. from django.core.signing import base64_hmac
  3. from hc.api.models import Check
  4. from hc.test import BaseTestCase
  5. class BadgeTestCase(BaseTestCase):
  6. def setUp(self):
  7. super(BadgeTestCase, self).setUp()
  8. self.check = Check.objects.create(user=self.alice, tags="foo bar")
  9. def test_it_rejects_bad_signature(self):
  10. r = self.client.get("/badge/%s/12345678/foo.svg" % self.alice.username)
  11. assert r.status_code == 404
  12. def test_it_returns_svg(self):
  13. sig = base64_hmac(str(self.alice.username), "foo", settings.SECRET_KEY)
  14. sig = sig[:8]
  15. url = "/badge/%s/%s/foo.svg" % (self.alice.username, sig)
  16. r = self.client.get(url)
  17. self.assertContains(r, "#4c1")