[14.0][MIG] report_qweb_encrypt

This commit is contained in:
Kitti U
2021-02-10 00:12:38 +07:00
committed by grzana12
parent 74075e5e3b
commit 60c723a84e
7 changed files with 19 additions and 548 deletions

View File

@@ -9,7 +9,7 @@ class TestReportQwebEncrypt(HttpCase):
ctx = {"force_report_rendering": True}
report = self.env.ref("web.action_report_internalpreview")
report.encrypt = False
pdf, _ = report.with_context(ctx).render_qweb_pdf([1])
pdf, _ = report.with_context(ctx)._render_qweb_pdf([1])
self.assertFalse(pdf.count(b"/Encrypt"))
def test_report_qweb_auto_encrypt(self):
@@ -18,15 +18,15 @@ class TestReportQwebEncrypt(HttpCase):
report.encrypt = "auto"
report.encrypt_password = False
# If no encrypt_password, still not encrypted
pdf, _ = report.with_context(ctx).render_qweb_pdf([1])
pdf, _ = report.with_context(ctx)._render_qweb_pdf([1])
self.assertFalse(pdf.count(b"/Encrypt"))
# If invalid encrypt_password, show error
report.encrypt_password = "invalid python syntax"
with self.assertRaises(ValidationError):
pdf, _ = report.with_context(ctx).render_qweb_pdf([1])
pdf, _ = report.with_context(ctx)._render_qweb_pdf([1])
# Valid python string for password
report.encrypt_password = "'secretcode'"
pdf, _ = report.with_context(ctx).render_qweb_pdf([1])
pdf, _ = report.with_context(ctx)._render_qweb_pdf([1])
self.assertTrue(pdf.count(b"/Encrypt"))
# TODO: test_report_qweb_manual_encrypt, require JS test?