|
|
@ -73,17 +73,12 @@ def test_check_notification(client, live_server):
|
|
|
|
# We write the PNG to disk, but a JPEG should appear in the notification
|
|
|
|
# We write the PNG to disk, but a JPEG should appear in the notification
|
|
|
|
# Write the last screenshot png
|
|
|
|
# Write the last screenshot png
|
|
|
|
testimage_png = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
|
|
|
|
testimage_png = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
|
|
|
|
# This one is created when we save the screenshot from the webdriver/playwright session (converted from PNG)
|
|
|
|
|
|
|
|
testimage_jpg = '/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/wAALCAABAAEBAREA/8QAFAABAAAAAAAAAAAAAAAAAAAACf/EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAD8AKp//2Q=='
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uuid = extract_UUID_from_client(client)
|
|
|
|
uuid = extract_UUID_from_client(client)
|
|
|
|
datastore = 'test-datastore'
|
|
|
|
datastore = 'test-datastore'
|
|
|
|
with open(os.path.join(datastore, str(uuid), 'last-screenshot.png'), 'wb') as f:
|
|
|
|
with open(os.path.join(datastore, str(uuid), 'last-screenshot.png'), 'wb') as f:
|
|
|
|
f.write(base64.b64decode(testimage_png))
|
|
|
|
f.write(base64.b64decode(testimage_png))
|
|
|
|
# We no longer create two images
|
|
|
|
|
|
|
|
# with open(os.path.join(datastore, str(uuid), 'last-screenshot.jpg'), 'wb') as f:
|
|
|
|
|
|
|
|
# f.write(base64.b64decode(testimage_jpg))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Goto the edit page, add our ignore text
|
|
|
|
# Goto the edit page, add our ignore text
|
|
|
|
# Add our URL to the import page
|
|
|
|
# Add our URL to the import page
|
|
|
@ -163,13 +158,12 @@ def test_check_notification(client, live_server):
|
|
|
|
|
|
|
|
|
|
|
|
# Check the attachment was added, and that it is a JPEG from the original PNG
|
|
|
|
# Check the attachment was added, and that it is a JPEG from the original PNG
|
|
|
|
notification_submission_object = json.loads(notification_submission)
|
|
|
|
notification_submission_object = json.loads(notification_submission)
|
|
|
|
# We actually convert the PNG to JPEG and send it
|
|
|
|
# We keep PNG screenshots for now
|
|
|
|
assert notification_submission_object['attachments'][0]['filename'] == 'last-screenshot.jpg'
|
|
|
|
assert notification_submission_object['attachments'][0]['filename'] == 'last-screenshot.png'
|
|
|
|
assert len(notification_submission_object['attachments'][0]['base64'])
|
|
|
|
assert len(notification_submission_object['attachments'][0]['base64'])
|
|
|
|
assert notification_submission_object['attachments'][0]['mimetype'] == 'image/jpeg'
|
|
|
|
assert notification_submission_object['attachments'][0]['mimetype'] == 'image/png'
|
|
|
|
jpeg_in_attachment = base64.b64decode(notification_submission_object['attachments'][0]['base64'])
|
|
|
|
jpeg_in_attachment = base64.b64decode(notification_submission_object['attachments'][0]['base64'])
|
|
|
|
assert b'JFIF' in jpeg_in_attachment
|
|
|
|
|
|
|
|
assert testimage_png not in notification_submission
|
|
|
|
|
|
|
|
# Assert that the JPEG is readable (didn't get chewed up somewhere)
|
|
|
|
# Assert that the JPEG is readable (didn't get chewed up somewhere)
|
|
|
|
from PIL import Image
|
|
|
|
from PIL import Image
|
|
|
|
import io
|
|
|
|
import io
|
|
|
@ -301,7 +295,10 @@ def test_notification_custom_endpoint_and_jinja2(client, live_server):
|
|
|
|
follow_redirects=True
|
|
|
|
follow_redirects=True
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assert b'Settings updated' in res.data
|
|
|
|
assert b'Settings updated' in res.data
|
|
|
|
|
|
|
|
client.get(
|
|
|
|
|
|
|
|
url_for("form_delete", uuid="all"),
|
|
|
|
|
|
|
|
follow_redirects=True
|
|
|
|
|
|
|
|
)
|
|
|
|
# Add a watch and trigger a HTTP POST
|
|
|
|
# Add a watch and trigger a HTTP POST
|
|
|
|
test_url = url_for('test_endpoint', _external=True)
|
|
|
|
test_url = url_for('test_endpoint', _external=True)
|
|
|
|
res = client.post(
|
|
|
|
res = client.post(
|
|
|
|