Debian Codegraph @

src/objective-c/tests/MacTests/StressTestsSSL.m

raw
1 /*
2 *
3 * Copyright 2019 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19 #import <GRPCClient/GRPCCall+Tests.h>
20 #import <GRPCClient/internal_testing/GRPCCall+InternalTests.h>
21
22 #include "StressTests.h"
23
24 static NSString *const kHostAddress = @"10.0.0.1";
25 // The Protocol Buffers encoding overhead of local interop server. Acquired
26 // by experiment. Adjust this when server's proto file changes.
27 static int32_t kLocalInteropServerOverhead = 10;
28
29 @interface StressTestsSSL : StressTests
30 @end
31
32 @implementation StressTestsSSL
33
34 + (NSString *)host {
35 return [NSString stringWithFormat:@"%@:5051", kHostAddress];
36 }
37
38 + (NSString *)hostAddress {
39 return kHostAddress;
40 }
41
42 + (NSString *)PEMRootCertificates {
43 NSBundle *bundle = [NSBundle bundleForClass:[self class]];
44 NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
45 ofType:@"pem"];
46 NSError *error;
47 return [NSString stringWithContentsOfFile:certsPath encoding:NSUTF8StringEncoding error:&error];
48 }
49
50 + (NSString *)hostNameOverride {
51 return @"foo.test.google.fr";
52 }
53
54 - (int32_t)encodingOverhead {
55 return kLocalInteropServerOverhead; // bytes
56 }
57
58 + (GRPCTransportType)transportType {
59 return GRPCTransportTypeChttp2BoringSSL;
60 }
61
62 - (void)setUp {
63 [super setUp];
64
65 // Register test server certificates and name.
66 NSBundle *bundle = [NSBundle bundleForClass:[self class]];
67 NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates"
68 ofType:@"pem"];
69 [GRPCCall useTestCertsPath:certsPath testName:@"foo.test.google.fr" forHost:[[self class] host]];
70 }
71 @end