updated to new prefixed KeePassKit API. Fixed tests

This commit is contained in:
michael starke
2016-12-09 10:43:53 +01:00
parent e9563f3f67
commit 08d11f1213
9 changed files with 17 additions and 16 deletions

View File

@@ -1,3 +1,3 @@
github "sparkle-project/Sparkle" ~> 1.13.1 github "sparkle-project/Sparkle" ~> 1.13.1
github "mstarke/KeePassKit" "ea4d8cd82bc388787d66866e578645693971d453" github "mstarke/KeePassKit" "f47b82b9404f606fcb0e989bb72df14839c0a35e"
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" "ea4d8cd82bc388787d66866e578645693971d453" github "mstarke/KeePassKit" "f47b82b9404f606fcb0e989bb72df14839c0a35e"
github "sparkle-project/Sparkle" "1.14.0" github "sparkle-project/Sparkle" "1.14.0"

View File

@@ -33,7 +33,7 @@
if(self) { if(self) {
_command = [sequence copy]; _command = [sequence copy];
_entry = entry; _entry = entry;
_normalizedCommand = sequence.normalizedAutotypeSequence; _normalizedCommand = sequence.kpk_normalizedAutotypeSequence;
} }
return self; return self;
} }
@@ -50,7 +50,7 @@
- (NSString *)evaluatedCommand { - (NSString *)evaluatedCommand {
if(!_evaluatedCommand) { if(!_evaluatedCommand) {
_evaluatedCommand = [[self.normalizedCommand finalValueForEntry:self.entry] copy]; _evaluatedCommand = [[self.normalizedCommand kpk_finalValueForEntry:self.entry] copy];
} }
return _evaluatedCommand; return _evaluatedCommand;
} }

View File

@@ -632,7 +632,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
NSArray *nodes = [self currentTargetNodes]; NSArray *nodes = [self currentTargetNodes];
KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil;
if(selectedEntry) { if(selectedEntry) {
[self _copyToPasteboard:[selectedEntry.password finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoPassword name:nil]; [self _copyToPasteboard:[selectedEntry.password kpk_finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoPassword name:nil];
} }
} }
@@ -640,7 +640,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
NSArray *nodes = [self currentTargetNodes]; NSArray *nodes = [self currentTargetNodes];
KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil;
if(selectedEntry) { if(selectedEntry) {
[self _copyToPasteboard:[selectedEntry.username finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoUsername name:nil]; [self _copyToPasteboard:[selectedEntry.username kpk_finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoUsername name:nil];
} }
} }
@@ -659,14 +659,14 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
NSArray *nodes = [self currentTargetNodes]; NSArray *nodes = [self currentTargetNodes];
KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil;
if(selectedEntry) { if(selectedEntry) {
[self _copyToPasteboard:[selectedEntry.url finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoURL name:nil]; [self _copyToPasteboard:[selectedEntry.url kpk_finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoURL name:nil];
} }
} }
- (void)openURL:(id)sender { - (void)openURL:(id)sender {
NSArray *nodes = [self currentTargetNodes]; NSArray *nodes = [self currentTargetNodes];
KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil;
NSString *expandedURL = [selectedEntry.url finalValueForEntry:selectedEntry]; NSString *expandedURL = [selectedEntry.url kpk_finalValueForEntry:selectedEntry];
if(expandedURL.length > 0) { if(expandedURL.length > 0) {
NSURL *webURL = [NSURL URLWithString:[expandedURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSURL *webURL = [NSURL URLWithString:[expandedURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *scheme = [webURL scheme]; NSString *scheme = [webURL scheme];

View File

@@ -277,7 +277,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
- (void)outlineViewSelectionDidChange:(NSNotification *)notification { - (void)outlineViewSelectionDidChange:(NSNotification *)notification {
MPDocument *document = self.windowController.document; MPDocument *document = self.windowController.document;
NSArray<KPKGroup *> *groups = [self currentTargetGroups]; NSArray<KPKGroup *> *groups = [self currentTargetGroups];
document.tree.metaData.lastSelectedGroup = (groups.count == 1 ? groups.firstObject.uuid : [NSUUID nullUUID]); document.tree.metaData.lastSelectedGroup = (groups.count == 1 ? groups.firstObject.uuid : [NSUUID kpk_nullUUID]);
document.selectedGroups = groups; document.selectedGroups = groups;
} }

View File

@@ -117,7 +117,7 @@
- (IBAction)generateKey:(id)sender { - (IBAction)generateKey:(id)sender {
MPDocument *document = self.document; MPDocument *document = self.document;
NSData *data = [NSData generateKeyfiledataForFormat:document.tree.minimumVersion.format]; NSData *data = [NSData kpk_generateKeyfiledataForFormat:document.tree.minimumVersion.format];
if(data) { if(data) {
NSSavePanel *savePanel = [NSSavePanel savePanel]; NSSavePanel *savePanel = [NSSavePanel savePanel];
savePanel.allowedFileTypes = @[@"key", @"xml"]; savePanel.allowedFileTypes = @[@"key", @"xml"];
@@ -149,9 +149,9 @@
if(hasKey) { if(hasKey) {
keyOk = [self.keyURL checkResourceIsReachableAndReturnError:nil]; keyOk = [self.keyURL checkResourceIsReachableAndReturnError:nil];
} }
BOOL hasPassword = ![NSString isEmptyString:password]; BOOL hasPassword = password.kpk_isNotEmpty;
if(!self.showPassword) { if(!self.showPassword) {
hasPassword |= ![NSString isEmptyString:repeat]; hasPassword |= repeat.kpk_isNotEmpty;
} }
BOOL passwordOk = YES; BOOL passwordOk = YES;
if(hasPassword ) { if(hasPassword ) {

View File

@@ -98,7 +98,7 @@ static NSString *mergeWithoutDuplicates(NSString* baseCharacters, NSString* cust
if([self length] == 0) { if([self length] == 0) {
return nil; return nil;
} }
NSData *data = [NSData dataWithRandomBytes:sizeof(NSUInteger)]; NSData *data = [NSData kpk_dataWithRandomBytes:sizeof(NSUInteger)];
NSUInteger randomIndex; NSUInteger randomIndex;
[data getBytes:&randomIndex length:data.length]; [data getBytes:&randomIndex length:data.length];
return [self substringWithRange:NSMakeRange(randomIndex % self.length, 1)]; return [self substringWithRange:NSMakeRange(randomIndex % self.length, 1)];

View File

@@ -28,8 +28,8 @@
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 = KPKDatabaseFormatKdb), @"Minimal Version should not increase with KDB File loaded"); KPKFileVersion kdb = { KPKDatabaseFormatKdb, kKPKKdbFileVersion };
//STAssertTrue([document.fileType isEqualToString:[MPDocument fileTypeForVersion:KPKLegacyVersion]], @"File type needs to match opened file"); XCTAssertEqual(NSOrderedSame, KPKFileVersionCompare(kdb, document.tree.minimumVersion), @"Minimal Version should not increase with KDB File loaded");
} }
- (void)testVersion1WrongPassword { - (void)testVersion1WrongPassword {

View File

@@ -28,7 +28,8 @@
- (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 == KPKDatabaseFormatKdb, @"Tree should be Legacy Version in default case"); KPKFileVersion kdb = { KPKDatabaseFormatKdb, kKPKKdbFileVersion };
XCTAssertEqual(NSOrderedSame, KPKFileVersionCompare(kdb, document.tree.minimumVersion), @"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");