GIDAppCheckProviderFake.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "GoogleSignIn/Sources/GIDAppCheck/Implementations/Fake/GIDAppCheckProviderFake.h"
  15. #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
  16. #import <AppCheckCore/GACAppCheckToken.h>
  17. NSUInteger const kGIDAppCheckProviderFakeError = 1;
  18. @interface GIDAppCheckProviderFake ()
  19. @property(nonatomic, strong, nullable) GACAppCheckToken *token;
  20. @property(nonatomic, strong, nullable) NSError *error;
  21. @end
  22. @implementation GIDAppCheckProviderFake
  23. - (instancetype)initWithAppCheckToken:(nullable GACAppCheckToken *)token
  24. error:(nullable NSError *)error {
  25. if (self = [super init]) {
  26. _token = token;
  27. _error = error;
  28. }
  29. return self;
  30. }
  31. - (void)getTokenWithCompletion:(void (^)(GACAppCheckToken *, NSError * _Nullable))handler {
  32. dispatch_async(dispatch_get_main_queue(), ^{
  33. handler(self.token, self.error);
  34. });
  35. }
  36. - (void)getLimitedUseTokenWithCompletion:(void (^)(GACAppCheckToken *,
  37. NSError * _Nullable))handler {
  38. dispatch_async(dispatch_get_main_queue(), ^{
  39. handler(self.token, self.error);
  40. });
  41. }
  42. @end
  43. #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST