Переглянути джерело

Add fake implementation for GIDKeychainHandler

pinlu 3 роки тому
батько
коміт
3f8c4eef7b

+ 29 - 0
GoogleSignIn/Sources/GIDKeychainHandler/Implementations/GIDFakeKeychainHandler.h

@@ -0,0 +1,29 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "GoogleSignIn/Sources/GIDKeychainHandler/GIDKeychainHandler.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface GIDFakeKeychainHandler : NSObject<GIDKeychainHandler>
+
+@property(nonatomic) BOOL failToSave;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 29 - 0
GoogleSignIn/Sources/GIDKeychainHandler/Implementations/GIDFakeKeychainHandler.m

@@ -0,0 +1,29 @@
+#import "GoogleSignIn/Sources/GIDKeychainHandler/Implementations/GIDFakeKeychainHandler.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@implementation GIDFakeKeychainHandler {
+  OIDAuthState *_savedAuthState;
+}
+
+- (OIDAuthState *)loadAuthState {
+  return _savedAuthState;
+}
+
+- (BOOL)saveAuthState:(OIDAuthState *)authState {
+  if (self.failToSave) {
+    _savedAuthState = nil;
+    return NO;
+  } else {
+    _savedAuthState = authState;
+    return YES;
+  }
+}
+
+- (void)removeAllKeychainEntries {
+  _savedAuthState = nil;
+}
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 0 - 1
GoogleSignIn/Sources/GIDKeychainHandlling/GIDFakeKeychainHandler.h

@@ -1 +0,0 @@
-

+ 0 - 1
GoogleSignIn/Sources/GIDKeychainHandlling/GIDFakeKeychainHandler.m

@@ -1 +0,0 @@
-