FIRDeviceCheckAPIServiceE2ETests.m 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright 2020 Google LLC
  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 "FBLPromise+Testing.h"
  18. #import <FirebaseCore/FirebaseCore.h>
  19. #import "FirebaseAppCheck/Sources/Core/APIService/FIRAppCheckAPIService.h"
  20. #import "FirebaseAppCheck/Sources/DeviceCheckProvider/API/FIRDeviceCheckAPIService.h"
  21. #import "FirebaseAppCheck/Sources/Public/FirebaseAppCheck/FIRAppCheckToken.h"
  22. @interface FIRDeviceCheckAPIServiceE2ETests : XCTestCase
  23. @property(nonatomic) FIRDeviceCheckAPIService *deviceCheckAPIService;
  24. @property(nonatomic) FIRAppCheckAPIService *APIService;
  25. @property(nonatomic) NSURLSession *URLSession;
  26. @end
  27. @implementation FIRDeviceCheckAPIServiceE2ETests
  28. - (void)setUp {
  29. self.URLSession = [NSURLSession
  30. sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
  31. FIROptions *options = [self firebaseTestOptions];
  32. self.APIService = [[FIRAppCheckAPIService alloc] initWithURLSession:self.URLSession
  33. APIKey:options.APIKey
  34. projectID:options.projectID
  35. appID:options.googleAppID];
  36. self.deviceCheckAPIService =
  37. [[FIRDeviceCheckAPIService alloc] initWithAPIService:self.APIService
  38. projectID:options.projectID
  39. appID:options.googleAppID];
  40. }
  41. - (void)tearDown {
  42. self.deviceCheckAPIService = nil;
  43. self.APIService = nil;
  44. self.URLSession = nil;
  45. }
  46. // TODO: Re-enable the test once secret with "GoogleService-Info.plist" is configured.
  47. - (void)temporaryDisabled_testAppCheckTokenSuccess {
  48. __auto_type appCheckPromise =
  49. [self.deviceCheckAPIService appCheckTokenWithDeviceToken:[NSData data]];
  50. XCTAssert(FBLWaitForPromisesWithTimeout(20));
  51. XCTAssertNil(appCheckPromise.error);
  52. XCTAssertNotNil(appCheckPromise.value);
  53. XCTAssertNotNil(appCheckPromise.value.token);
  54. XCTAssertNotNil(appCheckPromise.value.expirationDate);
  55. }
  56. #pragma mark - Helpers
  57. - (FIROptions *)firebaseTestOptions {
  58. NSString *plistPath =
  59. [[NSBundle bundleForClass:[self class]] pathForResource:@"GoogleService-Info"
  60. ofType:@"plist"];
  61. FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:plistPath];
  62. return options;
  63. }
  64. @end