Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp

Issue 2581873002: Relax the EncryptMetadata check. (Closed)
Patch Set: Add tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/parser/cpdf_security_handler.cpp ('k') | testing/embedder_test.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "testing/embedder_test.h" 5 #include "testing/embedder_test.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 class CPDFSecurityHandlerEmbeddertest : public EmbedderTest {}; 8 class CPDFSecurityHandlerEmbeddertest : public EmbedderTest {};
9 9
10 TEST_F(CPDFSecurityHandlerEmbeddertest, Unencrypted) { 10 TEST_F(CPDFSecurityHandlerEmbeddertest, Unencrypted) {
11 ASSERT_TRUE(OpenDocument("about_blank.pdf")); 11 ASSERT_TRUE(OpenDocument("about_blank.pdf"));
12 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocPermissions(document())); 12 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocPermissions(document()));
13 } 13 }
14 14
15 TEST_F(CPDFSecurityHandlerEmbeddertest, UnencryptedWithPassword) { 15 TEST_F(CPDFSecurityHandlerEmbeddertest, UnencryptedWithPassword) {
16 ASSERT_TRUE(OpenDocument("about_blank.pdf", "foobar")); 16 ASSERT_TRUE(OpenDocument("about_blank.pdf", "foobar"));
17 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocPermissions(document())); 17 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocPermissions(document()));
18 } 18 }
19 19
20 TEST_F(CPDFSecurityHandlerEmbeddertest, NoPassword) { 20 TEST_F(CPDFSecurityHandlerEmbeddertest, NoPassword) {
21 EXPECT_FALSE(OpenDocument("encrypted.pdf")); 21 EXPECT_FALSE(OpenDocument("encrypted.pdf"));
22 } 22 }
23 23
24 TEST_F(CPDFSecurityHandlerEmbeddertest, BadPassword) {
25 EXPECT_FALSE(OpenDocument("encrypted.pdf", "tiger"));
26 }
27
24 TEST_F(CPDFSecurityHandlerEmbeddertest, UserPassword) { 28 TEST_F(CPDFSecurityHandlerEmbeddertest, UserPassword) {
25 ASSERT_TRUE(OpenDocument("encrypted.pdf", "1234")); 29 ASSERT_TRUE(OpenDocument("encrypted.pdf", "1234"));
26 EXPECT_EQ(0xFFFFF2C0, FPDF_GetDocPermissions(document())); 30 EXPECT_EQ(0xFFFFF2C0, FPDF_GetDocPermissions(document()));
27 } 31 }
28 32
29 TEST_F(CPDFSecurityHandlerEmbeddertest, OwnerPassword) { 33 TEST_F(CPDFSecurityHandlerEmbeddertest, OwnerPassword) {
30 ASSERT_TRUE(OpenDocument("encrypted.pdf", "5678")); 34 ASSERT_TRUE(OpenDocument("encrypted.pdf", "5678"));
31 EXPECT_EQ(0xFFFFFFFC, FPDF_GetDocPermissions(document())); 35 EXPECT_EQ(0xFFFFFFFC, FPDF_GetDocPermissions(document()));
32 } 36 }
37
38 TEST_F(CPDFSecurityHandlerEmbeddertest, NoPasswordVersion5) {
39 ASSERT_FALSE(OpenDocument("bug_644.pdf", "1234"));
Wei Li 2016/12/16 23:45:57 Does no-password case test empty password? Otherwi
Tom Sepez 2016/12/17 00:23:48 Nice catch.
40 }
41
42 TEST_F(CPDFSecurityHandlerEmbeddertest, BadPasswordVersion5) {
43 ASSERT_FALSE(OpenDocument("bug_644.pdf", "1234"));
44 }
45
46 TEST_F(CPDFSecurityHandlerEmbeddertest, OnwerPasswordVersion5) {
Wei Li 2016/12/16 23:45:57 s/Onwer/Owner
Tom Sepez 2016/12/17 00:24:35 Done.
47 ASSERT_TRUE(OpenDocument("bug_644.pdf", "a"));
48 EXPECT_EQ(0xFFFFFFFC, FPDF_GetDocPermissions(document()));
49 }
50
51 TEST_F(CPDFSecurityHandlerEmbeddertest, UserPasswordVersion5) {
52 ASSERT_TRUE(OpenDocument("bug_644.pdf", "b"));
53 EXPECT_EQ(0xFFFFFFFC, FPDF_GetDocPermissions(document()));
54 }
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_security_handler.cpp ('k') | testing/embedder_test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698