[Pkg-javascript-commits] [pdf.js] 389/414: Add a couple of `CipherTransformFactory` unit-tests to check that blank passwords are correctly rejected
David Prévot
taffit at moszumanska.debian.org
Tue Jun 28 17:12:43 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 4523ae0b914a4c280c1bb9252275a357a85d47f0
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Sat Apr 16 20:24:55 2016 +0200
Add a couple of `CipherTransformFactory` unit-tests to check that blank passwords are correctly rejected
---
test/unit/crypto_spec.js | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/test/unit/crypto_spec.js b/test/unit/crypto_spec.js
index e22381d..e33fc18 100644
--- a/test/unit/crypto_spec.js
+++ b/test/unit/crypto_spec.js
@@ -481,6 +481,19 @@ describe('CipherTransformFactory', function() {
done();
}
+ function ensurePasswordNeeded(done, dict, fileId, password) {
+ try {
+ new CipherTransformFactory(dict, fileId, password);
+ } catch (ex) {
+ expect(ex instanceof PasswordException).toEqual(true);
+ expect(ex.code).toEqual(PasswordResponses.NEED_PASSWORD);
+
+ done();
+ return;
+ }
+ done.fail('Password should be rejected.');
+ }
+
function ensurePasswordIncorrect(done, dict, fileId, password) {
try {
new CipherTransformFactory(dict, fileId, password);
@@ -609,6 +622,9 @@ describe('CipherTransformFactory', function() {
it('should accept owner password', function (done) {
ensurePasswordCorrect(done, aes256Dict, fileId1, 'owner');
});
+ it('should not accept blank password', function (done) {
+ ensurePasswordNeeded(done, aes256Dict, fileId1);
+ });
it('should not accept wrong password', function (done) {
ensurePasswordIncorrect(done, aes256Dict, fileId1, 'wrong');
});
@@ -624,6 +640,9 @@ describe('CipherTransformFactory', function() {
it('should accept owner password', function (done) {
ensurePasswordCorrect(done, aes256IsoDict, fileId1, 'owner');
});
+ it('should not accept blank password', function (done) {
+ ensurePasswordNeeded(done, aes256IsoDict, fileId1);
+ });
it('should not accept wrong password', function (done) {
ensurePasswordIncorrect(done, aes256IsoDict, fileId1, 'wrong');
});
@@ -638,10 +657,13 @@ describe('CipherTransformFactory', function() {
it('should accept owner password', function (done) {
ensurePasswordCorrect(done, dict1, fileId1, '654321');
});
+ it('should not accept blank password', function (done) {
+ ensurePasswordNeeded(done, dict1, fileId1);
+ });
it('should not accept wrong password', function (done) {
ensurePasswordIncorrect(done, dict1, fileId1, 'wrong');
});
- it('should accept no password', function (done) {
+ it('should accept blank password', function (done) {
ensurePasswordCorrect(done, dict2, fileId2);
});
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list