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

Side by Side Diff: net/base/keygen_handler_unittest.cc

Issue 5195001: Fixes the remaining net_unittests for OpenSSL, with the exceptions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clarify comment Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/base/keygen_handler.h" 5 #include "net/base/keygen_handler.h"
6 6
7 #include "build/build_config.h" // Needs to be imported early for USE_NSS 7 #include "build/build_config.h" // Needs to be imported early for USE_NSS
8 8
9 #if defined(USE_NSS) 9 #if defined(USE_NSS)
10 #include <private/pprthred.h> // PR_DetachThread 10 #include <private/pprthred.h> // PR_DetachThread
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // Exponent: 65537 (0x10001) 66 // Exponent: 65537 (0x10001)
67 // Challenge String: some challenge 67 // Challenge String: some challenge
68 // Signature Algorithm: md5WithRSAEncryption 68 // Signature Algorithm: md5WithRSAEncryption
69 // 92:f3:cc:ff:0b:d3:d0:4a:3a:4c:ba:ff:d6:38:7f:a5:4b:b5: ..... 69 // 92:f3:cc:ff:0b:d3:d0:4a:3a:4c:ba:ff:d6:38:7f:a5:4b:b5: .....
70 // Signature OK 70 // Signature OK
71 // 71 //
72 // The value of |spkac| can be ASN.1-parsed with: 72 // The value of |spkac| can be ASN.1-parsed with:
73 // openssl asn1parse -inform DER 73 // openssl asn1parse -inform DER
74 } 74 }
75 75
76 TEST_F(KeygenHandlerTest, SmokeTest) { 76 // Keygen not yet implemented for OpenSSL: http://crbug.com/64917
77 #if defined(USE_OPENSSL)
78 #define MAYBE_SmokeTest FAILS_SmokeTest
79 #else
80 #define MAYBE_SmokeTest SmokeTest
81 #endif
82 TEST_F(KeygenHandlerTest, MAYBE_SmokeTest) {
77 KeygenHandler handler(768, "some challenge", GURL("http://www.example.com")); 83 KeygenHandler handler(768, "some challenge", GURL("http://www.example.com"));
78 handler.set_stores_key(false); // Don't leave the key-pair behind 84 handler.set_stores_key(false); // Don't leave the key-pair behind
79 std::string result = handler.GenKeyAndSignChallenge(); 85 std::string result = handler.GenKeyAndSignChallenge();
80 VLOG(1) << "KeygenHandler produced: " << result; 86 VLOG(1) << "KeygenHandler produced: " << result;
81 AssertValidSignedPublicKeyAndChallenge(result, "some challenge"); 87 AssertValidSignedPublicKeyAndChallenge(result, "some challenge");
82 } 88 }
83 89
84 class ConcurrencyTestTask : public Task { 90 class ConcurrencyTestTask : public Task {
85 public: 91 public:
86 ConcurrencyTestTask(base::WaitableEvent* event, 92 ConcurrencyTestTask(base::WaitableEvent* event,
(...skipping 23 matching lines...) Expand all
110 PR_DetachThread(); 116 PR_DetachThread();
111 #endif 117 #endif
112 } 118 }
113 119
114 private: 120 private:
115 base::WaitableEvent* event_; 121 base::WaitableEvent* event_;
116 std::string challenge_; 122 std::string challenge_;
117 std::string* result_; 123 std::string* result_;
118 }; 124 };
119 125
126 // Keygen not yet implemented for OpenSSL: http://crbug.com/64917
127 #if defined(USE_OPENSSL)
128 #define MAYBE_ConcurrencyTest FAILS_ConcurrencyTest
129 #else
130 #define MAYBE_ConcurrencyTest ConcurrencyTest
131 #endif
120 // We asynchronously generate the keys so as not to hang up the IO thread. This 132 // We asynchronously generate the keys so as not to hang up the IO thread. This
121 // test tries to catch concurrency problems in the keygen implementation. 133 // test tries to catch concurrency problems in the keygen implementation.
122 TEST_F(KeygenHandlerTest, ConcurrencyTest) { 134 TEST_F(KeygenHandlerTest, MAYBE_ConcurrencyTest) {
123 const int NUM_HANDLERS = 5; 135 const int NUM_HANDLERS = 5;
124 base::WaitableEvent* events[NUM_HANDLERS] = { NULL }; 136 base::WaitableEvent* events[NUM_HANDLERS] = { NULL };
125 std::string results[NUM_HANDLERS]; 137 std::string results[NUM_HANDLERS];
126 for (int i = 0; i < NUM_HANDLERS; i++) { 138 for (int i = 0; i < NUM_HANDLERS; i++) {
127 events[i] = new base::WaitableEvent(false, false); 139 events[i] = new base::WaitableEvent(false, false);
128 WorkerPool::PostTask(FROM_HERE, 140 WorkerPool::PostTask(FROM_HERE,
129 new ConcurrencyTestTask(events[i], "some challenge", 141 new ConcurrencyTestTask(events[i], "some challenge",
130 &results[i]), 142 &results[i]),
131 true); 143 true);
132 } 144 }
133 145
134 for (int i = 0; i < NUM_HANDLERS; i++) { 146 for (int i = 0; i < NUM_HANDLERS; i++) {
135 // Make sure the job completed 147 // Make sure the job completed
136 bool signaled = events[i]->Wait(); 148 bool signaled = events[i]->Wait();
137 EXPECT_TRUE(signaled); 149 EXPECT_TRUE(signaled);
138 delete events[i]; 150 delete events[i];
139 events[i] = NULL; 151 events[i] = NULL;
140 152
141 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i]; 153 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i];
142 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge"); 154 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge");
143 } 155 }
144 } 156 }
145 157
146 } // namespace 158 } // namespace
147 159
148 } // namespace net 160 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698