Removed files moved to KeePassKit project

Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
michael starke
2015-10-29 17:40:07 +01:00
parent cb3663f867
commit 7f22bcf296
33 changed files with 0 additions and 2252 deletions

6
.gitmodules vendored
View File

@@ -1,12 +1,6 @@
[submodule "KissXML"]
path = KissXML
url = https://github.com/robbiehanson/KissXML.git
[submodule "HNHUi"]
path = HNHUi
url = https://mstarke@github.com/mstarke/HNHUi.git
[submodule "KeePassKit"]
path = KeePassKit
url = https://mstarke@github.com/mstarke/KeePassKit
[submodule "DDHotKey"]
path = DDHotKey
url = https://github.com/mstarke/DDHotKey.git

Submodule KeePassKit deleted from 4f4af8c13e

Submodule KissXML deleted from 092aef800a

File diff suppressed because it is too large Load Diff

View File

@@ -1,150 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<KeePassFile>
<Meta>
<Generator>KeePassX</Generator>
<DatabaseName/>
<DatabaseNameChanged>2013-07-15T19:35:54Z</DatabaseNameChanged>
<DatabaseDescription/>
<DatabaseDescriptionChanged>2013-07-15T19:35:54Z</DatabaseDescriptionChanged>
<DefaultUserName/>
<DefaultUserNameChanged>2013-07-15T19:35:54Z</DefaultUserNameChanged>
<MaintenanceHistoryDays>365</MaintenanceHistoryDays>
<Color/>
<MasterKeyChanged>2013-07-15T19:36:02Z</MasterKeyChanged>
<MasterKeyChangeRec>-1</MasterKeyChangeRec>
<MasterKeyChangeForce>-1</MasterKeyChangeForce>
<MemoryProtection>
<ProtectTitle>False</ProtectTitle>
<ProtectUserName>False</ProtectUserName>
<ProtectPassword>True</ProtectPassword>
<ProtectURL>False</ProtectURL>
<ProtectNotes>False</ProtectNotes>
</MemoryProtection>
<CustomIcons>
<Icon>
<UUID>RaP8u/B18ngIutqc2B5c9g==</UUID>
<Data>iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAAsSAAALEgHS3X78AAACHUlEQVQokV2SzUtUYRTGn/Pe915HZyIwJ0FDEsqCXORGaBFYLWoR7foDglZt+xuCFu76G9q0iFBKMgQhhUhIhIRM7EuHq+N8ODN37uf7ntNCR249q7P4wfOccx4SEfRkwY4oEIyVNAoLJVdZTxxD0KeMQk4OKxCSKF5893KgJEkkcAyJzjOQnJiZRSp7P01rh4Ot+devjFjLeUT+cQCJyez3zRVH2sTd+/euB60O0T+IEjAACAAWIwfNg5lrZ5HWkNZxtL24NEcCgCEnVM+BACjlYG9jFU5HzCFnR+Duw1vjQdTpAUyAolyqSqU2PbGPqLrwYXf+/VdYH40vywtz1vZiCTR6s8mi0eK21Npg7NZ9sQWElLC+MymNuj9UHiFSICgc7wA0age8u0CpWLt/6VzxwlCfZK2+NHTT/eWltxADAGB9vEoUhmVnh6KqQb+WdPpKod6o0e+P1loNmSmO+od3R86PQZQGFEm2tbU+5c9K/Ed321BUGrx4Rg1mnZZrGZbKvPFpfW749iPxigowzSCbLG2nvzak6SPu2m61k4zFXHQ7KQIgDhAXJiovmkGsJaHM8I+11YmVm/CAzAOlrPHm21U/bD2ZqoIsGcWKlcHm5dnxB08pC41ee24/P3NsZPVJbYgoX8rjF7e5nDze0bFSCjoZvmGUUr2LAaAcnyrX4ywxxX6XiVkobTbR77H5r7yncjnp6tIA2z6v8BeUfknGrtTw7gAAAABJRU5ErkJggg==</Data>
</Icon>
</CustomIcons>
<RecycleBinEnabled>True</RecycleBinEnabled>
<RecycleBinUUID>AAAAAAAAAAAAAAAAAAAAAA==</RecycleBinUUID>
<RecycleBinChanged>2013-07-15T19:35:54Z</RecycleBinChanged>
<EntryTemplatesGroup>AAAAAAAAAAAAAAAAAAAAAA==</EntryTemplatesGroup>
<EntryTemplatesGroupChanged>2013-07-15T19:35:54Z</EntryTemplatesGroupChanged>
<HistoryMaxItems>10</HistoryMaxItems>
<HistoryMaxSize>6291456</HistoryMaxSize>
<LastSelectedGroup>AAAAAAAAAAAAAAAAAAAAAA==</LastSelectedGroup>
<LastTopVisibleGroup>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleGroup>
<Binaries/>
<CustomData/>
</Meta>
<Root>
<Group>
<UUID>8XPXLHyIoM9KLqrjDHjsZQ==</UUID>
<Name>Root</Name>
<Notes/>
<IconID>48</IconID>
<Times>
<LastModificationTime>2013-07-15T19:35:54Z</LastModificationTime>
<CreationTime>2013-07-15T19:35:54Z</CreationTime>
<LastAccessTime>2013-07-15T19:35:54Z</LastAccessTime>
<ExpiryTime>2013-07-15T19:35:54Z</ExpiryTime>
<Expires>False</Expires>
<UsageCount>0</UsageCount>
<LocationChanged>2013-07-15T19:35:54Z</LocationChanged>
</Times>
<IsExpanded>True</IsExpanded>
<DefaultAutoTypeSequence/>
<EnableAutoType>null</EnableAutoType>
<EnableSearching>null</EnableSearching>
<LastTopVisibleEntry>AAAAAAAAAAAAAAAAAAAAAA==</LastTopVisibleEntry>
<Entry>
<UUID>XW1C9XAjxqVKt4bJsOpgRQ==</UUID>
<IconID>0</IconID>
<CustomIconUUID>RaP8u/B18ngIutqc2B5c9g==</CustomIconUUID>
<ForegroundColor/>
<BackgroundColor/>
<OverrideURL/>
<Tags/>
<Times>
<LastModificationTime>2013-07-15T19:37:38Z</LastModificationTime>
<CreationTime>2013-07-15T19:36:04Z</CreationTime>
<LastAccessTime>2013-07-15T19:37:38Z</LastAccessTime>
<ExpiryTime>2013-07-15T19:36:04Z</ExpiryTime>
<Expires>False</Expires>
<UsageCount>0</UsageCount>
<LocationChanged>2013-07-15T19:36:08Z</LocationChanged>
</Times>
<String>
<Key>Title</Key>
<Value>CustomIcon</Value>
</String>
<String>
<Key>UserName</Key>
<Value/>
</String>
<String>
<Key>Password</Key>
<Value Protected="True"/>
</String>
<String>
<Key>URL</Key>
<Value/>
</String>
<String>
<Key>Notes</Key>
<Value/>
</String>
<AutoType>
<Enabled>True</Enabled>
<DataTransferObfuscation>0</DataTransferObfuscation>
<DefaultSequence/>
</AutoType>
<History>
<Entry>
<UUID>XW1C9XAjxqVKt4bJsOpgRQ==</UUID>
<IconID>0</IconID>
<ForegroundColor/>
<BackgroundColor/>
<OverrideURL/>
<Tags/>
<Times>
<LastModificationTime>2013-07-15T19:36:08Z</LastModificationTime>
<CreationTime>2013-07-15T19:36:04Z</CreationTime>
<LastAccessTime>2013-07-15T19:36:08Z</LastAccessTime>
<ExpiryTime>2013-07-15T19:36:04Z</ExpiryTime>
<Expires>False</Expires>
<UsageCount>0</UsageCount>
<LocationChanged>2013-07-15T19:36:08Z</LocationChanged>
</Times>
<String>
<Key>Title</Key>
<Value>CustomIcon</Value>
</String>
<String>
<Key>UserName</Key>
<Value/>
</String>
<String>
<Key>Password</Key>
<Value Protected="True"/>
</String>
<String>
<Key>URL</Key>
<Value/>
</String>
<String>
<Key>Notes</Key>
<Value/>
</String>
<AutoType>
<Enabled>True</Enabled>
<DataTransferObfuscation>0</DataTransferObfuscation>
<DefaultSequence/>
</AutoType>
</Entry>
</History>
</Entry>
</Group>
</Root>
</KeePassFile>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 803 B

