mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 15:12:21 +00:00
Migrated project to XCTest
This commit is contained in:
@@ -6,11 +6,15 @@
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "KPKTestLegacyWriting.h"
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "KPKCompositeKey.h"
|
||||
#import "KPKTree+Serializing.h"
|
||||
|
||||
@interface KPKTestLegacyWriting : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation KPKTestLegacyWriting
|
||||
|
||||
- (void)testWriting {
|
||||
@@ -18,15 +22,15 @@
|
||||
NSURL *dbUrl = [self _urlForFile:@"CustomIcon_Password_1234" extension:@"kdbx"];
|
||||
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"1234" key:nil];
|
||||
KPKTree *tree = [[KPKTree alloc] initWithContentsOfUrl:dbUrl password:password error:&error];
|
||||
STAssertNotNil(tree, @"Tree should be created");
|
||||
XCTAssertNotNil(tree, @"Tree should be created");
|
||||
error = nil;
|
||||
NSData *data = [tree encryptWithPassword:password forVersion:KPKLegacyVersion error:&error];
|
||||
STAssertNotNil(data, @"Serialized Data shoudl be created");
|
||||
XCTAssertNotNil(data, @"Serialized Data shoudl be created");
|
||||
NSString *tempFile = [NSTemporaryDirectory() stringByAppendingString:@"CustomIcon_Password_1234.kdb"];
|
||||
NSLog(@"Saved to %@", tempFile);
|
||||
[data writeToFile:tempFile atomically:YES];
|
||||
KPKTree *loadTree = [[KPKTree alloc] initWithData:data password:password error:&error];
|
||||
STAssertNotNil(loadTree, @"Tree should be loadable from kdb file data");
|
||||
XCTAssertNotNil(loadTree, @"Tree should be loadable from kdb file data");
|
||||
}
|
||||
|
||||
- (NSData *)_dataForFile:(NSString *)name extension:(NSString *)extension {
|
||||
|
||||
Reference in New Issue
Block a user