mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 00:02:28 +00:00
Setup for UnitTests
This commit is contained in:
BIN
MacPassTests/Databases/Test_Password_1234.kdb
Normal file
BIN
MacPassTests/Databases/Test_Password_1234.kdb
Normal file
Binary file not shown.
15
MacPassTests/MPDatabaseCreation.h
Normal file
15
MacPassTests/MPDatabaseCreation.h
Normal 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
|
||||
25
MacPassTests/MPDatabaseCreation.m
Normal file
25
MacPassTests/MPDatabaseCreation.m
Normal 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
|
||||
13
MacPassTests/MPDatabaseLoadingTest.h
Normal file
13
MacPassTests/MPDatabaseLoadingTest.h
Normal 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
|
||||
46
MacPassTests/MPDatabaseLoadingTest.m
Normal file
46
MacPassTests/MPDatabaseLoadingTest.m
Normal 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
|
||||
22
MacPassTests/MacPassTests-Info.plist
Normal file
22
MacPassTests/MacPassTests-Info.plist
Normal 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>
|
||||
7
MacPassTests/MacPassTests-Prefix.pch
Normal file
7
MacPassTests/MacPassTests-Prefix.pch
Normal 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
|
||||
2
MacPassTests/en.lproj/InfoPlist.strings
Normal file
2
MacPassTests/en.lproj/InfoPlist.strings
Normal file
@@ -0,0 +1,2 @@
|
||||
/* Localized versions of Info.plist keys */
|
||||
|
||||
Reference in New Issue
Block a user