diff --git a/KeePassKit b/KeePassKit index 3122304d..870d252a 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 3122304d9063a3c1f3cbb31307e3e76f5e31e5df +Subproject commit 870d252a2915a2f00326e85bfecebde26f003dca diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 4f83c038..8909d0bf 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -158,7 +158,7 @@ 4C45FB1D178E09ED0010007D /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C77E36615B84A240093A587 /* Cocoa.framework */; }; 4C45FB23178E09ED0010007D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4C45FB21178E09ED0010007D /* InfoPlist.strings */; }; 4C45FB2D178E0BCB0010007D /* MPDatabaseLoading.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C45FB2C178E0BCB0010007D /* MPDatabaseLoading.m */; }; - 4C45FB30178E0CE20010007D /* MPDatabaseCreation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C45FB2F178E0CE20010007D /* MPDatabaseCreation.m */; }; + 4C45FB30178E0CE20010007D /* MPTestDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C45FB2F178E0CE20010007D /* MPTestDocument.m */; }; 4C46B88517063A070046109A /* NSString+MPPasswordCreation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C46B88417063A070046109A /* NSString+MPPasswordCreation.m */; }; 4C46E09E17673A0A00DA62E8 /* HNHShadowBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C46E09D17673A0A00DA62E8 /* HNHShadowBox.m */; }; 4C473A7F18AFD6340073FD2E /* KPKTestReference.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C473A7E18AFD6340073FD2E /* KPKTestReference.m */; }; @@ -669,7 +669,7 @@ 4C45FB22178E09ED0010007D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 4C45FB27178E09ED0010007D /* MacPassTests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MacPassTests-Prefix.pch"; sourceTree = ""; }; 4C45FB2C178E0BCB0010007D /* MPDatabaseLoading.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDatabaseLoading.m; sourceTree = ""; }; - 4C45FB2F178E0CE20010007D /* MPDatabaseCreation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDatabaseCreation.m; sourceTree = ""; }; + 4C45FB2F178E0CE20010007D /* MPTestDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPTestDocument.m; sourceTree = ""; }; 4C46B88317063A070046109A /* NSString+MPPasswordCreation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+MPPasswordCreation.h"; sourceTree = ""; }; 4C46B88417063A070046109A /* NSString+MPPasswordCreation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+MPPasswordCreation.m"; sourceTree = ""; }; 4C46E09C17673A0A00DA62E8 /* HNHShadowBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HNHShadowBox.h; sourceTree = ""; }; @@ -1559,7 +1559,7 @@ 4C305F3F179A1A790082334F /* Images */, 4C18F9AC178E123200890BCE /* Databases */, 4C45FB2C178E0BCB0010007D /* MPDatabaseLoading.m */, - 4C45FB2F178E0CE20010007D /* MPDatabaseCreation.m */, + 4C45FB2F178E0CE20010007D /* MPTestDocument.m */, 4C19E502178E2871002F2CD0 /* MPDatabasePasswordAndKeyfile.m */, 4C6BC65F1A36717E00BDDF3D /* MPDatabaseSearch.m */, 4C45FB1F178E09ED0010007D /* Supporting Files */, @@ -2518,7 +2518,7 @@ buildActionMask = 2147483647; files = ( 4C45FB2D178E0BCB0010007D /* MPDatabaseLoading.m in Sources */, - 4C45FB30178E0CE20010007D /* MPDatabaseCreation.m in Sources */, + 4C45FB30178E0CE20010007D /* MPTestDocument.m in Sources */, 4C473A7F18AFD6340073FD2E /* KPKTestReference.m in Sources */, 4CD25F9318B17A17006098E9 /* KPKTestUUIDAdditions.m in Sources */, 4C19E503178E2871002F2CD0 /* MPDatabasePasswordAndKeyfile.m in Sources */, diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 94fac1e6..df190d01 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -299,6 +299,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey - (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL error:(NSError *__autoreleasing*)error{ self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyFileURL]; self.tree = [[KPKTree alloc] initWithData:self.encryptedData password:self.compositeKey error:error]; + /* clear out the encrypted data as we do not need it for now */ + self.encryptedData = nil; BOOL isUnlocked = (nil != self.tree); if(isUnlocked) { @@ -356,7 +358,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey } - (BOOL)encrypted { - return (self.tree == nil); + /* we have an encrypted document if there's data loaded but no tree set */ + return (nil != self.encryptedData && self.tree == nil); } - (KPKGroup *)root { diff --git a/MacPass/MPEntryInspectorViewController.m b/MacPass/MPEntryInspectorViewController.m index 45b061a4..0568703a 100644 --- a/MacPass/MPEntryInspectorViewController.m +++ b/MacPass/MPEntryInspectorViewController.m @@ -382,7 +382,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) { [self.URLTextField bind:NSValueBinding toObject:self.entry withKeyPath:NSStringFromSelector(@selector(url)) options:nil]; [self.expiresCheckButton bind:NSTitleBinding toObject:self.entry.timeInfo - withKeyPath:NSStringFromSelector(@selector(expiryTime)) + withKeyPath:NSStringFromSelector(@selector(expirationDate)) options:@{ NSValueTransformerNameBindingOption:MPExpiryDateValueTransformer }]; [self.expiresCheckButton bind:NSValueBinding toObject:self.entry.timeInfo withKeyPath:NSStringFromSelector(@selector(expires)) options:nil]; [self.tagsTokenField bind:NSValueBinding toObject:self.entry withKeyPath:NSStringFromSelector(@selector(tags)) options:nil]; diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 35c366ce..895d1f30 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -101,7 +101,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; + (NSString *)timeInfoModificationTimeKeyPath { static NSString *timeInfoModificationTimeKeyPath; if(nil == timeInfoModificationTimeKeyPath) { - timeInfoModificationTimeKeyPath = [[NSString alloc] initWithFormat:@"%@.%@", NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(lastModificationTime))]; + timeInfoModificationTimeKeyPath = [[NSString alloc] initWithFormat:@"%@.%@", NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(modificationDate))]; } return timeInfoModificationTimeKeyPath; } @@ -320,7 +320,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; NSString *modificatoinTimeKeyPath = [NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(timeInfo)), - NSStringFromSelector(@selector(lastModificationTime))]; + NSStringFromSelector(@selector(modificationDate))]; [view.textField bind:NSValueBinding toObject:view withKeyPath:modificatoinTimeKeyPath options:nil]; return view; diff --git a/MacPass/MPGroupInspectorViewController.m b/MacPass/MPGroupInspectorViewController.m index 4550fdef..f0509776 100644 --- a/MacPass/MPGroupInspectorViewController.m +++ b/MacPass/MPGroupInspectorViewController.m @@ -105,7 +105,7 @@ if(self.group) { [self.titleTextField bind:NSValueBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(name)) options:nil]; [self.expiresCheckButton bind:NSValueBinding toObject:self.group.timeInfo withKeyPath:NSStringFromSelector(@selector(expires)) options:nil]; - [self.expiresCheckButton bind:NSTitleBinding toObject:self.group.timeInfo withKeyPath:NSStringFromSelector(@selector(expiryTime)) options:@{ NSValueTransformerNameBindingOption:MPExpiryDateValueTransformer }]; + [self.expiresCheckButton bind:NSTitleBinding toObject:self.group.timeInfo withKeyPath:NSStringFromSelector(@selector(expirationDate)) options:@{ NSValueTransformerNameBindingOption:MPExpiryDateValueTransformer }]; [self.autotypePopupButton bind:NSSelectedTagBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(isAutoTypeEnabled)) options:nil]; [self.autotypeSequenceTextField bind:NSValueBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(defaultAutoTypeSequence)) options:nil]; [self.searchPopupButton bind:NSSelectedTagBinding toObject:self.group withKeyPath:NSStringFromSelector(@selector(isSearchEnabled)) options:nil]; diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m index 22f4d3ff..29a53c60 100644 --- a/MacPass/MPInspectorViewController.m +++ b/MacPass/MPInspectorViewController.m @@ -224,8 +224,8 @@ typedef NS_ENUM(NSUInteger, MPContentTab) { MPDatePickingViewController *controller = [[MPDatePickingViewController alloc] init]; controller.popover = self.popover; MPDocument *document = self.windowController.document; - if(document.selectedItem.timeInfo.expiryTime) { - controller.date = document.selectedItem.timeInfo.expiryTime; + if(document.selectedItem.timeInfo.expirationDate) { + controller.date = document.selectedItem.timeInfo.expirationDate; } self.popover.contentViewController = controller; [self.popover showRelativeToRect:NSZeroRect ofView:sender preferredEdge:NSMinYEdge]; @@ -267,7 +267,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) { - (void)_setExpiryDate:(NSDate *)date { MPDocument *document = [[self windowController] document]; - document.selectedItem.timeInfo.expiryTime = date; + document.selectedItem.timeInfo.expirationDate = date; } #pragma mark - diff --git a/MacPassTests/MPDatabaseSearch.m b/MacPassTests/MPDatabaseSearch.m index 89b37623..936bfe5d 100644 --- a/MacPassTests/MPDatabaseSearch.m +++ b/MacPassTests/MPDatabaseSearch.m @@ -54,6 +54,7 @@ } - (void)testSearch { + XCTFail(@"Missing Test"); } @end diff --git a/MacPassTests/MPDatabaseCreation.m b/MacPassTests/MPTestDocument.m similarity index 57% rename from MacPassTests/MPDatabaseCreation.m rename to MacPassTests/MPTestDocument.m index aa436531..e7c63a19 100644 --- a/MacPassTests/MPDatabaseCreation.m +++ b/MacPassTests/MPTestDocument.m @@ -12,18 +12,27 @@ #import "KPKTree.h" #import "KPKCompositeKey.h" -@interface MPDatabaseCreation : XCTestCase +@interface MPTestDocument : XCTestCase @end -@implementation MPDatabaseCreation +@implementation MPTestDocument -- (void)testCreateNewDatabase { +- (void)testCreateEmptyDocument { MPDocument *document = [[MPDocument alloc] init]; XCTAssertNotNil(document, @"Document should be created"); + XCTAssertNil(document.tree, @"Allocated document should not have a tree"); + XCTAssertFalse(document.encrypted, @"Document cannot be encrypted without a tree"); + XCTAssertNil(document.compositeKey, @"Document shoudl have not key at all"); +} + +- (void)testCreateUntitledDocument { + MPDocument *document = [[MPDocument alloc] initWithType:@"" error:nil]; + XCTAssertNotNil(document, @"Document should be created"); XCTAssertTrue(document.tree.minimumVersion == KPKLegacyVersion, @"Tree should be Legacy Version in default case"); XCTAssertFalse(document.encrypted, @"Document cannot be encrypted at creation"); XCTAssertFalse(document.compositeKey.hasPasswordOrKeyFile, @"Document has no Password/Keyfile and thus is not secured"); + } @end