View File

@@ -1,27 +0,0 @@
//
// KPKHashedDataTest.m
// MacPass
//
// Created by Michael Starke on 08.08.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKHashedDataTest : XCTestCase
@end
@implementation KPKHashedDataTest
- (void)testHashedData {
NSData *data = [NSData dataWithRandomBytes:10000];
NSData *hashedData = [data hashedDataWithBlockSize:512];
NSData *unhashedData = [hashedData unhashedData];
XCTAssertTrue([unhashedData isEqualToData:data], @"Data needs to be the same after hashing and unhashing");
}
@end

View File

@@ -1,50 +0,0 @@
//
// KPKIconLoading.m
// MacPass
//
// Created by Michael Starke on 20.07.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKIconLoading : XCTestCase {
NSImage *_image;
NSData *_imageData;
}
@end
@implementation KPKIconLoading
- (void)setUp {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
_image = [myBundle imageForResource:@"image.png"];
_imageData = [_image TIFFRepresentation];
//_imageData = [_image.representations.lastObject representationUsingType:NSPNGFileType properties:nil];
}
- (void)tearDown {
_image = nil;
_imageData = nil;
}
- (void)testLoading {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
NSURL *imageURL = [myBundle URLForImageResource:@"image.png"];
KPKIcon *icon = [[KPKIcon alloc] initWithImageAtURL:imageURL];
XCTAssertNotNil(icon, @"Icon should have been loaded");
NSString *iconString = icon.encodedString;
KPKIcon *iconFromString = [[KPKIcon alloc] initWithUUID:[NSUUID UUID] encodedString:iconString];
XCTAssertEqualObjects(iconString, iconFromString.encodedString, @"Encoding and Decoding should result in the same string");
Class repClass = [NSBitmapImageRep class];
NSImageRep *imageRep = icon.image.representations.lastObject;
XCTAssertNotNil(imageRep, @"One image rep shoudl be there");
XCTAssertTrue([imageRep isKindOfClass:repClass], @"Representation should be bitmap");
NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)imageRep;
NSData *pngData = [bitmapRep representationUsingType:NSPNGFileType properties:@{}];
XCTAssertEqualObjects(pngData, _imageData, @"Image and PNG data shoudl be identical");
}
@end

View File

@@ -1,38 +0,0 @@
//
// KPKTestAutotypeNormalization.m
// MacPass
//
// Created by Michael Starke on 18.02.14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestAutotype : XCTestCase
@end
@implementation KPKTestAutotype
- (void)testCommandValidation {
XCTAssertFalse(@"".validCommand, @"Emptry strings aren't valid commands");
}
- (void)testSimpleNormalization {
XCTAssertTrue([@"Whoo %{%}{^}{SHIFT}+ {SPACE}{ENTER}^V%V~T".normalizedAutotypeSequence isEqualToString:@"Whoo{SPACE}{ALT}{%}{^}{SHIFT}{SHIFT}{SPACE}{SPACE}{ENTER}{CONTROL}V{ALT}V{ENTER}T"]);
}
- (void)testCommandRepetition {
XCTAssertTrue([@"Whoo %{% 2}{^}{SHIFT 5}+ {SPACE}{ENTER}^V%V~T".normalizedAutotypeSequence isEqualToString:@"Whoo{SPACE}{ALT}{%}{%}{^}{SHIFT}{SHIFT}{SHIFT}{SHIFT}{SHIFT}{SHIFT}{SPACE}{SPACE}{ENTER}{CONTROL}V{ALT}V{ENTER}T"]);
XCTAssertTrue([@"{TAB 5}TAB{TAB}{SHIFT}{SHIFT 10}ENTER{ENTER}{%%}".normalizedAutotypeSequence isEqualToString:@"{TAB}{TAB}{TAB}{TAB}{TAB}TAB{TAB}{SHIFT}{SHIFT}{SHIFT}{SHIFT}{SHIFT}{SHIFT}{SHIFT}{SHIFT}{SHIFT}{SHIFT}{SHIFT}ENTER{ENTER}{%%}"]);
}
- (void)testeBracketValidation {
XCTAssertFalse(@"{BOOO}NO-COMMAND{TAB}{WHOO}{WHOO}{SPACE}!!!thisIsFun{{MISMATCH!!!}".validCommand);
XCTAssertFalse(@"{{}}}}".validCommand);
XCTAssertFalse(@"{}{}{{{}{{{{{{}}".validCommand);
XCTAssertTrue(@"{}{}{}{}{}{ }ThisIsValid{}{STOP}".validCommand);
}
@end

View File

