From 14c76cf2c9fe416530b248c0d817295ce6069ffd Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 9 Feb 2017 16:55:51 -0800 Subject: Warning and control the rest of interfaces in GRPCCall+Tests as well --- .../GRPCClient/internal_testing/GRPCCall+Tests.h | 9 +++++++++ .../GRPCClient/internal_testing/GRPCCall+Tests.m | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'src/objective-c') diff --git a/src/objective-c/GRPCClient/internal_testing/GRPCCall+Tests.h b/src/objective-c/GRPCClient/internal_testing/GRPCCall+Tests.h index 0325f5a192..92c718a749 100644 --- a/src/objective-c/GRPCClient/internal_testing/GRPCCall+Tests.h +++ b/src/objective-c/GRPCClient/internal_testing/GRPCCall+Tests.h @@ -45,6 +45,9 @@ * * Must be called before any gRPC call to that host is made. It's illegal to pass the same host to * more than one invocation of the methods of this category. + * + * This function is for internal testing of gRPC only. It is not part of gRPC's public interface. + * Do not use in production. To enable, set the preprocessor flag GRPC_TEST_OBJC. */ + (void)useTestCertsPath:(NSString *)certsPath testName:(NSString *)testName @@ -55,12 +58,18 @@ * * Must be called before any gRPC call to that host is made. It's illegal to pass the same host to * more than one invocation of the methods of this category. + * + * This function is for internal testing of gRPC only. It is not part of gRPC's public interface. + * Do not use in production. To enable, set the preprocessor flag GRPC_TEST_OBJC. */ + (void)useInsecureConnectionsForHost:(NSString *)host; /** * Resets all host configurations to their default values, and flushes all connections from the * cache. + * + * This function is for internal testing of gRPC only. It is not part of gRPC's public interface. + * Do not use in production. To enable, set the preprocessor flag GRPC_TEST_OBJC. */ + (void)resetHostSettings; diff --git a/src/objective-c/GRPCClient/internal_testing/GRPCCall+Tests.m b/src/objective-c/GRPCClient/internal_testing/GRPCCall+Tests.m index 5109480bef..40bd2a9c80 100644 --- a/src/objective-c/GRPCClient/internal_testing/GRPCCall+Tests.m +++ b/src/objective-c/GRPCClient/internal_testing/GRPCCall+Tests.m @@ -41,6 +41,7 @@ + (void)useTestCertsPath:(NSString *)certsPath testName:(NSString *)testName forHost:(NSString *)host { +#ifdef GRPC_TEST_OBJC if (!host || !certsPath || !testName) { [NSException raise:NSInvalidArgumentException format:@"host, path and name must be provided."]; } @@ -55,15 +56,32 @@ GRPCHost *hostConfig = [GRPCHost hostWithAddress:host]; [hostConfig setTLSPEMRootCerts:certs withPrivateKey:nil withCertChain:nil error:nil]; hostConfig.hostNameOverride = testName; +#else + NSLog(@"This function is for internal testing of gRPC only. " + "It is not part of gRPC's public interface. Do not use in production. " + "To enable, set the preprocessor flag GRPC_TEST_OBJC."); +#endif } + (void)useInsecureConnectionsForHost:(NSString *)host { +#ifdef GRPC_TEST_OBJC GRPCHost *hostConfig = [GRPCHost hostWithAddress:host]; hostConfig.secure = NO; +#else + NSLog(@"This function is for internal testing of gRPC only. " + "It is not part of gRPC's public interface. Do not use in production. " + "To enable, set the preprocessor flag GRPC_TEST_OBJC."); +#endif } + (void)resetHostSettings { +#ifdef GRPC_TEST_OBJC [GRPCHost resetAllHostSettings]; +#else + NSLog(@"This function is for internal testing of gRPC only. " + "It is not part of gRPC's public interface. Do not use in production. " + "To enable, set the preprocessor flag GRPC_TEST_OBJC."); +#endif } + (void)enableOpBatchLog:(BOOL)enabled { -- cgit v1.2.3