Exercise GRPCCall+OAuth2 in the tests

pull/2838/head
Jorge Canizales 9 years ago
parent 594ae574ad
commit 631dc00481
  1. 5
      src/objective-c/tests/GRPCClientTests.m

@ -35,6 +35,7 @@
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#import <GRPCClient/GRPCCall.h> #import <GRPCClient/GRPCCall.h>
#import <GRPCClient/GRPCCall+OAuth2.h>
#import <GRPCClient/GRPCCall+Tests.h> #import <GRPCClient/GRPCCall+Tests.h>
#import <ProtoRPC/ProtoMethod.h> #import <ProtoRPC/ProtoMethod.h>
#import <RemoteTest/Messages.pbobjc.h> #import <RemoteTest/Messages.pbobjc.h>
@ -160,7 +161,7 @@ static ProtoMethod *kUnaryCallMethod;
path:kUnaryCallMethod.HTTPPath path:kUnaryCallMethod.HTTPPath
requestsWriter:requestsWriter]; requestsWriter:requestsWriter];
call.requestMetadata[@"Authorization"] = @"Bearer bogusToken"; call.oauth2_accessToken = @"bogusToken";
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) { id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
XCTFail(@"Received unexpected response: %@", value); XCTFail(@"Received unexpected response: %@", value);
@ -169,7 +170,7 @@ static ProtoMethod *kUnaryCallMethod;
XCTAssertEqual(errorOrNil.code, 16, @"Finished with unexpected error: %@", errorOrNil); XCTAssertEqual(errorOrNil.code, 16, @"Finished with unexpected error: %@", errorOrNil);
XCTAssertEqualObjects(call.responseMetadata, errorOrNil.userInfo[kGRPCStatusMetadataKey], XCTAssertEqualObjects(call.responseMetadata, errorOrNil.userInfo[kGRPCStatusMetadataKey],
@"Metadata in the NSError object and call object differ."); @"Metadata in the NSError object and call object differ.");
NSString *challengeHeader = call.responseMetadata[@"www-authenticate"]; NSString *challengeHeader = call.oauth2_challengeHeader;
XCTAssertGreaterThan(challengeHeader.length, 0, XCTAssertGreaterThan(challengeHeader.length, 0,
@"No challenge in response headers %@", call.responseMetadata); @"No challenge in response headers %@", call.responseMetadata);
[expectation fulfill]; [expectation fulfill];

Loading…
Cancel
Save