Adopting KeePassKit API changes

This commit is contained in:
michael starke
2016-11-07 19:32:38 +01:00
parent abb450eed7
commit cfd559b759
16 changed files with 54 additions and 54 deletions

View File

@@ -1,3 +1,3 @@
github "sparkle-project/Sparkle" ~> 1.13.1 github "sparkle-project/Sparkle" ~> 1.13.1
github "mstarke/KeePassKit" "5c98755e9954549a74f421d90af8cd6b5c0e01cc" github "mstarke/KeePassKit" "d12bcc5e2e16115db19e26b6aaa29b62d23ce04b"
github "mstarke/HNHUi" ~> 1.1 github "mstarke/HNHUi" ~> 1.1

View File

@@ -1,3 +1,3 @@
github "mstarke/HNHUi" "1.1" github "mstarke/HNHUi" "1.1"
github "mstarke/KeePassKit" "5c98755e9954549a74f421d90af8cd6b5c0e01cc" github "mstarke/KeePassKit" "d12bcc5e2e16115db19e26b6aaa29b62d23ce04b"
github "sparkle-project/Sparkle" "1.14.0" github "sparkle-project/Sparkle" "1.14.0"

View File

@@ -17,8 +17,8 @@
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
typeToUTI = @{ typeToUTI = @{
@(KPKDatabaseTypeBinary) : MPLegacyDocumentUTI, @(KPKDatabaseFormatKdb) : MPKdbDocumentUTI,
@(KPKDatabaseTypeXml) : MPXMLDocumentUTI @(KPKDatabaseFormatKdbx) : MPKdbxDocumentUTI
}; };
}); });
return typeToUTI; return typeToUTI;
@@ -26,7 +26,7 @@
- (NSString *)typeForData:(NSData *)data { - (NSString *)typeForData:(NSData *)data {
KPKFileInfo fileInfo = [self fileInfoForData:data]; KPKFileInfo fileInfo = [self fileInfoForData:data];
return [self _typeToUTIdictionary][@(fileInfo.type)]; return [self _typeToUTIdictionary][@(fileInfo.format)];
} }
- (NSString *)typeForContentOfURL:(NSURL *)url { - (NSString *)typeForContentOfURL:(NSURL *)url {

View File

@@ -12,8 +12,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
FOUNDATION_EXPORT NSString *const MPPasteBoardType; FOUNDATION_EXPORT NSString *const MPPasteBoardType;
FOUNDATION_EXPORT NSString *const MPLegacyDocumentUTI; FOUNDATION_EXPORT NSString *const MPKdbDocumentUTI;
FOUNDATION_EXPORT NSString *const MPXMLDocumentUTI; FOUNDATION_EXPORT NSString *const MPKdbxDocumentUTI;
#endif #endif

View File

@@ -9,5 +9,5 @@
#import "MPConstants.h" #import "MPConstants.h"
NSString *const MPPasteBoardType = @"com.hicknhack.macpass.pasteboard"; NSString *const MPPasteBoardType = @"com.hicknhack.macpass.pasteboard";
NSString *const MPLegacyDocumentUTI = @"com.hicknhack.macpass.kdb"; NSString *const MPKdbDocumentUTI = @"com.hicknhack.macpass.kdb";
NSString *const MPXMLDocumentUTI = @"com.hicknhack.macpass.kdbx"; NSString *const MPKdbxDocumentUTI = @"com.hicknhack.macpass.kdbx";

View File

@@ -111,8 +111,9 @@
[defaults setBool:protectUsername forKey:kMPSettingsKeyLegacyHideUsername]; [defaults setBool:protectUsername forKey:kMPSettingsKeyLegacyHideUsername];
[defaults synchronize]; [defaults synchronize];
*/ */
metaData.keyDerivationParameters = @{ KPKAESRoundsOption : [[KPKNumber alloc] initWithUnsignedInteger64: MAX(0,self.encryptionRoundsTextField.integerValue)]};
metaData.rounds = MAX(0,self.encryptionRoundsTextField.integerValue);
/* Register an action to enable promts when user cloeses without saving */ /* Register an action to enable promts when user cloeses without saving */
[self.document updateChangeCount:NSChangeDone]; [self.document updateChangeCount:NSChangeDone];
[self close:nil]; [self close:nil];
@@ -124,8 +125,8 @@
- (IBAction)benchmarkRounds:(id)sender { - (IBAction)benchmarkRounds:(id)sender {
[self.benchmarkButton setEnabled:NO]; [self.benchmarkButton setEnabled:NO];
[KPKCompositeKey benchmarkTransformationRounds:1 completionHandler:^(NSUInteger rounds) { [KPKAESKeyDerivation parametersForDelay:1 completionHandler:^(NSDictionary * _Nonnull options) {
self.encryptionRoundsTextField.integerValue = rounds; self.encryptionRoundsTextField.integerValue = [options[KPKAESRoundsOption] unsignedInteger64Value];
self.benchmarkButton.enabled = YES; self.benchmarkButton.enabled = YES;
}]; }];
} }
@@ -186,7 +187,8 @@
self.protectURLCheckButton.state = HNHUIStateForBool(metaData.protectUrl); self.protectURLCheckButton.state = HNHUIStateForBool(metaData.protectUrl);
self.protectUserNameCheckButton.state = HNHUIStateForBool(metaData.protectUserName); self.protectUserNameCheckButton.state = HNHUIStateForBool(metaData.protectUserName);
[self.encryptionRoundsTextField setIntegerValue:metaData.rounds]; [self.encryptionRoundsTextField setIntegerValue:[metaData.keyDerivationParameters[KPKAESRoundsOption] unsignedInteger64Value]];
[self.benchmarkButton setEnabled:YES]; [self.benchmarkButton setEnabled:YES];
} }

