Skip to content

Commit

Permalink
fixup! mozillaGH-36 Add tests for multi-policy support and csp_append…
Browse files Browse the repository at this point in the history
…/csp_select decorators
  • Loading branch information
DylanYoung committed May 26, 2022
1 parent 22f7301 commit eb66ddc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions csp/tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ def view_with_decorator(request):
assert policy_list == ["default-src 'self'"]


def test_csp_case_insensitive():
@csp(img_src=['foo.com'], font_src=['bar.com'])
def view_with_decorator(request):
return HttpResponse()
response = view_with_decorator(REQUEST)
assert response._csp_config == {
policy_names.last_policy_name: {
'img-src': ['foo.com'],
'font-src': ['bar.com'],
}
}
mw.process_response(REQUEST, response)
policy_list = sorted(response[HEADER].split("; "))
assert policy_list == ["font-src bar.com", "img-src foo.com"]


def test_csp_with_args():
@csp(
{'img-src': ['foo.com']},
Expand Down

0 comments on commit eb66ddc

Please sign in to comment.