OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 "extensions/browser/api/cast_channel/cast_auth_util.h" | 5 #include "extensions/browser/api/cast_channel/cast_auth_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "components/cast_certificate/cast_cert_validator_test_helpers.h" |
10 #include "extensions/common/api/cast_channel/cast_channel.pb.h" | 11 #include "extensions/common/api/cast_channel/cast_channel.pb.h" |
11 #include "extensions/common/cast/cast_cert_validator_test_helpers.h" | |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace extensions { | 14 namespace extensions { |
15 namespace api { | 15 namespace api { |
16 namespace cast_channel { | 16 namespace cast_channel { |
17 namespace { | 17 namespace { |
18 | 18 |
19 class CastAuthUtilTest : public testing::Test { | 19 class CastAuthUtilTest : public testing::Test { |
20 public: | 20 public: |
21 CastAuthUtilTest() {} | 21 CastAuthUtilTest() {} |
22 ~CastAuthUtilTest() override {} | 22 ~CastAuthUtilTest() override {} |
23 | 23 |
24 void SetUp() override {} | 24 void SetUp() override {} |
25 | 25 |
26 protected: | 26 protected: |
27 static AuthResponse CreateAuthResponse(std::string* signed_data) { | 27 static AuthResponse CreateAuthResponse(std::string* signed_data) { |
28 auto chain = cast_test_helpers::ReadCertificateChainFromFile( | 28 auto chain = cast_certificate::testing::ReadCertificateChainFromFile( |
29 "cast_certificates/chromecast_gen1.pem"); | 29 "certificates/chromecast_gen1.pem"); |
30 CHECK(!chain.empty()); | 30 CHECK(!chain.empty()); |
31 | 31 |
32 auto signature_data = cast_test_helpers::ReadSignatureTestData( | 32 auto signature_data = cast_certificate::testing::ReadSignatureTestData( |
33 "cast_signeddata/2ZZBG9_FA8FCA3EF91A.pem"); | 33 "signeddata/2ZZBG9_FA8FCA3EF91A.pem"); |
34 | 34 |
35 AuthResponse response; | 35 AuthResponse response; |
36 | 36 |
37 response.set_client_auth_certificate(chain[0]); | 37 response.set_client_auth_certificate(chain[0]); |
38 for (size_t i = 1; i < chain.size(); ++i) | 38 for (size_t i = 1; i < chain.size(); ++i) |
39 response.add_intermediate_certificate(chain[i]); | 39 response.add_intermediate_certificate(chain[i]); |
40 | 40 |
41 response.set_signature(signature_data.signature_sha1); | 41 response.set_signature(signature_data.signature_sha1); |
42 *signed_data = signature_data.message; | 42 *signed_data = signature_data.message; |
43 | 43 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 MangleString(&signed_data); | 93 MangleString(&signed_data); |
94 AuthResult result = VerifyCredentials(auth_response, signed_data); | 94 AuthResult result = VerifyCredentials(auth_response, signed_data); |
95 EXPECT_FALSE(result.success()); | 95 EXPECT_FALSE(result.success()); |
96 EXPECT_EQ(AuthResult::ERROR_SIGNED_BLOBS_MISMATCH, result.error_type); | 96 EXPECT_EQ(AuthResult::ERROR_SIGNED_BLOBS_MISMATCH, result.error_type); |
97 } | 97 } |
98 | 98 |
99 } // namespace | 99 } // namespace |
100 } // namespace cast_channel | 100 } // namespace cast_channel |
101 } // namespace api | 101 } // namespace api |
102 } // namespace extensions | 102 } // namespace extensions |
OLD | NEW |