@@ -1,44 +0,0 @@
//
// KPKTestEntryLookup.m
// MacPass
//
// Created by Michael Starke on 21/07/15.
// Copyright (c) 2015 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestEntryLookup : XCTestCase
@property (strong) KPKTree *tree;
@property (weak) KPKEntry *includedInSearch;
@property (weak) KPKEntry *excludedFromSearch;
@end
@implementation KPKTestEntryLookup
- (void)setUp {
[super setUp];
KPKTree *tree = [[KPKTree alloc] init];
KPKGroup *root = [tree createGroup:nil];
tree.root = root;
KPKGroup *searchableGroup = [tree createGroup:tree.root];
KPKGroup *unsearchableGroup = [tree createGroup:tree.root];
[tree.root addGroup:searchableGroup];
[tree.root addGroup:unsearchableGroup];
searchableGroup.isSearchEnabled = KPKInheritYES;
unsearchableGroup.isSearchEnabled = KPKInheritNO;
KPKEntry *entryA = [tree createEntry:searchableGroup];
KPKEntry *entryB = [tree createEntry:unsearchableGroup];
[searchableGroup addEntry:entryA];
[unsearchableGroup addEntry:entryB];
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
@end

View File

@@ -1,58 +0,0 @@
//
// KPKTestHexColor.m
// MacPass
//
// Created by Michael Starke on 05.08.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestHexColor : XCTestCase
@end
@implementation KPKTestHexColor
- (void)testHexToColor {
NSString *redHex = @"FF000000";
NSString *greeHex = @"00FF0000";
NSString *blueHex = @"0000FF00";
NSColor *red = [NSColor colorWithHexString:redHex];
NSColor *green = [NSColor colorWithHexString:greeHex];
NSColor *blue = [NSColor colorWithHexString:blueHex];
XCTAssertEqual([red redComponent], 1.0, @"Red color should have 100%% red");
XCTAssertEqual([red blueComponent], 0.0, @"Red color should have 0%% blue");
XCTAssertEqual([red greenComponent], 0.0, @"Red color should have 0%% green");
XCTAssertEqual([green redComponent], 0.0, @"Green color should have 0%% red");
XCTAssertEqual([green greenComponent], 1.0, @"Green color should have 100%% green");
XCTAssertEqual([green blueComponent], 0.0, @"Green color should have 0%% blue");
XCTAssertEqual([blue redComponent], 0.0, @"Blue color should have 0%% red");
XCTAssertEqual([blue greenComponent], 0.0, @"Blue color should have 0%% green");
XCTAssertEqual([blue blueComponent], 1.0, @"Blue color should have 100%% blue");
}
- (void)testColorRefReading {
uint32_t colorBytes = 0x000000FF;
NSData *colorData = [NSData dataWithBytesNoCopy:&colorBytes length:3 freeWhenDone:NO];
NSColor *color = [NSColor colorWithData:colorData];
XCTAssertEqual([color redComponent], 1.0, @"Red 100%%");
XCTAssertEqual([color greenComponent], 0.0, @"Green 0%%");
XCTAssertEqual([color blueComponent], 0.0, @"Blue 100%%");
}
- (void)testColorRefWriting {
uint32_t colorBytes = 0x000000FF;
NSData *colorData = [NSData dataWithBytesNoCopy:&colorBytes length:4 freeWhenDone:NO];
NSColor *color = [NSColor colorWithData:colorData];
NSData *newData = [color colorData];
XCTAssertEqualObjects(colorData, newData, @"Conversion should result in same data");
}
@end

View File

@@ -1,52 +0,0 @@
//
// KPKTestKeyfileParsing.m
// MacPass
//
// Created by Michael Starke on 13.08.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestKeyfileParsing : XCTestCase
@end
@implementation KPKTestKeyfileParsing
- (void)testXmlKeyfileLoadingValidFile {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [myBundle URLForResource:@"Keepass2Key" withExtension:@"xml"];
NSError *error;
NSData *data = [NSData dataWithContentsOfKeyFile:url version:KPKLegacyVersion error:&error];
XCTAssertNotNil(data, @"Data should be loaded");
XCTAssertNil(error, @"No error should occur on keyfile loading");
}
- (void)testXmlKeyfileLoadingCorruptData {
XCTAssertFalse(NO, @"Not Implemented");
}
- (void)testXmlKeyfileLoadingMissingVersion {
XCTAssertFalse(NO, @"Not Implemented");
}
- (void)testXmlKeyfileLoadingLowerVersion {
XCTAssertFalse(NO, @"Not Implemented");
}
- (void)testXmlKeyfilGeneration {
NSData *data = [NSData generateKeyfiledataForVersion:KPKXmlVersion];
// Test if structure is sound;
XCTAssertNotNil(data, @"Keydata should have been generated");
}
- (void)testLegacyKeyfileGeneration {
NSData *data = [NSData generateKeyfiledataForVersion:KPKLegacyVersion];
// test if structure is sound;
XCTAssertNotNil(data, @"Keydata should have been generated");
}
@end

View File

@@ -1,64 +0,0 @@
//
// KPKTreeLoadingTest.m
// MacPass
//
// Created by Michael Starke on 20.07.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestLegacyLoading : XCTestCase
@end
@implementation KPKTestLegacyLoading
- (void)testValidFile {
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"1234" key:nil];
NSData *data = [self _loadTestDataBase:@"Test_Password_1234" extension:@"kdb"];
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:NULL];
XCTAssertNotNil(tree, @"Loading should result in a tree object");
}
- (void)testWrongPassword {
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"wrongPassword" key:nil];
NSData *data = [self _loadTestDataBase:@"KeePass1_native_test" extension:@"kdb"];
NSError *error;
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:&error];
XCTAssertNil(tree, @"Wrong password should yield nil tree");
XCTAssertNotNil(error, @"Wrong password should yield error");
//STAssertTrue([error code] == KPKErrorPasswordAndOrKeyfileWrong, @"Error code should be wrong password and/or keyfile");
}
- (void)testInvalidFile {
NSError *error;
uint8_t bytes[] = {0x00,0x11,0x22,0x33,0x44};
NSData *data = [NSData dataWithBytes:bytes length:5];
KPKTree *tree = [[KPKTree alloc] initWithData:data password:nil error:&error];
XCTAssertNil(tree, @"Tree should be nil with invalid data");
XCTAssertNotNil(error, @"Error object should have been created");
XCTAssertTrue(KPKErrorUnknownFileFormat == [error code], @"Error should be Unknown file format");
}
- (void)testMetaParsing {
NSData *data = [self _loadTestDataBase:@"KDB1_KeePassX_test" extension:@"kdb"];
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"test" key:nil];
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:NULL];
XCTAssertNotNil(tree, @"Tree shoudl be loaded" );
KPKIcon *icon = [tree.metaData.customIcons lastObject];
XCTAssertNotNil(icon, @"Should load one Icon");
}
- (NSData *)_loadTestDataBase:(NSString *)name extension:(NSString *)extension {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [myBundle URLForResource:name withExtension:extension];
return [NSData dataWithContentsOfURL:url];
}
@end

View File

@@ -1,45 +0,0 @@
//
// KPKLegacyWritingTest.m
// MacPass
//
// Created by Michael Starke on 02.08.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestLegacyWriting : XCTestCase
@end
@implementation KPKTestLegacyWriting
- (void)testWriting {
NSError __autoreleasing *error = nil;
NSURL *dbUrl = [self _urlForFile:@"CustomIcon_Password_1234" extension:@"kdbx"];
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"1234" key:nil];
KPKTree *tree = [[KPKTree alloc] initWithContentsOfUrl:dbUrl password:password error:&error];
XCTAssertNotNil(tree, @"Tree should be created");
error = nil;
NSData *data = [tree encryptWithPassword:password forVersion:KPKLegacyVersion error:&error];
XCTAssertNotNil(data, @"Serialized Data should be created");
NSString *tempFile = [NSTemporaryDirectory() stringByAppendingString:@"CustomIcon_Password_1234.kdb"];
NSLog(@"Saved to %@", tempFile);
[data writeToFile:tempFile atomically:YES];
KPKTree *loadTree = [[KPKTree alloc] initWithData:data password:password error:&error];
XCTAssertNotNil(loadTree, @"Tree should be loadable from kdb file data");
}
- (NSData *)_dataForFile:(NSString *)name extension:(NSString *)extension {
NSURL *url = [self _urlForFile:name extension:extension];
return [NSData dataWithContentsOfURL:url];
}
- (NSURL *)_urlForFile:(NSString *)file extension:(NSString *)extension {
return [[NSBundle bundleForClass:[self class]] URLForResource:file withExtension:extension];
}
@end

View File

