mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 21:42:32 +00:00
Fixed MPDocument tests to work again
This commit is contained in:
@@ -2203,6 +2203,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CODE_SIGN_IDENTITY = "Developer ID Application";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "MacPass/MacPass-Prefix.pch";
|
||||
@@ -2217,6 +2218,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CODE_SIGN_IDENTITY = "Developer ID Application";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "MacPass/MacPass-Prefix.pch";
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<string key="NSClassName">NSApplication</string>
|
||||
</object>
|
||||
<object class="NSCustomView" id="233312071">
|
||||
<nil key="NSNextResponder"/>
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<array class="NSMutableArray" key="NSSubviews">
|
||||
<object class="NSTextField" id="990836775">
|
||||
@@ -50,6 +50,7 @@
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{57, 409}, {204, 17}}</string>
|
||||
<reference key="NSSuperview" ref="233312071"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="45251842"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:1535</string>
|
||||
<string key="NSAntiCompressionPriority">{249, 750}</string>
|
||||
@@ -99,13 +100,14 @@
|
||||
</set>
|
||||
<string key="NSFrame">{{20, 401}, {32, 32}}</string>
|
||||
<reference key="NSSuperview" ref="233312071"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="990836775"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSImageCell" key="NSCell" id="152819686">
|
||||
<int key="NSCellFlags">134217728</int>
|
||||
<int key="NSCellFlags2">33554432</int>
|
||||
<object class="NSCustomResource" key="NSContents">
|
||||
<object class="NSCustomResource" key="NSContents" id="202092680">
|
||||
<string key="NSClassName">NSImage</string>
|
||||
<string key="NSResourceName">NSActionTemplate</string>
|
||||
</object>
|
||||
@@ -127,17 +129,20 @@
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{20, 2}, {42, 25}}</string>
|
||||
<reference key="NSSuperview" ref="381395509"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:22</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSButtonCell" key="NSCell" id="348505851">
|
||||
<int key="NSCellFlags">-2080374784</int>
|
||||
<int key="NSCellFlags2">134217728</int>
|
||||
<string key="NSContents">Edit</string>
|
||||
<string key="NSContents"/>
|
||||
<reference key="NSSupport" ref="240853158"/>
|
||||
<string key="NSCellIdentifier">_NS:22</string>
|
||||
<reference key="NSControlView" ref="830540359"/>
|
||||
<int key="NSButtonFlags">-2034483200</int>
|
||||
<int key="NSButtonFlags2">163</int>
|
||||
<reference key="NSNormalImage" ref="202092680"/>
|
||||
<string key="NSAlternateContents"/>
|
||||
<string key="NSKeyEquivalent"/>
|
||||
<int key="NSPeriodicDelay">400</int>
|
||||
@@ -148,6 +153,7 @@
|
||||
</array>
|
||||
<string key="NSFrameSize">{278, 30}</string>
|
||||
<reference key="NSSuperview" ref="233312071"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="830540359"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<string key="NSClassName">HNHGradientView</string>
|
||||
@@ -157,6 +163,8 @@
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{0, 30}, {278, 369}}</string>
|
||||
<reference key="NSSuperview" ref="233312071"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="906788312"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<array class="NSMutableArray" key="NSTabViewItems">
|
||||
<object class="NSTabViewItem" id="367063082">
|
||||
@@ -166,7 +174,8 @@
|
||||
<int key="NSvFlags">274</int>
|
||||
<string key="NSFrameSize">{278, 369}</string>
|
||||
<reference key="NSSuperview" ref="45251842"/>
|
||||
<reference key="NSNextKeyView" ref="381395509"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:28</string>
|
||||
</object>
|
||||
<string key="NSLabel">Entry</string>
|
||||
@@ -243,6 +252,8 @@
|
||||
</object>
|
||||
</array>
|
||||
<string key="NSFrameSize">{278, 443}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="621131831"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<string key="NSClassName">NSView</string>
|
||||
@@ -966,7 +977,100 @@
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">3117</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes"/>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">HNHGradientView</string>
|
||||
<string key="superclassName">NSView</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/HNHGradientView.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">MPInspectorViewController</string>
|
||||
<string key="superclassName">MPViewController</string>
|
||||
<object class="NSMutableDictionary" key="actions">
|
||||
<string key="NS.key.0">showImagePopup:</string>
|
||||
<string key="NS.object.0">id</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="actionInfosByName">
|
||||
<string key="NS.key.0">showImagePopup:</string>
|
||||
<object class="IBActionInfo" key="NS.object.0">
|
||||
<string key="name">showImagePopup:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="outlets">
|
||||
<string key="bottomBar">HNHGradientView</string>
|
||||
<string key="createdTextField">NSTextField</string>
|
||||
<string key="itemImageView">MPPopupImageView</string>
|
||||
<string key="itemNameTextField">NSTextField</string>
|
||||
<string key="modifiedTextField">NSTextField</string>
|
||||
<string key="noSelectionInfo">NSTextField</string>
|
||||
<string key="tabView">NSTabView</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
<object class="IBToOneOutletInfo" key="bottomBar">
|
||||
<string key="name">bottomBar</string>
|
||||
<string key="candidateClassName">HNHGradientView</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="createdTextField">
|
||||
<string key="name">createdTextField</string>
|
||||
<string key="candidateClassName">NSTextField</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="itemImageView">
|
||||
<string key="name">itemImageView</string>
|
||||
<string key="candidateClassName">MPPopupImageView</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="itemNameTextField">
|
||||
<string key="name">itemNameTextField</string>
|
||||
<string key="candidateClassName">NSTextField</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="modifiedTextField">
|
||||
<string key="name">modifiedTextField</string>
|
||||
<string key="candidateClassName">NSTextField</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="noSelectionInfo">
|
||||
<string key="name">noSelectionInfo</string>
|
||||
<string key="candidateClassName">NSTextField</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="tabView">
|
||||
<string key="name">tabView</string>
|
||||
<string key="candidateClassName">NSTabView</string>
|
||||
</object>
|
||||
</dictionary>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/MPInspectorViewController.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">MPPopupImageView</string>
|
||||
<string key="superclassName">NSImageView</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/MPPopupImageView.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">MPViewController</string>
|
||||
<string key="superclassName">NSViewController</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/MPViewController.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">NSLayoutConstraint</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBProjectSource</string>
|
||||
<string key="minorKey">./Classes/NSLayoutConstraint.h</string>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
|
||||
<bool key="IBDocument.previouslyAttemptedUpgradeToXcode5">YES</bool>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<string>kdbx</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string></string>
|
||||
<string>kdbxFileType</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
@@ -28,7 +28,7 @@
|
||||
<string>kdb</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string></string>
|
||||
<string>kdbFileType</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
|
||||
@@ -8,26 +8,15 @@
|
||||
|
||||
#import "MPDatabaseCreation.h"
|
||||
#import "MPDocument.h"
|
||||
#import "KPKTree.h"
|
||||
|
||||
@implementation MPDatabaseCreation
|
||||
|
||||
- (void)testCreateDatabaseVersion1 {
|
||||
MPDocument *document = [[MPDocument alloc] initWithVersion:MPDatabaseVersion3];
|
||||
- (void)testCreateNewDatabase {
|
||||
MPDocument *document = [[MPDocument alloc] init];
|
||||
STAssertNotNil(document, @"Document should be created");
|
||||
STAssertTrue(document.version == MPDatabaseVersion3, @"Database should be Version1");
|
||||
STAssertNotNil(document.treeV3, @"Database Tree needs to be Kdb3Tree");
|
||||
STAssertNil(document.treeV4, @"Database Tree cannot be Kdb4Tree");
|
||||
STAssertTrue(document.decrypted, @"Document has to be decrypted new database is created");
|
||||
STAssertFalse(document.hasPasswordOrKey, @"Document has no Password/Keyfile and thus is not secured");
|
||||
}
|
||||
|
||||
- (void)testCreateDatabaseVersion2 {
|
||||
MPDocument *document = [[MPDocument alloc] initWithVersion:MPDatabaseVersion4];
|
||||
STAssertNotNil(document, @"Document should be created");
|
||||
STAssertTrue(document.version == MPDatabaseVersion4, @"Database should be Version2");
|
||||
STAssertNotNil(document.treeV4, @"Database Tree needs to be Kdb4Tree");
|
||||
STAssertNil(document.treeV3, @"Database Tree cannot be Kdb3Tree");
|
||||
STAssertTrue(document.decrypted, @"Document has to be decrypted new database is created");
|
||||
STAssertTrue(document.tree.minimumVersion == KPKLegacyVersion, @"Tree should be Legacy Version in defautl case");
|
||||
STAssertFalse(document.encrypted, @"Document cannot be encrypted at creation");
|
||||
STAssertFalse(document.hasPasswordOrKey, @"Document has no Password/Keyfile and thus is not secured");
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#import "MPDocument.h"
|
||||
|
||||
#import "KPKTree.h"
|
||||
|
||||
@implementation MPDatabaseLoading
|
||||
|
||||
|
||||
@@ -20,12 +22,11 @@
|
||||
MPDocument *document = [[MPDocument alloc] initWithContentsOfURL:url ofType:@"kdb" error:&error];
|
||||
STAssertNil(error, @"No Error should occur on loading");
|
||||
STAssertNotNil(document, @"Document cannot be nil");
|
||||
STAssertFalse(document.decrypted, @"Document is not decrypted after inital load");
|
||||
STAssertTrue([document unlockWithPassword:@"1234" keyFileURL:nil], @"Should decrypt with password");
|
||||
STAssertTrue(document.decrypted, @"Document is decrypted if decryptiong succeeds");
|
||||
STAssertNotNil(document.treeV3, @"Tree shoudl be version1");
|
||||
STAssertNil(document.treeV4, @"Tree should not be version2");
|
||||
STAssertTrue(document.version == MPDatabaseVersion3, @"Internal databse version should be correct");
|
||||
STAssertTrue(document.encrypted, @"Loaded but unencrypted should be not decrypted");
|
||||
STAssertTrue([document unlockWithPassword:@"1234" keyFileURL:nil error:&error], @"Should decrypt with password");
|
||||
STAssertNil(error, @"No Error should occur on unlocking with correct password");
|
||||
STAssertTrue((document.tree.minimumVersion = KPKLegacyVersion), @"Minimal Version should not increase with KDB File loaded");
|
||||
//STAssertTrue([document.fileType isEqualToString:[MPDocument fileTypeForVersion:KPKLegacyVersion]], @"File type needs to match opened file");
|
||||
}
|
||||
|
||||
- (void)testVersion1WrongPassword {
|
||||
@@ -35,9 +36,9 @@
|
||||
MPDocument *document = [[MPDocument alloc] initWithContentsOfURL:url ofType:@"kdb" error:&error];
|
||||
STAssertNil(error, @"No Error should occur on loading");
|
||||
STAssertNotNil(document, @"Document should not be nil");
|
||||
STAssertFalse(document.decrypted, @"Document is not decrypted after inital load");
|
||||
STAssertFalse([document unlockWithPassword:@"123" keyFileURL:nil], @"Decryption should fail");
|
||||
STAssertFalse(document.decrypted, @"Document is not decrypted with wrong password supplied");
|
||||
STAssertTrue(document.encrypted, @"Loaded but unencrypted should be not decrypted");
|
||||
STAssertFalse([document unlockWithPassword:@"123" keyFileURL:nil error:&error], @"Decryption should fail");
|
||||
STAssertNotNil(error, @"Error should occur on unlocking with correct password");
|
||||
}
|
||||
|
||||
- (void)testLoadDatabaseVerions2 {
|
||||
@@ -47,12 +48,14 @@
|
||||
MPDocument *document = [[MPDocument alloc] initWithContentsOfURL:url ofType:@"kdbx" error:&error];
|
||||
STAssertNil(error, @"No Error should occur on loading");
|
||||
STAssertNotNil(document, @"Document cannot be nil");
|
||||
/*
|
||||
STAssertFalse(document.decrypted, @"Document is not decrypted after inital load");
|
||||
STAssertTrue([document unlockWithPassword:@"1234" keyFileURL:nil], @"Should decrypt with password");
|
||||
STAssertTrue(document.decrypted, @"Document is decrypted if decryptiong succeeds");
|
||||
STAssertNil(document.treeV3, @"Tree should not be version1");
|
||||
STAssertNotNil(document.treeV4, @"Tree shoud be version2");
|
||||
STAssertTrue(document.version == MPDatabaseVersion4, @"Internal database version should be correct");
|
||||
*/
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
@class MPDocument;
|
||||
|
||||
@interface MPDatabasePasswordAndKeyfile : SenTestCase {
|
||||
MPDocument *_databaseV3;
|
||||
MPDocument *_databaseV4;
|
||||
MPDocument *_database;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -13,34 +13,32 @@
|
||||
@implementation MPDatabasePasswordAndKeyfile
|
||||
|
||||
- (void)setUp {
|
||||
_databaseV3 = [[MPDocument alloc] initWithVersion:MPDatabaseVersion3];
|
||||
_databaseV4 = [[MPDocument alloc] initWithVersion:MPDatabaseVersion4];
|
||||
_database = [[MPDocument alloc] init];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
_databaseV3 = nil;
|
||||
_databaseV4 = nil;
|
||||
_database = nil;
|
||||
}
|
||||
|
||||
- (void)testSetPassword {
|
||||
STAssertTrue([_databaseV3.password length] == 0, @"Password should not be set");
|
||||
STAssertNil(_databaseV3.key, @"Keyfile should not be set");
|
||||
STAssertFalse(_databaseV3.hasPasswordOrKey, @"Database without password is not secure");
|
||||
_databaseV3.password = @"test";
|
||||
STAssertTrue([_databaseV3.password isEqualToString:@"test"], @"Password should be set");
|
||||
STAssertTrue(_databaseV3.hasPasswordOrKey, @"Database with password is secured");
|
||||
_databaseV3.password = nil;
|
||||
STAssertFalse(_databaseV3.hasPasswordOrKey, @"Database with removed password is not secure anymore");
|
||||
STAssertTrue([_database.password length] == 0, @"Password should not be set");
|
||||
STAssertNil(_database.key, @"Keyfile should not be set");
|
||||
STAssertFalse(_database.hasPasswordOrKey, @"Database without password is not secure");
|
||||
_database.password = @"test";
|
||||
STAssertTrue([_database.password isEqualToString:@"test"], @"Password should be set");
|
||||
STAssertTrue(_database.hasPasswordOrKey, @"Database with password is secured");
|
||||
_database.password = nil;
|
||||
STAssertFalse(_database.hasPasswordOrKey, @"Database with removed password is not secure anymore");
|
||||
}
|
||||
|
||||
- (void)testSetKeyfile {
|
||||
STAssertTrue([_databaseV3.password length] == 0, @"Password should not be set");
|
||||
STAssertNil(_databaseV3.key, @"Keyfile should not be set");
|
||||
STAssertFalse(_databaseV3.hasPasswordOrKey, @"Database without keyfile is not secure");
|
||||
_databaseV3.key = [NSURL URLWithString:@"noKeyFile"];
|
||||
STAssertTrue(_databaseV3.hasPasswordOrKey, @"Database with keyfile is secured");
|
||||
_databaseV3.key = nil;
|
||||
STAssertFalse(_databaseV3.hasPasswordOrKey, @"Database with removed keyfile is not secure anymore");
|
||||
STAssertTrue([_database.password length] == 0, @"Password should not be set");
|
||||
STAssertNil(_database.key, @"Keyfile should not be set");
|
||||
STAssertFalse(_database.hasPasswordOrKey, @"Database without keyfile is not secure");
|
||||
_database.key = [NSURL URLWithString:@"noKeyFile"];
|
||||
STAssertTrue(_database.hasPasswordOrKey, @"Database with keyfile is secured");
|
||||
_database.key = nil;
|
||||
STAssertFalse(_database.hasPasswordOrKey, @"Database with removed keyfile is not secure anymore");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user