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 "android_webview/native/aw_contents_client_bridge.h" | 5 #include "android_webview/native/aw_contents_client_bridge.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 cert_selected_callbacks_ = 0; | 85 cert_selected_callbacks_ = 0; |
86 cert_request_info_ = new net::SSLCertRequestInfo; | 86 cert_request_info_ = new net::SSLCertRequestInfo; |
87 } | 87 } |
88 | 88 |
89 void AwContentsClientBridgeTest::CertSelected(X509Certificate* cert) { | 89 void AwContentsClientBridgeTest::CertSelected(X509Certificate* cert) { |
90 selected_cert_ = cert; | 90 selected_cert_ = cert; |
91 cert_selected_callbacks_++; | 91 cert_selected_callbacks_++; |
92 } | 92 } |
93 | 93 |
94 TEST_F(AwContentsClientBridgeTest, TestClientCertKeyTypesCorrectlyEncoded) { | 94 TEST_F(AwContentsClientBridgeTest, TestClientCertKeyTypesCorrectlyEncoded) { |
95 SSLClientCertType cert_types[3] = {net::CLIENT_CERT_RSA_SIGN, | 95 SSLClientCertType cert_types[2] = {net::CLIENT_CERT_RSA_SIGN, |
96 net::CLIENT_CERT_DSS_SIGN, net::CLIENT_CERT_ECDSA_SIGN}; | 96 net::CLIENT_CERT_ECDSA_SIGN}; |
97 std::string expected_names[3] = {"RSA", "DSA" ,"ECDSA"}; | 97 std::string expected_names[2] = {"RSA", "ECDSA"}; |
98 | 98 |
99 for(int i = 0; i < 3; i++) { | 99 for (int i = 0; i < 2; i++) { |
100 TestCertType(cert_types[i], expected_names[i]); | 100 TestCertType(cert_types[i], expected_names[i]); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 void AwContentsClientBridgeTest::TestCertType(SSLClientCertType type, | 104 void AwContentsClientBridgeTest::TestCertType(SSLClientCertType type, |
105 const std::string& expected_name) { | 105 const std::string& expected_name) { |
106 cert_request_info_->cert_key_types.clear(); | 106 cert_request_info_->cert_key_types.clear(); |
107 cert_request_info_->cert_key_types.push_back(type); | 107 cert_request_info_->cert_key_types.push_back(type); |
108 bridge_->SelectClientCertificate( | 108 bridge_->SelectClientCertificate( |
109 cert_request_info_.get(), | 109 cert_request_info_.get(), |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 requestId, | 154 requestId, |
155 NULL, | 155 NULL, |
156 Java_MockAwContentsClientBridge_createTestPrivateKey( | 156 Java_MockAwContentsClientBridge_createTestPrivateKey( |
157 env_, jbridge_.obj()).obj()); | 157 env_, jbridge_.obj()).obj()); |
158 base::RunLoop().RunUntilIdle(); | 158 base::RunLoop().RunUntilIdle(); |
159 EXPECT_EQ(NULL, selected_cert_); | 159 EXPECT_EQ(NULL, selected_cert_); |
160 EXPECT_EQ(1, cert_selected_callbacks_); | 160 EXPECT_EQ(1, cert_selected_callbacks_); |
161 } | 161 } |
162 | 162 |
163 } // android_webview | 163 } // android_webview |
OLD | NEW |