aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/contentviews/test_image.py2
-rw-r--r--test/mitmproxy/contentviews/test_image_parser.py63
-rw-r--r--test/mitmproxy/data/all.jpegbin0 -> 230334 bytes
-rw-r--r--test/mitmproxy/data/image-err1.jpgbin82674 -> 0 bytes
-rw-r--r--test/mitmproxy/data/image_parser/README.md17
-rw-r--r--test/mitmproxy/data/image_parser/all.jpegbin0 -> 230334 bytes
-rw-r--r--test/mitmproxy/data/image_parser/app1.jpegbin0 -> 82670 bytes
-rw-r--r--test/mitmproxy/data/image_parser/comment.jpgbin0 -> 1779 bytes
-rw-r--r--test/mitmproxy/data/image_parser/example.jpgbin0 -> 1755 bytes
9 files changed, 81 insertions, 1 deletions
diff --git a/test/mitmproxy/contentviews/test_image.py b/test/mitmproxy/contentviews/test_image.py
index 9e7e28f5..e3dfb714 100644
--- a/test/mitmproxy/contentviews/test_image.py
+++ b/test/mitmproxy/contentviews/test_image.py
@@ -8,7 +8,7 @@ def test_view_image():
for img in [
"mitmproxy/data/image.png",
"mitmproxy/data/image.gif",
- "mitmproxy/data/image-err1.jpg",
+ "mitmproxy/data/all.jpeg",
"mitmproxy/data/image.ico"
]:
with open(tutils.test_data.path(img), "rb") as f:
diff --git a/test/mitmproxy/contentviews/test_image_parser.py b/test/mitmproxy/contentviews/test_image_parser.py
index 4241a1bb..3c8bfdf7 100644
--- a/test/mitmproxy/contentviews/test_image_parser.py
+++ b/test/mitmproxy/contentviews/test_image_parser.py
@@ -104,3 +104,66 @@ def test_parse_png(filename, metadata):
def test_parse_gif(filename, metadata):
with open(tutils.test_data.path(filename), 'rb') as f:
assert metadata == image_parser.parse_gif(f.read())
+
+
+@pytest.mark.parametrize("filename, metadata", {
+ # check app0
+ "mitmproxy/data/image_parser/example.jpg": [
+ ('Format', 'JPEG (ISO 10918)'),
+ ('jfif_version', '(1, 1)'),
+ ('jfif_density', '(96, 96)'),
+ ('jfif_unit', '1'),
+ ('Size', '256 x 256 px')
+ ],
+ # check com
+ "mitmproxy/data/image_parser/comment.jpg": [
+ ('Format', 'JPEG (ISO 10918)'),
+ ('jfif_version', '(1, 1)'),
+ ('jfif_density', '(96, 96)'),
+ ('jfif_unit', '1'),
+ ('comment', "b'mitmproxy test image'"),
+ ('Size', '256 x 256 px')
+ ],
+ # check app1
+ "mitmproxy/data/image_parser/app1.jpeg": [
+ ('Format', 'JPEG (ISO 10918)'),
+ ('jfif_version', '(1, 1)'),
+ ('jfif_density', '(72, 72)'),
+ ('jfif_unit', '1'),
+ ('make', 'Canon'),
+ ('model', 'Canon PowerShot A60'),
+ ('modify_date', '2004:07:16 18:46:04'),
+ ('Size', '717 x 558 px')
+ ],
+ # check multiple segments
+ "mitmproxy/data/image_parser/all.jpeg": [
+ ('Format', 'JPEG (ISO 10918)'),
+ ('jfif_version', '(1, 1)'),
+ ('jfif_density', '(300, 300)'),
+ ('jfif_unit', '1'),
+ ('comment', 'b\'BARTOLOMEO DI FRUOSINO\\r\\n(b. ca. 1366, Firenze, d. 1441, '
+ 'Firenze)\\r\\n\\r\\nInferno, from the Divine Comedy by Dante (Folio 1v)'
+ '\\r\\n1430-35\\r\\nTempera, gold, and silver on parchment, 365 x 265 mm'
+ '\\r\\nBiblioth\\xe8que Nationale, Paris\\r\\n\\r\\nThe codex in Paris '
+ 'contains the text of the Inferno, the first of three books of the Divine '
+ 'Comedy, the masterpiece of the Florentine poet Dante Alighieri (1265-1321).'
+ ' The codex begins with two full-page illuminations. On folio 1v Dante and '
+ 'Virgil stand within the doorway of Hell at the upper left and observe its '
+ 'nine different zones. Dante and Virgil are to wade through successive '
+ 'circles teeming with images of the damned. The gates of Hell appear in '
+ 'the middle, a scarlet row of open sarcophagi before them. Devils orchestrate'
+ ' the movements of the wretched souls.\\r\\n\\r\\nThe vision of the fiery '
+ 'inferno follows a convention established by <A onclick="return OpenOther'
+ '(\\\'/html/n/nardo/strozzi3.html\\\')" HREF="/html/n/nardo/strozzi3.html">'
+ 'Nardo di Cione\\\'s fresco</A> in the church of Santa Maria Novella, Florence.'
+ ' Of remarkable vivacity and intensity of expression, the illumination is '
+ 'executed in Bartolomeo\\\'s late style.\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n'
+ '--- Keywords: --------------\\r\\n\\r\\nAuthor: BARTOLOMEO DI FRUOSINO'
+ '\\r\\nTitle: Inferno, from the Divine Comedy by Dante (Folio 1v)\\r\\nTime-line:'
+ ' 1401-1450\\r\\nSchool: Italian\\r\\nForm: illumination\\r\\nType: other\\r\\n\''),
+ ('Size', '750 x 1055 px')
+ ],
+}.items())
+def test_parse_jpeg(filename, metadata):
+ with open(tutils.test_data.path(filename), 'rb') as f:
+ assert metadata == image_parser.parse_jpeg(f.read())
diff --git a/test/mitmproxy/data/all.jpeg b/test/mitmproxy/data/all.jpeg
new file mode 100644
index 00000000..ea5d8d0f
--- /dev/null
+++ b/test/mitmproxy/data/all.jpeg
Binary files differ
diff --git a/test/mitmproxy/data/image-err1.jpg b/test/mitmproxy/data/image-err1.jpg
deleted file mode 100644
index 1b251e6e..00000000
--- a/test/mitmproxy/data/image-err1.jpg
+++ /dev/null
Binary files differ
diff --git a/test/mitmproxy/data/image_parser/README.md b/test/mitmproxy/data/image_parser/README.md
new file mode 100644
index 00000000..c23409bf
--- /dev/null
+++ b/test/mitmproxy/data/image_parser/README.md
@@ -0,0 +1,17 @@
+# Sources of the images used
+
+## PNG
+
+`aspect.png` - http://pngimg.com/upload/water_PNG3290.png
+All other PNGs are from the [PNGTestSuite](http://www.schaik.com/pngsuite/)
+
+# GIF
+
+All the GIFs are from the Pillow repository [here](https://github.com/python-pillow/Pillow/tree/master/Tests/images)
+
+# JPEG
+
+`app1.jpeg` - https://commons.wikimedia.org/wiki/File:PT05_ubt.jpeg
+`all.jpeg` - https://commons.wikimedia.org/wiki/Category:Dante's_Inferno#/media/File:Bartolomeo_Di_Fruosino_-_Inferno,_from_the_Divine_Comedy_by_Dante_(Folio_1v)_-_WGA01339.jpg
+`comment.jpg` has been taken from [here](https://commons.wikimedia.org/wiki/File:JPEG_example_image.jpg) and has a comment added locally
+All other JPEGs are from the Pillow repository [here](https://github.com/python-pillow/Pillow/tree/master/Tests/images)
diff --git a/test/mitmproxy/data/image_parser/all.jpeg b/test/mitmproxy/data/image_parser/all.jpeg
new file mode 100644
index 00000000..ea5d8d0f
--- /dev/null
+++ b/test/mitmproxy/data/image_parser/all.jpeg
Binary files differ
diff --git a/test/mitmproxy/data/image_parser/app1.jpeg b/test/mitmproxy/data/image_parser/app1.jpeg
new file mode 100644
index 00000000..baa77dfe
--- /dev/null
+++ b/test/mitmproxy/data/image_parser/app1.jpeg
Binary files differ
diff --git a/test/mitmproxy/data/image_parser/comment.jpg b/test/mitmproxy/data/image_parser/comment.jpg
new file mode 100644
index 00000000..74d443dd
--- /dev/null
+++ b/test/mitmproxy/data/image_parser/comment.jpg
Binary files differ
diff --git a/test/mitmproxy/data/image_parser/example.jpg b/test/mitmproxy/data/image_parser/example.jpg
new file mode 100644
index 00000000..415ee4b2
--- /dev/null
+++ b/test/mitmproxy/data/image_parser/example.jpg
Binary files differ