def match(reference, value, expected): r = DummyRequest() r.referer = value self.assertEqual( is_valid_referer(r, {"authorized_referers": [reference]}), expected)
def _referer_log(self) -> None: if not hasattr(self.request, "is_valid_referer"): self.request.is_valid_referer = is_valid_referer(self.request) if not self.request.is_valid_referer: LOG.info("Invalid referer for %s: %s", self.request.path_qs, repr(self.request.referer))