View File

@@ -78,7 +78,7 @@ FOUNDATION_EXPORT NSString *const MPDocumentGroupKey;
@property (nonatomic, strong, readonly) KPKCompositeKey *compositeKey; @property (nonatomic, strong, readonly) KPKCompositeKey *compositeKey;
@property (assign, readonly, getter = isReadOnly) BOOL readOnly; @property (assign, readonly, getter = isReadOnly) BOOL readOnly;
@property (nonatomic, readonly, assign) KPKDatabaseType versionForFileType; @property (nonatomic, readonly, assign) KPKDatabaseFormat versionForFileType;
/* /*
State (active group/entry) State (active group/entry)
@@ -96,8 +96,8 @@ FOUNDATION_EXPORT NSString *const MPDocumentGroupKey;
@property (nonatomic, copy) MPEntrySearchContext *searchContext; @property (nonatomic, copy) MPEntrySearchContext *searchContext;
@property (nonatomic, strong, readonly) NSArray *searchResult; @property (nonatomic, strong, readonly) NSArray *searchResult;
+ (KPKDatabaseType)versionForFileType:(NSString *)fileType; + (KPKDatabaseFormat)versionForFileType:(NSString *)fileType;
+ (NSString *)fileTypeForVersion:(KPKDatabaseType)version; + (NSString *)fileTypeForVersion:(KPKDatabaseFormat)format;
#pragma mark Lock/Decrypt #pragma mark Lock/Decrypt
- (IBAction)lockDatabase:(id)sender; - (IBAction)lockDatabase:(id)sender;

View File

@@ -89,23 +89,23 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
return [NSSet setWithObject:NSStringFromSelector(@selector(tree))]; return [NSSet setWithObject:NSStringFromSelector(@selector(tree))];
} }
+ (KPKDatabaseType)versionForFileType:(NSString *)fileType { + (KPKDatabaseFormat)versionForFileType:(NSString *)fileType {
if( NSOrderedSame == [fileType compare:MPLegacyDocumentUTI options:NSCaseInsensitiveSearch]) { if( NSOrderedSame == [fileType compare:MPKdbDocumentUTI options:NSCaseInsensitiveSearch]) {
return KPKDatabaseTypeBinary; return KPKDatabaseFormatKdb;
} }
if( NSOrderedSame == [fileType compare:MPXMLDocumentUTI options:NSCaseInsensitiveSearch]) { if( NSOrderedSame == [fileType compare:MPKdbxDocumentUTI options:NSCaseInsensitiveSearch]) {
return KPKDatabaseTypeXml; return KPKDatabaseFormatKdbx;
} }
return KPKDatabaseTypeUnknown; return KPKDatabaseFormatUnknown;
} }
+ (NSString *)fileTypeForVersion:(KPKDatabaseType)version { + (NSString *)fileTypeForVersion:(KPKDatabaseFormat)format {
switch(version) { switch(format) {
case KPKDatabaseTypeBinary: case KPKDatabaseFormatKdb:
return MPLegacyDocumentUTI; return MPKdbDocumentUTI;
case KPKDatabaseTypeXml: case KPKDatabaseFormatKdbx:
return MPXMLDocumentUTI; return MPKdbxDocumentUTI;
default: default:
return @"Unknown"; return @"Unknown";
@@ -134,7 +134,6 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
self = [self init]; self = [self init];
if(self) { if(self) {
self.tree = [[KPKTree alloc] initWithTemplateContents]; self.tree = [[KPKTree alloc] initWithTemplateContents];
self.tree.metaData.rounds = [[NSUserDefaults standardUserDefaults] integerForKey:kMPSettingsKeyDefaultPasswordRounds];
} }
return self; return self;
} }
@@ -183,15 +182,15 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
return nil; // Saving without a password/key is not possible return nil; // Saving without a password/key is not possible
} }
NSString *fileType = self.fileTypeFromLastRunSavePanel; NSString *fileType = self.fileTypeFromLastRunSavePanel;
KPKDatabaseType version = [self.class versionForFileType:fileType]; KPKDatabaseFormat format = [self.class versionForFileType:fileType];
if(version == KPKDatabaseTypeUnknown) { if(format == KPKDatabaseFormatUnknown) {
if(outError != NULL) { if(outError != NULL) {
NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: NSLocalizedString(@"UNKNOWN_FILE_VERSION", "") }; NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: NSLocalizedString(@"UNKNOWN_FILE_VERSION", "") };
*outError = [NSError errorWithDomain:MPErrorDomain code:0 userInfo:userInfo]; *outError = [NSError errorWithDomain:MPErrorDomain code:0 userInfo:userInfo];
} }
return nil; // We do not know what version to save! return nil; // We do not know what version to save!
} }
return [self.tree encryptWithPassword:self.compositeKey forVersion:version error:outError]; return [self.tree encryptWithKey:self.compositeKey format:format error:outError];
} }
- (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError { - (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError {
@@ -342,7 +341,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
[self.undoManager removeAllActions]; [self.undoManager removeAllActions];
NSError *error; NSError *error;
/* TODO let the tree chose the encryption */ /* TODO let the tree chose the encryption */
self.encryptedData = [self.tree encryptWithPassword:self.compositeKey forVersion:KPKDatabaseTypeXml error:&error]; self.encryptedData = [self.tree encryptWithKey:self.compositeKey format:KPKDatabaseFormatKdbx error:&error];
if(nil == self.encryptedData && error ) { if(nil == self.encryptedData && error ) {
[self presentError:error]; [self presentError:error];
return; return;
@@ -354,7 +353,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
- (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL error:(NSError *__autoreleasing*)error{ - (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL error:(NSError *__autoreleasing*)error{
self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyFileURL]; self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyFileURL];
self.tree = [[KPKTree alloc] initWithData:self.encryptedData password:self.compositeKey error:error]; self.tree = [[KPKTree alloc] initWithData:self.encryptedData key:self.compositeKey error:error];
BOOL isUnlocked = (nil != self.tree); BOOL isUnlocked = (nil != self.tree);
@@ -410,7 +409,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
} }
#pragma mark Properties #pragma mark Properties
- (KPKDatabaseType)versionForFileType { - (KPKDatabaseFormat)versionForFileType {
return [[self class] versionForFileType:self.fileType]; return [[self class] versionForFileType:self.fileType];
} }

View File

@@ -34,7 +34,7 @@
NSArray *topLevelObjects; NSArray *topLevelObjects;
[myBundle loadNibNamed:@"OpenPanelAccessoryView" owner:self topLevelObjects:&topLevelObjects]; [myBundle loadNibNamed:@"OpenPanelAccessoryView" owner:self topLevelObjects:&topLevelObjects];
} }
self.openPanel.allowedFileTypes = @[MPLegacyDocumentUTI, MPXMLDocumentUTI]; self.openPanel.allowedFileTypes = @[MPKdbDocumentUTI, MPKdbxDocumentUTI];
self.allowAllCheckBox.state = NSOffState; self.allowAllCheckBox.state = NSOffState;
self.showHiddenCheckBox.state = NSOffState; self.showHiddenCheckBox.state = NSOffState;
self.openPanel.accessoryView = self.accessoryView; self.openPanel.accessoryView = self.accessoryView;
@@ -46,7 +46,7 @@
BOOL allowAllFiles = HNHUIBoolForState(button.state); BOOL allowAllFiles = HNHUIBoolForState(button.state);
/* Toggle hidden to force a refresh */ /* Toggle hidden to force a refresh */
self.openPanel.showsHiddenFiles = !self.openPanel.showsHiddenFiles; self.openPanel.showsHiddenFiles = !self.openPanel.showsHiddenFiles;
self.openPanel.allowedFileTypes = allowAllFiles ? nil : @[MPLegacyDocumentUTI, MPXMLDocumentUTI]; self.openPanel.allowedFileTypes = allowAllFiles ? nil : @[MPKdbDocumentUTI, MPKdbxDocumentUTI];
self.openPanel.showsHiddenFiles = !self.openPanel.showsHiddenFiles; self.openPanel.showsHiddenFiles = !self.openPanel.showsHiddenFiles;
} }

