FIRInstallationsItem+Tests.m 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright 2019 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 "FirebaseInstallations/Source/Tests/Utils/FIRInstallationsItem+Tests.h"
  17. #import "FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
  18. #import "FirebaseInstallations/Source/Library/InstallationsStore/FIRInstallationsStoredAuthToken.h"
  19. @implementation FIRInstallationsItem (Tests)
  20. + (FIRInstallationsItem *)createUnregisteredInstallationItem {
  21. FIRInstallationsItem *item = [[FIRInstallationsItem alloc] initWithAppID:@"appID"
  22. firebaseAppName:kFIRDefaultAppName];
  23. item.firebaseInstallationID = @"firebaseInstallationID";
  24. item.registrationStatus = FIRInstallationStatusUnregistered;
  25. return item;
  26. }
  27. + (FIRInstallationsItem *)createRegisteredInstallationItem {
  28. FIRInstallationsItem *item = [self createRegisteredInstallationItemWithAppID:@"appID"
  29. appName:kFIRDefaultAppName];
  30. item.firebaseInstallationID = @"firebaseInstallationID";
  31. item.registrationStatus = FIRInstallationStatusRegistered;
  32. return item;
  33. }
  34. + (FIRInstallationsItem *)createCorruptedItem {
  35. FIRInstallationsItem *item = [self createRegisteredInstallationItemWithAppID:@"appID"
  36. appName:kFIRDefaultAppName];
  37. item.firebaseInstallationID = nil;
  38. return item;
  39. }
  40. + (FIRInstallationsItem *)createRegisteredInstallationItemWithAppID:(NSString *)appID
  41. appName:(NSString *)appName {
  42. FIRInstallationsItem *item = [[FIRInstallationsItem alloc] initWithAppID:appID
  43. firebaseAppName:appName];
  44. item.firebaseInstallationID = [FIRInstallationsItem generateFID];
  45. item.refreshToken = @"refreshToken";
  46. item.registrationStatus = FIRInstallationStatusRegistered;
  47. FIRInstallationsStoredAuthToken *authToken = [[FIRInstallationsStoredAuthToken alloc] init];
  48. authToken.token = @"auth-token";
  49. authToken.expirationDate = [NSDate dateWithTimeIntervalSinceNow:2 * 60 * 60];
  50. item.authToken = authToken;
  51. return item;
  52. }
  53. @end