@@ -1,65 +0,0 @@
//
// KPKTestModificationDates.m
// MacPass
//
// Created by Michael Starke on 26/10/15.
// Copyright © 2015 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
#import "KeePassKit+Private.h"
@interface KPKTestModificationDates : XCTestCase
@property (strong) KPKTree *tree;
@property (weak) KPKGroup *group;
@property (weak) KPKEntry *entry;
@end
@implementation KPKTestModificationDates
- (void)setUp {
[super setUp];
self.tree = [[KPKTree alloc] init];
self.tree.root = [[KPKGroup alloc] init];
self.group = self.tree.root;
[self.group addEntry:[[KPKEntry alloc] init]];
self.entry = self.group.entries.firstObject;
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testEnableDisableModificationRecording {
XCTAssertTrue(self.group.updateTiming, @"updateTiming is enabled for newly created groups!");
XCTAssertTrue(self.entry.updateTiming, @"updateTiming is enabled for newly created entries!");
self.group.updateTiming = NO;
self.entry.updateTiming = NO;
XCTAssertFalse(self.group.updateTiming, @"updateTiming is disabled!");
XCTAssertFalse(self.entry.updateTiming, @"updateTiming is disabled!");
self.group.updateTiming = YES;
self.entry.updateTiming = YES;
XCTAssertTrue(self.group.updateTiming, @"updateTiming is enabled!");
XCTAssertTrue(self.entry.updateTiming, @"updateTiming is enabled!");
}
- (void)testGroupModificationDate {
XCTFail(@"Missing Test");
}
- (void)testEntryModifiationDate {
static NSString *const _kUpdatedString = @"Updated";
for(NSString *key in [KPKFormat sharedFormat].entryDefaultKeys) {
NSDate *before = [self.entry.timeInfo.modificationDate copy];
[self.entry _setValue:_kUpdatedString forAttributeWithKey:key];
NSComparisonResult compare = [before compare:self.entry.timeInfo.modificationDate];
XCTAssertTrue(compare == NSOrderedAscending,@"Modification date has to be updated after modification");
}
}
@end

View File

@@ -1,165 +0,0 @@
//
// KPKTestNSCopying.m
// MacPass
//
// Created by Michael Starke on 31.07.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestNSCoding : XCTestCase
@end
@implementation KPKTestNSCoding
- (void)testAttributeCoding {
KPKAttribute *attribute = [[KPKAttribute alloc] initWithKey:kKPKXmlKey value:kKPKXmlValue isProtected:YES];
NSData *data = [self encode:attribute];
KPKAttribute *copy = [self decode:data ofClass:[KPKAttribute class]];
XCTAssertTrue([copy.value isEqualToString:attribute.value], @"Values should be preseved");
XCTAssertTrue([copy.key isEqualToString:attribute.key], @"Keys should be preserved");
XCTAssertTrue(copy.isProtected == attribute.isProtected, @"Protected status should be the same");
}
- (void)testBinaryCoding {
KPKBinary *binary = [[KPKBinary alloc] init];
binary.name = @"Binary";
binary.data = [NSData dataWithRandomBytes:1*1024*1024];
NSData *data = [self encode:binary];
KPKBinary *decodedBinary = [self decode:data ofClass:[KPKBinary class]];
XCTAssertTrue([decodedBinary.data isEqualToData:binary.data]);
XCTAssertTrue([decodedBinary.name isEqualToString:binary.name]);
}
- (void)testEntryCoding {
KPKEntry *entry = [[KPKEntry alloc] init];
entry.title = @"Title";
entry.url = @"URL";
entry.username = @"Username";
entry.password = @"Password";
uint8_t bytes[] = { 0xFF, 0x00, 0xFF, 0x00, 0xFF };
NSData *data = [[NSData alloc] initWithBytes:bytes length:5];
KPKBinary *binary = [[KPKBinary alloc] init];
binary.data = data;
binary.name = @"Binary";
[entry addBinary:binary];
[entry addCustomAttribute:[[KPKAttribute alloc] initWithKey:@"Custom" value:kKPKXmlValue isProtected:NO]];
NSData *encodedData = [self encode:entry];
KPKEntry *copyEntry = [self decode:encodedData ofClass:[KPKEntry class]];
XCTAssertNotNil(copyEntry, @"Copied Entry cannot be nil");
XCTAssertTrue([copyEntry.title isEqualToString:entry.title], @"Titles should match");
XCTAssertTrue([copyEntry.url isEqualToString:entry.url], @"URLS should match");
XCTAssertTrue([copyEntry.binaries count] == 1, @"Binaries should be copied");
KPKBinary *copiedBinary = [copyEntry.binaries lastObject];
XCTAssertTrue([copiedBinary.data isEqualToData:binary.data], @"Binary data should match");
XCTAssertTrue([copiedBinary.name isEqualToString:binary.name], @"Binary names should match");
}
- (void)testIconCoding {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
NSURL *imageURL = [myBundle URLForImageResource:@"image.png"];
KPKIcon *icon = [[KPKIcon alloc] initWithImageAtURL:imageURL];
NSData *data = [self encode:icon];
KPKIcon *decodedIcon = [self decode:data ofClass:[KPKIcon class]];
NSImageRep *originalRep = icon.image.representations.lastObject;
NSImageRep *decodedRep = decodedIcon.image.representations.lastObject;
XCTAssertTrue([originalRep isKindOfClass:[NSBitmapImageRep class]]);
XCTAssertTrue([decodedRep isKindOfClass:[NSBitmapImageRep class]]);
/*
We cannot assert bit depth since TIFF conversion might just strip a full white alpha channel
XCTAssertEqual([originalRep bitsPerPixel], [decodedRep bitsPerPixel]);
*/
XCTAssertEqual(originalRep.pixelsHigh, decodedRep.pixelsHigh);
XCTAssertEqual(originalRep.pixelsWide, decodedRep.pixelsWide);
NSData *originalData = [icon.image TIFFRepresentation];
NSData *decodedData = [decodedIcon.image TIFFRepresentation];
XCTAssertTrue([originalData isEqualToData:decodedData]);
}
- (void)testGroupCoding {
KPKGroup *group = [[KPKGroup alloc] init];
group.title = @"A Group";
group.iconId = 50;
group.notes = @"Some notes";
group.isAutoTypeEnabled = KPKInheritYES;
KPKEntry *entry = [[KPKEntry alloc] init];
entry.title = @"Entry";
entry.url = @"www.url.com";
[group addEntry:entry];
KPKGroup *childGroup = [[KPKGroup alloc] init];
childGroup.title = @"Subgroup";
childGroup.iconId = 1;
childGroup.isAutoTypeEnabled = KPKInheritNO;
[group addGroup:childGroup];
KPKEntry *subEntry = [[KPKEntry alloc] init];
subEntry.title = @"Subentry";
subEntry.url = @"www.url.com";
[childGroup addEntry:subEntry];
NSData *data = [self encode:group];
KPKGroup *decodedGroup = [self decode:data ofClass:[KPKGroup class]];
XCTAssertTrue([group.uuid isEqual:decodedGroup.uuid]);
XCTAssertTrue([group.title isEqualToString:decodedGroup.title]);
XCTAssertEqual(group.entries.count, decodedGroup.entries.count);
XCTAssertEqual(group.iconId, decodedGroup.iconId);
XCTAssertTrue([group.notes isEqualToString:decodedGroup.notes]);
XCTAssertEqualObjects(childGroup.parent, group);
XCTAssertEqualObjects(subEntry.parent, childGroup);
KPKEntry *decodedEntry = [decodedGroup entryForUUID:entry.uuid];
XCTAssertNotNil(decodedEntry);
XCTAssertEqualObjects(decodedEntry.parent, decodedGroup);
XCTAssertTrue([decodedEntry isEqualToEntry:entry]);
}
- (NSData *)encode:(id)object {
NSMutableData *data = [[NSMutableData alloc] initWithCapacity:500];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
if(![object respondsToSelector:@selector(encodeWithCoder:)]) {
return nil;
}
[object encodeWithCoder:archiver];
[archiver finishEncoding];
return data;
}
- (id)decode:(NSData *)data ofClass:(Class)class usingSecureCoding:(BOOL)secureCoding {
if(secureCoding && ![class instancesRespondToSelector:@selector(supportsSecureCoding)]) {
return nil;
}
if(![class instancesRespondToSelector:@selector(initWithCoder:)]) {
return nil;
}
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
id object = [[class alloc] initWithCoder:unarchiver];
[unarchiver finishDecoding];
return object;
}
- (id)decode:(NSData *)data ofClass:(Class)class {
return [self decode:data ofClass:class usingSecureCoding:NO];
}
@end

View File

@@ -1,114 +0,0 @@
//
// KPKTestNSCopying.m
// MacPass
//
// Created by Michael Starke on 31.07.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestNSCopying : XCTestCase
@end
@implementation KPKTestNSCopying
- (void)testAttributeCopying {
KPKAttribute *attribute = [[KPKAttribute alloc] initWithKey:@"Key" value:kKPKXmlValue isProtected:NO];
KPKAttribute *copy = [attribute copy];
attribute.key = @"NewKey";
attribute.value = @"NewValue";
attribute.isProtected = YES;
XCTAssertNotNil(copy, @"Copy shoule exist");
XCTAssertTrue([copy.key isEqualToString:@"Key"], @"Copy key should be key");
XCTAssertTrue([copy.value isEqualToString:kKPKXmlValue], @"Copy value should be value");
XCTAssertFalse(copy.isProtected, @"Copy should not be protected");
}
- (void)testEntryCopying {
KPKEntry *entry = [[KPKEntry alloc] init];
entry.title = @"Title";
entry.url = @"URL";
entry.username = @"Username";
entry.password = @"Password";
uint8_t bytes[] = { 0xFF, 0x00, 0xFF, 0x00, 0xFF };
NSData *data = [[NSData alloc] initWithBytes:bytes length:5];
KPKBinary *binary = [[KPKBinary alloc] init];
binary.data = data;
binary.name = @"Binary";
[entry addBinary:binary];
[entry addCustomAttribute:[[KPKAttribute alloc] initWithKey:@"Custom" value:kKPKXmlValue isProtected:NO]];
KPKEntry *copyEntry = [entry copy];
entry.title = @"NewTitle";
[entry removeBinary:binary];
((KPKAttribute *)entry.customAttributes.lastObject).key = @"NewCustomKey";
XCTAssertNotNil(copyEntry, @"Copied Entry cannot be nil");
XCTAssertEqualObjects(copyEntry.title, @"Title", @"Titles should match");
XCTAssertEqualObjects(copyEntry.url, @"URL", @"URLS should match");
XCTAssertEqual(copyEntry.binaries.count, 1, @"Binareis should be copied");
KPKBinary *copiedBinary = copyEntry.binaries.lastObject;
XCTAssertTrue([copiedBinary.data isEqualToData:binary.data], @"Binary data should match");
XCTAssertTrue([copiedBinary.name isEqualToString:binary.name], @"Binary names should macht");
}
- (void)testGroupCopying {
/*
root
+ Group A
+ Entry A
+ Group A1
+ Group A2
+ Entry B
*/
KPKGroup *root = [[KPKGroup alloc] init];
root.title = @"root";
KPKGroup *groupA = [[KPKGroup alloc] init];
groupA.title = @"Group A";
groupA.isAutoTypeEnabled = KPKInheritNO;
KPKGroup *groupA1 = [[KPKGroup alloc] init];
groupA1.title = @"Group A1";
groupA1.notes = @"Some notes";
groupA1.iconId = KPKIconASCII;
KPKGroup *groupA2 = [[KPKGroup alloc] init];
groupA2.title = @"Group A2";
groupA2.notes = @"More notes";
groupA2.isSearchEnabled = KPKInheritYES;
KPKEntry *entryA = [[KPKEntry alloc] init];
entryA.title = @"Entry A";
entryA.url = @"www.url.com";
KPKEntry *entryB = [[KPKEntry alloc] init];
entryB.title = @"Entry B";
entryB.url = @"www.nope.com";
[groupA addEntry:entryA];
[groupA addGroup:groupA1];
[groupA addGroup:groupA2];
[groupA2 addEntry:entryB];
[root addGroup:groupA];
KPKGroup *copy = [root copy];
XCTAssertEqualObjects(root, copy);
}
@end

View File

@@ -1,56 +0,0 @@
//
// KPKTestPerformance.m
// MacPass
//
// Created by Michael Starke on 21/10/15.
// Copyright © 2015 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
NSUInteger const _kKPKEntryCount = 1000;
@interface KPKTestPerformance : XCTestCase {
KPKEntry *testEntry;
}
@end
@implementation KPKTestPerformance
- (void)setUp {
[super setUp];
testEntry = [[KPKEntry alloc] init];
NSUInteger count = _kKPKEntryCount;
while(count-- > 0) {
[testEntry addCustomAttribute:[[KPKAttribute alloc] initWithKey:@(count).stringValue
value:@(count).stringValue]];
}
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testAttributeLookupPerformanceA {
[self measureBlock:^{
[testEntry customAttributeForKey:@(0).stringValue];
}];
}
- (void)testAttributeLookupPerformanceB {
[self measureBlock:^{
[testEntry customAttributeForKey:@(_kKPKEntryCount - 1).stringValue];
}];
}
- (void)testAttributeLookupPerformanceC {
[self measureBlock:^{
[testEntry customAttributeForKey:kKPKTitleKey];
}];
}
@end

View File

@@ -1,36 +0,0 @@
//
// KPKTextPlaceholder.m
// MacPass
//
// Created by Michael Starke on 15.08.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTextPlaceholder : XCTestCase
@end
@implementation KPKTextPlaceholder
- (void)testPlaceholder {
KPKEntry *entry = [[KPKEntry alloc] init];
entry.title = @"TestTitle";
entry.username = @"TestUsername";
entry.notes = @"TestNotes";
entry.url = @"TestURL";
entry.password = @"TestPassword";
KPKAttribute *attribute = [[KPKAttribute alloc] initWithKey:@"extended" value:@"valueForExtended"];
[entry addCustomAttribute:attribute];
NSString *placeholder = @"{USERNAME}{PASSWORD}{NOTHING}{URL}{S:extended}";
NSString *evaluated = [placeholder evaluatePlaceholderWithEntry:entry];
NSString *evaluatedGoal = [NSString stringWithFormat:@"%@%@{NOTHING}%@%@", entry.username, entry.password, entry.url, attribute.value];
XCTAssertTrue([evaluated isEqualToString:evaluatedGoal], @"Evaluated string must match");
}
@end

View File

@@ -1,93 +0,0 @@
//
// KPKTestReference.m
// MacPass
//
// Created by Michael Starke on 15.02.14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestReference : XCTestCase
@property (strong) KPKTree *tree;
@property (weak) KPKEntry *entry1;
@property (weak) KPKEntry *entry2;
@end
@implementation KPKTestReference
- (void)setUp {
self.tree = [[KPKTree alloc] init];
self.tree.root = [[KPKGroup alloc] init];
self.tree.root.title = @"Root";
KPKEntry *entry1 = [self.tree createEntry:self.tree.root];
KPKEntry *entry2 = [self.tree createEntry:self.tree.root];
[self.tree.root addEntry:entry1];
[self.tree.root addEntry:entry2];
self.entry1 = entry1;
self.entry2 = entry2;
self.entry2.url = @"-Entry2URL-";
[super setUp];
}
- (void)tearDown {
self.tree = nil;
[super tearDown];
}
- (void)testCorrectUUIDReference {
self.entry1.title = @"-Entry1Title-";
self.entry2.title = [[NSString alloc] initWithFormat:@"Nothing{ref:t@i:%@}Changed", self.entry1.uuid.UUIDString];;
self.entry2.url = @"-Entry2URL-";
NSString *result = [self.entry2.title resolveReferencesWithTree:self.tree];
XCTAssertTrue([result isEqualToString:@"Nothing-Entry1Title-Changed"], @"Replaced Strings should match");
}
- (void)testRecursiveUUIDReference{
self.entry1.title = [[NSString alloc] initWithFormat:@"Title1{REF:A@i:%@}", self.entry2.uuid.UUIDString];
self.entry2.title = [[NSString alloc] initWithFormat:@"Nothing{REF:t@I:%@}Changed", self.entry1.uuid.UUIDString];
NSString *result = [self.entry2.title resolveReferencesWithTree:self.tree];
XCTAssertTrue([result isEqualToString:@"NothingTitle1-Entry2URL-Changed"], @"Replaced Strings should match");
}
- (void)testReferncePasswordByTitle {
self.entry1.title = [[NSString alloc] initWithFormat:@"Title1{REF:A@i:%@}", self.entry2.uuid.UUIDString];
self.entry2.title = [[NSString alloc] initWithFormat:@"Nothing{REF:t@I:%@}Changed", self.entry1.uuid.UUIDString];
NSString *result = [self.entry2.title resolveReferencesWithTree:self.tree];
XCTAssertTrue([result isEqualToString:@"NothingTitle1-Entry2URL-Changed"], @"Replaced Strings should match");
}
- (void)testReferncePasswordByCustomAttribute {
self.entry1.title = [[NSString alloc] initWithFormat:@"Title1{REF:T@i:%@}", self.entry2.uuid.UUIDString];
self.entry2.title = @"Entry2Title";
KPKAttribute *attribute1 = [[KPKAttribute alloc] initWithKey:@"Custom1" value:@"Value1"];
[self.entry2 addCustomAttribute:attribute1];
KPKAttribute *attribute2 = [[KPKAttribute alloc] initWithKey:@"Custom2" value:@"Value2"];
[self.entry2 addCustomAttribute:attribute2];
}
- (void)testWrongRefernce {
XCTFail(@"Missing Test");
}
- (void)testUnknownReference {
XCTFail(@"Missing Test");
}
- (void)testMultipleMatchinReference {
XCTFail(@"Missing Test");
}
@end

View File

@@ -1,25 +0,0 @@
//
// KPKTestUUIDAdditions.m
// MacPass
//
// Created by Michael Starke on 16.02.14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestUUIDAdditions : XCTestCase
@end
@implementation KPKTestUUIDAdditions
- (void)testUndelemitedUUID {
NSUUID *uuid1 = [[NSUUID alloc] initWithUUIDString:@"31C1F2E6-BF71-4350-BE58-05216AFC5AFF"];
NSUUID *uuid2 = [[NSUUID alloc] initWithUndelemittedUUIDString:@"31C1F2E6BF714350BE5805216AFC5AFF"];
XCTAssertTrue([uuid1 isEqual:uuid2], @"UUIDs should match");
}
@end

View File

@@ -1,364 +0,0 @@
//
// KPKUndo.m
// MacPass
//
// Created by Michael Starke on 04/08/15.
// Copyright (c) 2015 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
#import "KeePassKit+Private.h"
@interface KPKTestUndo : XCTestCase <KPKTreeDelegate> {
NSUndoManager *_undoManager;
KPKTree *_tree;
KPKGroup *_root, *_groupA, *_groupB;
KPKEntry *_entryA, *_entryB;
}
@end
@implementation KPKTestUndo
- (NSUndoManager *)undoManagerForTree:(KPKTree *)tree {
return _undoManager;
}
- (void)setUp {
[super setUp];
_undoManager = [[NSUndoManager alloc] init];
_tree = [[KPKTree alloc] init];
_tree.delegate = self;
/* Disable undo registration in the setup to have a clean test environment */
[_undoManager disableUndoRegistration];
_root = [[KPKGroup alloc] init];
_tree.root = _root;
_groupA = [[KPKGroup alloc] init];
_groupA.title = @"Group A";
_groupB = [[KPKGroup alloc] init];
_groupB.title = @"Group B";
[_root addGroup:_groupA];
[_root addGroup:_groupB];
_entryA = [[KPKEntry alloc] init];
_entryA.title = @"Entry A";
_entryA.username = @"Username A";
_entryA.url = @"http://www.a.com";
[_groupA addEntry:_entryA];
_entryB = [[KPKEntry alloc] init];
_entryB.title = @"Entry B";
_entryB.username = @"Username B";
_entryB.url = @"http://www.b.com";
[_groupB addEntry:_entryB];
/* Enable undo registration for the tests */
[_undoManager enableUndoRegistration];
}
- (void)tearDown {
_entryA = nil;
_entryB = nil;
_groupB = nil;
_groupA = nil;
_tree = nil;
_undoManager = nil;
[super tearDown];
}
- (void)testUndoRedoCreateEntry {
XCTAssertFalse(_undoManager.canUndo, @"Undo stack is empty");
XCTAssertFalse(_undoManager.canRedo, @"Redo stack is empty");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
KPKEntry *entry = [_tree createEntry:_groupA];
[_groupA addEntry:entry];
XCTAssertTrue(_undoManager.canUndo, @"Undomanager can undo");
XCTAssertEqual(_groupA.entries.count, 2, @"Group A has two entries");
XCTAssertTrue([_groupA.entries containsObject:entry], @"Created entry is in group A");
XCTAssertEqual(_groupB.entries.count, 1, @"Group B has one entry");
XCTAssertFalse([_groupB.entries containsObject:entry], @"Created entry is not in group B");
XCTAssertEqual(_root.entries.count, 0, @"Root has no entries");
XCTAssertFalse([_root.entries containsObject:entry], @"Created entry is not in root group");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
[_undoManager undo];
XCTAssertFalse(_undoManager.canUndo, @"Undomanager cannot undo anymore");
XCTAssertTrue(_undoManager.canRedo, @"Undomanger can redo executed undo");
XCTAssertEqual(_groupA.entries.count, 1, @"Group A has one entry after undo");
XCTAssertFalse([_groupA.entries containsObject:entry], @"Created enty is not in group A");
XCTAssertEqual(_groupB.entries.count, 1, @"Group B has one entry");
XCTAssertFalse([_groupB.entries containsObject:entry], @"Created enty is not in group A");
XCTAssertEqual(_root.entries.count, 0, @"Root has no entries");
XCTAssertFalse([_root.entries containsObject:entry], @"Created enty is not in group A");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
[_undoManager redo];
XCTAssertTrue(_undoManager.canUndo, @"Undomanager can undo again after redo");
XCTAssertFalse(_undoManager.canRedo, @"Undomanger cannot redo after redo");
XCTAssertEqual(_groupA.entries.count, 2, @"Group A has two entries");
XCTAssertTrue([_groupA.entries containsObject:entry], @"Created entry is in group A");
XCTAssertEqual(_groupB.entries.count, 1, @"Group B has one entry");
XCTAssertFalse([_groupB.entries containsObject:entry], @"Created entry is not in group B");
XCTAssertEqual(_root.entries.count, 0, @"Root has no entries");
XCTAssertFalse([_root.entries containsObject:entry], @"Created entry is not in root group");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
}
- (void)testUndoRedoCreateGroup {
XCTAssertFalse(_undoManager.canUndo, @"Undo stack is empty");
XCTAssertFalse(_undoManager.canRedo, @"Redo stack is empty");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
KPKGroup *group = [_tree createGroup:_tree.root];
/* insert group between group A and B */
[_tree.root addGroup:group atIndex:1];
XCTAssertTrue(_undoManager.canUndo, @"Undomanager can undo");
XCTAssertFalse(_undoManager.canRedo, @"Undomanager cannot redo");
XCTAssertEqual(_groupA.groups.count, 0, @"Group A has no child groups");
XCTAssertEqual(_groupB.groups.count, 0, @"Group B has no child groups");
XCTAssertEqual(_tree.root.groups.count, 3, @"Root has 3 child groups");
XCTAssertTrue([_tree.root.groups containsObject:group], @"Created group is in root group");
XCTAssertEqual([_tree.root.groups indexOfObject:group], 1, @"Created group is at index 1");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
[_undoManager undo];
XCTAssertFalse(_undoManager.canUndo, @"No undo after undo");
XCTAssertTrue(_undoManager.canRedo, @"Redo is available after undo");
XCTAssertEqual(_groupA.groups.count, 0, @"Group A has no child groups");
XCTAssertEqual(_groupB.groups.count, 0, @"Group B has no child groups");
XCTAssertEqual(_tree.root.groups.count, 2, @"Root has 2 child groups");
XCTAssertFalse([_tree.root.groups containsObject:group], @"Created group is not in root after undo");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
[_undoManager redo];
XCTAssertTrue(_undoManager.canUndo, @"Undomanager can undo after redo");
XCTAssertFalse(_undoManager.canRedo, @"Undomanager cannot redo after redo");
XCTAssertEqual(_groupA.groups.count, 0, @"Group A has no child groups after redo");
XCTAssertEqual(_groupB.groups.count, 0, @"Group B has no child groups after redo");
XCTAssertEqual(_tree.root.groups.count, 3, @"Root has 3 child groups after redo");
XCTAssertTrue([_tree.root.groups containsObject:group], @"Created group is in root group after redo");
XCTAssertEqual([_tree.root.groups indexOfObject:group], 1, @"Created group is at index 1 after redo");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
}
- (void)testUndoRedoMoveEntry {
XCTAssertFalse(_undoManager.canUndo, @"Undo stack is empty");
XCTAssertFalse(_undoManager.canRedo, @"Redo stack is empty");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
XCTAssertEqual(_groupA.entries.count, 1, @"Group A has one entry");
XCTAssertTrue([_groupA.entries containsObject:_entryA], @"Entry A is in group A");
XCTAssertEqual(_groupB.entries.count, 1, @"Group B has one entry");
XCTAssertTrue([_groupB.entries containsObject:_entryB], @"Entry B is in group B");
XCTAssertEqual(_root.entries.count, 0, @"Root has no entries");
XCTAssertFalse([_root.entries containsObject:_entryB], @"Entry A is not in root group");
XCTAssertFalse([_root.entries containsObject:_entryA], @"Entry A is not in root group");
[_entryA moveToGroup:_groupB];
XCTAssertEqual(_groupA.entries.count, 0, @"Group A has no entries");
XCTAssertEqual(_groupB.entries.count, 2, @"Group B has two entries");
XCTAssertTrue([_groupB.entries containsObject:_entryA], @"Entry A is moved to group B");
XCTAssertTrue([_groupB.entries containsObject:_entryB], @"Entry B is in group B");
XCTAssertEqual(_root.entries.count, 0, @"Root has no entries");
XCTAssertFalse([_root.entries containsObject:_entryB], @"Entry A is not in root group");
XCTAssertFalse([_root.entries containsObject:_entryA], @"Entry A is not in root group");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
XCTAssertTrue(_undoManager.canUndo, @"Undomanager can undo");
XCTAssertFalse(_undoManager.canRedo, @"Undomanager still cannot redo");
[_undoManager undo];
XCTAssertEqual(_groupA.entries.count, 1, @"Group A has one entry after undo");
XCTAssertTrue([_groupA.entries containsObject:_entryA], @"Entry A is in group A after undo");
XCTAssertEqual(_groupB.entries.count, 1, @"Group B has one entry after undo");
XCTAssertTrue([_groupB.entries containsObject:_entryB], @"Entry B is in group B after undo");
XCTAssertEqual(_root.entries.count, 0, @"Root has no entries");
XCTAssertFalse([_root.entries containsObject:_entryA], @"Entry A is not in root group after undo");
XCTAssertFalse([_root.entries containsObject:_entryB], @"Entry B is not in root group after undo");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
XCTAssertFalse(_undoManager.canUndo, @"Undomanager cannot undo anymore");
XCTAssertTrue(_undoManager.canRedo, @"Undomanger can redo executed undo");
[_undoManager redo];
XCTAssertEqual(_groupA.entries.count, 0, @"Group A has no entries after redo");
XCTAssertEqual(_groupB.entries.count, 2, @"Group B has two entries");
XCTAssertTrue([_groupB.entries containsObject:_entryA], @"Entry A is moved to group B after redo");
XCTAssertTrue([_groupB.entries containsObject:_entryB], @"Entry B is in group B");
XCTAssertEqual(_root.entries.count, 0, @"Root has no entries");
XCTAssertFalse([_root.entries containsObject:_entryA], @"Entry A is not in root group after redo");
XCTAssertFalse([_root.entries containsObject:_entryB], @"Entry B is not in root group after redo");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
XCTAssertTrue(_undoManager.canUndo, @"Undomanager can undo again after redo");
XCTAssertFalse(_undoManager.canRedo, @"Undomanager cannot redo anymore after redo");
}
- (void)testUndoRedoMoveGroup {
XCTAssertFalse(_undoManager.canUndo, @"Undo stack is empty");
XCTAssertFalse(_undoManager.canRedo, @"Redo stack is empty");
XCTAssertEqual(_groupA.groups.count, 0, @"Group A has no child groups");
XCTAssertEqual(_groupB.groups.count, 0, @"Group B has no child groups");
XCTAssertEqual(_root.groups.count, 2, @"Root has two child groups");
XCTAssertTrue([_root.groups containsObject:_groupA], @"Group A is in root group");
XCTAssertTrue([_root.groups containsObject:_groupB], @"Group B is in root group");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
[_groupA moveToGroup:_groupB];
XCTAssertTrue(_undoManager.canUndo, @"Undomanager can undo after move");
XCTAssertFalse(_undoManager.canRedo, @"Redo stack is still empty");
XCTAssertEqual(_groupA.groups.count, 0, @"Group A has no child groups");
XCTAssertEqual(_groupB.groups.count, 1, @"Group B has one child group");
XCTAssertTrue([_groupB.groups containsObject:_groupA], @"Group A is child group of Group B");
XCTAssertEqual(_groupB, _groupA.parent, @"Group B is parent of Group A");
XCTAssertEqual(_root.groups.count, 1, @"Root has one child group");
XCTAssertFalse([_root.groups containsObject:_groupA], @"Group A is not root group");
XCTAssertTrue([_root.groups containsObject:_groupB], @"Group B is in root group");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
[_undoManager undo];
XCTAssertFalse(_undoManager.canUndo, @"Undo stack is empty after undo");
XCTAssertTrue(_undoManager.canRedo, @"Undomanager can redo after undo");
XCTAssertEqual(_groupA.groups.count, 0, @"Group A has no child groups after undo");
XCTAssertEqual(_groupB.groups.count, 0, @"Group B has no child groups after undo");
XCTAssertEqual(_root, _groupA.parent, @"Root is parent of Group A after undo");
XCTAssertEqual(_root, _groupB.parent, @"Root is parent of Group B after undo");
XCTAssertEqual(_root.groups.count, 2, @"Root has two child groups after undo");
XCTAssertTrue([_root.groups containsObject:_groupA], @"Group A is in root group after undo");
XCTAssertTrue([_root.groups containsObject:_groupB], @"Group B is in root group after undo");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
[_undoManager redo];
XCTAssertTrue(_undoManager.canUndo, @"Undomanager can undo again after redo");
XCTAssertFalse(_undoManager.canRedo, @"Redo stack is empty after redo");
XCTAssertEqual(_groupA.groups.count, 0, @"Group A has no child groups after redo");
XCTAssertEqual(_groupB.groups.count, 1, @"Group B has one child group after redo");
XCTAssertTrue([_groupB.groups containsObject:_groupA], @"Group A is child group of Group B after redo");
XCTAssertEqual(_groupB, _groupA.parent, @"Group B is parent of Group A after redo");
XCTAssertEqual(_root.groups.count, 1, @"Root has one child group after redo");
XCTAssertFalse([_root.groups containsObject:_groupA], @"Group A is not root group after redo");
XCTAssertTrue([_root.groups containsObject:_groupB], @"Group B is in root group after redo");
XCTAssertEqual(_tree.deletedObjects.count, 0, @"There are no deleted objects in the database");
}
- (void)testUndoRedoReorderGroups {
XCTFail(@"Missing test");
}
- (void)testUndoRedoDeleteGroupWithoutTrash {
/* TODO: Deleting groups needs to be moved from MPDocument to KeePassKit */
XCTFail(@"Missing test");
}
- (void)testUndoRedoDeleteEntryWithoutTrash {
/* TODO: Deleting entries needs to be moved from MPDocument to KeePassKit */
XCTFail(@"Missing test");
}
- (void)testUndoRedoDeleteGroupWithTrash {
XCTFail(@"Missing test");
}
- (void)testUndoRedoDeleteEntryWithTrash {
XCTFail(@"Missing test");
}
- (void)testUpdateToInvalidNode {
XCTAssertFalse(_undoManager.canUndo, @"Undo stack is empty");
XCTAssertFalse(_undoManager.canRedo, @"Redo stack is empty");
XCTAssertThrows([_entryA _updateToNode:_groupA], @"Updating Entry to Group is not possible");
XCTAssertThrows([_groupA _updateToNode:_entryA], @"Updating Group to Entry is not possible");
XCTAssertFalse(_undoManager.canUndo, @"Undo stack is empty after failed update");
XCTAssertFalse(_undoManager.canRedo, @"Redo stack is empty after failed update");
}
- (void)testUndoRedoEditEntry {
XCTAssertFalse(_undoManager.canUndo, @"Undo stack is empty");
XCTAssertFalse(_undoManager.canRedo, @"Redo stack is empty");
KPKEntry *copy = [_entryA copy];
copy.title = @"New Title";
copy.url = @"New URL";
}
- (void)testUndoRedoEditGroup {
XCTFail(@"Missing test");
}
@end

View File

@@ -1,58 +0,0 @@
//
// KPKXmlLoadingTest.m
// MacPass
//
// Created by Michael Starke on 23.07.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestXmlLoading : XCTestCase {
@private
NSData *_data;
KPKCompositeKey *_password;
}
@end
@implementation KPKTestXmlLoading
- (void)setUp {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [myBundle URLForResource:@"Test_Password_1234" withExtension:@"kdbx"];
_data = [NSData dataWithContentsOfURL:url];
_password = [[KPKCompositeKey alloc] initWithPassword:@"1234" key:nil];
}
- (void)tearDown {
_data = nil;
_password = nil;
}
- (void)testLoading {
NSError *error;
KPKTree *tree = [[KPKTree alloc] initWithData:_data password:_password error:&error];
XCTAssertNotNil(tree, @"Loading should result in a tree object");
XCTAssertEqual(tree.root.groups.count, 0, @"Tree contains just root group");
XCTAssertEqual(tree.root.entries.count, 1, @"Tree has only one entry");
}
- (void)testAutotypeLoading {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [myBundle URLForResource:@"Autotype_test" withExtension:@"kdbx"];
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"test" key:nil];
NSError *error;
KPKTree *tree = [[KPKTree alloc] initWithContentsOfUrl:url password:password error:&error];
XCTAssertNotNil(tree, @"Tree shoud be loaded");
KPKEntry *entry = tree.root.entries[0];
XCTAssertNotNil(entry, @"Entry should be there");
XCTFail(@"Uncomplete Test!");
}
@end