View File

@@ -198,8 +198,8 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
MPDocument *document = self.document; MPDocument *document = self.document;
NSString *fileType = document.fileType; NSString *fileType = document.fileType;
/* we did open as legacy */ /* we did open as legacy */
if([fileType isEqualToString:MPLegacyDocumentUTI]) { if([fileType isEqualToString:MPKdbDocumentUTI]) {
if(document.tree.minimumType != KPKDatabaseTypeBinary) { if(document.tree.minimumType != KPKDatabaseFormatKdb) {
NSAlert *alert = [[NSAlert alloc] init]; NSAlert *alert = [[NSAlert alloc] init];
alert.alertStyle = NSWarningAlertStyle; alert.alertStyle = NSWarningAlertStyle;
alert.messageText = NSLocalizedString(@"WARNING_ON_LOSSY_SAVE", ""); alert.messageText = NSLocalizedString(@"WARNING_ON_LOSSY_SAVE", "");

View File

@@ -15,7 +15,7 @@
@property (nonatomic, weak) NSSavePanel *savePanel; @property (nonatomic, weak) NSSavePanel *savePanel;
@property (nonatomic, weak) MPDocument *document; @property (nonatomic, weak) MPDocument *document;
@property (nonatomic, assign, readonly) KPKDatabaseType selectedVersion; @property (nonatomic, assign, readonly) KPKDatabaseFormat selectedVersion;
@property (nonatomic, weak) IBOutlet NSPopUpButton *fileTypePopupButton; @property (nonatomic, weak) IBOutlet NSPopUpButton *fileTypePopupButton;
@property (nonatomic, weak) IBOutlet NSTextField *infoTextField; @property (nonatomic, weak) IBOutlet NSTextField *infoTextField;

View File

@@ -13,7 +13,7 @@
#import "KeePassKit/KeePassKit.h" #import "KeePassKit/KeePassKit.h"
@interface MPSavePanelAccessoryViewController () @interface MPSavePanelAccessoryViewController ()
@property (readwrite, assign) KPKDatabaseType selectedVersion; @property (readwrite, assign) KPKDatabaseFormat selectedVersion;
@end @end
@implementation MPSavePanelAccessoryViewController @implementation MPSavePanelAccessoryViewController
@@ -41,11 +41,11 @@
- (IBAction)setFileType:(id)sender { - (IBAction)setFileType:(id)sender {
NSString *uti = self.fileTypePopupButton.selectedItem.representedObject; NSString *uti = self.fileTypePopupButton.selectedItem.representedObject;
if([uti isEqualToString:MPLegacyDocumentUTI]) { if([uti isEqualToString:MPKdbDocumentUTI]) {
self.selectedVersion = KPKDatabaseTypeBinary; self.selectedVersion = KPKDatabaseFormatKdb;
} }
else if([uti isEqualToString:MPXMLDocumentUTI]) { else if([uti isEqualToString:MPKdbxDocumentUTI]) {
self.selectedVersion = KPKDatabaseTypeXml; self.selectedVersion = KPKDatabaseFormatKdbx;
} }
NSAssert(uti != nil, @"UTI cannot be nil"); NSAssert(uti != nil, @"UTI cannot be nil");
[self _updateNote]; [self _updateNote];
@@ -66,10 +66,10 @@
NSView *view = self.view; NSView *view = self.view;
NSAssert(view != nil, @"View has to be loaded at this point"); NSAssert(view != nil, @"View has to be loaded at this point");
switch(self.document.versionForFileType) { switch(self.document.versionForFileType) {
case KPKDatabaseTypeBinary: case KPKDatabaseFormatKdb:
[self.fileTypePopupButton selectItemAtIndex:1]; [self.fileTypePopupButton selectItemAtIndex:1];
break; break;
case KPKDatabaseTypeXml: case KPKDatabaseFormatKdbx:
[self.fileTypePopupButton selectItemAtIndex:0]; [self.fileTypePopupButton selectItemAtIndex:0];
break; break;
default: default:
@@ -82,7 +82,7 @@
- (void)_updateNote { - (void)_updateNote {
NSString *uti = self.fileTypePopupButton.selectedItem.representedObject; NSString *uti = self.fileTypePopupButton.selectedItem.representedObject;
BOOL showInfoText = (self.document.tree.minimumType == KPKDatabaseTypeXml && [uti isEqualToString:MPLegacyDocumentUTI]); BOOL showInfoText = (self.document.tree.minimumType == KPKDatabaseFormatKdbx && [uti isEqualToString:MPKdbDocumentUTI]);
self.infoTextField.hidden = !showInfoText; self.infoTextField.hidden = !showInfoText;
} }

View File

@@ -76,7 +76,6 @@ typedef NS_ENUM(NSUInteger, MPDoubleClickTitleAction) {
/* Password Generation */ /* Password Generation */
APPKIT_EXTERN NSString *const kMPSettingsKeyCopyGeneratedPasswordToClipboard; APPKIT_EXTERN NSString *const kMPSettingsKeyCopyGeneratedPasswordToClipboard;
APPKIT_EXTERN NSString *const kMPSettingsKeyDefaultPasswordRounds;
APPKIT_EXTERN NSString *const kMPSettingsKeyDefaultPasswordLength; APPKIT_EXTERN NSString *const kMPSettingsKeyDefaultPasswordLength;
APPKIT_EXTERN NSString *const kMPSettingsKeyPasswordCharacterFlags; APPKIT_EXTERN NSString *const kMPSettingsKeyPasswordCharacterFlags;
APPKIT_EXTERN NSString *const kMPSettingsKeyPasswordUseCustomString; APPKIT_EXTERN NSString *const kMPSettingsKeyPasswordUseCustomString;
@@ -109,4 +108,4 @@ typedef NS_ENUM(NSUInteger, MPPasswordEncoding) {
*/ */
+ (NSString *)defaultControllerPathForKey:(NSString *)key; + (NSString *)defaultControllerPathForKey:(NSString *)key;
@end @end

View File

@@ -47,7 +47,6 @@ NSString *const kMPSettingsKeyEnableQuicklookPreview = @"Enable
NSString *const kMPSettingsKeyCopyGeneratedPasswordToClipboard = @"CopyGeneratedPasswordToClipboard"; NSString *const kMPSettingsKeyCopyGeneratedPasswordToClipboard = @"CopyGeneratedPasswordToClipboard";
NSString *const kMPSettingsKeyDefaultPasswordRounds = @"KeyDefaultPasswordRounds";
NSString *const kMPSettingsKeyDefaultPasswordLength = @"DefaultPasswordLength"; NSString *const kMPSettingsKeyDefaultPasswordLength = @"DefaultPasswordLength";
NSString *const kMPSettingsKeyPasswordCharacterFlags = @"PasswordCharacterFlags"; NSString *const kMPSettingsKeyPasswordCharacterFlags = @"PasswordCharacterFlags";
NSString *const kMPSettingsKeyPasswordUseCustomString = @"PasswordUseCustomString"; NSString *const kMPSettingsKeyPasswordUseCustomString = @"PasswordUseCustomString";
@@ -70,6 +69,7 @@ NSString *const kMPDeprecatedSettingsKeyEntrySearchFilterMode = @"En
NSString *const kMPDeprecatedSettingsKeyHttpPort = @"HttpPort"; NSString *const kMPDeprecatedSettingsKeyHttpPort = @"HttpPort";
NSString *const kMPDeprecatedSettingsKeyEnableHttpServer = @"EnableHttpServer"; NSString *const kMPDeprecatedSettingsKeyEnableHttpServer = @"EnableHttpServer";
NSString *const kMPDeprecatedSettingsKeyShowMenuItem = @"ShowMenuItem"; NSString *const kMPDeprecatedSettingsKeyShowMenuItem = @"ShowMenuItem";
NSString *const kMPDeprecatedSettingsKeyDefaultPasswordRounds = @"KeyDefaultPasswordRounds";
@implementation MPSettingsHelper @implementation MPSettingsHelper
@@ -118,7 +118,6 @@ NSString *const kMPDeprecatedSettingsKeyShowMenuItem = @"Sh
kMPSettingsKeyAutotypeMatchTags: @NO, kMPSettingsKeyAutotypeMatchTags: @NO,
kMPSettingsKeyEnableQuicklookPreview: @NO, kMPSettingsKeyEnableQuicklookPreview: @NO,
kMPSettingsKeyCopyGeneratedPasswordToClipboard: @NO, kMPSettingsKeyCopyGeneratedPasswordToClipboard: @NO,
kMPSettingsKeyDefaultPasswordRounds: @50000,
kMPSettingsKeyDefaultPasswordLength: @12, kMPSettingsKeyDefaultPasswordLength: @12,
kMPSettingsKeyPasswordCharacterFlags: @(MPPasswordCharactersAll), kMPSettingsKeyPasswordCharacterFlags: @(MPPasswordCharactersAll),
kMPSettingsKeyPasswordUseCustomString: @NO, kMPSettingsKeyPasswordUseCustomString: @NO,
@@ -141,6 +140,7 @@ NSString *const kMPDeprecatedSettingsKeyShowMenuItem = @"Sh
kMPDeprecatedSettingsKeyDocumentsAutotypeFixNoteWasShown, kMPDeprecatedSettingsKeyDocumentsAutotypeFixNoteWasShown,
kMPDeprecatedSettingsKeyDoubleClickURLToLaunch, kMPDeprecatedSettingsKeyDoubleClickURLToLaunch,
kMPDeprecatedSettingsKeyEntrySearchFilterMode, kMPDeprecatedSettingsKeyEntrySearchFilterMode,
kMPDeprecatedSettingsKeyDefaultPasswordRounds,
/* Moved to KeePassHttp Plugin */ /* Moved to KeePassHttp Plugin */
kMPDeprecatedSettingsKeyHttpPort, kMPDeprecatedSettingsKeyHttpPort,
kMPDeprecatedSettingsKeyEnableHttpServer, kMPDeprecatedSettingsKeyEnableHttpServer,

View File

@@ -28,7 +28,7 @@
XCTAssertTrue(document.encrypted, @"Loaded but unencrypted should be not decrypted"); XCTAssertTrue(document.encrypted, @"Loaded but unencrypted should be not decrypted");
XCTAssertTrue([document unlockWithPassword:@"1234" keyFileURL:nil error:&error], @"Should decrypt with password"); XCTAssertTrue([document unlockWithPassword:@"1234" keyFileURL:nil error:&error], @"Should decrypt with password");
XCTAssertNil(error, @"No Error should occur on unlocking with correct password"); XCTAssertNil(error, @"No Error should occur on unlocking with correct password");
XCTAssertTrue((document.tree.minimumType = KPKDatabaseTypeBinary), @"Minimal Version should not increase with KDB File loaded"); XCTAssertTrue((document.tree.minimumType = KPKDatabaseFormatKdb), @"Minimal Version should not increase with KDB File loaded");
//STAssertTrue([document.fileType isEqualToString:[MPDocument fileTypeForVersion:KPKLegacyVersion]], @"File type needs to match opened file"); //STAssertTrue([document.fileType isEqualToString:[MPDocument fileTypeForVersion:KPKLegacyVersion]], @"File type needs to match opened file");
} }

View File

@@ -28,7 +28,7 @@
- (void)testCreateUntitledDocument { - (void)testCreateUntitledDocument {
MPDocument *document = [[MPDocument alloc] initWithType:@"" error:nil]; MPDocument *document = [[MPDocument alloc] initWithType:@"" error:nil];
XCTAssertNotNil(document, @"Document should be created"); XCTAssertNotNil(document, @"Document should be created");
XCTAssertTrue(document.tree.minimumType == KPKDatabaseTypeBinary, @"Tree should be Legacy Version in default case"); XCTAssertTrue(document.tree.minimumType == KPKDatabaseFormatKdb, @"Tree should be Legacy Version in default case");
XCTAssertFalse(document.encrypted, @"Document cannot be encrypted at creation"); XCTAssertFalse(document.encrypted, @"Document cannot be encrypted at creation");
XCTAssertFalse(document.compositeKey.hasPasswordOrKeyFile, @"Document has no Password/Keyfile and thus is not secured"); XCTAssertFalse(document.compositeKey.hasPasswordOrKeyFile, @"Document has no Password/Keyfile and thus is not secured");