aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/tests/GRPCClientTests.m
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2015-06-12 19:15:18 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2015-06-13 01:30:34 -0700
commitd7981253de93fcfd3666a3e3bd1714b2f66a448b (patch)
tree7d1aa13895f7a913c1bda7e96dd8b37ee8ab2f57 /src/objective-c/tests/GRPCClientTests.m
parentd666fd068bfcd37461c73354f5dc2fdc2b8f72b0 (diff)
Add test to set and read headers. Flaky!!
Diffstat (limited to 'src/objective-c/tests/GRPCClientTests.m')
-rw-r--r--src/objective-c/tests/GRPCClientTests.m31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m
index 4f4fe591e8..917e637d68 100644
--- a/src/objective-c/tests/GRPCClientTests.m
+++ b/src/objective-c/tests/GRPCClientTests.m
@@ -144,4 +144,35 @@ static GRPCMethodName *kUnaryCallMethod;
[self waitForExpectationsWithTimeout:2. handler:nil];
}
+- (void)testMetadata {
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"RPC unauthorized."];
+
+ RMTSimpleRequest *request = [RMTSimpleRequest message];
+ request.fillUsername = YES;
+ request.fillOauthScope = YES;
+ id<GRXWriter> requestsWriter = [GRXWriter writerWithValue:[request data]];
+
+ GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress
+ method:kUnaryCallMethod
+ requestsWriter:requestsWriter];
+
+ call.requestMetadata = [NSMutableDictionary dictionaryWithDictionary:
+ @{@"Authorization": @"Bearer bogusToken"}];
+
+ id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
+ XCTFail(@"Received unexpected response: %@", value);
+ } completionHandler:^(NSError *errorOrNil) {
+ XCTAssertNotNil(errorOrNil, @"Finished without error!");
+ XCTAssertEqual(errorOrNil.code, 16, @"Finished with unexpected error: %@", errorOrNil);
+ NSString *challengeHeader = call.responseMetadata[@"www-authenticate"][0];
+ XCTAssertGreaterThan(challengeHeader.length, 0,
+ @"No challenge in response headers %@", call.responseMetadata);
+ [expectation fulfill];
+ }];
+
+ [call startWithWriteable:responsesWriteable];
+
+ [self waitForExpectationsWithTimeout:2. handler:nil];
+}
+
@end