diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-20 00:17:20 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-20 00:17:20 +0000 |
commit | dde7cf8802c6951d39f8bcdc77296b0654e87a23 (patch) | |
tree | aef652180c48a4e80d38cb9e31a604e2b317ef6b /net/base/ssl_cipher_suite_names_unittest.cc | |
parent | 7cb128c307edf2b1842980e0b6d0d17b3927091a (diff) | |
download | chromium_src-dde7cf8802c6951d39f8bcdc77296b0654e87a23.zip chromium_src-dde7cf8802c6951d39f8bcdc77296b0654e87a23.tar.gz chromium_src-dde7cf8802c6951d39f8bcdc77296b0654e87a23.tar.bz2 |
Add basic support for parsing SSL/TLS cipher suite strings.
BUG=58831
TEST=net_unittests --gtest_filter=CipherSuiteNamesTest.Parse*
Review URL: http://codereview.chromium.org/7396014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93134 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/ssl_cipher_suite_names_unittest.cc')
-rw-r--r-- | net/base/ssl_cipher_suite_names_unittest.cc | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/net/base/ssl_cipher_suite_names_unittest.cc b/net/base/ssl_cipher_suite_names_unittest.cc index 3a9c2ee..03ceef6 100644 --- a/net/base/ssl_cipher_suite_names_unittest.cc +++ b/net/base/ssl_cipher_suite_names_unittest.cc @@ -1,8 +1,10 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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/ssl_cipher_suite_names.h" + +#include "base/basictypes.h" #include "testing/gtest/include/gtest/gtest.h" namespace net { @@ -22,6 +24,28 @@ TEST(CipherSuiteNamesTest, Basic) { EXPECT_STREQ(mac, "???"); } +TEST(CipherSuiteNamesTest, ParseSSLCipherString) { + uint16 cipher_suite = 0; + EXPECT_TRUE(ParseSSLCipherString("0x0004", &cipher_suite)); + EXPECT_EQ(0x00004u, cipher_suite); + + EXPECT_TRUE(ParseSSLCipherString("0xBEEF", &cipher_suite)); + EXPECT_EQ(0xBEEFu, cipher_suite); +} + +TEST(CipherSuiteNamesTest, ParseSSLCipherStringFails) { + const char* const cipher_strings[] = { + "0004", + "0x004", + "0xBEEFY", + }; + + for (size_t i = 0; i < arraysize(cipher_strings); ++i) { + uint16 cipher_suite = 0; + EXPECT_FALSE(ParseSSLCipherString(cipher_strings[i], &cipher_suite)); + } +} + } // anonymous namespace } // namespace net |