summaryrefslogtreecommitdiffstats
path: root/net/base/pem_tokenizer_unittest.cc
diff options
context:
space:
mode:
authorrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-17 03:17:46 +0000
committerrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-17 03:17:46 +0000
commit3aee726050eeb2b29f26abf7da806ba1d1af2389 (patch)
tree392e18d2923ee9de4c9d297893de1ebbd47ba2bd /net/base/pem_tokenizer_unittest.cc
parent3a612be14f1bd1aa730cedbd11bb3ec333cc078c (diff)
downloadchromium_src-3aee726050eeb2b29f26abf7da806ba1d1af2389.zip
chromium_src-3aee726050eeb2b29f26abf7da806ba1d1af2389.tar.gz
chromium_src-3aee726050eeb2b29f26abf7da806ba1d1af2389.tar.bz2
Revert 52799 - Add support for parsing certificate formats other than raw, DER-encoded certificates - specifically formats that represent collections of certificates. The certificate format can now be specified as an explicit format, or as a bit-mask of formats that are acceptable/expected, with the first parsable format winning.
This is one half of a commit to address BUG #37142, with the second half involving connecting this through the X509UserCertHandler and the actual UI. R=wtc BUG=37142 TEST=X509CertificateParseTest* and PEMTokenizerTest.* Review URL: http://codereview.chromium.org/2819018 TBR=rsleevi@chromium.org Review URL: http://codereview.chromium.org/2812064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52801 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/pem_tokenizer_unittest.cc')
-rw-r--r--net/base/pem_tokenizer_unittest.cc169
1 files changed, 0 insertions, 169 deletions
diff --git a/net/base/pem_tokenizer_unittest.cc b/net/base/pem_tokenizer_unittest.cc
deleted file mode 100644
index af2446c..0000000
--- a/net/base/pem_tokenizer_unittest.cc
+++ /dev/null
@@ -1,169 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/base/pem_tokenizer.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace net {
-
-TEST(PEMTokenizerTest, BasicParsing) {
- const char data[] =
- "-----BEGIN EXPECTED-BLOCK-----\n"
- "TWF0Y2hlc0FjY2VwdGVkQmxvY2tUeXBl\n"
- "-----END EXPECTED-BLOCK-----\n";
- base::StringPiece string_piece(data);
- std::vector<std::string> accepted_types;
- accepted_types.push_back("EXPECTED-BLOCK");
-
- PEMTokenizer tokenizer(string_piece, accepted_types);
- EXPECT_TRUE(tokenizer.GetNext());
-
- EXPECT_EQ("EXPECTED-BLOCK", tokenizer.block_type());
- EXPECT_EQ("MatchesAcceptedBlockType", tokenizer.data());
-
- EXPECT_FALSE(tokenizer.GetNext());
-}
-
-TEST(PEMTokenizerTest, CarriageReturnLineFeeds) {
- const char data[] =
- "-----BEGIN EXPECTED-BLOCK-----\r\n"
- "TWF0Y2hlc0FjY2VwdGVkQmxvY2tUeXBl\r\n"
- "-----END EXPECTED-BLOCK-----\r\n";
- base::StringPiece string_piece(data);
- std::vector<std::string> accepted_types;
- accepted_types.push_back("EXPECTED-BLOCK");
-
- PEMTokenizer tokenizer(string_piece, accepted_types);
- EXPECT_TRUE(tokenizer.GetNext());
-
- EXPECT_EQ("EXPECTED-BLOCK", tokenizer.block_type());
- EXPECT_EQ("MatchesAcceptedBlockType", tokenizer.data());
-
- EXPECT_FALSE(tokenizer.GetNext());
-}
-
-TEST(PEMTokenizerTest, NoAcceptedBlockTypes) {
- const char data[] =
- "-----BEGIN UNEXPECTED-BLOCK-----\n"
- "SWdub3Jlc1JlamVjdGVkQmxvY2tUeXBl\n"
- "-----END UNEXPECTED-BLOCK-----\n";
- base::StringPiece string_piece(data);
- std::vector<std::string> accepted_types;
- accepted_types.push_back("EXPECTED-BLOCK");
-
- PEMTokenizer tokenizer(string_piece, accepted_types);
- EXPECT_FALSE(tokenizer.GetNext());
-}
-
-TEST(PEMTokenizerTest, MultipleAcceptedBlockTypes) {
- const char data[] =
- "-----BEGIN BLOCK-ONE-----\n"
- "RW5jb2RlZERhdGFPbmU=\n"
- "-----END BLOCK-ONE-----\n"
- "-----BEGIN BLOCK-TWO-----\n"
- "RW5jb2RlZERhdGFUd28=\n"
- "-----END BLOCK-TWO-----\n";
- base::StringPiece string_piece(data);
- std::vector<std::string> accepted_types;
- accepted_types.push_back("BLOCK-ONE");
- accepted_types.push_back("BLOCK-TWO");
-
- PEMTokenizer tokenizer(string_piece, accepted_types);
- EXPECT_TRUE(tokenizer.GetNext());
-
- EXPECT_EQ("BLOCK-ONE", tokenizer.block_type());
- EXPECT_EQ("EncodedDataOne", tokenizer.data());
-
- EXPECT_TRUE(tokenizer.GetNext());
-
- EXPECT_EQ("BLOCK-TWO", tokenizer.block_type());
- EXPECT_EQ("EncodedDataTwo", tokenizer.data());
-
- EXPECT_FALSE(tokenizer.GetNext());
-}
-
-TEST(PEMTokenizerTest, MissingFooter) {
- const char data[] =
- "-----BEGIN MISSING-FOOTER-----\n"
- "RW5jb2RlZERhdGFPbmU=\n"
- "-----END MISSING-FOOTER-----\n"
- "-----BEGIN MISSING-FOOTER-----\n"
- "RW5jb2RlZERhdGFUd28=\n";
- base::StringPiece string_piece(data);
- std::vector<std::string> accepted_types;
- accepted_types.push_back("MISSING-FOOTER");
-
- PEMTokenizer tokenizer(string_piece, accepted_types);
- EXPECT_TRUE(tokenizer.GetNext());
-
- EXPECT_EQ("MISSING-FOOTER", tokenizer.block_type());
- EXPECT_EQ("EncodedDataOne", tokenizer.data());
-
- EXPECT_FALSE(tokenizer.GetNext());
-}
-
-TEST(PEMTokenizerTest, NestedEncoding) {
- const char data[] =
- "-----BEGIN BLOCK-ONE-----\n"
- "RW5jb2RlZERhdGFPbmU=\n"
- "-----BEGIN BLOCK-TWO-----\n"
- "RW5jb2RlZERhdGFUd28=\n"
- "-----END BLOCK-TWO-----\n"
- "-----END BLOCK-ONE-----\n"
- "-----BEGIN BLOCK-ONE-----\n"
- "RW5jb2RlZERhdGFUaHJlZQ==\n"
- "-----END BLOCK-ONE-----\n";
- base::StringPiece string_piece(data);
- std::vector<std::string> accepted_types;
- accepted_types.push_back("BLOCK-ONE");
-
- PEMTokenizer tokenizer(string_piece, accepted_types);
- EXPECT_TRUE(tokenizer.GetNext());
-
- EXPECT_EQ("BLOCK-ONE", tokenizer.block_type());
- EXPECT_EQ("EncodedDataThree", tokenizer.data());
-
- EXPECT_FALSE(tokenizer.GetNext());
-}
-
-TEST(PEMTokenizerTest, EmptyAcceptedTypes) {
- const char data[] =
- "-----BEGIN BLOCK-ONE-----\n"
- "RW5jb2RlZERhdGFPbmU=\n"
- "-----END BLOCK-ONE-----\n";
- base::StringPiece string_piece(data);
- std::vector<std::string> accepted_types;
-
- PEMTokenizer tokenizer(string_piece, accepted_types);
- EXPECT_FALSE(tokenizer.GetNext());
-}
-
-TEST(PEMTokenizerTest, BlockWithHeader) {
- const char data[] =
- "-----BEGIN BLOCK-ONE-----\n"
- "Header-One: Data data data\n"
- "Header-Two: \n"
- " continuation\n"
- "Header-Three: Mix-And,Match\n"
- "\n"
- "RW5jb2RlZERhdGFPbmU=\n"
- "-----END BLOCK-ONE-----\n"
- "-----BEGIN BLOCK-ONE-----\n"
- "RW5jb2RlZERhdGFUd28=\n"
- "-----END BLOCK-ONE-----\n";
- base::StringPiece string_piece(data);
- std::vector<std::string> accepted_types;
- accepted_types.push_back("BLOCK-ONE");
-
- PEMTokenizer tokenizer(string_piece, accepted_types);
- EXPECT_TRUE(tokenizer.GetNext());
-
- EXPECT_EQ("BLOCK-ONE", tokenizer.block_type());
- EXPECT_EQ("EncodedDataTwo", tokenizer.data());
-
- EXPECT_FALSE(tokenizer.GetNext());
-}
-
-} // namespace net