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

Unified Diff: extensions/browser/api/cast_channel/cast_auth_util_unittest.cc

Issue 627573002: Enable passing cast channel certificate authority keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Browser and unit tests. Created 6 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/cast_channel/cast_auth_util_unittest.cc
diff --git a/extensions/browser/api/cast_channel/cast_auth_util_unittest.cc b/extensions/browser/api/cast_channel/cast_auth_util_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9d59824997c4913436e4dacf37ab955b5b430f44
--- /dev/null
+++ b/extensions/browser/api/cast_channel/cast_auth_util_unittest.cc
@@ -0,0 +1,77 @@
+// Copyright 2014 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 <string>
+#include "base/base64.h"
+#include "extensions/browser/api/cast_channel/cast_auth_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace extensions {
+namespace core_api {
+namespace cast_channel {
+class CastChannelAuthorityKeysTest : public testing::Test {
+ public:
+ CastChannelAuthorityKeysTest() {}
+ virtual ~CastChannelAuthorityKeysTest() {}
+
+ protected:
+ void TestKeys();
+ AuthorityKeysStore authority_keys_store_;
+};
+
+const net::SHA256HashValue kFingerprintValid = { {
+ 0x52, 0x9D, 0x9C, 0xD6, 0x7F, 0xE5, 0xEB, 0x69, 0x8E, 0x70, 0xDD, 0x26,
+ 0xD7, 0xD8, 0xF1, 0x26, 0x59, 0xF1, 0xE6, 0xE5, 0x23, 0x48, 0xBF, 0x6A,
+ 0x5C, 0xF7, 0x16, 0xE1, 0x3F, 0x41, 0x0E, 0x73
+} };
+
+const net::SHA256HashValue kFingerprintInvalid = { {
+ 0x00, 0x9D, 0x9C, 0xD6, 0x7F, 0xE5, 0xEB, 0x69, 0x8E, 0x70, 0xDD, 0x26,
+ 0xD7, 0xD8, 0xF1, 0x26, 0x59, 0xF1, 0xE6, 0xE5, 0x23, 0x48, 0xBF, 0x6A,
+ 0x5C, 0xF7, 0x16, 0xE1, 0x3F, 0x41, 0x0E, 0x73
+} };
+
+void CastChannelAuthorityKeysTest::TestKeys() {
mark a. foltz 2014/10/16 22:46:18 ExpectDefaultKeysLoaded() - since TestKeys makes i
vadimgo 2014/10/17 00:42:12 Done. Renamed it to ExpectKeysLoaded.
+ const SECItem* key = authority_keys_store_.GetDefaultICAPublicKey();
+ EXPECT_NE(static_cast<SECItem*>(NULL), key);
+
+ key = authority_keys_store_.GetICAPublicKeyFromFingerprint(kFingerprintValid);
+ EXPECT_NE(static_cast<SECItem*>(NULL), key);
+
+ key =
+ authority_keys_store_.GetICAPublicKeyFromFingerprint(kFingerprintInvalid);
+ EXPECT_EQ(static_cast<SECItem*>(NULL), key);
+}
+
+TEST_F(CastChannelAuthorityKeysTest, TestDefaultKeys) {
+ TestKeys();
+}
+
+TEST_F(CastChannelAuthorityKeysTest, TestInvalidProtobuf) {
+ std::string keys = "test";
+ EXPECT_EQ(authority_keys_store_.Load(keys), false);
+
+ const SECItem* key = authority_keys_store_.GetDefaultICAPublicKey();
+ EXPECT_EQ(static_cast<SECItem*>(NULL), key);
+}
+
+TEST_F(CastChannelAuthorityKeysTest, TestValidProtobuf) {
+ std::string keys =
+ "CrMCCiBSnZzWf+XraY5w3SbX2PEmWfHm5SNIv2pc9xbhP0EOcxKOAjCCAQoCggEBALwigL"
+ "2A9johADuudl41fz3DZFxVlIY0LwWHKM33aYwXs1CnuIL638dDLdZ+q6BvtxNygKRHFcEg"
+ "mVDN7BRiCVukmM3SQbY2Tv/oLjIwSoGoQqNsmzNuyrL1U2bgJ1OGGoUepzk/SneO+1RmZv"
+ "tYVMBeOcf1UAYL4IrUzuFqVR+LFwDmaaMn5gglaTwSnY0FLNYuojHetFJQ1iBJ3nGg+a0g"
+ "TOmZer5ufkQBLx3SXr1ea4NvTWj3/KQ9zXEFvmP1GKhbPz//YDLcsjT5ytGOeTBYysUpr3"
+ "0K48YcqZP6OqWRXRy9ZuvMYNyGdMrP+JIcmH1X+mFHnquAt+RIgCqSxRsCAwEAAQ==";
+ std::string decoded_keys;
+
+ EXPECT_EQ(base::Base64Decode(keys, &decoded_keys), true);
+ EXPECT_EQ(authority_keys_store_.Load(decoded_keys), true);
+
+ TestKeys();
mark a. foltz 2014/10/16 22:46:18 Can you update the test to verify than an addition
vadimgo 2014/10/17 00:42:11 Done.
+}
+
+} // namespace cast_channel
+} // namespace core_api
+} // namespace extensions
« no previous file with comments | « extensions/browser/api/cast_channel/cast_auth_util_nss.cc ('k') | extensions/browser/api/cast_channel/cast_channel_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698