Skip to content

Commit

Permalink
fixup! Fix: Frame Injection (azul-private#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsotirho-ucsc committed Apr 18, 2023
1 parent ce7f301 commit 77544d6
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions test/test_content_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import (
Any,
Callable,
Tuple,
)
from unittest import (
mock,
Expand Down Expand Up @@ -74,7 +73,7 @@ def _shrink_traceback(self, s: str) -> str:

def _test_route(self,
handler_fn: Callable[[None], Any],
expected_fn: Callable[[bool, bool], Tuple[str, str]]
expected_fn: Callable[[bool, bool], tuple[str, str]]
):
"""
Verify the response against expected for requests made with various
Expand Down Expand Up @@ -106,8 +105,7 @@ def test_string(self):
def route():
return '<script />'

# noinspection PyUnusedLocal
def expected(debug: bool, wrapped: bool) -> Tuple[str, str]:
def expected(_debug: bool, _wrapped: bool) -> tuple[str, str]:
text = '<script />'
content_type = 'application/json'
return text, content_type
Expand All @@ -119,8 +117,7 @@ def test_json(self):
def route():
return {'<script />': '<iframe></iframe>'}

# noinspection PyUnusedLocal
def expected(debug: bool, wrapped: bool) -> Tuple[str, str]:
def expected(_debug: bool, _wrapped: bool) -> tuple[str, str]:
text = '{"<script />":"<iframe></iframe>"}'
content_type = 'application/json'
return text, content_type
Expand All @@ -132,8 +129,7 @@ def test_response_200(self):
def route():
return Response(status_code=200, body='<script />')

# noinspection PyUnusedLocal
def expected(debug: bool, wrapped: bool) -> Tuple[str, str]:
def expected(_debug: bool, _wrapped: bool) -> tuple[str, str]:
text = '<script />'
content_type = 'application/json'
return text, content_type
Expand All @@ -147,9 +143,8 @@ def route():
headers={'Content-Type': 'text/plain'},
body='<script />')

# noinspection PyUnusedLocal
def expected(debug: bool, wrapped: bool) -> Tuple[str, str]:
if wrapped:
def expected(_debug: bool, _wrapped: bool) -> tuple[str, str]:
if _wrapped:
text = (
'<html><body>'
'<h1>Status 200</h1>'
Expand All @@ -171,8 +166,7 @@ def route():
headers={'Content-Type': 'text/html'},
body='<script />')

# noinspection PyUnusedLocal
def expected(debug: bool, wrapped: bool) -> Tuple[str, str]:
def expected(_debug: bool, _wrapped: bool) -> tuple[str, str]:
text = '<script />'
content_type = 'text/html'
return text, content_type
Expand All @@ -184,8 +178,7 @@ def test_NotFoundError(self):
def route():
raise NotFoundError('<script />')

# noinspection PyUnusedLocal
def expected(debug: bool, wrapped: bool) -> Tuple[str, str]:
def expected(_debug: bool, _wrapped: bool) -> tuple[str, str]:
text = '{"Code":"NotFoundError","Message":"<script />"}'
content_type = 'application/json'
return text, content_type
Expand All @@ -197,9 +190,8 @@ def test_ChaliceUnhandledError(self):
def route():
raise ChaliceUnhandledError('<script />')

# noinspection PyUnusedLocal
def expected(debug: bool, wrapped: bool) -> Tuple[str, str]:
if debug:
def expected(_debug: bool, _wrapped: bool) -> tuple[str, str]:
if _debug:
text = (
'Traceback (most recent call last):\n'
'...\n'
Expand All @@ -221,11 +213,11 @@ def test_exception(self):
def route():
raise Exception('<script />')

def expected(debug: bool, wrapped: bool) -> Tuple[str, str]:
def expected(_debug: bool, _wrapped: bool) -> tuple[str, str]:
# Chalice's `_unhandled_exception_to_response` returns a
# stacktrace if debug is enabled
if debug:
if wrapped:
if _debug:
if _wrapped:
text = (
'<html><body>'
'<h1>Status 500</h1>'
Expand Down

0 comments on commit 77544d6

Please sign in to comment.