Skip to content

Commit

Permalink
fixes request URL (firebase#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
protocol86 authored Aug 25, 2017
1 parent 11a4a4f commit e812581
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
20 changes: 20 additions & 0 deletions Example/Auth/Tests/FIRGetProjectConfigRequestTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,26 @@
#import "FIRGetProjectConfigResponse.h"
#import "FIRFakeBackendRPCIssuer.h"

/** @var kGetProjectConfigEndPoint
@brief The "getProjectConfig" endpoint.
*/
static NSString *const kGetProjectConfigEndPoint = @"getProjectConfig";

/** @var kTestAPIKey
@brief Fake API key used for testing.
*/
static NSString *const kTestAPIKey = @"APIKey";

/** @var kAPIURLFormat
@brief URL format for server API calls.
*/
static NSString *const kAPIURLFormat = @"https://%@/identitytoolkit/v3/relyingparty/%@?key=%@";

/** @var gAPIHost
@brief Host for server API calls.
*/
static NSString *gAPIHost = @"www.googleapis.com";

@interface FIRGetProjectConfigRequestTests : XCTestCase
@end

Expand Down Expand Up @@ -68,6 +83,11 @@ - (void)testGetProjectConfigRequest {
XCTAssertFalse([request containsPostBody]);
// Confirm that the quest has no decoded body as it is get request.
XCTAssertNil(_RPCIssuer.decodedRequest);
NSString *URLString = [NSString stringWithFormat:kAPIURLFormat,
gAPIHost,
kGetProjectConfigEndPoint,
kTestAPIKey];
XCTAssertTrue([URLString isEqualToString:[request requestURL]]);
}

@end
6 changes: 2 additions & 4 deletions Firebase/Auth/Source/RPCs/FIRGetProjectConfigRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ @implementation FIRGetProjectConfigRequest

- (nullable instancetype)initWithRequestConfiguration:
(FIRAuthRequestConfiguration *)requestConfiguration {
NSString *APIKey = requestConfiguration.APIKey;
NSString *getProjectConfigURL =
[NSString stringWithFormat:@"%@?key=%@", kGetProjectConfigEndPoint, APIKey];
return [super initWithEndpoint:getProjectConfigURL requestConfiguration:requestConfiguration];
return [super initWithEndpoint:kGetProjectConfigEndPoint
requestConfiguration:requestConfiguration];
}

- (BOOL)containsPostBody {
Expand Down

0 comments on commit e812581

Please sign in to comment.