View File

@@ -1,53 +0,0 @@
//
// KPKTestXmlParsing.m
// MacPass
//
// Created by Michael Starke on 03.08.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
#import "KeePassKit+Private.h"
#import "DDXMLDocument.h"
@interface KPKTestXmlParsing : XCTestCase
@end
@implementation KPKTestXmlParsing
- (void)testEmptyXmlFile {
DDXMLDocument *document = [[DDXMLDocument alloc] initWithXMLString:@"" options:0 error:NULL];
KPKXmlTreeReader *reader = [[KPKXmlTreeReader alloc] initWithData:[document XMLData] headerReader:nil];
NSError *error;
KPKTree *tree = [reader tree:&error];
XCTAssertNil(tree, @"No Tree from empty data");
XCTAssertNotNil(error, @"Error Object should be provided");
XCTAssertTrue([error code] == KPKErrorNoData, @"Error Code should be No Data");
}
- (void)testNoNodeXmlFile {
DDXMLDocument *document = [[DDXMLDocument alloc] initWithXMLString:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><root></root>" options:0 error:NULL];
KPKXmlTreeReader *reader = [[KPKXmlTreeReader alloc] initWithData:[document XMLData] headerReader:nil];
NSError *error;
KPKTree *tree = [reader tree:&error];
XCTAssertNil(tree, @"No Tree from empty data");
XCTAssertNotNil(error, @"Error Object should be provided");
XCTAssertTrue([error code] == KPKErrorXMLKeePassFileElementMissing, @"Error Code should be KeePassFile root missing");
}
- (void)testNoRoodXmlFil {
DDXMLDocument *document = [[DDXMLDocument alloc] initWithXMLString:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?><KeePassFile><Root></Root></KeePassFile>" options:0 error:NULL];
KPKXmlTreeReader *reader = [[KPKXmlTreeReader alloc] initWithData:[document XMLData] headerReader:nil];
NSError *error;
KPKTree *tree = [reader tree:&error];
XCTAssertNil(tree, @"No Tree from empty data");
XCTAssertNotNil(error, @"Error Object should be provided");
XCTAssertTrue([error code] == KPKErrorXMLMetaElementMissing, @"Error Code should be KeePassFile root missing");
}
@end

View File

@@ -1,45 +0,0 @@
//
// KPKTestXmlWriting.m
// MacPass
//
// Created by Michael Starke on 20.08.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTestXmlWriting : XCTestCase
@end
@implementation KPKTestXmlWriting
- (void)testXmlWriting {
NSData *data = [self _loadTestDataBase:@"CustomIcon_Password_1234" extension:@"kdbx"];
NSError *error;
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"1234" key:nil];
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:&error];
error = nil;
NSData *saveData = [tree encryptWithPassword:password forVersion:KPKXmlVersion error:&error];
XCTAssertNotNil(saveData, @"Serialization should yield data");
NSString *tempFile = [NSTemporaryDirectory() stringByAppendingString:@"CustomIcon_Password_1234_save.kdbx"];
NSLog(@"Saved file to %@", tempFile);
[saveData writeToFile:tempFile atomically:YES];
error = nil;
NSURL *url = [NSURL fileURLWithPath:tempFile];
KPKTree *reloadedTree = [[KPKTree alloc] initWithContentsOfUrl:url password:password error:&error];
XCTAssertNotNil(reloadedTree, @"Reloaded tree should not be nil");
}
- (NSData *)_loadTestDataBase:(NSString *)name extension:(NSString *)extension {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [myBundle URLForResource:name withExtension:extension];
return [NSData dataWithContentsOfURL:url];
}
@end

View File

@@ -1,32 +0,0 @@
//
// KPKTextXMLUtilities.m
// MacPass
//
// Created by Michael Starke on 12/12/14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import "KeePassKit.h"
@interface KPKTextXMLUtilities : XCTestCase
@end
@implementation KPKTextXMLUtilities
- (void)setUp {
[super setUp];
}
- (void)tearDown {
[super tearDown];
}
- (void)testExample {
NSString *unsave = @"*EORDIE\x10\x16\x12\x10";
XCTAssertEqualObjects(@"*EORDIE", unsave.XMLCompatibleString);
}
@end

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<KeyFile>
<Meta>
<Version>1.00</Version>
</Meta>
<Key>
<Data>L8JyIjlAd3SowrQPm6ZaR9mMolm/7iL6T1GJRGBNrAE=</Data>
</Key>
</KeyFile>