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

Side by Side Diff: components/cronet/ios/test/cronet_test_base.h

Issue 2928653002: [Cronet-iOS] Public-Key-Pinning Tests (Closed)
Patch Set: Addressed Lily's comments. Created 3 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PRODUCTS_CRONET_TEST_BASE_H
mef 2017/06/12 22:25:24 nit: COMPONENTS_CRONET_IOS_TEST_CRONET_TEST_BASE_H
kapishnikov 2017/06/16 20:11:05 Done.
6 #define PRODUCTS_CRONET_TEST_BASE_H
7
8 #include "Cronet/Cronet.h"
mef 2017/06/12 22:25:24 Should this be #import <Cronet/Cronet.h>?
kapishnikov 2017/06/16 20:11:05 Done.
9 #include "net/cert/cert_verifier.h"
10 #include "net/cert/x509_certificate.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 #pragma mark
14
15 // Exposes private test-only methods of the Cronet class.
16 @interface Cronet (ExposedForTesting)
17 + (void)shutdownForTesting;
18 + (void)setMockCertVerifier:(std::unique_ptr<net::CertVerifier>)certVerifier;
19 @end
20
21 // NSURLSessionDataDelegate delegate implementation used by the tests to
22 // wait for a response and check its status.
23 @interface TestDelegate : NSObject<NSURLSessionDataDelegate>
24
25 // Completion semaphore for this TestDelegate. When the request this delegate is
26 // attached to finishes (either successfully or with an error), this delegate
27 // signals this semaphore.
28 @property(strong, atomic) dispatch_semaphore_t semaphore;
mef 2017/06/12 22:25:24 Maybe hide this in implementation and add a 'waitF
kapishnikov 2017/06/16 20:11:05 Done. Added waitForDone() to the delegate.
29
30 // Error the request this delegate is attached to failed with, if any.
31 @property(retain, atomic) NSError* error;
32
33 // Contains total amount of received data.
34 @property(readonly) long totalBytesReceived;
35
36 // Resets the delegate, so it can be used again for another request.
37 - (void)reset;
38
39 // Contains the response body.
40 - (NSString*)responseBody;
41
42 @end
43
44 // Forward declaration.
45 namespace net {
46 class MockCertVerifier;
47 }
48
49 namespace cronet {
50
51 // A base class that should be extended by all other Cronet tests.
52 // The class automatically starts and stoppes the test QUIC server.
mef 2017/06/12 22:25:24 nit: stops.
kapishnikov 2017/06/16 20:11:05 Done.
53 class CronetTestBase : public ::testing::Test {
54 protected:
55 static bool CalculatePublicKeySha256(const net::X509Certificate& cert,
mef 2017/06/12 22:25:24 Do we need this in base or in PKP only?
kapishnikov 2017/06/16 20:11:05 I would consider this method non-PKP specific but
56 net::HashValue* out_hash_value);
57
58 void SetUp() override;
59 void TearDown() override;
60 void StartDataTaskAndWaitForCompletion(NSURLSessionDataTask* task);
61 std::unique_ptr<net::MockCertVerifier> CreateMockCertVerifier(
62 const std::vector<std::string>& certs,
63 bool known_root);
64
65 ::testing::AssertionResult IsResponseSuccessful();
66
67 TestDelegate* delegate_;
68 }; // class CronetTestBase
69
70 } // namespace cronet
71
72 #endif // PRODUCTS_CRONET_TEST_BASE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698