]> git.saurik.com Git - apple/security.git/blob - keychain/ckks/tests/CKKSPBFileStorageTests.m
Security-59306.101.1.tar.gz
[apple/security.git] / keychain / ckks / tests / CKKSPBFileStorageTests.m
1 //
2 // CKKSPBFileStorageTests.m
3 //
4
5 #import <XCTest/XCTest.h>
6
7 #import "keychain/ckks/CKKSPBFileStorage.h"
8 #import "keychain/ckks/proto/generated_source/CKKSSerializedKey.h"
9
10 @interface CKKSPBFileStorageTests : XCTestCase
11 @property NSURL * tempDir;
12 @end
13
14 @implementation CKKSPBFileStorageTests
15
16 - (void)setUp {
17 self.tempDir = [[NSFileManager defaultManager] temporaryDirectory];
18 }
19 - (void)tearDown {
20 [[NSFileManager defaultManager] removeItemAtURL:self.tempDir error:nil];
21 self.tempDir = nil;
22 }
23
24 - (void)testCKKSPBStorage {
25
26 NSURL *file = [self.tempDir URLByAppendingPathComponent:@"file"];
27
28 CKKSPBFileStorage<CKKSSerializedKey *> *pbstorage;
29
30 pbstorage = [[CKKSPBFileStorage alloc] initWithStoragePath:file
31 storageClass:[CKKSSerializedKey class]];
32 XCTAssertNotNil(pbstorage, "CKKSPBFileStorage should create an object");
33
34 CKKSSerializedKey *storage = pbstorage.storage;
35 storage.uuid = @"uuid";
36 storage.zoneName = @"uuid";
37 storage.keyclass = @"ak";
38 storage.key = [NSData data];
39
40 [pbstorage setStorage:storage];
41
42 pbstorage = [[CKKSPBFileStorage alloc] initWithStoragePath:file
43 storageClass:[CKKSSerializedKey class]];
44 XCTAssertNotNil(pbstorage, "CKKSPBFileStorage should create an object");
45
46 XCTAssertEqualObjects(pbstorage.storage.keyclass, @"ak", "should be the same");
47 }
48
49 @end