Skip to content

Commit

Permalink
Match testing asserts on translated strings
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov committed Apr 21, 2023
1 parent d5fc420 commit bfa5ff0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tcms/kiwi_attachments/tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import base64
from xmlrpc.client import Fault

from django.utils.translation import gettext_lazy as _

from tcms.rpc.tests.utils import APITestCase


Expand All @@ -12,18 +14,19 @@ def test_uploading_svg_with_inline_script_should_fail(self):
with open("tests/ui/data/inline_javascript.svg", "rb") as svg_file:
b64 = base64.b64encode(svg_file.read()).decode()

with self.assertRaisesRegex(Fault, "File contains forbidden <script> tag"):
message = str(_("File contains forbidden <script> tag"))
with self.assertRaisesRegex(Fault, message):
self.rpc_client.User.add_attachment("inline_javascript.svg", b64)

def test_uploading_filename_ending_in_dot_exe_should_fail(self):
with self.assertRaisesRegex(Fault, "Uploading executable files is forbidden"):
message = str(_("Uploading executable files is forbidden"))
with self.assertRaisesRegex(Fault, message):
self.rpc_client.User.add_attachment("hello.exe", "a2l3aXRjbXM=")

def test_uploading_real_exe_file_should_fail(self):
with open("tests/ui/data/reactos_csrss.exe", "rb") as exe_file:
b64 = base64.b64encode(exe_file.read()).decode()

with self.assertRaisesRegex(
Fault, "Uploading executable files is forbidden"
):
message = str(_("Uploading executable files is forbidden"))
with self.assertRaisesRegex(Fault, message):
self.rpc_client.User.add_attachment("csrss.exe_from_reactos", b64)

0 comments on commit bfa5ff0

Please sign in to comment.