mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 14:02:28 +00:00
Updated submodule
Fixed error in Autotype test (password wrong)
This commit is contained in:
54
MacPassTests/KPKTestLegacyLoading.m
Normal file
54
MacPassTests/KPKTestLegacyLoading.m
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// KPKTreeLoadingTest.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 20.07.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "KPKTestLegacyLoading.h"
|
||||
|
||||
#import "KPKTree+Serializing.h"
|
||||
#import "KPKPassword.h"
|
||||
#import "KPKMetaData.h"
|
||||
#import "KPKIcon.h"
|
||||
|
||||
#import "KPKErrors.h"
|
||||
|
||||
@implementation KPKTestLegacyLoading
|
||||
|
||||
- (void)testValidFile {
|
||||
KPKPassword *password = [[KPKPassword alloc] initWithPassword:@"1234" key:nil];
|
||||
NSData *data = [self _loadTestDataBase:@"Test_Password_1234" extension:@"kdb"];
|
||||
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:NULL];
|
||||
STAssertNotNil(tree, @"Loading should result in a tree object");
|
||||
}
|
||||
|
||||
- (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];
|
||||
STAssertNil(tree, @"Tree should be nil with invalid data");
|
||||
STAssertNotNil(error, @"Error object should have been created");
|
||||
STAssertTrue(KPKErrorUnknownFileFormat == [error code], @"Error should be Unknown file format");
|
||||
}
|
||||
|
||||
|
||||
- (void)testMetaParsing {
|
||||
NSData *data = [self _loadTestDataBase:@"KDB1_KeePassX_test" extension:@"kdb"];
|
||||
KPKPassword *password = [[KPKPassword alloc] initWithPassword:@"test" key:nil];
|
||||
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:NULL];
|
||||
STAssertNotNil(tree, @"Tree shoudl be loaded" );
|
||||
|
||||
KPKIcon *icon = [tree.metaData.customIcons lastObject];
|
||||
STAssertNotNil(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
|
||||
Reference in New Issue
Block a user