22 lines
790 B
Swift
22 lines
790 B
Swift
|
|
import XCTest
|
||
|
|
import CryptoKit
|
||
|
|
@testable import Closer
|
||
|
|
|
||
|
|
final class CoupleKeyStoreTests: XCTestCase {
|
||
|
|
func testInMemoryStoreLoadDeleteRoundTrip() throws {
|
||
|
|
let store = InMemoryCoupleKeyStore()
|
||
|
|
let coupleId = "couple-test-123"
|
||
|
|
var bytes = [UInt8](repeating: 0, count: 32)
|
||
|
|
_ = SecRandomCopyBytes(kSecRandomDefault, 32, &bytes)
|
||
|
|
let key = CoupleKeyMaterial(rawBytes: Data(bytes))
|
||
|
|
|
||
|
|
XCTAssertNil(try store.loadCoupleKey(for: coupleId))
|
||
|
|
try store.storeCoupleKey(key, for: coupleId)
|
||
|
|
let loaded = try XCTUnwrap(try store.loadCoupleKey(for: coupleId))
|
||
|
|
XCTAssertEqual(loaded.rawKey.bytes, key.rawKey.bytes)
|
||
|
|
|
||
|
|
try store.deleteCoupleKey(for: coupleId)
|
||
|
|
XCTAssertNil(try store.loadCoupleKey(for: coupleId))
|
||
|
|
}
|
||
|
|
}
|