2 // CKKSPBFileStorageTests.m
5 #import <XCTest/XCTest.h>
7 #import "keychain/ckks/CKKSPBFileStorage.h"
8 #import "keychain/ckks/proto/generated_source/CKKSSerializedKey.h"
10 @interface CKKSPBFileStorageTests : XCTestCase
11 @property NSURL * tempDir;
14 @implementation CKKSPBFileStorageTests
17 self.tempDir = [[NSFileManager defaultManager] temporaryDirectory];
20 [[NSFileManager defaultManager] removeItemAtURL:self.tempDir error:nil];
24 - (void)testCKKSPBStorage {
26 NSURL *file = [self.tempDir URLByAppendingPathComponent:@"file"];
28 CKKSPBFileStorage<CKKSSerializedKey *> *pbstorage;
30 pbstorage = [[CKKSPBFileStorage alloc] initWithStoragePath:file
31 storageClass:[CKKSSerializedKey class]];
32 XCTAssertNotNil(pbstorage, "CKKSPBFileStorage should create an object");
34 CKKSSerializedKey *storage = pbstorage.storage;
35 storage.uuid = @"uuid";
36 storage.zoneName = @"uuid";
37 storage.keyclass = @"ak";
38 storage.key = [NSData data];
40 [pbstorage setStorage:storage];
42 pbstorage = [[CKKSPBFileStorage alloc] initWithStoragePath:file
43 storageClass:[CKKSSerializedKey class]];
44 XCTAssertNotNil(pbstorage, "CKKSPBFileStorage should create an object");
46 XCTAssertEqualObjects(pbstorage.storage.keyclass, @"ak", "should be the same");