metatext/Keychain/Sources/MockKeychain/MockKeychainService.swift

43 lines
1.1 KiB
Swift
Raw Permalink Normal View History

2020-08-31 18:57:02 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
2020-09-04 00:54:05 +00:00
import Keychain
2020-08-31 18:57:02 +00:00
2020-09-04 00:54:05 +00:00
public struct MockKeychain {}
2020-08-31 18:57:02 +00:00
2020-09-04 00:54:05 +00:00
public extension MockKeychain {
2020-08-31 18:57:02 +00:00
static func reset() {
items = [String: Data]()
}
}
2020-09-04 00:54:05 +00:00
extension MockKeychain: Keychain {
2020-08-31 18:57:02 +00:00
public static func setGenericPassword(data: Data, forAccount key: String, service: String) throws {
items[key] = data
}
public static func deleteGenericPassword(account: String, service: String) throws {
items[account] = nil
}
public static func getGenericPassword(account: String, service: String) throws -> Data? {
items[account]
}
public static func generateKeyAndReturnPublicKey(applicationTag: String, attributes: [String: Any]) throws -> Data {
fatalError("not implemented")
}
public static func getPrivateKey(applicationTag: String, attributes: [String: Any]) throws -> Data? {
fatalError("not implemented")
}
public static func deleteKey(applicationTag: String) throws {
fatalError("not implemented")
}
}
2020-09-04 00:54:05 +00:00
private extension MockKeychain {
2020-08-31 18:57:02 +00:00
static var items = [String: Data]()
}