mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-24 21:59:30 +00:00
Fixed Tests
Fixed error that lead to trying to create and array with nil object
This commit is contained in:
@@ -253,6 +253,15 @@
|
||||
<reference key="NSOnImage" ref="35465992"/>
|
||||
<reference key="NSMixedImage" ref="502551668"/>
|
||||
</object>
|
||||
<object class="NSMenuItem" id="663106531">
|
||||
<reference key="NSMenu" ref="720053764"/>
|
||||
<string key="NSTitle">Save As…</string>
|
||||
<string key="NSKeyEquiv">S</string>
|
||||
<int key="NSKeyEquivModMask">1048576</int>
|
||||
<int key="NSMnemonicLoc">2147483647</int>
|
||||
<reference key="NSOnImage" ref="35465992"/>
|
||||
<reference key="NSMixedImage" ref="502551668"/>
|
||||
</object>
|
||||
<object class="NSMenuItem" id="579971712">
|
||||
<reference key="NSMenu" ref="720053764"/>
|
||||
<string key="NSTitle">Revert to Saved</string>
|
||||
@@ -794,6 +803,14 @@
|
||||
</object>
|
||||
<int key="connectionID">1234</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">saveDocumentAs:</string>
|
||||
<reference key="source" ref="1014"/>
|
||||
<reference key="destination" ref="663106531"/>
|
||||
</object>
|
||||
<int key="connectionID">1255</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">showPreferences:</string>
|
||||
@@ -896,6 +913,7 @@
|
||||
<reference ref="1010469920"/>
|
||||
<reference ref="915918141"/>
|
||||
<reference ref="544639599"/>
|
||||
<reference ref="663106531"/>
|
||||
</array>
|
||||
<reference key="parent" ref="379814623"/>
|
||||
</object>
|
||||
@@ -1226,6 +1244,11 @@
|
||||
<reference key="object" ref="544639599"/>
|
||||
<reference key="parent" ref="720053764"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1243</int>
|
||||
<reference key="object" ref="663106531"/>
|
||||
<reference key="parent" ref="720053764"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
@@ -1241,6 +1264,7 @@
|
||||
<string key="1203.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="1231.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="124.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="1243.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="125.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="126.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="129.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
@@ -1298,7 +1322,7 @@
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">1234</int>
|
||||
<int key="maxID">1258</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
||||
@@ -34,14 +34,15 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
@interface MPDocument : NSDocument
|
||||
|
||||
/* true, if password and/or keyfile are set */
|
||||
@property (assign, readonly, getter = isSecured) BOOL secured;
|
||||
@property (assign, readonly) BOOL hasPasswordOrKey;
|
||||
/* true, if lock screen is present (no phyiscal locking) */
|
||||
@property (assign, getter = isLocked) BOOL locked;
|
||||
/* true, if document is loaded and decrypted (tree is loaded) */
|
||||
@property (assign, readonly, getter = isDecrypted) BOOL decrypted;
|
||||
@property (assign, nonatomic) BOOL locked;
|
||||
@property (assign, readonly) BOOL decrypted;
|
||||
|
||||
@property (strong, readonly, nonatomic) KdbTree *tree;
|
||||
@property (weak, readonly, nonatomic) KdbGroup *root;
|
||||
@property (readonly, strong) MPRootAdapter *rootAdapter;
|
||||
|
||||
@property (nonatomic, copy) NSString *password;
|
||||
@property (nonatomic, strong) NSURL *key;
|
||||
|
||||
@@ -49,7 +50,10 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
@property (assign, readonly, getter = isReadOnly) BOOL readOnly;
|
||||
|
||||
- (id)initWithVersion:(MPDatabaseVersion)version;
|
||||
- (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL;
|
||||
|
||||
#pragma mark Lock/Decrypt
|
||||
- (void)lockDatabase:(id)sender;
|
||||
- (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL;
|
||||
|
||||
#pragma mark Data Lookup
|
||||
/*
|
||||
|
||||
@@ -40,6 +40,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
@interface MPDocument () {
|
||||
@private
|
||||
BOOL _didLockFile;
|
||||
NSData *_fileData;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +49,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
@property (weak, nonatomic, readonly) KdbPassword *passwordHash;
|
||||
@property (assign) MPDatabaseVersion version;
|
||||
|
||||
@property (assign, nonatomic) BOOL secured;
|
||||
@property (assign, nonatomic) BOOL hasPasswordOrKey;
|
||||
@property (assign) BOOL decrypted;
|
||||
@property (assign) BOOL readOnly;
|
||||
|
||||
@@ -72,9 +73,10 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
- (id)initWithVersion:(MPDatabaseVersion)version {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
_fileData = nil;
|
||||
_didLockFile = NO;
|
||||
_decrypted = YES;
|
||||
_secured = NO;
|
||||
_hasPasswordOrKey = NO;
|
||||
_locked = NO;
|
||||
_readOnly = NO;
|
||||
_rootAdapter = [[MPRootAdapter alloc] init];
|
||||
@@ -131,6 +133,11 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
self.readOnly = NO;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
Delete our old Tree, and just grab the data
|
||||
*/
|
||||
self.tree = nil;
|
||||
_fileData = [NSData dataWithContentsOfURL:url options:NSDataReadingUncached error:outError];
|
||||
self.decrypted = NO;
|
||||
return YES;
|
||||
}
|
||||
@@ -153,9 +160,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
[super close];
|
||||
}
|
||||
|
||||
#pragma mark Protection
|
||||
#pragma mark Lock/Unlock/Decrypt
|
||||
|
||||
- (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL {
|
||||
- (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL {
|
||||
self.key = keyFileURL;
|
||||
self.password = [password length] > 0 ? password : nil;
|
||||
@try {
|
||||
@@ -175,6 +182,15 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)lockDatabase:(id)sender {
|
||||
// Persist Tree into data
|
||||
self.tree = nil;
|
||||
self.locked = YES;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Custom Setter
|
||||
|
||||
- (void)setPassword:(NSString *)password {
|
||||
if(![_password isEqualToString:password]) {
|
||||
_password = [password copy];
|
||||
@@ -200,7 +216,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
}
|
||||
|
||||
- (BOOL)prepareSavePanel:(NSSavePanel *)savePanel {
|
||||
if(self.isSecured) {
|
||||
if(self.hasPasswordOrKey) {
|
||||
[savePanel setAccessoryView:nil];
|
||||
return YES;
|
||||
}
|
||||
@@ -440,7 +456,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
- (void)_updateIsSecured {
|
||||
BOOL securePassword = ([self.password length] > 0);
|
||||
BOOL secureKey = (nil != self.key);
|
||||
self.secured = (secureKey || securePassword);
|
||||
self.hasPasswordOrKey = (secureKey || securePassword);
|
||||
}
|
||||
|
||||
- (void)_cleanupLock {
|
||||
|
||||
@@ -97,7 +97,7 @@ NSString *const MPCurrentItemChangedNotification = @"com.hicknhack.macpass.MPCur
|
||||
[[self window] setDelegate:self];
|
||||
|
||||
MPDocument *document = [self document];
|
||||
if(!document.isDecrypted) {
|
||||
if(!document.decrypted) {
|
||||
[self showPasswordInput];
|
||||
}
|
||||
else {
|
||||
@@ -178,7 +178,7 @@ NSString *const MPCurrentItemChangedNotification = @"com.hicknhack.macpass.MPCur
|
||||
}
|
||||
SEL itemAction = [theItem action];
|
||||
if( itemAction == [MPActionHelper actionOfType:MPActionLock]) {
|
||||
return document.isSecured;
|
||||
return document.hasPasswordOrKey;
|
||||
}
|
||||
if(itemAction == [MPActionHelper actionOfType:MPActionAddEntry]) {
|
||||
return (nil != _outlineViewController.selectedGroup);
|
||||
@@ -211,7 +211,7 @@ NSString *const MPCurrentItemChangedNotification = @"com.hicknhack.macpass.MPCur
|
||||
|
||||
- (void)lock:(id)sender {
|
||||
MPDocument *document = [self document];
|
||||
if(!document.isSecured) {
|
||||
if(!document.hasPasswordOrKey) {
|
||||
return; // Document needs a password/keyfile to be lockable
|
||||
}
|
||||
if(document.isLocked) {
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
MPDocument *document = [windowController document];
|
||||
if(document) {
|
||||
BOOL isOk = NO;
|
||||
if(document.isDecrypted) {
|
||||
if(document.decrypted) {
|
||||
// TODO: Fix unlocking to actually test
|
||||
BOOL noPassword = !document.password && [[self.passwordTextField stringValue] length] == 0;
|
||||
BOOL passwordOk = [document.password isEqualToString:[self.passwordTextField stringValue]];
|
||||
@@ -69,7 +69,7 @@
|
||||
isOk = (noPassword || passwordOk) && (noKey || keyOk);
|
||||
}
|
||||
else {
|
||||
isOk = [document decryptWithPassword:[self.passwordTextField stringValue] keyFileURL:[self.keyPathControl URL]];
|
||||
isOk = [document unlockWithPassword:[self.passwordTextField stringValue] keyFileURL:[self.keyPathControl URL]];
|
||||
}
|
||||
if(!isOk) {
|
||||
[self _showError];
|
||||
|
||||
@@ -21,7 +21,12 @@
|
||||
- (void)setTree:(KdbTree *)tree {
|
||||
if(_tree != tree) {
|
||||
_tree = tree;
|
||||
self.groups = @[_tree.root];
|
||||
if(_tree) {
|
||||
self.groups = @[_tree.root];
|
||||
}
|
||||
else {
|
||||
self.groups = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2409</string>
|
||||
<string>2485</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
Reference in New Issue
Block a user