mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 02:22:28 +00:00
Added test databases (copied from KeePassKit)
Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
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.
BIN
MacPassTests/Databases/Test_Password_1234.kdbx
Normal file
BIN
MacPassTests/Databases/Test_Password_1234.kdbx
Normal file
Binary file not shown.
@@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
- (void)testLoadVersion1 {
|
||||
NSBundle *myBundle = [NSBundle bundleForClass:[KPKTree class]];
|
||||
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];
|
||||
@@ -33,7 +33,7 @@
|
||||
}
|
||||
|
||||
- (void)testVersion1WrongPassword {
|
||||
NSBundle *myBundle = [NSBundle bundleForClass:[KPKTree class]];
|
||||
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];
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
|
||||
- (void)testLoadDatabaseVerions2 {
|
||||
NSBundle *myBundle = [NSBundle bundleForClass:[KPKTree class]];
|
||||
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
|
||||
NSURL *url = [myBundle URLForResource:@"Test_Password_1234" withExtension:@"kdbx"];
|
||||
NSError *error = nil;
|
||||
MPDocument *document = [[MPDocument alloc] initWithContentsOfURL:url ofType:@"kdbx" error:&error];
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
//
|
||||
// MPDatabasePasswordAndKeyfile.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 11.07.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "MPDocument.h"
|
||||
#import "KeePassKit/KeePassKit.h"
|
||||
|
||||
@interface MPDatabasePasswordAndKeyfile : XCTestCase {
|
||||
MPDocument *_database;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation MPDatabasePasswordAndKeyfile
|
||||
|
||||
- (void)setUp {
|
||||
_database = [[MPDocument alloc] init];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
_database = nil;
|
||||
}
|
||||
|
||||
- (void)testSetPassword {
|
||||
XCTAssertNil(_database.compositeKey, @"New database should not have a composite key");
|
||||
XCTAssertTrue([_database changePassword:@"password" keyFileURL:nil], @"Setting the Password should succeed");
|
||||
XCTAssertFalse([_database changePassword:nil keyFileURL:nil], @"resetting the password and key to nil should not work");
|
||||
}
|
||||
|
||||
- (void)testSetKeyfile {/*
|
||||
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");*/
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user