FIRInstallationsItem+Tests.m 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 *)createRegisteredInstallationItemWithAppID:(NSString *)appID
  35. appName:(NSString *)appName {
  36. FIRInstallationsItem *item = [[FIRInstallationsItem alloc] initWithAppID:appID
  37. firebaseAppName:appName];
  38. item.firebaseInstallationID = [FIRInstallationsItem generateFID];
  39. item.refreshToken = @"refreshToken";
  40. item.registrationStatus = FIRInstallationStatusRegistered;
  41. FIRInstallationsStoredAuthToken *authToken = [[FIRInstallationsStoredAuthToken alloc] init];
  42. authToken.token = @"auth-token";
  43. authToken.expirationDate = [NSDate dateWithTimeIntervalSinceNow:2 * 60 * 60];
  44. item.authToken = authToken;
  45. return item;
  46. }
  47. @end