Jorge Canizales | 9195233 | 2015-07-31 17:50:49 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
Jorge Canizales | 9195233 | 2015-07-31 17:50:49 -0700 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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 |
Jorge Canizales | 9195233 | 2015-07-31 17:50:49 -0700 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Jorge Canizales | 9195233 | 2015-07-31 17:50:49 -0700 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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. |
Jorge Canizales | 9195233 | 2015-07-31 17:50:49 -0700 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
Muxi Yan | 8e6aec5 | 2017-02-10 09:40:18 -0800 | [diff] [blame] | 19 | #import <GRPCClient/GRPCCall+Tests.h> |
| 20 | #import <GRPCClient/internal_testing/GRPCCall+InternalTests.h> |
Jorge Canizales | 82b68d8 | 2015-08-01 17:56:03 -0700 | [diff] [blame] | 21 | |
Jorge Canizales | 9195233 | 2015-07-31 17:50:49 -0700 | [diff] [blame] | 22 | #import "InteropTests.h" |
Makarand Dharmapurikar | b4e9727 | 2017-04-12 12:16:28 -0700 | [diff] [blame] | 23 | // The server address is derived from preprocessor macro, which is |
| 24 | // in turn derived from environment variable of the same name. |
| 25 | #define NSStringize_helper(x) #x |
| 26 | #define NSStringize(x) @NSStringize_helper(x) |
| 27 | static NSString * const kLocalSSLHost = NSStringize(HOST_PORT_LOCALSSL); |
Jorge Canizales | 82b68d8 | 2015-08-01 17:56:03 -0700 | [diff] [blame] | 28 | |
Muxi Yan | dc87ef5 | 2017-03-10 11:41:53 -0800 | [diff] [blame] | 29 | // The Protocol Buffers encoding overhead of local interop server. Acquired |
| 30 | // by experiment. Adjust this when server's proto file changes. |
| 31 | static int32_t kLocalInteropServerOverhead = 10; |
| 32 | |
Jorge Canizales | 2beb88c | 2015-10-28 15:13:40 -0700 | [diff] [blame] | 33 | /** Tests in InteropTests.m, sending the RPCs to a local SSL server. */ |
Jorge Canizales | 9195233 | 2015-07-31 17:50:49 -0700 | [diff] [blame] | 34 | @interface InteropTestsLocalSSL : InteropTests |
| 35 | @end |
| 36 | |
| 37 | @implementation InteropTestsLocalSSL |
Jorge Canizales | 82b68d8 | 2015-08-01 17:56:03 -0700 | [diff] [blame] | 38 | |
Jorge Canizales | 9195233 | 2015-07-31 17:50:49 -0700 | [diff] [blame] | 39 | + (NSString *)host { |
Jorge Canizales | 82b68d8 | 2015-08-01 17:56:03 -0700 | [diff] [blame] | 40 | return kLocalSSLHost; |
Jorge Canizales | 9195233 | 2015-07-31 17:50:49 -0700 | [diff] [blame] | 41 | } |
Jorge Canizales | 82b68d8 | 2015-08-01 17:56:03 -0700 | [diff] [blame] | 42 | |
Jorge Canizales | 9e83d7e | 2016-08-01 12:51:31 -0700 | [diff] [blame] | 43 | - (int32_t)encodingOverhead { |
Muxi Yan | dc87ef5 | 2017-03-10 11:41:53 -0800 | [diff] [blame] | 44 | return kLocalInteropServerOverhead; // bytes |
Jorge Canizales | 9e83d7e | 2016-08-01 12:51:31 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Jorge Canizales | 82b68d8 | 2015-08-01 17:56:03 -0700 | [diff] [blame] | 47 | - (void)setUp { |
Jorge Canizales | 4bb2eb2 | 2016-07-29 13:59:43 -0700 | [diff] [blame] | 48 | [super setUp]; |
| 49 | |
Jorge Canizales | 82b68d8 | 2015-08-01 17:56:03 -0700 | [diff] [blame] | 50 | // Register test server certificates and name. |
| 51 | NSBundle *bundle = [NSBundle bundleForClass:self.class]; |
| 52 | NSString *certsPath = [bundle pathForResource:@"TestCertificates.bundle/test-certificates" |
| 53 | ofType:@"pem"]; |
| 54 | [GRPCCall useTestCertsPath:certsPath testName:@"foo.test.google.fr" forHost:kLocalSSLHost]; |
Jorge Canizales | 82b68d8 | 2015-08-01 17:56:03 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Test User | 9656eca | 2016-02-18 14:47:22 -0800 | [diff] [blame] | 57 | - (void)testExceptions { |
| 58 | // Try to set userAgentPrefix for host that is nil. This should cause |
| 59 | // an exception. |
| 60 | @try { |
| 61 | [GRPCCall useTestCertsPath:nil testName:nil forHost:nil]; |
| 62 | XCTFail(@"Did not receive an exception when parameters are nil"); |
| 63 | } @catch(NSException *theException) { |
| 64 | NSLog(@"Received exception as expected: %@", theException.name); |
| 65 | } |
| 66 | } |
| 67 | |
Jorge Canizales | 9195233 | 2015-07-31 17:50:49 -0700 | [diff] [blame] | 68 | @end |