Setup for UnitTests

This commit is contained in:
michael starke
2013-07-11 00:23:30 +02:00
parent 515190a74e
commit ab0199e3dd
10 changed files with 295 additions and 1 deletions

Binary file not shown.

View File

@@ -0,0 +1,15 @@
//
// MPDatabaseCreation.h
// MacPass
//
// Created by Michael Starke on 10.07.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
@interface MPDatabaseCreation : SenTestCase
@end

View File

@@ -0,0 +1,25 @@
//
// MPDatabaseCreation.m
// MacPass
//
// Created by Michael Starke on 10.07.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPDatabaseCreation.h"
#import "MPDocument.h"
@implementation MPDatabaseCreation
- (void)testCreateDatabaseVersion1 {
}
- (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");
}
@end

View File

@@ -0,0 +1,13 @@
//
// MPDatabaseLoadingTest.h
// MacPass
//
// Created by Michael Starke on 10.07.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
@interface MPDatabaseLoadingTest : SenTestCase
@end

View File

@@ -0,0 +1,46 @@
//
// MPDatabaseLoadingTest.m
// MacPass
//
// Created by Michael Starke on 10.07.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPDatabaseLoadingTest.h"
#import "MPDocument.h"
@implementation MPDatabaseLoadingTest
- (void)testLoadVersion1 {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [myBundle URLForResource:@"Test_Password_1234" withExtension:@"kdb"];
NSError *error = nil;
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 decryptWithPassword:@"1234" keyFileURL:nil], @"Should decrypt with password");
STAssertTrue(document.decrypted, @"Document is decrypted if decryptiong succeeds");
STAssertNotNil(document.treeV3, @"Tree shoudl be version1");
STAssertTrue(document.version == MPDatabaseVersion3, @"Internal databse version should be correct");
}
- (void)testVersion1WrongPassword {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [myBundle URLForResource:@"Test_Password_1234" withExtension:@"kdb"];
NSError *error = nil;
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 decryptWithPassword:@"123" keyFileURL:nil], @"Decryption should fail");
STAssertFalse(document.decrypted, @"Document is not decrypted with wrong password supplied");
}
- (void)testLoadDatabaseVerions2 {
//STFail(@"Not implemented");
}
@end

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.hicknhacksoftware.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'MacPassTests' target in the 'MacPassTests' project
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

View File

@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */