From 02f67da2ca15773209ea4295a7a06a2a54a1dc5e Mon Sep 17 00:00:00 2001 From: CF Mitrah Date: Wed, 27 Sep 2023 11:21:14 +0530 Subject: [PATCH 1/2] Added a testcase to check for an invalid password with the action='removepassword' in cfpdf on LDEV-4694 --- tests/LDEV4694.cfc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/LDEV4694.cfc diff --git a/tests/LDEV4694.cfc b/tests/LDEV4694.cfc new file mode 100644 index 0000000..9e4724b --- /dev/null +++ b/tests/LDEV4694.cfc @@ -0,0 +1,30 @@ +component extends=org.lucee.cfml.test.LuceeTestCase { + + function beforeAll() { + variables.testPdf = getTempFile( getTempDirectory(), "ldev4694", "pdf" ); + variables.password = createUniqueID(); + + if( not fileExists('#testPdf#') ){ + document format="pdf" filename="#testPdf#" overwrite=true { + echo(" "); + } + pdf action="protect" source="#testPdf#" newUserPassword="#password#"; + } + } + + function run( testResults , testBox ) { + describe( title="Testcase for LDEV-4694" , body=function() { + it( title="Checking for invalid password with action='removepassword' in cfpdf" , body=function( currentSpec ) { + expect( function(){ + pdf action="removePassword" source=#testPdf# destination=#testPdf# password="invalidPassword" overwrite=true; + }).toThrow(); + expect( fileExists( variables.testPdf ) ).toBeFalse(); + }); + }); + } + + function afterAll(){ + if ( fileExists( variables.testPdf ) ) + fileDelete( variables.testPdf ); + }; +} \ No newline at end of file From 6d63b5f5b6a783d71ff3361f2e15b6bc3537e200 Mon Sep 17 00:00:00 2001 From: Saravanamuthu Aka CF Mitrah Date: Wed, 27 Sep 2023 11:23:08 +0530 Subject: [PATCH 2/2] Update LDEV4694.cfc --- tests/LDEV4694.cfc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/LDEV4694.cfc b/tests/LDEV4694.cfc index 9e4724b..88b06a8 100644 --- a/tests/LDEV4694.cfc +++ b/tests/LDEV4694.cfc @@ -1,4 +1,4 @@ -component extends=org.lucee.cfml.test.LuceeTestCase { +component extends=org.lucee.cfml.test.LuceeTestCase skip=true { function beforeAll() { variables.testPdf = getTempFile( getTempDirectory(), "ldev4694", "pdf" ); @@ -27,4 +27,4 @@ component extends=org.lucee.cfml.test.LuceeTestCase { if ( fileExists( variables.testPdf ) ) fileDelete( variables.testPdf ); }; -} \ No newline at end of file +}