FIRGetProjectConfigRequestTests.m 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <XCTest/XCTest.h>
  17. #import "FIRAuthBackend.h"
  18. #import "FIRGetProjectConfigRequest.h"
  19. #import "FIRGetProjectConfigResponse.h"
  20. #import "FIRFakeBackendRPCIssuer.h"
  21. /** @var kTestAPIKey
  22. @brief Fake API key used for testing.
  23. */
  24. static NSString *const kTestAPIKey = @"APIKey";
  25. @interface FIRGetProjectConfigRequestTests : XCTestCase
  26. @end
  27. @implementation FIRGetProjectConfigRequestTests {
  28. /** @var _RPCIssuer
  29. @brief This backend RPC issuer is used to fake network responses for each test in the suite.
  30. In the @c setUp method we initialize this and set @c FIRAuthBackend's RPC issuer to it.
  31. */
  32. FIRFakeBackendRPCIssuer *_RPCIssuer;
  33. }
  34. - (void)setUp {
  35. [super setUp];
  36. FIRFakeBackendRPCIssuer *RPCIssuer = [[FIRFakeBackendRPCIssuer alloc] init];
  37. [FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:RPCIssuer];
  38. _RPCIssuer = RPCIssuer;
  39. }
  40. - (void)tearDown {
  41. _RPCIssuer = nil;
  42. [FIRAuthBackend setDefaultBackendImplementationWithRPCIssuer:nil];
  43. [super tearDown];
  44. }
  45. /** @fn testGetProjectConfigRequest
  46. @brief Tests get project config request.
  47. */
  48. - (void)testGetProjectConfigRequest {
  49. FIRAuthRequestConfiguration *requestConfiguration =
  50. [[FIRAuthRequestConfiguration alloc] initWithAPIKey:kTestAPIKey];
  51. FIRGetProjectConfigRequest *request =
  52. [[FIRGetProjectConfigRequest alloc] initWithRequestConfiguration:requestConfiguration];
  53. [FIRAuthBackend getProjectConfig:request
  54. callback:^(FIRGetProjectConfigResponse *_Nullable response,
  55. NSError *_Nullable error) {
  56. }];
  57. XCTAssertFalse([request containsPostBody]);
  58. // Confirm that the quest has no decoded body as it is get request.
  59. XCTAssertNil(_RPCIssuer.decodedRequest);
  60. }
  61. @end