Skip to content
Snippets Groups Projects
Commit d7981253 authored by Jorge Canizales's avatar Jorge Canizales
Browse files

Add test to set and read headers. Flaky!!

parent d666fd06
No related branches found
No related tags found
No related merge requests found
...@@ -144,4 +144,35 @@ static GRPCMethodName *kUnaryCallMethod; ...@@ -144,4 +144,35 @@ static GRPCMethodName *kUnaryCallMethod;
[self waitForExpectationsWithTimeout:2. handler:nil]; [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 @end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment